From 8b8c56b77514d2c20905e36fcd7fbfc53fe3f12a Mon Sep 17 00:00:00 2001 From: Lei OT Date: Thu, 21 Nov 2024 17:23:36 +0800 Subject: [PATCH] =?UTF-8?q?todo:=20=E7=BB=9F=E4=B8=80=E5=A4=84=E7=90=86?= =?UTF-8?q?=E4=BC=9A=E8=AF=9Ditem=E7=9A=84=E8=AE=B0=E5=BD=95=E7=BB=93?= =?UTF-8?q?=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/useConversation.js | 45 ++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/src/hooks/useConversation.js b/src/hooks/useConversation.js index 19b768a..b5947ed 100644 --- a/src/hooks/useConversation.js +++ b/src/hooks/useConversation.js @@ -2,6 +2,34 @@ import useAuthStore from '@/stores/AuthStore'; import useConversationStore from '@/stores/ConversationStore'; import { fetchConversationsList, fetchOrderConversationsList, postNewOrEditConversationItem } from '@/actions/ConversationActions'; import { isEmpty } from '@/utils/commons'; + +const CHAT_ITEM_RECORD = { + "sn": null, + "opi_sn": 0, + "coli_sn": null, + "whatsapp_phone_number": null, + "last_received_time": null, + "last_send_time": null, + "unread_msg_count": 0, + "whatsapp_name": null, + "coli_id": "", + "conversation_expiretime": null, + "tags": null, + "channels": { + "email": null, + "phone_number": null, + "whatsapp_phone_number": null + }, + "nick_name": null, + "top_state": 0, + "conversation_memo": null, + "order_label_id": null, + "order_state_id": null, + "intour": 0, + "last_message": {}, + "lasttime": "" +}; + export function useConversationNewItem() { const [currentConversation, setCurrentConversation] = useConversationStore((state) => [ state.currentConversation, @@ -54,8 +82,21 @@ export function useConversationNewItem() { const _list = await fetchConversationsList({ opisn }); addToConversationList(_list); if (!body.conversationid) { - const newChat = _list.find(item => item.sn === createdNew.conversationid); - setCurrentConversation(newChat); + // const newChat = _list.find((item) => item.sn === createdNew.conversationid) + // setCurrentConversation(newChat); + setCurrentConversation({ + ...CHAT_ITEM_RECORD, + ...createdNew, + sn: createdNew.conversationid, + channels: { + email: createdNew.guest_email, + phone_number: createdNew.guest_phone, + whatsapp_phone_number: createdNew.whatsapp_phone_number, + }, + conversation_memo: createdNew.remark, + lasttime: createdNew.session_creatime, + show_default: createdNew.remark || createdNew.guest_name || createdNew.guest_phone || createdNew.guest_email || createdNew.whatsapp_phone_number || '', + }) } };