import { useMemo, useState } from 'react' import { Download, Globe, ShieldCheck } from 'lucide-react' import { ToolHeader } from '../../components/ToolHeader' import { Panel } from '../../components/ui' import { recruitBrand } from './brand' import { reportApi } from './reportApi' import { useReport } from './reportQueries' const chip = (on: boolean) => `rounded-full px-3 py-1 text-xs font-semibold transition ${ on ? 'bg-recruit/25 text-recruit shadow-[inset_0_0_0_1px_var(--color-recruit)]' : 'bg-navy-900 text-faint hover:text-muted border border-line/60' }` const PERIODS = [ { key: 'day', label: 'Daily' }, { key: 'week', label: 'Weekly' }, { key: 'month', label: 'Monthly' }, { key: 'quarter', label: 'Calendar quarter' }, // The one that matters for a federal contractor, and the one a generic tool gets wrong. { key: 'fiscal_quarter', label: 'Federal fiscal quarter' }, ] as const const EXPORTS = [ { kind: 'periods', label: 'This report' }, { kind: 'pipeline', label: 'Pipeline' }, { kind: 'placements', label: 'Placements' }, { kind: 'activity', label: 'Activity' }, ] as const export function Reports() { const [period, setPeriod] = useState('month') const [days, setDays] = useState(365) // Memoised on the window, not recomputed per render: a value derived from Date.now() in the render // body changes the query key every pass and the screen refetches forever. const since = useMemo(() => new Date(Date.now() - days * 864e5).toISOString(), [days]) const q = useReport(period, since) if (q.isLoading) return Building the report… if (q.isError || !q.data) { return ( Could not build the report. {(q.error as Error)?.message} ) } const v = q.data const max = Math.max(1, ...v.rows.map((r) => Math.max(r.opened, r.placements, r.submissions))) return (
{v.time_zone}
{PERIODS.map((p) => ( ))} {[90, 365, 730].map((d) => ( ))}
{period === 'fiscal_quarter' && (

Federal fiscal quarters begin on 1 October, and a fiscal year is named for the calendar year it ends in, so October 2025 falls in FY2026 Q1. Use the calendar quarter option if your client reports on the calendar year instead.

)}
{EXPORTS.map((e) => ( {e.label} ))}

{/* Worth saying plainly: the export is safe to open, and every download is recorded. */} Cells that would otherwise be read as spreadsheet formulas are neutralised before the file is written, so an export is safe to open and safe to forward. Every download is recorded against your account.

p.key === period)?.label.toLowerCase()}`} hint={`${v.rows.length} periods`}> {v.rows.length === 0 ? (

Nothing recorded in this window yet.

) : (
{v.rows.map((r) => ( ))}
Period Opened Filled Submissions Placements Activity Connects Connect %
{r.label}
{r.opened} {r.filled} {r.submissions} {r.placements} {r.activities} {r.connects} {r.connect_rate || '—'}
Total {v.totals.opened} {v.totals.filled} {v.totals.submissions} {v.totals.placements} {v.totals.activities} {v.totals.connects} {v.totals.connect_rate || '—'}
)}

Each column is counted on the period its own event falls in, so a placement in March against an order opened in January is March's placement. Days are counted in {v.time_zone}.

) }