diff --git a/src/components/pastIncidents/PastIncidents.stories.tsx b/src/components/pastIncidents/PastIncidents.stories.tsx new file mode 100644 index 00000000..7c725ee6 --- /dev/null +++ b/src/components/pastIncidents/PastIncidents.stories.tsx @@ -0,0 +1,41 @@ +import { Meta, StoryFn } from "@storybook/react"; +import { PastIncidents } from "./PastIncidents"; + +export default { + title: "Component/PastIncidents", + component: PastIncidents, +} as Meta; + +const Template: StoryFn = (args) => ( + +); + +export const Simple = Template.bind({}); +Simple.args = { + title: "Past Incidents", + subTitle: "Showing all past incidents in the last 6 months", + lastUpdated: "2024-07-02T15:53:42+1000", + incidents: [ + { + reported: "2024-04-16T10:53:42+1000", + reason: "PB Server - service disrupted", + }, + { + reported: "2024-02-12T09:43:42+1000", + reason: "HPC-FS Scheduled maintenance", + }, + { + reported: "2023-12-13T06:33:42+1000", + reason: "PB Server - service disrupted", + }, + { + reported: "2023-10-19T07:33:32+1000", + reason: "HPC-FS Scheduled maintenance", + }, + ], +}; + +export const NoDataAvailable = Template.bind({}); +NoDataAvailable.args = { + incidents: undefined, +}; diff --git a/src/components/pastIncidents/PastIncidents.tsx b/src/components/pastIncidents/PastIncidents.tsx new file mode 100644 index 00000000..e0def163 --- /dev/null +++ b/src/components/pastIncidents/PastIncidents.tsx @@ -0,0 +1,66 @@ +import React, { FunctionComponent } from "react"; +import { + Text, + Flex, + Box, + Table, + Tbody, + Tr, + Td, + TableContainer, +} from "@chakra-ui/react"; + +interface Incident { + reported: string; + reason: string; +} + +export interface PastIncidentsProps { + title: string; + subTitle: string; + lastUpdated: string; + incidents: Incident[]; +} + +export const PastIncidents: FunctionComponent = ({ + title, + subTitle, + lastUpdated = "", + incidents = [], +}) => { + if (incidents.length === 0) return null; + + return ( + + + + {title} + + {subTitle} + {lastUpdated !== "" && ( + Last Updated: {lastUpdated} + )} + + + + + {incidents.map((incident: any, index: number) => ( + + + + ))} + +
+ + {incident?.reported} + + + {incident?.reason} + +
+
+
+ ); +}; + +export default PastIncidents; diff --git a/src/components/pastIncidents/index.ts b/src/components/pastIncidents/index.ts new file mode 100644 index 00000000..6d69d8c7 --- /dev/null +++ b/src/components/pastIncidents/index.ts @@ -0,0 +1 @@ +export { PastIncidents, type PastIncidentsProps } from "./PastIncidents";