feat: enhance various pages with improved UI elements and search functionality

This commit is contained in:
hamed
2026-06-10 13:20:21 +03:30
parent 06ab875693
commit 4b8504df91
8 changed files with 86 additions and 34 deletions
+19 -4
View File
@@ -23,6 +23,7 @@ export default function CommentsPage() {
const [page, setPage] = useState(1);
const [search, setSearch] = useState('');
const [approvedFilter, setApprovedFilter] = useState('pending');
const [approveTarget, setApproveTarget] = useState<Comment | null>(null);
const [deleteTarget, setDeleteTarget] = useState<Comment | null>(null);
const limit = 15;
@@ -40,6 +41,7 @@ export default function CommentsPage() {
mutationFn: (c: Comment) => api.post<ApiResponse<null>>(`/api/v1/admin/comment/${c.uuid}/approve`, {}),
onSuccess: () => {
toast.success('نظر تأیید شد');
setApproveTarget(null);
qc.invalidateQueries({ queryKey: ['comments'] });
},
onError: (err: Error) => toast.error(err.message),
@@ -67,7 +69,7 @@ export default function CommentsPage() {
key: 'body',
header: 'متن',
render: (c) => (
<span className="text-gray-500 text-xs line-clamp-2 max-w-xs">{c.body}</span>
<span className="text-slate-500 dark:text-slate-400 text-xs line-clamp-2 max-w-xs block">{c.body}</span>
),
},
{
@@ -111,8 +113,11 @@ export default function CommentsPage() {
actions={(comment) => (
<>
{!comment.is_approved && (
<button onClick={() => approveMutation.mutate(comment)}
className="p-1.5 text-gray-400 hover:text-green-600 hover:bg-green-50 rounded-lg transition-colors" title="تأیید">
<button
onClick={() => setApproveTarget(comment)}
className="cp-action-approve"
title="تأیید"
>
<CheckIcon className="w-4 h-4" />
</button>
)}
@@ -126,10 +131,20 @@ export default function CommentsPage() {
<Pagination page={page} total={total} limit={limit} onPageChange={setPage} />
</div>
<ConfirmDialog
open={!!approveTarget}
title="تأیید نظر"
message={`نظر "${approveTarget?.title}" از ${approveTarget?.patient_name} را تأیید می‌کنید؟`}
confirmLabel="تأیید"
loading={approveMutation.isPending}
onConfirm={() => approveTarget && approveMutation.mutate(approveTarget)}
onCancel={() => setApproveTarget(null)}
/>
<ConfirmDialog
open={!!deleteTarget}
title="حذف نظر"
message="آیا از حذف این نظر اطمینان دارید؟"
message={`آیا از حذف نظر "${deleteTarget?.title}" از ${deleteTarget?.patient_name} اطمینان دارید؟`}
confirmLabel="حذف"
danger
loading={deleteMutation.isPending}