import { caseView, deleteQuote, patchQuote } from "@/lib/research/boards"; import { CaseError } from "@/lib/research/cases.mjs"; import { fail, ok } from "../../../../_respond"; export const dynamic = "force-dynamic"; // One quote of a case (the API is documented in ../../../route.ts). // PATCH { claim?, note?, section?, speakerChecked?, useCurrentWords? } -> { quote, case: CaseView } // DELETE -> { quote, index, case: CaseView } type Ctx = { params: Promise<{ id: string; qid: string }> }; export async function PATCH(request: Request, ctx: Ctx) { try { const { id, qid } = await ctx.params; const body = (await request.json().catch(() => null)) as Record | null; if (!body || typeof body !== "object" || Array.isArray(body)) throw new CaseError("expected a JSON object: { claim?, note?, section?, speakerChecked?, useCurrentWords? }"); const r = await patchQuote(id, qid, body); return ok({ quote: r.quote, case: await caseView(id) }); } catch (e) { return fail(e); } } export async function DELETE(_request: Request, ctx: Ctx) { try { const { id, qid } = await ctx.params; const r = await deleteQuote(id, qid); return ok({ quote: r.quote, index: r.index, case: await caseView(id) }); } catch (e) { return fail(e); } }