import Header from "../../Components/Header/Header"; import styles from "../../styles"; import { useQueries } from "@tanstack/react-query"; import { EquipmentsAPI, EquipmentInstancesAPI } from "../../Components/API/API"; import { Button, CircularProgress } from "@mui/material"; import ComputerIcon from "@mui/icons-material/Computer"; import RouterIcon from "@mui/icons-material/Router"; import CameraOutdoorIcon from "@mui/icons-material/CameraOutdoor"; import ChairIcon from "@mui/icons-material/Chair"; import FormatListBulletedIcon from "@mui/icons-material/FormatListBulleted"; import AddToQueueIcon from "@mui/icons-material/AddToQueue"; import NoteAddIcon from "@mui/icons-material/NoteAdd"; import NoteIcon from "@mui/icons-material/Note"; import ManageSearchIcon from "@mui/icons-material/ManageSearch"; import { colors } from "../../styles"; import { useNavigate } from "react-router-dom"; import { useState } from "react"; import AddSKUModal from "../../Components/AddSKUModal/AddSKUModal"; import Popup from "reactjs-popup"; import AddItemModal from "../../Components/AddItemModal/AddItemModal"; export default function Dashboard() { const navigate = useNavigate(); const queries = useQueries({ queries: [ { queryKey: ["equipments"], queryFn: EquipmentsAPI, }, { queryKey: ["equipment_instances"], queryFn: EquipmentInstancesAPI, }, ], }); const isLoading = queries.some((result) => result.isLoading); const [addSKUmodalOpen, SetAddSKUModalOpen] = useState(false); const [additemmodalOpen, SetAddItemModalOpen] = useState(false); if (isLoading) { return (
Loading
SKUs in Database
{queries[0].data ? queries[0].data.length : 0}
Items in Database
{queries[1].data ? queries[1].data.length : 0}
Functional Items
{queries[1].data ? queries[1].data.filter( (equipment) => equipment.status == "WORKING" ).length : 0}
Broken Items
{queries[1].data ? queries[1].data.filter( (equipment) => equipment.status == "BROKEN" ).length : 0}
Equipments
Logs