diff --git a/src/legal-api.ts b/src/legal-api.ts index 5a72dfb..702ee69 100644 --- a/src/legal-api.ts +++ b/src/legal-api.ts @@ -194,6 +194,7 @@ export class LegalApi { export interface CaseStatusEntry { case_number: string; status: string; + updated_at?: string | null; } export interface CaseSummary { diff --git a/src/worker.ts b/src/worker.ts index f732762..38d426c 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -1391,7 +1391,7 @@ const plugin = definePlugin({ if (!caseNumber) return null; const apiBase = await resolveApiBase(ctx, companyIdOf(params)); try { - const resp = await ctx.http.fetch( + const resp = await fetchLegalApi( `${apiBase}/api/cases/${encodeURIComponent(caseNumber)}/legal-arguments`, ); if (!resp.ok) { @@ -1428,7 +1428,7 @@ const plugin = definePlugin({ if (!caseNumber) return []; const apiBase = await resolveApiBase(ctx, companyIdOf(params)); try { - const resp = await ctx.http.fetch( + const resp = await fetchLegalApi( `${apiBase}/api/cases/${encodeURIComponent(caseNumber)}/precedents`, ); if (!resp.ok) { @@ -1467,7 +1467,7 @@ const plugin = definePlugin({ const url = new URL(`${apiBase}/api/missing-precedents`); url.searchParams.set("case_number", caseNumber); url.searchParams.set("status", "open"); - const resp = await ctx.http.fetch(url.toString()); + const resp = await fetchLegalApi(url.toString()); if (!resp.ok) { ctx.logger.warn("legal-case-missing-precedents: API error", { caseNumber, @@ -1488,13 +1488,13 @@ const plugin = definePlugin({ ctx.data.register("legal-dashboard-stats", async () => { try { - const cases = await api.listCases(); + const cases = await api.listCaseStatuses(); const byStatus: Record = {}; let weekActivity = 0; const weekAgoMs = Date.now() - 7 * 24 * 60 * 60 * 1000; for (const c of cases) { byStatus[c.status] = (byStatus[c.status] ?? 0) + 1; - const updated = (c as { updated_at?: string | null }).updated_at; + const updated = c.updated_at; if (updated) { const t = Date.parse(updated); if (!Number.isNaN(t) && t >= weekAgoMs) weekActivity += 1;