diff --git a/src/components/OperationalStatus/OperationalStatus.stories.tsx b/src/components/OperationalStatus/OperationalStatus.stories.tsx new file mode 100644 index 00000000..bb6ebbe8 --- /dev/null +++ b/src/components/OperationalStatus/OperationalStatus.stories.tsx @@ -0,0 +1,25 @@ +import { Meta, StoryFn } from "@storybook/react"; +import { OperationalStatus, OperationalStatusData } from "./OperationalStatus"; +import jsonData from "../../../public/status.json"; + +const typedJsonData: OperationalStatusData["data"] = + jsonData as OperationalStatusData["data"]; + +export default { + title: "Component/OperationalStatus", + component: OperationalStatus, +} as Meta; + +const Template: StoryFn = (args) => ( + +); + +export const Default = Template.bind({}); +Default.args = { + data: typedJsonData, +}; + +export const NoDataAvailable = Template.bind({}); +NoDataAvailable.args = { + data: undefined, +}; diff --git a/src/components/OperationalStatus/OperationalStatus.tsx b/src/components/OperationalStatus/OperationalStatus.tsx new file mode 100644 index 00000000..e41efe0f --- /dev/null +++ b/src/components/OperationalStatus/OperationalStatus.tsx @@ -0,0 +1,74 @@ +import React, { FunctionComponent } from "react"; +import { + Text, + Box, + Table, + Thead, + Tbody, + Tr, + Th, + Td, + TableContainer, + Tag, + TagLabel, +} from "@chakra-ui/react"; + +interface Service { + name: string; + status: string; + error?: string; +} + +interface Data extends Service { + last_updated?: string; + services: Service[]; +} + +export interface OperationalStatusData extends Data { + data?: Data; +} + +export const OperationalStatus: FunctionComponent = ({ + data, +}) => { + return ( + + + Operational status + + {data && data?.services.length > 0 ? ( + + + + + + + + + + {data?.services.map((service: any) => ( + + + + + ))} + +
SERVICESTATUS
{service?.name} + + + {service?.status === "OK" ? "Operational" : "Disrupted"} + + +
+
+ ) : ( + No Data available. + )} +
+ ); +}; + +export default OperationalStatus; diff --git a/src/components/OperationalStatus/index.ts b/src/components/OperationalStatus/index.ts new file mode 100644 index 00000000..784b3c13 --- /dev/null +++ b/src/components/OperationalStatus/index.ts @@ -0,0 +1,4 @@ +export { + OperationalStatus, + type OperationalStatusData, +} from "./OperationalStatus";