Merge pull request 'auth-check' (#25) from auth-check into main
Reviewed-on: #25
This commit is contained in:
commit
8797ba0778
@ -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 }) => {
|
||||
<BaseButton
|
||||
onClick={async (e) => {
|
||||
e.preventDefault();
|
||||
setLoader(true);
|
||||
const result = await handleSubmit(e);
|
||||
if (result === true) {
|
||||
closeModal();
|
||||
}
|
||||
setLoader(false);
|
||||
await handleSubmit(e);
|
||||
}}
|
||||
styles="button-box__submit"
|
||||
>
|
||||
|
@ -249,6 +249,5 @@
|
||||
|
||||
.loader {
|
||||
justify-content: start;
|
||||
left: 80px;
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,9 @@ export const useFormValidation = (
|
||||
fields,
|
||||
showNotificationError,
|
||||
showNotificationTrue,
|
||||
isPartner
|
||||
isPartner,
|
||||
setLoader,
|
||||
closeModal
|
||||
) => {
|
||||
// Состояние формы, содержащее значения полей
|
||||
const [formData, setFormData] = useState(fields);
|
||||
@ -85,6 +87,7 @@ export const useFormValidation = (
|
||||
e.preventDefault();
|
||||
// Проверка валидации формы
|
||||
if (validateForm()) {
|
||||
setLoader(true);
|
||||
let newformData = { ...formData, is_partner: isPartner ? 1 : 0 };
|
||||
delete newformData.secondPassword;
|
||||
|
||||
@ -93,12 +96,18 @@ export const useFormValidation = (
|
||||
method: "POST",
|
||||
data: newformData
|
||||
}).then((data) => {
|
||||
setLoader(false);
|
||||
if ("errors" in data) {
|
||||
showNotificationError();
|
||||
} else {
|
||||
return showNotificationError(
|
||||
"Аккаунт с таким логином или email уже существуе"
|
||||
);
|
||||
}
|
||||
if (!data.id) {
|
||||
return showNotificationError("Ошибка");
|
||||
}
|
||||
handleClearForm();
|
||||
showNotificationTrue();
|
||||
}
|
||||
closeModal();
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error submitting form:", error);
|
||||
|
@ -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}
|
||||
/>
|
||||
</div>
|
||||
{modalResetOpen && (
|
||||
<ModalLayout active={modalResetOpen} setActive={setModalReset}>
|
||||
<ModalReset setModalReset={setModalReset} />
|
||||
</ModalLayout>
|
||||
)}
|
||||
<ModalResetPassword active={modalResetOpen} setActive={setModalReset} />
|
||||
{/*{modalResetOpen && (*/}
|
||||
{/* <ModalLayout active={modalResetOpen} setActive={setModalReset}>*/}
|
||||
{/* <ModalReset setModalReset={setModalReset} />*/}
|
||||
{/* </ModalLayout>*/}
|
||||
{/*)}*/}
|
||||
</div>
|
||||
<Footer />
|
||||
</div>
|
||||
|
@ -5,7 +5,9 @@ import { useFormValidation } from "@hooks/useFormValidation";
|
||||
import { useNotification } from "@hooks/useNotification";
|
||||
|
||||
import { AuthHeader } from "@components/Common/AuthHeader/AuthHeader";
|
||||
import BaseButton from "@components/Common/BaseButton/BaseButton";
|
||||
import { Footer } from "@components/Common/Footer/Footer";
|
||||
import { Loader } from "@components/Common/Loader/Loader";
|
||||
import ModalLayout from "@components/Common/ModalLayout/ModalLayout";
|
||||
import { ModalTrackerRegistration } from "@components/Modal/ModalTrackerRegistration/ModalTrackerRegistration";
|
||||
import SideBar from "@components/SideBar/SideBar";
|
||||
@ -18,6 +20,8 @@ import "./trackerRegistration.scss";
|
||||
|
||||
export const TrackerRegistration = () => {
|
||||
const [modalConfirmOpen, setModalConfirm] = useState(false);
|
||||
const [loader, setLoader] = useState(false);
|
||||
const [isPartner, setIsPartner] = useState(false);
|
||||
const fields = {
|
||||
username: "",
|
||||
email: "",
|
||||
@ -28,10 +32,10 @@ export const TrackerRegistration = () => {
|
||||
const apiEndpoint = "/register/sign-up";
|
||||
|
||||
const { showNotification } = useNotification();
|
||||
const showNotificationError = () => {
|
||||
const showNotificationError = (error) => {
|
||||
showNotification({
|
||||
show: true,
|
||||
text: "Аккаунт с таким логином или email уже существует",
|
||||
text: error,
|
||||
type: "error"
|
||||
});
|
||||
};
|
||||
@ -48,9 +52,10 @@ export const TrackerRegistration = () => {
|
||||
apiEndpoint,
|
||||
fields,
|
||||
showNotificationError,
|
||||
showNotificationTrue
|
||||
showNotificationTrue,
|
||||
isPartner,
|
||||
setLoader
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="tracker-registration">
|
||||
<AuthHeader />
|
||||
@ -115,17 +120,19 @@ export const TrackerRegistration = () => {
|
||||
</div>
|
||||
</div>
|
||||
<div className="tracker-registration__form__submit">
|
||||
<button
|
||||
{loader ? (
|
||||
<Loader />
|
||||
) : (
|
||||
<BaseButton
|
||||
onClick={async (e) => {
|
||||
e.preventDefault();
|
||||
const result = await handleSubmit(e);
|
||||
if (result === true) {
|
||||
setModalConfirm(true);
|
||||
}
|
||||
await handleSubmit(e);
|
||||
}}
|
||||
styles="button-box__submit"
|
||||
>
|
||||
Отправить
|
||||
</button>
|
||||
</BaseButton>
|
||||
)}
|
||||
<div className="tracker-registration__form__info">
|
||||
<img src={authImg} alt="img" />
|
||||
<p>
|
||||
|
@ -56,7 +56,7 @@
|
||||
font-size: 18px;
|
||||
color: #fff;
|
||||
border: none;
|
||||
margin-right: 165px;
|
||||
max-width: 170px;
|
||||
}
|
||||
|
||||
@media (max-width: 1000px) {
|
||||
@ -68,10 +68,15 @@
|
||||
align-items: start;
|
||||
row-gap: 35px;
|
||||
}
|
||||
|
||||
.loader {
|
||||
max-width: 170px;
|
||||
}
|
||||
}
|
||||
|
||||
&__info {
|
||||
display: flex;
|
||||
margin-left: 165px;
|
||||
align-items: center;
|
||||
img {
|
||||
margin-right: 31px;
|
||||
|
Loading…
Reference in New Issue
Block a user