chrysopedia/frontend/src/api/reports.ts
jlightner 39e169b4ce feat: Split 945-line public-client.ts into 10 domain API modules with s…
- "frontend/src/api/client.ts"
- "frontend/src/api/index.ts"
- "frontend/src/api/search.ts"
- "frontend/src/api/techniques.ts"
- "frontend/src/api/creators.ts"
- "frontend/src/api/topics.ts"
- "frontend/src/api/stats.ts"
- "frontend/src/api/reports.ts"

GSD-Task: S05/T01
2026-04-03 23:04:56 +00:00

71 lines
2.1 KiB
TypeScript

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<ContentReport> {
return request<ContentReport>(`${BASE}/reports`, {
method: "POST",
body: JSON.stringify(body),
});
}
export async function fetchReports(params: {
status?: string;
content_type?: string;
offset?: number;
limit?: number;
} = {}): Promise<ContentReportListResponse> {
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<ContentReportListResponse>(
`${BASE}/admin/reports${query ? `?${query}` : ""}`,
);
}
export async function updateReport(
id: string,
body: { status?: string; admin_notes?: string },
): Promise<ContentReport> {
return request<ContentReport>(`${BASE}/admin/reports/${id}`, {
method: "PATCH",
body: JSON.stringify(body),
});
}