import { request, BASE } from "./client"; // ── Types ──────────────────────────────────────────────────────────────────── export interface ContentReportCreate { content_type: string; content_id?: string | null; content_title?: string | null; report_type: string; description: string; page_url?: string | null; } export interface ContentReport { id: string; content_type: string; content_id: string | null; content_title: string | null; report_type: string; description: string; status: string; admin_notes: string | null; page_url: string | null; created_at: string; resolved_at: string | null; } export interface ContentReportListResponse { items: ContentReport[]; total: number; offset: number; limit: number; } // ── Functions ──────────────────────────────────────────────────────────────── export async function submitReport( body: ContentReportCreate, ): Promise { return request(`${BASE}/reports`, { method: "POST", body: JSON.stringify(body), }); } export async function fetchReports(params: { status?: string; content_type?: string; offset?: number; limit?: number; } = {}): Promise { const qs = new URLSearchParams(); if (params.status) qs.set("status", params.status); if (params.content_type) qs.set("content_type", params.content_type); if (params.offset !== undefined) qs.set("offset", String(params.offset)); if (params.limit !== undefined) qs.set("limit", String(params.limit)); const query = qs.toString(); return request( `${BASE}/admin/reports${query ? `?${query}` : ""}`, ); } export async function updateReport( id: string, body: { status?: string; admin_notes?: string }, ): Promise { return request(`${BASE}/admin/reports/${id}`, { method: "PATCH", body: JSON.stringify(body), }); }