|
|
@ -1,3 +1,4 @@
|
|
|
|
|
|
|
|
import useAuthStore from '@/stores/AuthStore';
|
|
|
|
import useConversationStore from '@/stores/ConversationStore';
|
|
|
|
import useConversationStore from '@/stores/ConversationStore';
|
|
|
|
import { fetchOrderConversationsList, postNewConversationItem } from '@/actions/ConversationActions';
|
|
|
|
import { fetchOrderConversationsList, postNewConversationItem } from '@/actions/ConversationActions';
|
|
|
|
import { isEmpty } from '@/utils/commons';
|
|
|
|
import { isEmpty } from '@/utils/commons';
|
|
|
@ -8,6 +9,7 @@ export function useConversationNewItem() {
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
const conversationsList = useConversationStore((state) => state.conversationsList);
|
|
|
|
const conversationsList = useConversationStore((state) => state.conversationsList);
|
|
|
|
const addToConversationList = useConversationStore((state) => state.addToConversationList);
|
|
|
|
const addToConversationList = useConversationStore((state) => state.addToConversationList);
|
|
|
|
|
|
|
|
const userId = useAuthStore((state) => state.loginUser.userId);
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 打开订单的会话, 不存在自动新增
|
|
|
|
* 打开订单的会话, 不存在自动新增
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -42,7 +44,7 @@ export function useConversationNewItem() {
|
|
|
|
const newConversation = async (whatsappID, whatsappName = '') => {
|
|
|
|
const newConversation = async (whatsappID, whatsappName = '') => {
|
|
|
|
const { opi_sn } = currentConversation;
|
|
|
|
const { opi_sn } = currentConversation;
|
|
|
|
const newChat = { phone_number: whatsappID, remark_name: whatsappName };
|
|
|
|
const newChat = { phone_number: whatsappID, remark_name: whatsappName };
|
|
|
|
const createdNew = await postNewConversationItem({ ...newChat, opi_sn: opi_sn });
|
|
|
|
const createdNew = await postNewConversationItem({ ...newChat, opi_sn: opi_sn || userId });
|
|
|
|
addToConversationList([createdNew]);
|
|
|
|
addToConversationList([createdNew]);
|
|
|
|
setCurrentConversation(createdNew);
|
|
|
|
setCurrentConversation(createdNew);
|
|
|
|
};
|
|
|
|
};
|
|
|
|