diff --git a/src/components/FormInput.jsx b/src/components/FormInput.jsx
index 50309f9..8cf296c 100644
--- a/src/components/FormInput.jsx
+++ b/src/components/FormInput.jsx
@@ -1,22 +1,38 @@
import PropTypes from "prop-types";
-
+import { motion, AnimatePresence } from "motion/react";
function FormInput({
value,
onChange,
- maxLength=17,
+ valid = true,
+ maxLength = 17,
readOnly = false,
className = "",
type = "text",
}) {
return (
-
+
+
+
+ {!valid && (
+
+ Invalid Value
+
+ )}
+
+
);
}
@@ -27,6 +43,7 @@ FormInput.propTypes = {
className: PropTypes.string,
type: PropTypes.string,
maxLength: PropTypes.number,
+ valid: PropTypes.bool,
};
export default FormInput;
diff --git a/src/components/FormSelect.jsx b/src/components/FormSelect.jsx
index abf140b..db7022a 100644
--- a/src/components/FormSelect.jsx
+++ b/src/components/FormSelect.jsx
@@ -1,11 +1,13 @@
import PropTypes from "prop-types";
+import { motion, AnimatePresence } from "motion/react";
-function FormSelect({ value, onChange, options, className }) {
+function FormSelect({ value, onChange, options, className, valid = true }) {
return (
+
+
+ {!valid && (
+
+ Invalid Value
+
+ )}
+
+
);
}
@@ -26,6 +42,7 @@ FormSelect.propTypes = {
value: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
className: PropTypes.string,
+ valid: PropTypes.bool,
options: PropTypes.arrayOf(
PropTypes.shape({
value: PropTypes.string.isRequired,
diff --git a/src/pages/AccountCreation.jsx b/src/pages/AccountCreation.jsx
index 4557eaa..6bf371d 100644
--- a/src/pages/AccountCreation.jsx
+++ b/src/pages/AccountCreation.jsx
@@ -9,13 +9,11 @@ import FormField from "../components/FormField";
import FormInput from "../components/FormInput";
import FormSelect from "../components/FormSelect";
import Button from "../components/Button";
-import { useToast } from "../hooks/useToast";
import productInfo from "../util/productList";
import ProductListTable from "../components/ProductListTable";
function AccountCreation() {
const { t } = useTranslation();
- const showToast = useToast();
const [notification] = useState({
visible: false,
message: "",
@@ -179,7 +177,6 @@ function AccountCreation() {
setAccountDetails(newValidationState);
if (!isValid) {
- showToast("Highlighted fields are invalid", "error");
return;
}
console.log("Form is valid", accountDetails);
@@ -216,6 +213,7 @@ function AccountCreation() {
const renerField = (field) => {
const commonProps = {
value: accountDetails[field.name],
+ valid: accountDetails[`${field.name}Valid`],
onChange: (e) => {
const newAccountDetails = { ...accountDetails };
newAccountDetails[field.name] = e.target.value;
diff --git a/src/pages/CabinetMaintenance.jsx b/src/pages/CabinetMaintenance.jsx
index b313099..d5bb967 100644
--- a/src/pages/CabinetMaintenance.jsx
+++ b/src/pages/CabinetMaintenance.jsx
@@ -25,7 +25,7 @@ function CabinetMaintenace() {
-
-
diff --git a/src/pages/LockerStatus.jsx b/src/pages/LockerStatus.jsx
index 41990b4..93bb2b1 100644
--- a/src/pages/LockerStatus.jsx
+++ b/src/pages/LockerStatus.jsx
@@ -4,7 +4,6 @@ import FormInput from "../components/FormInput";
import FormSelect from "../components/FormSelect";
import { useTranslation } from "react-i18next";
import { useState } from "react";
-import { useToast } from "../hooks/useToast";
import clsx from "clsx";
import Button from "../components/Button";
import { lockerService } from "../services/locker.service";
@@ -14,7 +13,6 @@ import Notification from "../components/Notification";
function LockerStatus() {
const { t } = useTranslation();
- const showToast = useToast();
const [lockerDetails, setLockerDetails] = useState({
cabinetId: "",
lockerId: "",
@@ -73,7 +71,6 @@ function LockerStatus() {
setLockerDetails(newValidationState);
if (!isValid) {
- showToast("Highlighted fields are invalid", "error");
return;
}
@@ -101,6 +98,7 @@ function LockerStatus() {
const renderField = (field) => {
const commonProps = {
value: lockerDetails[field.name],
+ valid: lockerDetails[`${field.name}Valid`],
onChange: (e) => {
const newLockerDetails = { ...lockerDetails };
newLockerDetails[field.name] = e.target.value.toUpperCase();