import { useQuery } from "@tanstack/react-query"; import Header from "../../Components/Header/Header"; import styles from "../../styles"; import { EquipmentsAPI } 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"; import EditSKUModal from "../../Components/EditSKUModal/EditSKUModal"; import Popup from "reactjs-popup"; import { useState } from "react"; export default function EquipmentListPage() { const [editmodalOpen, SetEditModalOpen] = useState(false); const [selectedItem, SetSelectedItem] = useState(0); const equipments = useQuery({ queryKey: ["equipments"], queryFn: EquipmentsAPI, }); if (equipments.isLoading) { return (

Loading

); } return (
ID Name Description Category Last Modified {equipments.data ? ( equipments.data.map((equipment) => ( { SetSelectedItem(equipment.id); SetEditModalOpen(true); }} > {equipment.id} {equipment.name} {equipment.description} {equipment.category}
{equipment.last_updated}
{equipment.last_updated_by ? "by " + equipment.last_updated_by : ""}
)) ) : ( <> )}
SetEditModalOpen(false)} modal position={"top center"} contentStyle={{ width: "512px", borderRadius: 16, borderColor: "grey", borderStyle: "solid", borderWidth: 1, padding: 16, alignContent: "center", justifyContent: "center", textAlign: "center", }} >
); }