diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json
index 78e14ea..49dc105 100644
--- a/public/locales/en/translation.json
+++ b/public/locales/en/translation.json
@@ -51,5 +51,9 @@
"create": "Create",
"operation": "Operation",
"next": "Next",
- "select": "Select"
+ "select": "Select",
+ "cabinetCreation": "Cabinet Creation",
+ "cabinetId": "Cabinet ID",
+ "cabinetKeyId": "Cabinet Key ID",
+ "noOfLockers": "No of Lockers"
}
\ No newline at end of file
diff --git a/src/components/FormBox.jsx b/src/components/FormBox.jsx
index a52977d..6a18b84 100644
--- a/src/components/FormBox.jsx
+++ b/src/components/FormBox.jsx
@@ -3,12 +3,12 @@ import clsx from 'clsx';
function FormBox({ title, children, alt = false }) {
return (
-
+
+
);
}
diff --git a/src/main.jsx b/src/main.jsx
index 382cc35..98e8547 100644
--- a/src/main.jsx
+++ b/src/main.jsx
@@ -6,6 +6,7 @@ import './i18n'
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
import Home from './pages/Home.jsx'
import CabinetMaintenace from './pages/CabinetMaintenance.jsx'
+import CabinetCreation from './pages/CabinetCreation.jsx'
const router = createBrowserRouter([
{
@@ -19,6 +20,10 @@ const router = createBrowserRouter([
{
path: 'operation/cabinet',
element:
+ },
+ {
+ path: 'operation/cabinet/create',
+ element:
}
]
}
diff --git a/src/pages/CabinetCreation.jsx b/src/pages/CabinetCreation.jsx
new file mode 100644
index 0000000..8d933e1
--- /dev/null
+++ b/src/pages/CabinetCreation.jsx
@@ -0,0 +1,86 @@
+import { useState } from "react";
+import { useTranslation } from "react-i18next";
+import FormBox from "../components/FormBox";
+import Button from "../components/Button";
+import { useNavigate } from "react-router-dom";
+import clsx from "clsx";
+
+function CabinetCreation() {
+ const { t } = useTranslation();
+ const navigate = useNavigate();
+
+ const [cabinetId, setCabinetId] = useState({id: "", valid: true});
+ const [cabinetKeyId, setCabinetKeyId] = useState({id: "", valid: true});
+ const [noOfLockers, setNoOfLockers] = useState({number: 0, valid: true});
+
+ const handleNext = (e) => {
+ e.preventDefault();
+ const idRegex = /^[A-Z]{2}[0-9]{4}$/;
+ if (!idRegex.test(cabinetId.id)) {
+ setCabinetId({id: cabinetId.id, valid: false});
+ return;
+ } else if (!idRegex.test(cabinetKeyId.id)) {
+ setCabinetKeyId({id: cabinetKeyId.id, valid: false});
+ return;
+ } else if (noOfLockers.number === 0) {
+ setNoOfLockers({number: noOfLockers.number, valid: false});
+ return;
+ }
+ navigate("register-lockers", {state: {cabinetId: cabinetId.id, cabinetKeyId: cabinetKeyId.id, noOfLockers: noOfLockers.number}});
+ };
+ return (
+
+
+
+
+
+
+
setCabinetId({id: e.target.value.toUpperCase(), valid: true })}
+ type="text"
+ maxLength={6}
+ />
+ {!cabinetId.valid &&
Invalid Cabinet Id
}
+
+
+
+
+
+
setCabinetKeyId({id: e.target.value.toUpperCase(), valid: true })}
+ type="text"
+ maxLength={6}
+ />
+ {!cabinetKeyId.valid &&
Invalid Key Id
}
+
+
+
+
+
+
setNoOfLockers({number: e.target.value, valid: true })}
+ type="number"
+ />
+ {!noOfLockers.valid &&
Invalid Number of Lockers
}
+
+
+
+
+
+ );
+}
+
+export default CabinetCreation;