import { useEffect, useState } from "react"; import styles from "../../styles"; import { colors } from "../../styles"; import TextField from "@mui/material/TextField"; import AddToQueueIcon from "@mui/icons-material/AddToQueue"; import Button from "../Button/Button"; import { toast } from "react-toastify"; import { EquipmentInstanceCreateAPI, EquipmentsAPI } from "../API/API"; import RadioGroup from "@mui/material/RadioGroup"; import FormControlLabel from "@mui/material/FormControlLabel"; import FormControl from "@mui/material/FormControl"; import FormLabel from "@mui/material/FormLabel"; import Radio from "@mui/material/Radio"; import { useQueryClient } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query"; import { CircularProgress } from "@mui/material"; import React from "react"; export default function AddItemModal() { const queryClient = useQueryClient(); const [item, setItem] = useState({ equipment: 0, remarks: "", status: "Available", }); const [error, setError] = useState(""); const equipments = useQuery({ queryKey: ["equipments"], queryFn: EquipmentsAPI, }); useEffect(() => { if (equipments.data) { setItem({ ...item, equipment: equipments.data[0].id }); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [equipments.data]); if (equipments.isLoading) { return (
Loading
Add Item
{error}