diff --git a/client/src/pages/SectorComplianceDetail.tsx b/client/src/pages/SectorComplianceDetail.tsx index 1d69914d07..780fc4eeba 100644 --- a/client/src/pages/SectorComplianceDetail.tsx +++ b/client/src/pages/SectorComplianceDetail.tsx @@ -27,17 +27,6 @@ import { } from "lucide-react"; // Rendered inside DashboardLayout via App.tsx router -// ─── Sector compliance baseline scores (last audit cycle) ──────────────────── -// TODO: migrate to DB-driven config (e.g. /api/trpc/sectorConfig.baselines) -// so scores update per audit cycle without redeploying. -const BASELINE_SCORES: Record = { - fintech: 87, - healthcare: 92, - energy: 78, - insurance: 85, - telecom: 81, -}; - // ─── Sector metadata ────────────────────────────────────────────────────────── const SECTOR_META: Record { + const rows = (benchmarkQuery.data ?? []) as Array<{ avg_compliance_score?: number | string }>; + const v = rows[0]?.avg_compliance_score; + return v != null && !Number.isNaN(Number(v)) ? Math.round(Number(v)) : null; + })(); + // ── Resolve active query ───────────────────────────────────────────────── type EntityRow = Record; let entities: EntityRow[] = []; @@ -371,8 +371,8 @@ export default function SectorComplianceDetail() {
Compliance Score
{score}%
- {BASELINE_SCORES[sector] && ( -
Baseline: {BASELINE_SCORES[sector]}%
+ {baselineScore != null && ( +
Sector baseline: {baselineScore}%
)} diff --git a/server/phase21.test.ts b/server/phase21.test.ts index da2b363cf6..7f2119d97f 100644 --- a/server/phase21.test.ts +++ b/server/phase21.test.ts @@ -43,10 +43,13 @@ describe("SectorComplianceDetail page", () => { expect(c).toContain("trpc.insurance.listCompanies.useQuery"); expect(c).toContain("trpc.telecom.listOperators.useQuery"); }); - it("shows compliance score per sector", () => { + it("sources the sector baseline from the DB (sectorBenchmarks), not hardcoded scores", () => { const c = fs.readFileSync(detailPath, "utf-8"); - expect(c).toContain("fintech: 87"); - expect(c).toContain("healthcare: 92"); + expect(c).toContain("trpc.sectorBenchmarks.list.useQuery"); + expect(c).toContain("avg_compliance_score"); + // Guard against reintroducing the old hardcoded baseline map + expect(c).not.toContain("fintech: 87"); + expect(c).not.toContain("BASELINE_SCORES"); }); it("has pagination controls", () => { const c = fs.readFileSync(detailPath, "utf-8");