"use client"; import { useEffect, useState } from "react"; import { fmtPrice, fmtDate } from "@/lib/format"; import { STATUS_LABEL } from "@/lib/listings/types"; type Row = { l: { id: string; slug: string; title: string | null; status: string; listingType: string; priceAmount: string | null; moderationNote: string | null; updatedAt: string; sourceType: string }; p: { city: string | null; canonicalAddress: string | null; propertyType: string }; ownerEmail: string | null }; export function AdminListings() { const [status, setStatus] = useState("PENDING_REVIEW"); const [rows, setRows] = useState([]); const load = () => fetch(`/api/admin/listings?status=${status}`).then((r) => r.json()).then((j) => setRows(j.items ?? [])); useEffect(() => { load(); }, [status]); // eslint-disable-line react-hooks/exhaustive-deps const act = async (id: string, action: string) => { const note = action !== "approve" ? prompt("Motif communiqué à l'annonceur :") ?? undefined : undefined; if (action !== "approve" && note == null) return; await fetch("/api/admin/listings", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ id, action, note }) }); load(); }; return (

Annonces

); }