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() {
-
-