import { useState } from 'react' import { AlertTriangle, Briefcase, Crown, Layers, MapPin, Radar, RefreshCw, ScanSearch, ShieldAlert, ShieldCheck, Target, TrendingUp, Users, } from 'lucide-react' import { useMissionAdoptForecast, useMissionCommandCenter } from './queries' import { missionBrand } from './brand' import { WhoCanSupport } from './WhoCanSupport' import { Badge, Bar, Panel, Stat } from '../../components/ui' import { Gauge } from '../../components/Gauge' import { MissionCheckModal } from '../../components/MissionCheckModal' import { ToolHeader } from '../../components/ToolHeader' import { bandColor, fmtUSD, num, stateColor } from '../../lib/format' import type { CCRecommendation, CCUpcomingOpportunity } from '../../lib/types' const riskColor: Record = { high: 'var(--color-risk)', medium: 'var(--color-warn)', low: 'var(--color-ok)', } const sevColor: Record = { high: 'var(--color-risk)', critical: 'var(--color-risk)', medium: 'var(--color-warn)', warning: 'var(--color-warn)', low: 'var(--color-blue-soft)', info: 'var(--color-blue-soft)', } export function CommandCenter() { const { data: d, isLoading, refetch, isFetching } = useMissionCommandCenter() const [missionCheck, setMissionCheck] = useState(false) if (isLoading || !d) { return Aggregating mission readiness… } const mr = d.mission_readiness const ci = d.clearance_intelligence return (
setMissionCheck(false)} /> {/* header */}

Workforce Command Center™

Can we staff this mission today? · as of {d.as_of}
{/* SECTION: banner */}
} /> } /> } /> } /> 0 ? 'var(--color-warn)' : undefined} icon={} /> 0 ? 'var(--color-risk)' : undefined} icon={} />
{/* LEFT: opportunities + clearance */}
{d.active_opportunities.map((o) => (
{o.name}
{o.customer_agency} · {fmtUSD(o.value)}
{o.staffing_risk}
{num(o.readiness_score).toFixed(0)}%
))}
{ci.inventory_by_level.map((l) => { const max = Math.max(...ci.inventory_by_level.map((x) => x.total), 1) return (
{l.label} {l.total.toLocaleString()} · {l.available} avail
) })}
{ci.inventory_by_poly.map((p) => ( {p.label} {p.total} ))}
{[ ['Now', ci.availability_windows.now], ['30d', ci.availability_windows.d30], ['60d', ci.availability_windows.d60], ['90d', ci.availability_windows.d90], ].map(([k, v]) => (
{(v as number).toLocaleString()}
{k as string}
))}
{(ci.expiring.due_90 > 0 || ci.expiring.expired > 0) && (
{ci.expiring.expired} expired · {ci.expiring.due_90} expiring ≤90d
)}
{/* CENTER: mission readiness + labor category */}
{mr.drivers.map((dr) => (
{dr.label} {num(dr.pct).toFixed(0)}%
))}
{d.labor_category_coverage.map((c) => (
{c.labor_category} {c.filled}/{c.demanded} ·{' '} {num(c.coverage).toFixed(0)}%
))}
{/* RIGHT: staffing gaps + proposal readiness */}
{d.staffing_gaps.length === 0 ? (

Fully staffed against current demand.

) : (
{d.staffing_gaps.map((g) => (
{g.headline} {g.blocks_key_personnel && ( KP )}
{g.value_at_risk ? ( <> {fmtUSD(g.value_at_risk)} exposure {g.value_representative && ( representative )} {' · '} ) : null} {g.impacted_opportunities.slice(0, 2).join(', ')}
{/* counted basis, so the dollar is auditable, never a bare sum */}
{g.value_basis}
{/* modeled Mission Readiness Impact */} {num(g.impact_modeled_pct) > 0 && (
Mission Readiness Impact, plus {g.impact_modeled_pct} pts coverage if filled, modeled
)}
))}
)}
{[ ['Ready', d.proposal_readiness.ready, 'var(--color-ok)'], ['At Risk', d.proposal_readiness.at_risk, 'var(--color-warn)'], ['KP Missing', d.proposal_readiness.key_personnel_missing, 'var(--color-risk)'], ['LCAT Missing', d.proposal_readiness.labor_categories_missing, 'var(--color-warn)'], ].map(([k, v, c]) => (
{v as number}
{k as string}
))}
{/* ROW: win impact + heat map + recommendations */}
{d.win_impact.high_impact_count}
high impact candidates
    {d.win_impact.top.slice(0, 5).map((c) => (
  • {c.full_name} {c.clearance_level === 'ts_sci' ? 'TS/SCI' : c.clearance_level} · {c.years_experience}y
  • ))}
{d.heat_map.slice(0, 8).map((m) => { const max = Math.max(...d.heat_map.map((x) => x.total), 1) return (
{m.metro} {m.total}
) })}
    {d.ai_recommendations.map((r: CCRecommendation, i) => (
  • {r.message}
  • ))}
{/* ROW: upcoming opportunities (forecasts) + incumbent landscape (contract awards) */}
{d.upcoming_opportunities.length === 0 ? (

No forecasts ingested yet.

) : (
{d.upcoming_opportunities.map((u) => ( ))}
)}
{d.incumbent_landscape.length === 0 ? (

No award data ingested yet.

) : (
{d.incumbent_landscape.map((inc) => (
{inc.incumbent}
{inc.agency} {inc.naics ? ` · NAICS ${inc.naics}` : ''}
{fmtUSD(inc.value)}
{inc.value_source || inc.source}
))}
)}
{/* Executive Action Center */}
{d.action_center.open_opportunities_without_slate} opps without a slate ·{' '} {d.action_center.requirements_unscreened} requirements unscreened
{/* Who can support this mission today, read from the persisted screenMATCH evaluations. */}
) } // UpcomingCard renders one forecast with its honest fit note and a compact adopt as requirement form. // Adopting creates a real requirement the shared engine scores; on success the dashboard refreshes so // the new requirement shows up in coverage. The forecast itself never alters the current readiness. function UpcomingCard({ u }: { u: CCUpcomingOpportunity }) { const [open, setOpen] = useState(false) const [level, setLevel] = useState('secret') const [years, setYears] = useState(3) const [skills, setSkills] = useState('') const adopt = useMissionAdoptForecast() return (
{u.title}
{u.agency} {u.naics ? ` · NAICS ${u.naics}` : ''} {u.place_of_performance ? ` · ${u.place_of_performance}` : ''} {u.estimated_award_date ? ` · est. award ${u.estimated_award_date}` : ''} {u.estimated_value ? ` · ${fmtUSD(u.estimated_value)}` : ''}
{u.planning_note}
{u.fit_note}
{u.adoptable && (
{!open ? ( ) : (
{ e.preventDefault() adopt.mutate( { recordID: u.record_id, input: { required_level: level, required_poly: 'none', required_years: years, key_personnel: false, skills: skills .split(',') .map((s) => s.trim()) .filter(Boolean), }, }, { onSuccess: () => setOpen(false) }, ) }} className="mt-1 space-y-1.5 rounded-md border border-line/50 bg-navy-950/40 p-2" >
setYears(Number(e.target.value))} className="w-16 rounded border border-line/70 bg-navy-950/60 px-1.5 py-1 text-[11px] outline-none" aria-label="Required years" />
setSkills(e.target.value)} placeholder="Required skills, comma separated" className="w-full rounded border border-line/70 bg-navy-950/60 px-1.5 py-1 text-[11px] outline-none" aria-label="Required skills" />
{adopt.isError && Could not adopt. Try again.}
)}
)}
) }