From f6a181074095ac664db4929a0d530128be1a2b24 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Sat, 2 Dec 2023 22:04:46 +0800 Subject: [PATCH] Finalize equipment instances list page --- src/Components/Revalidator/Revalidator.tsx | 1 - src/Components/Types/Types.tsx | 2 + .../EquipmentInstancesListPage.tsx | 131 +++++++++++++++++- 3 files changed, 132 insertions(+), 2 deletions(-) diff --git a/src/Components/Revalidator/Revalidator.tsx b/src/Components/Revalidator/Revalidator.tsx index fc37f5d..7631fcc 100644 --- a/src/Components/Revalidator/Revalidator.tsx +++ b/src/Components/Revalidator/Revalidator.tsx @@ -36,7 +36,6 @@ export default function Revalidator() { JWTRefreshAPI().then(async (response) => { if (response) { await dispatch(auth_toggle()); - navigate("/dashboard"); toast("User session restored", { position: "top-right", autoClose: 2000, diff --git a/src/Components/Types/Types.tsx b/src/Components/Types/Types.tsx index 3030362..3f263ce 100644 --- a/src/Components/Types/Types.tsx +++ b/src/Components/Types/Types.tsx @@ -48,11 +48,13 @@ export type AddEquipmentInstanceType = { export type EquipmentInstanceType = { id: number; equipment: string; + equipment_name: string; status: string; remarks: string; last_updated: string; last_updated_by: string; date_added: string; + category: string; }; export type EquipmentInstanceListType = Array; diff --git a/src/Pages/EquipmentInstancesListPage/EquipmentInstancesListPage.tsx b/src/Pages/EquipmentInstancesListPage/EquipmentInstancesListPage.tsx index 779ab7c..b56d28e 100644 --- a/src/Pages/EquipmentInstancesListPage/EquipmentInstancesListPage.tsx +++ b/src/Pages/EquipmentInstancesListPage/EquipmentInstancesListPage.tsx @@ -1,5 +1,134 @@ +import { useQuery } from "@tanstack/react-query"; +import Header from "../../Components/Header/Header"; import styles from "../../styles"; +import { EquipmentInstancesAPI } from "../../Components/API/API"; +import { CircularProgress } from "@mui/material"; +import Table from "@mui/material/Table"; +import TableBody from "@mui/material/TableBody"; +import TableCell from "@mui/material/TableCell"; +import TableContainer from "@mui/material/TableContainer"; +import TableHead from "@mui/material/TableHead"; +import TableRow from "@mui/material/TableRow"; +import Paper from "@mui/material/Paper"; +import { colors } from "../../styles"; export default function EquipmentInstancesListPage() { - return
{"EquipmentInstancesListPage"}
; + const equipment_instances = useQuery({ + queryKey: ["equipment_instances"], + queryFn: EquipmentInstancesAPI, + }); + if (equipment_instances.isLoading) { + return ( +
+
+
+ +

+ Loading +

+
+
+ ); + } + return ( +
+
+
+
+ + + + + ID + + Name + + + Status + + + Category + + + Last Modified + + + + + {equipment_instances.data ? ( + equipment_instances.data.map((equipment) => ( + { + console.log("HEH"); + }} + > + + {equipment.id} + + + {equipment.equipment_name} + + + + {equipment.status} + + + {equipment.category} + + +
+
{equipment.last_updated}
+
+ {equipment.last_updated_by + ? "by " + equipment.last_updated_by + : ""} +
+
+
+
+ )) + ) : ( + <> + )} +
+
+
+
+
+
+ ); }