diff --git a/components/IncidentList.tsx b/components/IncidentList.tsx new file mode 100644 index 0000000..10c1ae8 --- /dev/null +++ b/components/IncidentList.tsx @@ -0,0 +1,57 @@ +import { Card, Text, Grid, Flex, Badge } from '@mantine/core' +import { formatDistance } from 'date-fns' + +export default function IncidentList({ + incidents, +}: { + incidents: { start: number[]; end: number | undefined; error: string[] }[] +}) { + if (!incidents || incidents.length === 0) { + return No historical incidents found. + } + + return ( + + {[...incidents].reverse().map((incident, index) => ( + + + +
+ {incident.error[0]} +
+ +
+ + {incident.end ? 'Resolved' : 'Ongoing'} + +
+
+ + +
+ + Start:{' '} + {formatDistance(new Date(incident.start[0] * 1000), new Date(), { + addSuffix: true, + })} + +
+ + {incident.end && ( +
+ + Duration:{' '} + {formatDistance( + new Date(incident.start[0] * 1000), + new Date(incident.end * 1000) + )} + +
+ )} +
+
+
+ ))} +
+ ) +}