'use client';
import type { InsightsResult } from '@/libs/api';
function Bar({ rate, positive }: { rate: number; positive?: boolean }) {
return (
= 0.6 ? '#22c55e' : rate >= 0.4 ? '#f59e0b' : '#94a3b8',
borderRadius: 3,
transition: 'width 0.3s',
}} />
);
}
function Pct({ v }: { v: number }) {
return
= 0.6 ? '#16a34a' : v >= 0.4 ? '#d97706' : '#6b7280' }}>{Math.round(v * 100)}%;
}
export default function InsightsPanel({ data }: { data: InsightsResult | null }) {
if (!data) return (
Loading insights…
);
if (!data.has_data) return (
Not enough data yet. Submit applications and mark outcomes to unlock insights.
);
return (
{/* headline numbers */}
{[
{ label: 'Total submissions', value: data.total_submissions },
{ label: 'Passed screening', value: data.positive_count },
{ label: 'Screening rate', value: `${Math.round(data.positive_rate * 100)}%` },
].map(({ label, value }) => (
))}
{/* operation impact */}
{data.operation_impact.length > 0 && (
Patch operation impact
{data.operation_impact.map(op => (
{op.operation}
{op.positive}/{op.total}
))}
% of accepted patches of this type in submissions that passed screening.
)}
{/* section impact */}
{data.section_impact.length > 0 && (
CV section impact
{data.section_impact.map(s => (
{s.section}
{s.count} edits
))}
)}
{/* keyword signals */}
{(data.top_positive_keywords.length > 0 || data.top_negative_keywords.length > 0) && (
Keyword signals
Positive signals
{data.top_positive_keywords.map(k => (
{k.keyword}
+{k.positive_count} ({k.lift}×)
))}
Negative signals
{data.top_negative_keywords.length === 0
?
None yet
: data.top_negative_keywords.map(k => (
{k.keyword}
{k.negative_count}×
))}
Keywords extracted from accepted AI suggestions, split by outcome.
)}
);
}