From 0764002a6017d96d8214d25fa137b64cb395cdcb Mon Sep 17 00:00:00 2001 From: Gubar Nikita Date: Tue, 9 Jan 2024 20:13:51 +0300 Subject: [PATCH] fix ModalRegistration --- .../Modal/ModalRegistration/ModalRegistration.jsx | 8 +++++--- src/hooks/useFormValidation.js | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/Modal/ModalRegistration/ModalRegistration.jsx b/src/components/Modal/ModalRegistration/ModalRegistration.jsx index df089e29..83e3118b 100644 --- a/src/components/Modal/ModalRegistration/ModalRegistration.jsx +++ b/src/components/Modal/ModalRegistration/ModalRegistration.jsx @@ -129,12 +129,14 @@ export const ModalRegistration = ({ active, setActive }) => { ) : ( { + onClick={async (e) => { e.preventDefault(); setLoader(true); - handleSubmit(e); + const result = await handleSubmit(e); + if (result === true) { + closeModal(); + } setLoader(false); - closeModal(); }} styles="button-box__submit" > diff --git a/src/hooks/useFormValidation.js b/src/hooks/useFormValidation.js index 40ac4f31..f19880e5 100644 --- a/src/hooks/useFormValidation.js +++ b/src/hooks/useFormValidation.js @@ -102,6 +102,9 @@ export const useFormValidation = ( } catch (error) { console.error("Error submitting form:", error); } + return true; + } else { + return false; } };