import React, { useState, useEffect } from 'react'; import { ShieldCheck, ShieldAlert, FileText, Download, Eye, Link as LinkIcon } from 'lucide-react'; interface TrustCertificateProps { projectId: string; credibilityFlags?: any; regulationGrounding?: string; preciseRegulationUrl?: string; regulationLinkQuality?: string; snapshotData?: any; onExportCertificate?: () => void; onExportJSON?: () => void; } interface CredibilityHealth { overall_credibility: string; components: any; } export const TrustCertificatePanel: React.FC = ({ projectId, credibilityFlags, regulationGrounding, preciseRegulationUrl, regulationLinkQuality = 'medium', snapshotData, onExportCertificate, onExportJSON }) => { const [health, setHealth] = useState(null); const [showCert, setShowCert] = useState(false); const [showModal, setShowModal] = useState(false); useEffect(() => { fetch('/api/admin/credibility-health') .then(r => r.json()) .then(setHealth) .catch(() => {}); }, []); const trustLevel = credibilityFlags?.overall_trust_level || (credibilityFlags?.msp_using_real_data ? 'high' : 'medium'); const badgeColor = trustLevel === 'high' ? '#10b981' : trustLevel === 'medium' ? '#f59e0b' : '#ef4444'; const qualityColor = regulationLinkQuality === 'high' ? '#10b981' : regulationLinkQuality === 'medium' ? '#f59e0b' : '#64748b'; const openFullCertificate = () => setShowModal(true); return ( <>
{trustLevel.toUpperCase()} TRUST REG LINK: {regulationLinkQuality.toUpperCase()} Regulation Grounding Certificate
{onExportCertificate && ( )} {onExportJSON && ( )}
{preciseRegulationUrl && (
Oficjalny dokument regulaminu (najwyższa precyzja)
)} {showCert && (
Regulation Grounding Certificate v1
{snapshotData && (
Program: {snapshotData.program}
Version Hash: {snapshotData.version_hash}
Snapshot ID: {snapshotData.id}
Effective: {snapshotData.effective_date || 'N/A'} | Institution: {snapshotData.source_institution || 'N/A'}
)} {regulationGrounding && (
                {regulationGrounding.slice(0, 650)}
              
)} {credibilityFlags && (
Trust Flags: MSP Real={!!credibilityFlags.msp_using_real_data} | GUS Enriched={!!credibilityFlags.gus_enriched} | Level: {credibilityFlags.overall_trust_level}
)} {health && (
System Health: {health.overall_credibility} {health.components?.acquisition_regulation_link_quality && ( <> | Link Quality: {health.components.acquisition_regulation_link_quality.high_quality_links_pct}% high )}
)}
Pełna audytowalność: hash wersji + snapshot + EUR-Lex + GUS. Dokument nadaje się do załączenia instytucji finansującej.
)}
{/* Full Certificate Modal */} {showModal && (
setShowModal(false)}>
e.stopPropagation()}>

Pełne Świadectwo Zgodności — Regulation Grounding Certificate

Projekt ID: {projectId}

{preciseRegulationUrl &&

Najbardziej precyzyjny dokument: {preciseRegulationUrl}

} {regulationGrounding &&
{regulationGrounding}
} {snapshotData &&
{JSON.stringify(snapshotData, null, 2)}
}
{onExportCertificate && } {onExportJSON && }
)} ); }; export default TrustCertificatePanel;