perf: 未分配会话: 入口链接删去conversationid, 从会话获取

dev/timezone
Lei OT 1 year ago
parent 9cd2c72eb6
commit 7c7882a67d

@ -45,7 +45,7 @@ const router = createBrowserRouter([
{ path: 'unassign', element: <Unassign /> }, { path: 'unassign', element: <Unassign /> },
], ],
}, },
{ path: 'chat/unassign/:whatsappid/:conversationid', element: <ChatAssign /> }, { path: 'chat/unassign/:whatsappid', element: <ChatAssign /> },
{ path: 'm/chat/:order_sn', element: <MobileChat /> }, { path: 'm/chat/:order_sn', element: <MobileChat /> },
{ path: 'm/chat', element: <MobileChat /> }, { path: 'm/chat', element: <MobileChat /> },
{ {
@ -66,7 +66,7 @@ const router = createBrowserRouter([
{ path: 'order/chat/:order_sn', element: <ChatWindow /> }, { path: 'order/chat/:order_sn', element: <ChatWindow /> },
{ path: 'order/chat', element: <ChatWindow /> }, { path: 'order/chat', element: <ChatWindow /> },
{ path: 'account/profile', element: <AccountProfile /> }, { path: 'account/profile', element: <AccountProfile /> },
{ path: 'chat/unassign/:whatsappid/:conversationid', element: <ChatAssign /> }, { path: 'chat/unassign/:whatsappid', element: <ChatAssign /> },
{ path: 'chat/unassign', element: <Unassign /> }, { path: 'chat/unassign', element: <Unassign /> },
], ],
}, },

@ -1,4 +1,4 @@
import { useEffect } from 'react'; import { useEffect, useState } from 'react';
import { Layout } from 'antd'; import { Layout } from 'antd';
import MessagesHeader from '@/views/Conversations/Online/MessagesHeader'; import MessagesHeader from '@/views/Conversations/Online/MessagesHeader';
import MessagesWrapper from '@/views/Conversations/Online/MessagesWrapper'; import MessagesWrapper from '@/views/Conversations/Online/MessagesWrapper';
@ -13,14 +13,19 @@ const { Content, Header, Footer } = Layout;
function ChatAssign() { function ChatAssign() {
const navigate = useNavigate(); const navigate = useNavigate();
const { whatsappid, conversationid } = useParams(); const { whatsappid, } = useParams();
const [currentConversation, setCurrentConversation] = useConversationStore(useShallow((state) => [state.currentConversation, state.setCurrentConversation])); const [currentConversation, setCurrentConversation] = useConversationStore(useShallow((state) => [state.currentConversation, state.setCurrentConversation]));
const [conversationid, setConversationid] = useState();
const [opi, setOpi] = useState({});
async function refreshConversationList() { async function refreshConversationList() {
const _list = await fetchConversationsSearch({ whatsapp_id: whatsappid }); const _list = await fetchConversationsSearch({ whatsapp_id: whatsappid });
if (_list.length > 0) { if (_list.length > 0) {
setCurrentConversation(_list[0]); setCurrentConversation(_list[0]);
setConversationid(String(_list[0].conversationid));
setOpi({ label: _list[0].opi_name, value: String(_list[0].opi_sn) });
} }
} }
@ -35,7 +40,7 @@ function ChatAssign() {
<> <>
<Layout className='h-full chatwindow-wrapper mobilechat-wrapper' style={{ maxHeight: 'calc(100vh - 32px)', height: 'calc(100vh - 32px)', minWidth: '360px' }}> <Layout className='h-full chatwindow-wrapper mobilechat-wrapper' style={{ maxHeight: 'calc(100vh - 32px)', height: 'calc(100vh - 32px)', minWidth: '360px' }}>
<Header className=' px-2 ant-layout-sider-light ant-card h-auto flex flex-col justify-between gap-1 '> <Header className=' px-2 ant-layout-sider-light ant-card h-auto flex flex-col justify-between gap-1 '>
<InputAssign className={'block py-2'} initialValues={{ conversationid, whatsappid }} /> <InputAssign className={'block py-2'} initialValues={{ conversationid, whatsappid }} {...{ conversationid, opi }} />
<MessagesHeader /> <MessagesHeader />
</Header> </Header>
<Content className='flex-grow bg-whatsapp-bg relative'> <Content className='flex-grow bg-whatsapp-bg relative'>

@ -5,7 +5,7 @@ import { fetchSalesAgentWithDD } from '@/actions/CommonActions';
import { postAssignConversation } from '@/actions/ConversationActions'; import { postAssignConversation } from '@/actions/ConversationActions';
import useAuthStore from '@/stores/AuthStore'; import useAuthStore from '@/stores/AuthStore';
const InputAssign = ({ initialValues, ...props }) => { const InputAssign = ({ initialValues, conversationid, ...props }) => {
const [userId, username] = useAuthStore((state) => [state.loginUser.userId, state.loginUser.username]); const [userId, username] = useAuthStore((state) => [state.loginUser.userId, state.loginUser.username]);
const actionDisabled = !['79', '383', '404', '227'].includes(String(userId)); const actionDisabled = !['79', '383', '404', '227'].includes(String(userId));
@ -16,9 +16,11 @@ const InputAssign = ({ initialValues, ...props }) => {
async function handleSubmit(values) { async function handleSubmit(values) {
const valuesSub = { const valuesSub = {
...values, ...values,
conversationid,
opi_sn: values.opi_sn.value, opi_sn: values.opi_sn.value,
from_opi_sn: userId, // from_opi_sn: userId, //
}; };
// console.log(valuesSub);
setSubLoading(true); setSubLoading(true);
await postAssignConversation(valuesSub); await postAssignConversation(valuesSub);
setSubLoading(false); setSubLoading(false);

Loading…
Cancel
Save