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

); } return ( <>

Add Item

Select Associated SKU ) => { setItem({ ...item, equipment: Number(e.target.value) }); setError(""); }} >
{equipments.data ? ( equipments.data.map((equipment) => ( } label={equipment.name} style={styles.text_dark} /> )) ) : ( <> )}
Item Status ) => { setItem({ ...item, status: e.target.value }); setError(""); }} >
} label="Available" style={styles.text_dark} /> } label="Broken" style={styles.text_dark} />
) => { setItem({ ...item, remarks: e.target.value }); setError(""); }} value={item.remarks} placeholder={"Optionally add a brief description of the item"} />

{error}