diff --git a/src/App.tsx b/src/App.tsx index 1576413..a962f0c 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -12,8 +12,6 @@ import Revalidator from "./Components/Revalidator/Revalidator"; import ActivationPage from "./Pages/ActivationPage/ActivationPage"; import ResetPasswordPage from "./Pages/ResetPasswordPage/ResetPasswordPage"; import EquipmentInstancesListPage from "./Pages/EquipmentInstancesListPage/EquipmentInstancesListPage"; -import AddEquipmentInstancePage from "./Pages/AddEquipmentInstancePage/AddEquipmentInstancePage"; -import AddEquipmentPage from "./Pages/AddEquipmentPage/AddEquipmentPage"; const queryClient = new QueryClient(); const router = createHashRouter([ @@ -47,26 +45,6 @@ const router = createHashRouter([ ), errorElement: , }, - { - path: "/add/equipment_instance", - element: ( - <> - - - - ), - errorElement: , - }, - { - path: "/add/equipment", - element: ( - <> - - - - ), - errorElement: , - }, { path: "/activation/:uid/:token", element: ( diff --git a/src/Components/API/API.tsx b/src/Components/API/API.tsx index 9b49d7c..63d6866 100644 --- a/src/Components/API/API.tsx +++ b/src/Components/API/API.tsx @@ -7,6 +7,8 @@ import { RegisterType, ResetPasswordConfirmType, EquipmentInstanceListType, + EquipmentType, + AddEquipmentType, } from "../Types/Types"; const instance = axios.create({ @@ -171,6 +173,19 @@ export async function EquipmentsAPI() { }); } +export async function EquipmentCreateAPI(equipment: AddEquipmentType) { + const config = await GetConfig(); + return instance + .post("api/v1/equipments/equipments/", equipment, config) + .then((response) => { + return [true, response.data as EquipmentType]; + }) + .catch((error) => { + console.log("Error creating equipment"); + return [false, ParseError(error)]; + }); +} + export async function EquipmentInstancesAPI() { const config = await GetConfig(); return instance diff --git a/src/Components/AddSKUModal/AddSKUModal.tsx b/src/Components/AddSKUModal/AddSKUModal.tsx new file mode 100644 index 0000000..82cf06d --- /dev/null +++ b/src/Components/AddSKUModal/AddSKUModal.tsx @@ -0,0 +1,166 @@ +import { useState } from "react"; +import styles from "../../styles"; +import { colors } from "../../styles"; +import TextField from "@mui/material/TextField"; +import NoteAddIcon from "@mui/icons-material/NoteAdd"; +import Button from "../Button/Button"; +import { toast } from "react-toastify"; +import { EquipmentCreateAPI } 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"; + +export default function AddSKUModal() { + const queryClient = useQueryClient(); + const [sku, setSKU] = useState({ + name: "", + description: "", + category: "", + }); + const [error, setError] = useState(""); + + return ( + <> +
+ +

Add SKU

+
+ +
+ ) => { + setSKU({ ...sku, name: e.target.value }); + setError(""); + }} + value={sku.name} + placeholder={"Enter SKU name"} + /> + ) => + setSKU({ ...sku, description: e.target.value }) + } + value={sku.description} + placeholder={"Give a brief description of the SKU"} + /> + + + Category + + ) => { + setSKU({ ...sku, category: e.target.value }); + }} + > +
+
+ } + label="Workstation" + style={styles.text_dark} + /> + } + label="Networking" + style={styles.text_dark} + /> + } + label="CCTV" + style={styles.text_dark} + /> +
+
+ } + label="Furniture" + style={styles.text_dark} + /> + } + label="Peripherals" + style={styles.text_dark} + /> + } + label="Miscellaneous" + style={styles.text_dark} + /> +
+
+
+
+
+

{error}

+
+
+ SetAddSKUModalOpen(false)} + modal + position={"top center"} + contentStyle={{ + width: "512px", + borderRadius: 16, + borderColor: "grey", + borderStyle: "solid", + borderWidth: 1, + padding: 16, + alignContent: "center", + justifyContent: "center", + textAlign: "center", + }} + > + + ); } diff --git a/src/Pages/LandingPage/LandingPage.tsx b/src/Pages/LandingPage/LandingPage.tsx index fd5ef05..6e18c0e 100644 --- a/src/Pages/LandingPage/LandingPage.tsx +++ b/src/Pages/LandingPage/LandingPage.tsx @@ -36,9 +36,12 @@ export default function LandingPage() { width: "100%", minHeight: "100%", minWidth: "100%", + flexWrap: "wrap", }} > -
+