diff --git a/components/layout/Auth/InputField.tsx b/components/layout/Auth/InputField.tsx index cf28ef2e..bc7383bf 100644 --- a/components/layout/Auth/InputField.tsx +++ b/components/layout/Auth/InputField.tsx @@ -11,50 +11,61 @@ interface InputFieldProps { error?: string; } -const InputField: React.FC = ({ field, control, error }) => { - const [inputType, setInputType] = useState(field.type); +const InputField: React.FC = ({ + field: { + type, + id, + label, + name, + required, + emptyErrorMessage, + placeholder, + autoComplete, + invalidErrorMessage, + validationFunction, + }, + control, + error, +}) => { + const [inputType, setInputType] = useState(type); const handlePasswordVisible = (updatedVisible: boolean) => { - if ( - field.id === "password" || - field.id === FIELDTYPE.PASSWORDCONFIRMATION - ) { + if (id === "password" || id === FIELDTYPE.PASSWORDCONFIRMATION) { setInputType(updatedVisible ? "text" : "password"); } }; return ( -
- +
+
- field.validationFunction(value) || field.invalidErrorMessage + required: required ? emptyErrorMessage : false, + validate: validationFunction + ? (value) => validationFunction(value) || invalidErrorMessage : undefined, }} render={({ field: { onChange, onBlur, value } }) => ( = ({ field, control, error }) => { /> )} /> - {(field.name === FIELDTYPE.PASSWORD || - field.name === FIELDTYPE.PASSWORDCONFIRMATION) && ( + {(name === FIELDTYPE.PASSWORD || + name === FIELDTYPE.PASSWORDCONFIRMATION) && ( )}