diff --git a/src/components/Modal/ModalRegistration/ModalRegistration.jsx b/src/components/Modal/ModalRegistration/ModalRegistration.jsx index 1ac82c98..84e5a1bc 100644 --- a/src/components/Modal/ModalRegistration/ModalRegistration.jsx +++ b/src/components/Modal/ModalRegistration/ModalRegistration.jsx @@ -32,10 +32,10 @@ export const ModalRegistration = ({ active, setActive }) => { const apiEndpoint = "/register/sign-up"; const { showNotification } = useNotification(); - const showNotificationError = () => { + const showNotificationError = (error) => { showNotification({ show: true, - text: "Аккаунт с таким логином или email уже существует", + text: error, type: "error" }); }; @@ -58,7 +58,9 @@ export const ModalRegistration = ({ active, setActive }) => { fields, showNotificationError, showNotificationTrue, - isPartner + isPartner, + setLoader, + closeModal ); return ( @@ -142,12 +144,7 @@ export const ModalRegistration = ({ active, setActive }) => { { e.preventDefault(); - setLoader(true); - const result = await handleSubmit(e); - if (result === true) { - closeModal(); - } - setLoader(false); + await handleSubmit(e); }} styles="button-box__submit" > diff --git a/src/components/Modal/ModalRegistration/modalRegistration.scss b/src/components/Modal/ModalRegistration/modalRegistration.scss index 86fa8b64..a8ba7d92 100644 --- a/src/components/Modal/ModalRegistration/modalRegistration.scss +++ b/src/components/Modal/ModalRegistration/modalRegistration.scss @@ -249,6 +249,5 @@ .loader { justify-content: start; - left: 80px; } } diff --git a/src/hooks/useFormValidation.js b/src/hooks/useFormValidation.js index 041ca836..cf4a7580 100644 --- a/src/hooks/useFormValidation.js +++ b/src/hooks/useFormValidation.js @@ -7,7 +7,9 @@ export const useFormValidation = ( fields, showNotificationError, showNotificationTrue, - isPartner + isPartner, + setLoader, + closeModal ) => { // Состояние формы, содержащее значения полей const [formData, setFormData] = useState(fields); @@ -85,20 +87,26 @@ export const useFormValidation = ( e.preventDefault(); // Проверка валидации формы if (validateForm()) { + setLoader(true) let newformData = { ...formData, is_partner: isPartner ? 1 : 0 }; delete newformData.secondPassword; + try { apiRequest(apiEndpoint, { method: "POST", data: newformData }).then((data) => { + setLoader(false) if ("errors" in data) { - showNotificationError(); - } else { - handleClearForm(); - showNotificationTrue(); + return showNotificationError('Аккаунт с таким логином или email уже существуе'); } + if (!data.id) { + return showNotificationError('Ошибка'); + } + handleClearForm(); + showNotificationTrue(); + closeModal(); }); } catch (error) { console.error("Error submitting form:", error); diff --git a/src/pages/TrackerAuth/TrackerAuth.jsx b/src/pages/TrackerAuth/TrackerAuth.jsx index d75f32c0..4564d535 100644 --- a/src/pages/TrackerAuth/TrackerAuth.jsx +++ b/src/pages/TrackerAuth/TrackerAuth.jsx @@ -5,6 +5,7 @@ import { AuthHeader } from "@components/Common/AuthHeader/AuthHeader"; import { Footer } from "@components/Common/Footer/Footer"; import ModalLayout from "@components/Common/ModalLayout/ModalLayout"; import { ModalReset } from "@components/Modal/ModalReset/ModalReset"; +import ModalResetPassword from "@components/Modal/ModalResetPassword/ModalResetPassword"; import SideBar from "@components/SideBar/SideBar"; import arrowInfo from "assets/icons/trackerIntroInfo.svg"; @@ -33,11 +34,12 @@ export const TrackerAuth = () => { resetModal={setModalReset} /> - {modalResetOpen && ( - - - - )} + + {/*{modalResetOpen && (*/} + {/* */} + {/* */} + {/* */} + {/*)}*/}