feat: implement admin API for user and representation management
- Updated UsersPage to fetch users from the new admin endpoint. - Enhanced user data structure to include 'name' and modified rendering logic. - Added RepresentationDetailPage for detailed representation management. - Created AdminApiController to handle user and representation CRUD operations. - Implemented pagination and search functionality for users and representations. - Updated user and representation data models to reflect new API structure.
This commit is contained in:
@@ -14,15 +14,15 @@ import ConfirmDialog from '../components/ui/ConfirmDialog';
|
||||
|
||||
const FILTERS = [
|
||||
{ value: '', label: 'همه' },
|
||||
{ value: 'false', label: 'در انتظار تأیید' },
|
||||
{ value: 'true', label: 'تأییدشده' },
|
||||
{ value: 'pending', label: 'در انتظار تأیید' },
|
||||
{ value: 'approved', label: 'تأییدشده' },
|
||||
];
|
||||
|
||||
export default function CommentsPage() {
|
||||
const qc = useQueryClient();
|
||||
const [page, setPage] = useState(1);
|
||||
const [search, setSearch] = useState('');
|
||||
const [approvedFilter, setApprovedFilter] = useState('false');
|
||||
const [approvedFilter, setApprovedFilter] = useState('pending');
|
||||
const [deleteTarget, setDeleteTarget] = useState<Comment | null>(null);
|
||||
const limit = 15;
|
||||
|
||||
@@ -31,13 +31,13 @@ export default function CommentsPage() {
|
||||
queryFn: () => {
|
||||
const params = new URLSearchParams({ page: String(page), limit: String(limit) });
|
||||
if (search) params.set('search', search);
|
||||
if (approvedFilter !== '') params.set('is_approved', approvedFilter);
|
||||
return api.get<PaginatedResponse<Comment>>(`/api/v1/comments?${params}`);
|
||||
if (approvedFilter !== '') params.set('status', approvedFilter);
|
||||
return api.get<PaginatedResponse<Comment>>(`/api/v1/admin/comments?${params}`);
|
||||
},
|
||||
});
|
||||
|
||||
const approveMutation = useMutation({
|
||||
mutationFn: (c: Comment) => api.patch<ApiResponse<null>>(`/api/v1/comment/${c.uuid}/approve`, {}),
|
||||
mutationFn: (c: Comment) => api.post<ApiResponse<null>>(`/api/v1/admin/comment/${c.uuid}/approve`, {}),
|
||||
onSuccess: () => {
|
||||
toast.success('نظر تأیید شد');
|
||||
qc.invalidateQueries({ queryKey: ['comments'] });
|
||||
@@ -78,8 +78,8 @@ export default function CommentsPage() {
|
||||
{ key: 'created_at', header: 'تاریخ', render: (c) => formatDate(c.created_at) },
|
||||
];
|
||||
|
||||
const items = data?.data?.items ?? [];
|
||||
const total = data?.data?.total ?? 0;
|
||||
const items = data?.data ?? [];
|
||||
const total = data?.meta?.totalRecords ?? 0;
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
||||
Reference in New Issue
Block a user