Second hardened fan-out converted the 7 untouched admin/portal files; hand-finished the configurator (8 block labels + full summary column), portal dashboard, and describe-intake. English renders by default; SV toggle flips the whole app. A few tuple-array data labels intentionally left SV (no-reshape safety) + lib/data label i18n remain as follow-up. build green. Co-Authored-By: Claude Opus 4.8 <[email protected]>
67 lines
2.9 KiB
TypeScript
67 lines
2.9 KiB
TypeScript
"use client";
|
|
|
|
import { useCallback, useEffect, useState } from "react";
|
|
import { useT } from "@/components/locale-provider";
|
|
import { PortalShell } from "@/components/portal-shell";
|
|
import { LoadingSkeleton, ErrorState } from "@/components/states";
|
|
|
|
interface Source {
|
|
source_id: string;
|
|
name: string;
|
|
market: string;
|
|
access: string;
|
|
licence: string;
|
|
cadence: string;
|
|
confidence: number;
|
|
}
|
|
|
|
const ACCESS_COLOR: Record<string, string> = {
|
|
api: "var(--prov-3)", bulk: "var(--prov-2)", authorized_web: "var(--prov-1)", licensed: "var(--prov-0)",
|
|
};
|
|
|
|
export default function AdminSourcesPage() {
|
|
const t = useT();
|
|
const [sources, setSources] = useState<Source[] | null>(null);
|
|
const [error, setError] = useState(false);
|
|
|
|
const load = useCallback(async () => {
|
|
setError(false);
|
|
try {
|
|
const r = await fetch("/api/sources", { cache: "no-store" });
|
|
setSources(await r.json());
|
|
} catch { setError(true); }
|
|
}, []);
|
|
useEffect(() => { void load(); }, [load]);
|
|
|
|
return (
|
|
<PortalShell variant="admin" title={t({ en: "Source registry & freshness", sv: "Källregister & färskhet" })}>
|
|
<p className="font-mono text-[11px] uppercase tracking-[0.1em] text-muted-foreground">
|
|
{t({ en: "Legal sourcing. API > bulk > authorized web > licence. Verify terms.", sv: "Laglig sourcing. API > bulk > auktoriserad webb > licens. Verifiera villkor." })}
|
|
</p>
|
|
{error ? (
|
|
<div className="mt-6"><ErrorState onRetry={load} /></div>
|
|
) : !sources ? (
|
|
<div className="mt-6"><LoadingSkeleton rows={8} /></div>
|
|
) : (
|
|
<div className="mt-6 border border-border">
|
|
<div className="grid grid-cols-[1.6fr_0.8fr_1fr_1.6fr_1fr] border-b border-border bg-secondary/50 px-4 py-2.5 font-mono text-[10px] uppercase tracking-[0.1em] text-muted-foreground">
|
|
<span>{t({ en: "Source", sv: "Källa" })}</span><span>{t({ en: "Market", sv: "Marknad" })}</span><span>{t({ en: "Access", sv: "Åtkomst" })}</span><span>{t({ en: "Licence", sv: "Licens" })}</span><span>{t({ en: "Freshness", sv: "Färskhet" })}</span>
|
|
</div>
|
|
{sources.map((s) => (
|
|
<div key={s.source_id} className="grid grid-cols-[1.6fr_0.8fr_1fr_1.6fr_1fr] items-center border-b border-border px-4 py-3 text-sm last:border-b-0">
|
|
<span className="font-medium">{s.name}</span>
|
|
<span className="font-mono text-xs">{s.market}</span>
|
|
<span className="flex items-center gap-2 font-mono text-[11px] uppercase tracking-[0.06em]">
|
|
<span className="inline-block h-2 w-2" style={{ backgroundColor: ACCESS_COLOR[s.access] ?? "var(--muted-foreground)" }} />
|
|
{s.access}
|
|
</span>
|
|
<span className="truncate pr-3 text-xs text-muted-foreground">{s.licence}</span>
|
|
<span className="font-mono text-xs text-muted-foreground">{s.cadence}</span>
|
|
</div>
|
|
))}
|
|
</div>
|
|
)}
|
|
</PortalShell>
|
|
);
|
|
}
|