|
|
|
@ -7,7 +7,7 @@ import MessagesMatchList from './Conversations/History/MessagesMatchList';
|
|
|
|
|
import MessagesList from './Conversations/History/MessagesList';
|
|
|
|
|
import ImageAlbumPreview from './Conversations/History/ImageAlumPreview';
|
|
|
|
|
import { flush, pick } from '@/utils/commons';
|
|
|
|
|
import { fetchConversationsSearch } from '@/actions/ConversationActions';
|
|
|
|
|
import { fetchConversationsSearch, CONVERSATION_PAGE_SIZE } from '@/actions/ConversationActions';
|
|
|
|
|
|
|
|
|
|
const { Sider, Content } = Layout;
|
|
|
|
|
|
|
|
|
@ -18,8 +18,12 @@ const Index = (props) => {
|
|
|
|
|
const [conversationsListLoading, setConversationsListLoading] = useState(false);
|
|
|
|
|
const [conversationsList, setConversationsList] = useState([]);
|
|
|
|
|
|
|
|
|
|
const [pageParam, setPageParam] = useState({ lasttime: '', loadNextPage: true });
|
|
|
|
|
|
|
|
|
|
const handleSubmit = useCallback((values) => {
|
|
|
|
|
setFormValues({ ...values });
|
|
|
|
|
setPageParam({ lasttime: '', loadNextPage: true });
|
|
|
|
|
setConversationsList([]);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
@ -29,10 +33,14 @@ const Index = (props) => {
|
|
|
|
|
|
|
|
|
|
const getConversationsList = async () => {
|
|
|
|
|
setConversationsListLoading(true);
|
|
|
|
|
const params = flush(pick(formValues, ['opisn', 'whatsapp_id', 'search', 'from_date', 'end_date', 'coli_id']));
|
|
|
|
|
const data = await fetchConversationsSearch(params);
|
|
|
|
|
const params = flush(pick(formValues, ['opisn', 'whatsapp_id', 'search', 'from_date', 'end_date', 'coli_id', 'lasttime']));
|
|
|
|
|
const data = await fetchConversationsSearch({ ...params, ...pageParam, pagesize: CONVERSATION_PAGE_SIZE });
|
|
|
|
|
setConversationsListLoading(false);
|
|
|
|
|
setConversationsList(data);
|
|
|
|
|
setConversationsList(conversationsList.concat(data));
|
|
|
|
|
setPageParam({
|
|
|
|
|
lasttime: data.length > 0 ? data[data.length - 1].lasttime : '',
|
|
|
|
|
loadNextPage: !(data.length === 0 || data.length < CONVERSATION_PAGE_SIZE),
|
|
|
|
|
});
|
|
|
|
|
if (data.length === 1) {
|
|
|
|
|
setSelectedConversation(data[0]);
|
|
|
|
|
}
|
|
|
|
@ -41,11 +49,11 @@ const Index = (props) => {
|
|
|
|
|
<>
|
|
|
|
|
<SearchForm onSubmit={handleSubmit} initialValues={formValues} />
|
|
|
|
|
<Divider plain orientation='left' className='mb-0'></Divider>
|
|
|
|
|
<Layout hasSider className='h-screen chathistory-wrapper chatwindow-wrapper' style={{ maxHeight: 'calc(100% - 279px)', height: 'calc(100% - 279px)' }}>
|
|
|
|
|
<Sider width={300} theme={'light'} className='h-full overflow-y-auto overflow-x-hidden' style={{ maxHeight: 'calc(100vh - 279px)', height: 'calc(100vh - 279px)' }}>
|
|
|
|
|
<ConversationsList {...{ conversationsListLoading, conversationsList, selectedConversation, handleChatItemClick: setSelectedConversation }} />
|
|
|
|
|
<Layout hasSider className='h-screen chathistory-wrapper chatwindow-wrapper' style={{ maxHeight: 'calc(100% - 300px)', height: 'calc(100% - 300px)' }}>
|
|
|
|
|
<Sider width={300} theme={'light'} className='h-full overflow-y-auto overflow-x-hidden' style={{ maxHeight: 'calc(100vh - 300px)', height: 'calc(100vh - 300px)' }}>
|
|
|
|
|
<ConversationsList {...{ conversationsListLoading, conversationsList, selectedConversation, handleChatItemClick: setSelectedConversation, onLoadMore: getConversationsList, loadMoreVisible: pageParam.loadNextPage }} />
|
|
|
|
|
</Sider>
|
|
|
|
|
<Content style={{ maxHeight: 'calc(100vh - 279px)', height: 'calc(100vh - 279px)', minWidth: '360px' }}>
|
|
|
|
|
<Content style={{ maxHeight: 'calc(100vh - 300px)', height: 'calc(100vh - 300px)', minWidth: '360px' }}>
|
|
|
|
|
<Flex className='h-full relative'>
|
|
|
|
|
<MessagesMatchList />
|
|
|
|
|
<MessagesList />
|
|
|
|
|