import { type ReactNode, useEffect, useState } from 'react' import { useNavigate } from 'react-router-dom' import { ChevronRight, LayoutGrid, Rows3, ScanSearch, ShieldQuestion, Target, Trash2, TrendingUp, Trophy } from 'lucide-react' import { useCandidateIntelligence, useDeleteExternalCandidate } from '../lib/queries' import type { CandidateIntelligence, IntelClearance } from '../lib/types' import { Badge, Panel } from '../components/ui' import { MissionCheckModal } from '../components/MissionCheckModal' import { bandColor, num, proposalColor, winImpactColor } from '../lib/format' type View = 'intelligence' | 'list' const VIEW_KEY = 'screenmatch.candidatesView' export function Candidates() { const { data, isLoading } = useCandidateIntelligence() const [view, setView] = useState(() => (localStorage.getItem(VIEW_KEY) as View) || 'intelligence') const [missionCheck, setMissionCheck] = useState(false) useEffect(() => { localStorage.setItem(VIEW_KEY, view) }, [view]) const rows = data ?? [] const greens = rows.filter((c) => c.mission_readiness.band === 'green').length const highImpact = rows.filter((c) => c.win_impact.level === 'HIGH').length return (
Cleared Workforce Intelligence Demo data
{isLoading ? 'Scoring the workforce against open requirements…' : `${rows.length} synthetic candidates, ${greens} proposal ready, ${highImpact} fill an open gap. Shaped for Galapagos cleared IT and cyber.`}
setView('intelligence')} icon={} label="Intelligence View" /> setView('list')} icon={} label="List View" />
setMissionCheck(false)} /> {isLoading ? ( Computing Mission Readiness, Win Impact, and Best Fit… ) : rows.length === 0 ? ( No candidates yet. ) : view === 'intelligence' ? ( ) : ( )}

Mission Readiness, Proposal Ready, Win Impact, and Best Fit are computed live from the shared scoring engine and the Command Center coverage, so a candidate shows the same Mission Readiness here, on the dashboard, in Top Matches, and in the evaluation view. Every candidate shown is synthetic Demo data, a generated profile for demonstration, not a real person. The sourced External leads additionally carry an Unknown clearance. Clearance is a self reported clearance intelligence indicator, never verified. The real check is the hiring client FSO through DISS at onboarding. When Galapagos loads their own bench the staffing picture becomes real.

) } function ToggleButton({ active, onClick, icon, label }: { active: boolean; onClick: () => void; icon: ReactNode; label: string }) { return ( ) } // ---------------- List View ---------------- function ListView({ rows }: { rows: CandidateIntelligence[] }) { const nav = useNavigate() const del = useDeleteExternalCandidate() return (
{rows.map((c) => ( ))}
Candidate Clearance Intelligence Mission Ready Proposal Ready Win Impact Best Fit
{c.full_name}
{c.years_experience} yrs{c.location ? ` · ${c.location}` : ''} {c.source === 'external' && ( External · Demo )}
{num(c.mission_readiness.score).toFixed(0)}%
{c.mission_readiness.status}
{c.proposal_ready.value}
{c.proposal_ready.reason}
{c.win_impact.level}
{c.best_fit.name}
{c.best_fit.customer_agency ? `${c.best_fit.customer_agency} · ` : ''} {num(c.best_fit.score).toFixed(0)}% fit
{c.source === 'external' && ( )}
) } // ---------------- Intelligence View ---------------- function IntelligenceView({ rows }: { rows: CandidateIntelligence[] }) { return (
{rows.map((c) => ( ))}
) } function IntelCard({ c }: { c: CandidateIntelligence }) { const nav = useNavigate() const del = useDeleteExternalCandidate() const r = c.mission_readiness return (
{c.full_name}
{c.years_experience} yrs{c.location ? ` · ${c.location}` : ''} {c.source === 'external' && ( External · Demo )}
Proposal {c.proposal_ready.value} Win {c.win_impact.level} {r.status}
Best Fit
{c.best_fit.name}
{c.best_fit.customer_agency ? `${c.best_fit.customer_agency} · ` : ''} {num(c.best_fit.score).toFixed(0)}% fit
{c.win_impact.basis}
Labor Category Coverage
{c.labor_category_coverage.length > 0 ? (
{c.labor_category_coverage.map((l) => ( {l} ))}
) : (
{c.headline ? c.headline : 'Qualification review pending'}
)}
{c.source === 'external' ? ( ) : ( )}
) } // ---------------- shared ---------------- function ClearanceCell({ c }: { c: IntelClearance }) { const unknown = !c.sci_known || c.level === 'Unknown' const lapsed = c.sci_known && c.status !== 'Active' // Expired or Inactive, never shown as confident const badgeColor = unknown ? 'var(--color-muted)' : lapsed ? 'var(--color-warn)' : 'var(--color-blue)' return (
{unknown ? ( {c.level || 'Unknown'} ) : ( c.level )}
{!unknown && (
{c.status} {c.sci_eligible ? ' · SCI eligible' : ''} {c.investigation_year ? ` · investigated ${c.investigation_year}` : ''}
)}
{c.verified ? '✓ ' : ''} {c.provenance}
{c.available ? 'Available now' : 'Engaged'}
) } function Ring({ value, color }: { value: number; color: string }) { const r = 22 const circ = 2 * Math.PI * r return (
{value.toFixed(0)}
) }