|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import { useRef, useEffect, useState } from 'react';
|
|
|
|
|
import { useNavigate } from "react-router-dom";
|
|
|
|
|
import { List, Avatar, Flex } from 'antd';
|
|
|
|
|
import { useConversationContext } from '@/stores/Conversations/ConversationContext';
|
|
|
|
|
import { ChatItem, ChatList } from 'react-chat-elements';
|
|
|
|
@ -6,7 +7,8 @@ import { useGetJson } from '@/hooks/userFetch';
|
|
|
|
|
/**
|
|
|
|
|
* []
|
|
|
|
|
*/
|
|
|
|
|
const Conversations = (({ conversations }) => {
|
|
|
|
|
const Conversations = (() => {
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
const { switchConversation, conversationsList } = useConversationContext();
|
|
|
|
|
// console.log(conversationsList);
|
|
|
|
|
const [chatlist, setChatlist] = useState([]);
|
|
|
|
@ -28,24 +30,12 @@ const Conversations = (({ conversations }) => {
|
|
|
|
|
|
|
|
|
|
const onSwitchConversation = (item) => {
|
|
|
|
|
switchConversation(item);
|
|
|
|
|
navigate(`/order/chat/${item.order_sn}`, { replace: true });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<ChatList className='chat-list' dataSource={chatlist} onClick={(item) => onSwitchConversation(item)} />
|
|
|
|
|
{/* <List
|
|
|
|
|
dataSource={conversationsList || []}
|
|
|
|
|
renderItem={(item, ii) => (
|
|
|
|
|
// actions={[<a key='list-loadmore-edit'>mark</a>]}
|
|
|
|
|
<List.Item onClick={() => switchConversation(item)}>
|
|
|
|
|
<List.Item.Meta
|
|
|
|
|
avatar={<Avatar src={`https://api.dicebear.com/7.x/avataaars/svg?seed=${item.name}`}>{item.name}</Avatar>}
|
|
|
|
|
title={item.name}
|
|
|
|
|
// description='{最近的消息}'
|
|
|
|
|
/>
|
|
|
|
|
</List.Item>
|
|
|
|
|
)}
|
|
|
|
|
/> */}
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|