todo: 统一处理会话item的记录结构

2.0/email-builder
Lei OT 10 months ago
parent 502ed894f4
commit 8b8c56b775

@ -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 || '',
})
}
};

Loading…
Cancel
Save