import React, { useEffect, useState } from "react"; interface TrustSummary { platform_score: number; overall_score: number; level: string; components: Record; recommendations: string[]; } const LEVEL_LABELS: Record = { excellent: "Doskonaly", good: "Dobry", fair: "Umiarkowany", needs_attention: "Wymaga uwagi", }; const COMPONENT_LABELS: Record = { link_precision: "Precyzja linkow", snapshot_richness: "Bogactwo snapshotow", eurlex: "EUR-Lex", msp_grounding: "Grounding MSP", monitoring: "Monitoring prawa", }; export const TrustCenterPanel: React.FC = () => { const [summary, setSummary] = useState(null); const [error, setError] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { fetch("/api/trust/summary") .then((r) => { if (!r.ok) throw new Error("Nie udalo sie pobrac podsumowania zaufania"); return r.json(); }) .then(setSummary) .catch((e) => setError(e.message)) .finally(() => setLoading(false)); }, []); if (loading) { return (

Ladowanie centrum zaufania...

); } if (error || !summary) { return (
{error || "Brak danych"}
); } const score = summary.overall_score ?? summary.platform_score; const levelKey = summary.level || "fair"; return (

Centrum zaufania

Ocena jakosci zrodel i regulaminow platformy

{score}
/ 100
{LEVEL_LABELS[levelKey] || levelKey}

Skladowe

{Object.entries(summary.components || {}).map(([key, value]) => { const pct = Math.min(100, Math.max(0, (value / 40) * 100)); return (
{COMPONENT_LABELS[key] || key} {value.toFixed(1)} pkt
); })}

Rekomendacje

    {(summary.recommendations || []).map((rec, i) => (
  • {rec}
  • ))}
); }; export default TrustCenterPanel;