import Link from 'next/link';
import { IncidentRow, TYPE_LABEL } from '@/components/incidents/IncidentRow';
import { Empty, PNum, Section } from '@/components/ui/primitives';
import { MONTH_NAMES, fmt, fmtInt } from '@/lib/format';
import { pressureColor } from '@/lib/pressure';
import type { HistoryDay, HistoryMonthRow, HistorySummary, Incident } from '@/lib/types';
/** Calendar heat strip: one cell per day coloured by max pressure. */
export function DayStrip({ days, year, month }: { days: HistoryDay[]; year: number; month: number }) {
const dim = new Date(Date.UTC(year, month, 0)).getUTCDate();
const byDate = new Map(days.map((d) => [d.date, d]));
const firstDow = (new Date(Date.UTC(year, month - 1, 1)).getUTCDay() + 6) % 7; // Monday first
return (
{['M', 'T', 'W', 'T', 'F', 'S', 'S'].map((d, i) => (
{d}
))}
{Array.from({ length: firstDow }).map((_, i) => (
))}
{Array.from({ length: dim }, (_, i) => i + 1).map((n) => {
const date = `${year}-${String(month).padStart(2, '0')}-${String(n).padStart(2, '0')}`;
const d = byDate.get(date);
return (
{n}
{d && d.events > 0 && {d.events}}
{d && (
{fmt(d.max, 0)}
)}
);
})}
Cell number = daily max pressure · red count = events opened that day · grey = not observed (observatory started 2026-09)
);
}
export function MonthStrip({ months }: { months: HistoryMonthRow[] }) {
if (!months.length) return No month observed yet.;
return (
);
}
export function LargestGrid({ largest }: { largest: HistorySummary['largest'] }) {
const cats: [keyof HistorySummary['largest'], string][] = [
['pressure', 'Largest by pressure'],
['routing', 'Largest routing event'],
['dns', 'Largest DNS event'],
['latency', 'Largest latency event'],
];
return (
{cats.map(([k, label]) => {
const inc = largest[k];
return (
-
{label}
{inc ? (
<>
{inc.title}
>
) : (
none in range
)}
);
})}
);
}
export function TopLists({ s }: { s: HistorySummary }) {
return (
{s.top_asns.length ? (
| ASN |
Events |
Max pressure |
{s.top_asns.map((a) => (
|
AS{a.asn} {a.name}
|
{fmtInt(a.events)} |
|
))}
) : (
)}
{s.top_regions.length ? (
| Region |
Events |
Max |
Hours elevated |
{s.top_regions.map((r) => (
|
{r.name}
|
{fmtInt(r.events)} |
|
{fmt(r.hours_elevated)} |
))}
) : (
)}
);
}
export function TopEvents({ events }: { events: Incident[] }) {
if (!events.length) return No event in this range.;
return (
);
}