Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/openstatusHQ/openstatus. ๐ซ Status page with uptime monitoring & API monitoring as code ๐ซ openstatus.dev
bun drizzle-orm monitoring monitoring-as-code nextjs observability on-call open-source shadcn-ui status-page statuspage synthetic-monitoring tinybird turso uptime uptime-checker uptime-monitor
Something went wrong. Try again.
1.5 kB ยท 52 lines
TypeScript
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import { Show, Delete } from "@openstatus/icons";
type StatusReportWithUpdates = { status: string; createdAt: Date | null; updatedAt: Date | null; updates: { date: Date }[];};
/** Earliest update, else the row's creation. */export function reportStartedAt(report: StatusReportWithUpdates): Date { const dates = report.updates.map((u) => u.date.getTime()); if (dates.length) return new Date(Math.min(...dates)); return report.createdAt ?? new Date(0);}
/** Latest update once resolved; `null` while the report is open. */export function reportResolvedAt(report: StatusReportWithUpdates): Date | null { if (report.status !== "resolved") return null; const dates = report.updates.map((u) => u.date.getTime()); // legacy resolved report without updates: fall back to updatedAt if (!dates.length) return report.updatedAt ?? report.createdAt; return new Date(Math.max(...dates));}
export const actions = [ { id: "view-report", label: "View Report", icon: Show, variant: "default" as const, }, { id: "delete", label: "Delete", icon: Delete, variant: "destructive" as const, },] as const;
export type StatusReportUpdateAction = (typeof actions)[number];
export const getActions = ( props: Partial< Record<StatusReportUpdateAction["id"], () => Promise<void> | void> >,): (StatusReportUpdateAction & { onClick?: () => Promise<void> | void })[] => { return actions.map((action) => ({ ...action, onClick: props[action.id as keyof typeof props], }));};