mark all as read + spam empty
This commit is contained in:
@@ -6,7 +6,7 @@ import { ColumnType } from '../../components/types/TableTypes';
|
||||
import { InfoCircle, More, Refresh2, Trash, Edit, Archive, ArchiveTick, Star1 } from 'iconsax-react';
|
||||
import { RowActionItem } from '../../components/RowActionsDropdown';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useGetInbox, useSummarizeEmail } from './hooks/useEmailData';
|
||||
import { useGetInbox, useMarkAllRead, useSummarizeEmail } from './hooks/useEmailData';
|
||||
import { InboxMessage } from './types/Types';
|
||||
import { formatDate } from '@/config/func';
|
||||
import MarkAsRead from '@/assets/images/mark_as_read.svg'
|
||||
@@ -15,6 +15,10 @@ import Favorite from './Components/Favorite';
|
||||
import Summerize from './Components/Summerize';
|
||||
import Intelligense from '@/assets/images/intelligense.svg'
|
||||
import SummarizeModal from './Components/SummarizeModal';
|
||||
import Button from '@/components/Button';
|
||||
import ModalConfrim from '@/components/ModalConfrim';
|
||||
import { ErrorType } from '@/helpers/types';
|
||||
import { toast } from '@/components/Toast';
|
||||
|
||||
const List: FC = () => {
|
||||
|
||||
@@ -25,7 +29,9 @@ const List: FC = () => {
|
||||
const [filters, setFilters] = useState<FilterValues>({});
|
||||
const emailActions = useEmailActions();
|
||||
const [openSummarizeModal, setOpenSummarizeModal] = useState(false);
|
||||
const [showModal, setShowModal] = useState(false);
|
||||
const { mutate: summarizeEmail, isPending: isSummarizing, data: summarizeData } = useSummarizeEmail();
|
||||
const { mutate: markAllRead, isPending: isMarkingAllRead } = useMarkAllRead();
|
||||
|
||||
const { data: inboxData, isLoading, refetch, isFetching } = useGetInbox({
|
||||
next: nextCursor,
|
||||
@@ -77,9 +83,15 @@ const List: FC = () => {
|
||||
<Refresh2
|
||||
size={18}
|
||||
color='black'
|
||||
className={`cursor-pointer ${isFetching ? 'animate-spin-reverse' : ''}`}
|
||||
className={`cursor-pointer min-w-[18px] ${isFetching ? 'animate-spin-reverse' : ''}`}
|
||||
onClick={() => refetch()}
|
||||
/>
|
||||
<Button
|
||||
label='علامتگذاری همه به عنوان خوانده شده'
|
||||
className='h-8'
|
||||
onClick={() => setShowModal(true)}
|
||||
loading={isMarkingAllRead}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -147,6 +159,18 @@ const List: FC = () => {
|
||||
setSelectedMessages([]);
|
||||
};
|
||||
|
||||
const handleMarkAll = () => {
|
||||
markAllRead(undefined, {
|
||||
onSuccess: () => {
|
||||
refetch();
|
||||
setShowModal(false);
|
||||
},
|
||||
onError: (error: ErrorType) => {
|
||||
toast(error.response?.data?.error.message[0], 'error')
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const getInlineActions = (item: InboxMessage) => [
|
||||
{
|
||||
icon: <Favorite flagged={item.flagged} id={item.id.toString()} mailbox={item.mailbox} />,
|
||||
@@ -285,6 +309,15 @@ const List: FC = () => {
|
||||
/>
|
||||
)}
|
||||
|
||||
<ModalConfrim
|
||||
isOpen={showModal}
|
||||
close={() => setShowModal(false)}
|
||||
onConfrim={handleMarkAll}
|
||||
isLoading={isMarkingAllRead}
|
||||
title={'خواندن همه'}
|
||||
label={'آیا از خواندن همه پیام ها اطمینان دارید؟'}
|
||||
/>
|
||||
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user