'use client'; import React from 'react'; import GaugeCard from './GaugeCard'; export default function AiUsageBody({ ai }: { ai?: { explanation?: string; key_findings?: string[]; originality_score?: number; transparency_score?: number; transparency_descriptor?: string; files_with_ai_findings?: number; files_analyzed?: number; files_with_disclosure?: number; repos_analyzed?: number; repos_with_ai_findings?: number; evidence?: Array<{ file_path?: string; snippet?: string; reason?: string }>; } }) { if (!ai) return null; const techGauge = { percent: Math.max(0, Math.min(100, Number(ai.originality_score ?? 0))), label: 'Originality', }; const riskGauge = { percent: Math.max(0, Math.min(100, Number(ai.transparency_score ?? 0))), label: ai.transparency_descriptor ? `Transparency — ${ai.transparency_descriptor}` : 'Transparency', }; const stats: Array<{ label: string; value: string }>= [ { label: 'Files analyzed', value: String(ai.files_analyzed ?? 0) }, { label: 'Files with AI findings', value: String(ai.files_with_ai_findings ?? 0) }, { label: 'Files with disclosure', value: String(ai.files_with_disclosure ?? 0) }, { label: 'Repos analyzed', value: String(ai.repos_analyzed ?? 0) }, { label: 'Repos with AI findings', value: String(ai.repos_with_ai_findings ?? 0) }, ]; const findings = Array.isArray(ai.evidence) ? ai.evidence.slice(0, 5) : []; const topMovers = Array.isArray(ai.key_findings) ? ai.key_findings : []; return (
{stats.map((s, i) => (
{s.label}
{s.value}
))}
{findings.length > 0 && (
Sample Findings
{findings.map((f, idx) => (
{f.file_path || 'file'}
{f.snippet ? (
{f.snippet}
) : null} {f.reason ? (
{f.reason}
) : null}
))}
)} {ai.explanation && (
{ai.explanation}
)}
); }