import { useEffect, type ReactNode } from 'react' import { Link, useParams } from 'react-router-dom' import { ArrowLeft, CheckCircle2, Clock, Compass, FileDown, Layers, Loader2, MapPin, Share2, ShieldCheck, } from 'lucide-react' import { useCandidate, useOpportunities, useRequirement, useScreen } from '../lib/queries' import { Badge, Bar, Panel } from '../components/ui' import { ScreeningResults } from '../components/ScreeningResults' import { WorkforceDNA } from '../components/WorkforceDNA' import { bandColor, clearanceLabel, num, statusLabel } from '../lib/format' import type { Band } from '../lib/types' function proposal(band: Band) { if (band === 'green') return { label: 'PROPOSAL READY', color: 'var(--color-ok)' } if (band === 'yellow') return { label: 'REVIEW REQUIRED', color: 'var(--color-warn)' } return { label: 'RECRUITING REQUIRED', color: 'var(--color-risk)' } } export function CandidateEvaluation() { const { candidateId = '', requirementId = '' } = useParams() const candidateQuery = useCandidate(candidateId || null) const requirementQuery = useRequirement(requirementId || null) const opps = useOpportunities(candidateId || null) const screen = useScreen() useEffect(() => { // Clear the prior result first so a stale screen.data never renders under the new candidate's // identity during the transition; only the loading state shows until the new score returns. screen.reset() if (candidateId && requirementId) screen.mutate({ candidateId, requirementId }) // eslint-disable-next-line react-hooks/exhaustive-deps }, [candidateId, requirementId]) const candidate = candidateQuery.data const requirement = requirementQuery.data return (
Back to Screening Queue {screen.isPending && ( Evaluating mission readiness… )} {screen.isError && (

{(screen.error as Error).message}

)} {screen.data && candidate && requirement && ( <> {/* SCREEN 2, Candidate Intelligence Profile + Workforce DNA */}
{candidate.full_name .split(' ') .map((p) => p[0]) .slice(0, 2) .join('')}

{candidate.full_name}

{requirement.title}
} k="Clearance (self-reported)" v={`${clearanceLabel[candidate.clearance_level] ?? candidate.clearance_level} · ${statusLabel[candidate.clearance_status] ?? candidate.clearance_status} · not verified`} /> } k="Experience" v={`${candidate.years_experience} years`} /> {candidate.location && } k="Location" v={candidate.location} />} } k="Availability" v={candidate.available ? 'Available Now' : 'Engaged'} />
Workforce DNA™
{/* SCREENS 3-5, full screening intelligence (header suppressed) */} {/* SCREEN 5/6, Best Fit Programs + Proposal Readiness */}
{opps.isLoading ? (

Scoring opportunities…

) : !opps.data?.length ? (

No matching opportunities.

) : (
{opps.data.map((o) => (
{o.title} {num(o.score).toFixed(0)}%
))}
)}
{(() => { const pr = proposal(screen.data.mission_readiness.band) const roles = (opps.data ?? []).filter((o) => o.band === 'green') return (
{pr.label}
Proposal strength {num(screen.data.mission_readiness.score).toFixed(0)}%
Can Fill These Roles
{requirement.title} {roles .filter((r) => r.requirement_id !== requirement.id) .map((r) => ( {r.title} ))}
) })()}
)}
) } function Fact({ icon, k, v }: { icon: ReactNode; k: string; v: string }) { return (
{icon} {k}
{v}
) }