|
|
@ -1,7 +1,7 @@
|
|
|
|
import { useEffect, useState, useRef } from 'react';
|
|
|
|
import { useEffect, useState, useRef } from 'react';
|
|
|
|
import { useParams, useNavigate, useLocation } from 'react-router-dom';
|
|
|
|
import { useParams, useNavigate, useLocation } from 'react-router-dom';
|
|
|
|
import { Dropdown, Input, Button, } from 'antd';
|
|
|
|
import { Dropdown, Input, Button, Empty, Tooltip } from 'antd';
|
|
|
|
import { PlusOutlined, WhatsAppOutlined, LoadingOutlined } from '@ant-design/icons';
|
|
|
|
import { PlusOutlined, WhatsAppOutlined, LoadingOutlined, HistoryOutlined, FireOutlined } from '@ant-design/icons';
|
|
|
|
import { fetchConversationsList, fetchOrderConversationsList, fetchConversationItemClose, postNewConversationItem } from '@/actions/ConversationActions';
|
|
|
|
import { fetchConversationsList, fetchOrderConversationsList, fetchConversationItemClose, postNewConversationItem } from '@/actions/ConversationActions';
|
|
|
|
import { ChatItem } from 'react-chat-elements';
|
|
|
|
import { ChatItem } from 'react-chat-elements';
|
|
|
|
import ConversationsNewItem from './ConversationsNewItem';
|
|
|
|
import ConversationsNewItem from './ConversationsNewItem';
|
|
|
@ -28,6 +28,8 @@ const Conversations = ({ mobile }) => {
|
|
|
|
const addToConversationList = useConversationStore((state) => state.addToConversationList);
|
|
|
|
const addToConversationList = useConversationStore((state) => state.addToConversationList);
|
|
|
|
const delConversationitem = useConversationStore((state) => state.delConversationitem);
|
|
|
|
const delConversationitem = useConversationStore((state) => state.delConversationitem);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const closedConversationsList = useConversationStore((state) => state.closedConversationsList);
|
|
|
|
|
|
|
|
|
|
|
|
const isVisible = useVisibilityState();
|
|
|
|
const isVisible = useVisibilityState();
|
|
|
|
|
|
|
|
|
|
|
|
const [tabSelectedConversation, setTabSelectedConversation] = useState({});
|
|
|
|
const [tabSelectedConversation, setTabSelectedConversation] = useState({});
|
|
|
@ -60,7 +62,7 @@ const Conversations = ({ mobile }) => {
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
setDataSource(conversationsList);
|
|
|
|
setDataSource(conversationsList);
|
|
|
|
return () => {};
|
|
|
|
return () => {};
|
|
|
|
}, [conversationsList]);
|
|
|
|
}, [conversationsList.length]);
|
|
|
|
|
|
|
|
|
|
|
|
const [switchToC, setSwitchToC] = useState({});
|
|
|
|
const [switchToC, setSwitchToC] = useState({});
|
|
|
|
const [shouldFetchCList, setShouldFetchCList] = useState(true);
|
|
|
|
const [shouldFetchCList, setShouldFetchCList] = useState(true);
|
|
|
@ -165,10 +167,19 @@ const Conversations = ({ mobile }) => {
|
|
|
|
// setNewChatFormValues(values);
|
|
|
|
// setNewChatFormValues(values);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const [activeList, setActiveList] = useState(true);
|
|
|
|
|
|
|
|
// const closedVisible = closedConversationsList.length > 0;
|
|
|
|
|
|
|
|
const toggleClosedConversationsList = () => {
|
|
|
|
|
|
|
|
const _active = activeList;
|
|
|
|
|
|
|
|
setDataSource(_active ? closedConversationsList : conversationsList);
|
|
|
|
|
|
|
|
setActiveList(!activeList);
|
|
|
|
|
|
|
|
setCurrentConversation({});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className='flex flex-col h-inherit'>
|
|
|
|
<div className='flex flex-col h-inherit'>
|
|
|
|
<div className='flex gap-1'>
|
|
|
|
<div className='flex gap-1'>
|
|
|
|
{([404, 383].includes(userId)) && <Button onClick={() => setNewChatModalVisible(true)} icon={<PlusOutlined />} type={'primary'} />}
|
|
|
|
{[404, 383].includes(userId) && <Button onClick={() => setNewChatModalVisible(true)} icon={<PlusOutlined />} type={'primary'} />}
|
|
|
|
<Input.Search
|
|
|
|
<Input.Search
|
|
|
|
className=''
|
|
|
|
className=''
|
|
|
|
ref={searchInputRef}
|
|
|
|
ref={searchInputRef}
|
|
|
@ -199,6 +210,13 @@ const Conversations = ({ mobile }) => {
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
placeholder={`搜索名称/号码/订单号${conversationsListLoading ? '...' : ''}`}
|
|
|
|
placeholder={`搜索名称/号码/订单号${conversationsListLoading ? '...' : ''}`}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Tooltip key={'conversation-list'} title={activeList ? '历史会话' : '活跃会话'}>
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
|
|
|
onClick={toggleClosedConversationsList}
|
|
|
|
|
|
|
|
icon={activeList ? <HistoryOutlined className='text-neutral-500' /> : <FireOutlined className=' text-orange-500' />}
|
|
|
|
|
|
|
|
type='text'
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</Tooltip>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className='flex-1 overflow-x-hidden overflow-y-auto relative'>
|
|
|
|
<div className='flex-1 overflow-x-hidden overflow-y-auto relative'>
|
|
|
|
{conversationsListLoading && dataSource.length === 0 ? (
|
|
|
|
{conversationsListLoading && dataSource.length === 0 ? (
|
|
|
@ -244,8 +262,14 @@ const Conversations = ({ mobile }) => {
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</Dropdown>
|
|
|
|
</Dropdown>
|
|
|
|
))}
|
|
|
|
))}
|
|
|
|
|
|
|
|
{dataSource.length === 0 && <Empty description={'无数据'} />}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<ConversationsNewItem initialValues={{coli_id: currentConversation.coli_id, coli_sn: currentConversation.coli_sn}} open={newChatModalVisible} onCreate={handleNewChat} onCancel={() => setNewChatModalVisible(false)} />
|
|
|
|
<ConversationsNewItem
|
|
|
|
|
|
|
|
initialValues={{ coli_id: currentConversation.coli_id, coli_sn: currentConversation.coli_sn }}
|
|
|
|
|
|
|
|
open={newChatModalVisible}
|
|
|
|
|
|
|
|
onCreate={handleNewChat}
|
|
|
|
|
|
|
|
onCancel={() => setNewChatModalVisible(false)}
|
|
|
|
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|