add pending bage for appeals tanstak-table
This commit is contained in:
@@ -119,9 +119,9 @@ export async function fetchAppealsContentList(page?: number, size?: number, sort
|
|||||||
message_body: {
|
message_body: {
|
||||||
action: 'all_appeals',
|
action: 'all_appeals',
|
||||||
page: page,
|
page: page,
|
||||||
page_size: size,
|
pageSize: size,
|
||||||
/* sort_by: sortDirection || 'asc',
|
sort_by: sortBy || '',
|
||||||
sort_order: sortBy || '', */
|
sort_order: sortDirection || 'asc',
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
headers: {
|
headers: {
|
||||||
@@ -173,7 +173,6 @@ export async function changeAppealContentStatus(appealId?: string, approve?: boo
|
|||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const parsed = await response.json();
|
const parsed = await response.json();
|
||||||
console.log(parsed);
|
|
||||||
|
|
||||||
if (parsed.message_code === 0) {
|
if (parsed.message_code === 0) {
|
||||||
return parsed.message_body.message_body;
|
return parsed.message_body.message_body;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import { FileTypeIcon } from '@/app/components/FileTypeIcon';
|
|||||||
import { downloadFile } from '@/app/actions/contentActions';
|
import { downloadFile } from '@/app/actions/contentActions';
|
||||||
import { useContentForAppeals, AppealsFile } from '@/app/hooks/react-query/useContentForAppeals';
|
import { useContentForAppeals, AppealsFile } from '@/app/hooks/react-query/useContentForAppeals';
|
||||||
import AppealModerationModal from '@/app/ui/content/AppealModerationModal';
|
import AppealModerationModal from '@/app/ui/content/AppealModerationModal';
|
||||||
|
import { formatDate, formatDateTime } from '@/app/lib/formatDate';
|
||||||
|
|
||||||
const cutFileExtension = (fileName: string) => {
|
const cutFileExtension = (fileName: string) => {
|
||||||
const lastDotIndex = fileName.lastIndexOf('.');
|
const lastDotIndex = fileName.lastIndexOf('.');
|
||||||
@@ -57,6 +58,7 @@ const StatusBadge = ({ status }: { status: string }) => {
|
|||||||
'REJECTED': { className: 'bg-red-100 text-red-800', label: 'Заблокировано' },
|
'REJECTED': { className: 'bg-red-100 text-red-800', label: 'Заблокировано' },
|
||||||
'MODERATION': { className: 'bg-yellow-100 text-yellow-800', label: 'На модерации' },
|
'MODERATION': { className: 'bg-yellow-100 text-yellow-800', label: 'На модерации' },
|
||||||
'APPROVED': { className: 'bg-green-100 text-green-800', label: 'Одобрено' },
|
'APPROVED': { className: 'bg-green-100 text-green-800', label: 'Одобрено' },
|
||||||
|
'PENDING': { className: 'bg-gray-100 text-gray-800', label: 'На рассмотрении' }
|
||||||
};
|
};
|
||||||
|
|
||||||
const config = statusConfig[status] || { className: 'bg-gray-100 text-gray-800', label: status };
|
const config = statusConfig[status] || { className: 'bg-gray-100 text-gray-800', label: status };
|
||||||
@@ -89,8 +91,8 @@ export default function ContentAppealsTable({ permission }: { permission: number
|
|||||||
|
|
||||||
const sort = sorting[0];
|
const sort = sorting[0];
|
||||||
const sortByMap: Record<string, string> = {
|
const sortByMap: Record<string, string> = {
|
||||||
'fileName': 'originalFileName',
|
'fileName': 'fileName',
|
||||||
'userId': 'userId',
|
'appealId': 'appealId',
|
||||||
'status': 'status',
|
'status': 'status',
|
||||||
'createdAt': 'createdAt',
|
'createdAt': 'createdAt',
|
||||||
};
|
};
|
||||||
@@ -237,7 +239,7 @@ export default function ContentAppealsTable({ permission }: { permission: number
|
|||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||||
className="sort-button hidden"
|
className="sort-button"
|
||||||
>
|
>
|
||||||
{column.getIsSorted() === 'asc' ?
|
{column.getIsSorted() === 'asc' ?
|
||||||
<span><IconArrowUp /></span>
|
<span><IconArrowUp /></span>
|
||||||
@@ -253,6 +255,34 @@ export default function ContentAppealsTable({ permission }: { permission: number
|
|||||||
<StatusBadge status={row.original.status} />
|
<StatusBadge status={row.original.status} />
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
accessorKey: 'createdAt',
|
||||||
|
header: ({ column }) => (
|
||||||
|
<div className="column">
|
||||||
|
<span>
|
||||||
|
createdAt
|
||||||
|
</span>
|
||||||
|
<button
|
||||||
|
onClick={() => column.toggleSorting(column.getIsSorted() === 'asc')}
|
||||||
|
className="sort-button"
|
||||||
|
>
|
||||||
|
{column.getIsSorted() === 'asc' ?
|
||||||
|
<span><IconArrowUp /></span>
|
||||||
|
: column.getIsSorted() === 'desc' ?
|
||||||
|
<span><IconArrowDown /></span>
|
||||||
|
: <span><IconFilter /></span>
|
||||||
|
}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
),
|
||||||
|
cell: ({ row }) => (
|
||||||
|
<div className="text-center">
|
||||||
|
{row.original.createdAt ? formatDate(row.original.createdAt) : '---'}
|
||||||
|
<br />
|
||||||
|
{row.original.createdAt ? formatDateTime(row.original.createdAt) : '---'}
|
||||||
|
</div>
|
||||||
|
),
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user