|
|
|
@ -40,14 +40,16 @@ const Conversations = () => {
|
|
|
|
|
const getOrderConversationList = async (colisn) => {
|
|
|
|
|
const { whatsapp_phone_number } = switchToC;
|
|
|
|
|
const whatsappID = coli_guest_WhatsApp || whatsapp_phone_number || '';
|
|
|
|
|
let findCurrent = -1; // conversationsList.findIndex((item) => item.coli_sn === Number(colisn));
|
|
|
|
|
if (!isEmpty(whatsappID)) {
|
|
|
|
|
const data = await fetchOrderConversationsList({ opisn: userId, colisn: colisn, whatsappid: whatsappID });
|
|
|
|
|
if (!isEmpty(data)) {
|
|
|
|
|
addToConversationList(data);
|
|
|
|
|
}
|
|
|
|
|
let ifCurrent = data.findIndex((item) => item.sn === currentConversation.sn);
|
|
|
|
|
ifCurrent = ifCurrent !== -1 ? ifCurrent : conversationsList.findIndex((item) => item.coli_sn === Number(colisn));
|
|
|
|
|
if (ifCurrent !== -1) {
|
|
|
|
|
switchConversation(conversationsList[ifCurrent === -1 ? 0 : ifCurrent]);
|
|
|
|
|
findCurrent = conversationsList.findIndex((item) => item.coli_sn === Number(colisn)); // data.findIndex((item) => item.sn === currentConversation.sn);
|
|
|
|
|
}
|
|
|
|
|
if (findCurrent !== -1) {
|
|
|
|
|
switchConversation(conversationsList[findCurrent]);
|
|
|
|
|
} else {
|
|
|
|
|
// reset chat window
|
|
|
|
|
setCurrentConversation({ sn: '', customer_name: '', coli_sn: order_sn });
|
|
|
|
|