Refactor code structure for improved readability and maintainability

This commit is contained in:
hamed
2026-06-19 00:54:34 +03:30
parent 2943e29663
commit ccfb3391f2
8 changed files with 18046 additions and 48 deletions
+5 -6
View File
@@ -6,7 +6,7 @@ import { toast } from 'sonner';
import { api } from '../lib/api';
import type { ApiResponse, PaginatedResponse } from '../lib/api';
import type { Blog } from '../types';
import { formatDate, formatNumber } from '../lib/utils';
import { formatDate } from '../lib/utils';
import DataTable, { Column } from '../components/ui/DataTable';
import Pagination from '../components/ui/Pagination';
import ConfirmDialog from '../components/ui/ConfirmDialog';
@@ -52,8 +52,8 @@ export default function BlogsPage() {
header: 'عنوان',
render: (b) => (
<div className="cell-user">
{b.cover_image ? (
<img src={b.cover_image} alt="" style={{ width: 40, height: 28, borderRadius: 6, objectFit: 'cover', flexShrink: 0 }} />
{b.image_url ? (
<img src={b.image_url} alt="" style={{ width: 40, height: 28, borderRadius: 6, objectFit: 'cover', flexShrink: 0 }} />
) : (
<div style={{ width: 40, height: 28, borderRadius: 6, background: 'var(--surface-3)', flexShrink: 0 }} />
)}
@@ -63,7 +63,7 @@ export default function BlogsPage() {
</div>
),
},
{ key: 'author_name', header: 'نویسنده' },
{ key: 'author', header: 'نویسنده', render: (b) => b.author?.name ?? '—' },
{
key: 'status',
header: 'وضعیت',
@@ -85,8 +85,7 @@ export default function BlogsPage() {
</div>
),
},
{ key: 'views_count', header: 'بازدید', render: (b) => formatNumber(b.views_count) },
{ key: 'published_at', header: 'انتشار', render: (b) => formatDate(b.published_at) },
{ key: 'created_at', header: 'تاریخ', render: (b) => formatDate(b.created_at) },
];
const items = data?.data ?? [];