import { Fragment, useMemo, useState } from 'react' import { Building2, ChevronDown, ChevronRight, DollarSign, ExternalLink, RefreshCw, Radio, Search, Trophy } from 'lucide-react' import { useGalapagosAwards, useIncumbents, useSamOpportunities, useWages } from '../lib/queries' import type { FederalAward, OpportunityFilters, SamOpportunity } from '../lib/types' import { Badge, Panel } from '../components/ui' import { fmtDate, fmtUSD, GALAPAGOS, NAICS_LABELS, timeAgo } from '../lib/format' type Agency = 'af_sf' | 'dod' | 'air_force' | 'space_force' const agencyOptions: { key: Agency; label: string }[] = [ { key: 'af_sf', label: 'Air Force + Space Force' }, { key: 'dod', label: 'All DoD' }, { key: 'air_force', label: 'Air Force' }, { key: 'space_force', label: 'Space Force' }, ] const chip = (on: boolean) => `rounded-full px-3 py-1 text-xs font-semibold transition ${ on ? 'bg-blue/25 text-blue-soft shadow-[inset_0_0_0_1px_var(--color-blue)]' : 'bg-navy-900 text-faint hover:text-muted border border-line/60' }` const selectCls = 'rounded-lg border border-line/70 bg-navy-900 px-3 py-1.5 text-sm text-ink outline-none focus:border-blue' // freshestSync returns the most recent synced_at across the rows, driving the "synced {relative}" badge. function freshestSync(rows: SamOpportunity[]): string { let best = '' for (const r of rows) if (r.synced_at && r.synced_at > best) best = r.synced_at return best } export function Requirements() { // Default the dashboard to the Galapagos profile so it opens on relevant federal opportunities. // Open on the relevant, non empty slice: Galapagos NAICS with their customers (Air Force and Space // Force). 8(a) and HI, NM are one click narrowers that surface their set aside and location stories. const [naics, setNaics] = useState([...GALAPAGOS.naics]) const [states, setStates] = useState([]) const [eightA, setEightA] = useState(false) const [agency, setAgency] = useState('af_sf') const [q, setQ] = useState('') const filters: OpportunityFilters = useMemo(() => { const f: OpportunityFilters = { limit: 200, active_only: true } if (naics.length) f.naics = naics if (states.length) f.state = states if (eightA) f.set_aside = [...GALAPAGOS.setAside] if (agency === 'af_sf') f.sub_agency = ['AIR FORCE', 'SPACE FORCE'] if (agency === 'dod') f.department = [...GALAPAGOS.departments] if (agency === 'air_force') f.sub_agency = ['AIR FORCE'] if (agency === 'space_force') f.sub_agency = ['SPACE FORCE'] if (q.trim()) f.q = q.trim() return f }, [naics, states, eightA, agency, q]) const { data, isLoading, isError, error, isFetching, refetch } = useSamOpportunities(filters) const rows = data ?? [] const synced = freshestSync(rows) const [openId, setOpenId] = useState(null) const toggle = (list: string[], set: (v: string[]) => void, v: string) => set(list.includes(v) ? list.filter((x) => x !== v) : [...list, v]) return (
{/* Live feed banner */}
Federal Contract Opportunities
Shaped for Galapagos Federal Systems, 8(a) DoD IT and cyber, Air Force and Space Force, HI and NM
{isError ? ( SAM.gov cache unavailable ) : ( Live from SAM.gov{synced ? ` · synced ${timeAgo(synced)}` : ' · not yet synced'} )}
{/* Filters */}
Agency
State {['HI', 'NM'].map((s) => ( ))}
NAICS {GALAPAGOS.naics.map((code) => ( ))}
{/* Galapagos own past performance (USASpending) */} {/* Regional wage baseline (BLS OEWS) */} {/* Results */} {isLoading ? (

Loading opportunities…

) : isError ? (

{(error as Error)?.message ?? 'Failed to load opportunities.'}

) : rows.length === 0 ? ( ) : ( {rows.map((o) => { const open = openId === o.notice_id return ( setOpenId(open ? null : o.notice_id)} > {open && ( )} ) })}
Opportunity Agency NAICS Set Aside Response Due
{open ? ( ) : ( )}
{o.title || '(untitled notice)'}
{o.solicitation_number || 'No solicitation number'} {o.place_of_performance.state ? ` · ${placeLabel(o)}` : ''}
{o.sub_agency || o.department || 'n/a'} {o.naics_code || 'n/a'} {NAICS_LABELS[o.naics_code] && (
{NAICS_LABELS[o.naics_code]}
)}
{o.set_aside_code ? ( {o.set_aside_code} ) : ( n/a )} {fmtDate(o.response_deadline)} {o.ui_link && ( e.stopPropagation()} className="inline-flex items-center gap-1.5 rounded-md border border-line/70 px-2.5 py-1 text-xs font-semibold text-muted hover:border-blue/60 hover:text-blue-soft" > SAM.gov )}
)}
) } // IncumbentsPanel shows who currently holds comparable work in this NAICS, largest awards first, so // the team can spot recompetes and teaming targets. Reads the USASpending cache only. function IncumbentsPanel({ naics }: { naics: string }) { const { data, isLoading } = useIncumbents(naics || null) if (!naics) return

No NAICS on this notice.

if (isLoading) return

Loading incumbents and similar awards…

const awards = data ?? [] return (
Incumbents and similar awards, NAICS {naics}
{awards.length === 0 ? (

No cached awards for this NAICS yet. Run make sync-awards.

) : (
{awards.map((a) => ( ))}
)}
) } // PastPerformance shows Galapagos own award history (their proof they have done this work). function PastPerformance() { const { data, isLoading } = useGalapagosAwards() const awards = data ?? [] if (!isLoading && awards.length === 0) return null return (
Their own federal award history, evidence of relevant experience.
{awards.slice(0, 6).map((a) => ( ))}
) } // WageBaselinePanel shows the BLS OEWS regional wage baseline for the Galapagos roles in Hawaii and // New Mexico. It is a regional wage baseline, current year, useful for pricing a proposal. function WageBaselinePanel() { const { data, isLoading } = useWages() const rows = data ?? [] if (!isLoading && rows.length === 0) return null const year = rows[0]?.year ?? '' return (
Annual mean wage by role and state, a baseline for proposal pricing.
{rows.map((w) => { const hi = w.areas.find((a) => a.area === 'HI') const nm = w.areas.find((a) => a.area === 'NM') return ( ) })}
Role Occupation (SOC) Hawaii New Mexico
{w.role} {w.occupation_title} {fmtUSD(hi?.annual_mean ?? '')} {fmtUSD(nm?.annual_mean ?? '')}
) } function AwardRow({ a }: { a: FederalAward }) { return (
{a.recipient_name || 'Unknown recipient'}
{a.awarding_sub_agency || a.awarding_agency || 'Federal'} {a.pop_end_date ? ` · ends ${a.pop_end_date}` : ''}
{fmtUSD(a.award_amount)}
) } function placeLabel(o: SamOpportunity): string { const { city, state } = o.place_of_performance return [city, state].filter(Boolean).join(', ') } function EmptyState() { return (

No cached opportunities match these filters yet.

Populate the cache with a real pull:{' '} make sync-sam (or{' '} npm run sync:sam) with{' '} SAM_API_KEY set, then refresh.

) }