Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -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 ?? [];
|
||||
|
||||
Reference in New Issue
Block a user