diff --git a/src/app/(dashboard)/photos/page.tsx b/src/app/(dashboard)/photos/page.tsx index 6d36fc5..005f0c7 100644 --- a/src/app/(dashboard)/photos/page.tsx +++ b/src/app/(dashboard)/photos/page.tsx @@ -1,16 +1,17 @@ "use client"; import { useCallback, useEffect, useState } from "react"; -import { ChevronLeft, ChevronRight, ImageOff, Trash2 } from "lucide-react"; +import { ChevronLeft, ChevronRight, ImageOff, Trash2, Flag } from "lucide-react"; import { Card } from "@/components/ui/Card"; import { Button } from "@/components/ui/Button"; import { EmptyState } from "@/components/ui/EmptyState"; import { FullScreenLoader } from "@/components/ui/FullScreenLoader"; import { ErrorBanner } from "@/components/ui/ErrorBanner"; import { ConfirmDialog } from "@/components/ui/ConfirmDialog"; +import { Modal } from "@/components/ui/Modal"; import { useToast } from "@/components/ui/Toast"; import { formatApiError } from "@/lib/hooks"; -import { AdminPhotoView, listAllPhotos, deletePhotoAdmin, photoUrl } from "@/lib/api"; +import { AdminPhotoView, listAllPhotos, deletePhotoAdmin, reportPhoto, photoUrl } from "@/lib/api"; const PAGE_SIZE = 24; @@ -22,6 +23,9 @@ export default function PhotosModerationPage() { const [error, setError] = useState(null); const [pendingDelete, setPendingDelete] = useState(null); const [deleting, setDeleting] = useState(false); + const [pendingReport, setPendingReport] = useState(null); + const [reportReason, setReportReason] = useState(""); + const [reporting, setReporting] = useState(false); const load = useCallback(async (p: number) => { setError(null); @@ -54,6 +58,21 @@ export default function PhotosModerationPage() { } } + async function handleReport() { + if (!pendingReport || reportReason.trim().length < 3) return; + setReporting(true); + try { + await reportPhoto(pendingReport.id, reportReason.trim()); + toast.showSuccess("گزارش ثبت شد"); + setPendingReport(null); + setReportReason(""); + } catch (err) { + toast.showError(formatApiError(err)); + } finally { + setReporting(false); + } + } + const totalPages = Math.max(1, Math.ceil(total / PAGE_SIZE)); return ( @@ -102,13 +121,22 @@ export default function PhotosModerationPage() { {p.owner_phone}

- +
+ + +
))} @@ -149,6 +177,38 @@ export default function PhotosModerationPage() { onConfirm={handleDelete} onCancel={() => setPendingDelete(null)} /> + + setPendingReport(null)} + title="گزارش عکس" + > +
+

+ یک یادداشت نظارتی روی صاحب این عکس ثبت می‌شه (مستقل از حذف کردن). +

+