From 8b28a2dee0c27f89c900e43055e063239b83fc74 Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Mon, 28 Jul 2025 16:38:27 +0330 Subject: [PATCH] inbox 3 row --- src/components/Table.tsx | 2 +- src/pages/received/List.tsx | 97 ++++++++++++++++++++++++++++++------- 2 files changed, 80 insertions(+), 19 deletions(-) diff --git a/src/components/Table.tsx b/src/components/Table.tsx index cc80173..5fcedde 100644 --- a/src/components/Table.tsx +++ b/src/components/Table.tsx @@ -384,7 +384,7 @@ const Table = ({
{(actionsPosition === 'top' || actionsPosition === 'above-header') && (
-
+
{actions} {selectable && selectedRows.length > 0 && selectedActions && selectedActions}
diff --git a/src/pages/received/List.tsx b/src/pages/received/List.tsx index f440728..f65a408 100644 --- a/src/pages/received/List.tsx +++ b/src/pages/received/List.tsx @@ -1,5 +1,5 @@ import Filters, { FilterValues } from '../../components/Filters'; -import { FC, useState } from 'react' +import React, { FC, useState } from 'react' import { useTranslation } from 'react-i18next' import Table from '../../components/Table'; import { ColumnType } from '../../components/types/TableTypes'; @@ -8,7 +8,7 @@ import { RowActionItem } from '../../components/RowActionsDropdown'; import { useNavigate } from 'react-router-dom'; 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' import { useEmailActions } from '@/hooks/useEmailActions'; import Favorite from './Components/Favorite'; @@ -40,11 +40,28 @@ const List: FC = () => { ...filters }); + // تابع برای گرفتن فقط ساعت + const formatTime = (dateString: string) => { + try { + if (!dateString) return '--:--'; + const date = new Date(dateString); + if (isNaN(date.getTime())) return '--:--'; + + return new Intl.DateTimeFormat("fa-IR", { + hour: "2-digit", + minute: "2-digit", + }).format(date); + } catch (error) { + console.error('خطا در فرمت زمان:', error); + return '--:--'; + } + }; const [selectedMessages, setSelectedMessages] = useState([]); const [selectedMessage, setSelectedMessage] = useState(null); - const columns: ColumnType[] = [ + // ستون‌های دسکتاپ (مثل اولیه) + const desktopColumns: ColumnType[] = [ { key: 'subject', title: 'عنوان پیام', @@ -73,11 +90,56 @@ const List: FC = () => { title: 'تاریخ', align: 'center', render: (item) => ( - {formatDate(item.date)} + {formatTime(item.date)} ) }, ]; + // ستون‌های موبایل (سه خطی) + const mobileColumns: ColumnType[] = [ + { + key: 'content', + title: 'محتوا', + render: (item) => ( +
+ {/* سطر اول: فرستنده + ساعت */} +
+ + {item.from.name || item.from.address} + + + {formatTime(item.date)} + +
+ + {/* سطر دوم: موضوع */} +
+ {item.subject || 'بدون موضوع'} +
+ + {/* سطر سوم: خلاصه */} +
+ {item.intro || 'بدون متن پیش‌نمایش'} +
+
+ ) + } + ]; + + // انتخاب ستون‌ها بر اساس سایز صفحه + const [isMobile, setIsMobile] = useState(window.innerWidth < 768); + + React.useEffect(() => { + const handleResize = () => { + setIsMobile(window.innerWidth < 768); + }; + + window.addEventListener('resize', handleResize); + return () => window.removeEventListener('resize', handleResize); + }, []); + + const columns = isMobile ? mobileColumns : desktopColumns; + const tableActions = (
{ return (
-

{t('received.title')}

+
+

{t('received.title')}

+ +
{ searchField="search" /> -
- -
- columns={columns} data={messages}