import { useNavigate } from "react-router-dom"; import { IncidentRow } from "./Issues.tsx"; import { useIncidents, useMe } from "./api.ts"; import { SetupTodos } from "./onboarding/SetupTodos.tsx"; const ACTIVE_INCIDENT_WINDOW_MS = 24 * 60 * 60 * 1000; const ACTIVE_INCIDENT_LIMIT = 5; export function Overview() { const me = useMe(); if (me.isLoading) { return (
loading…
); } if (me.error) { return
error: {String(me.error)}
; } if (!me.data || !me.data.project) return null; const projectId = me.data.project.id; return (
); } function ActiveIncidentsSection({ projectId }: { projectId: string }) { const navigate = useNavigate(); const incidents = useIncidents(projectId, "open"); const cutoff = Date.now() - ACTIVE_INCIDENT_WINDOW_MS; const important = (incidents.data ?? []) .filter( (row) => (row.incident.severity === "SEV-1" || row.incident.severity === "SEV-2") && new Date(row.incident.lastSeen).getTime() >= cutoff, ) .slice(0, ACTIVE_INCIDENT_LIMIT); return (
Active critical incidents {incidents.isFetching && ( refreshing… )}
{incidents.isLoading ? (
Loading…
) : incidents.error ? (
Failed to load: {String(incidents.error)}
) : important.length === 0 ? (

All clear — no SEV-1 or SEV-2 incidents in the last 24h

) : (
{important.map((row) => ( navigate(`/incidents/${row.incident.id}`)} /> ))}
)}
); }