auth-check #25

Merged
nik.polishuk merged 2 commits from auth-check into main 2024-03-11 18:25:07 +03:00
2 changed files with 17 additions and 20 deletions
Showing only changes of commit 176dd29625 - Show all commits

View File

@ -87,22 +87,23 @@ export const useFormValidation = (
e.preventDefault();
// Проверка валидации формы
if (validateForm()) {
setLoader(true)
setLoader(true);
let newformData = { ...formData, is_partner: isPartner ? 1 : 0 };
delete newformData.secondPassword;
try {
apiRequest(apiEndpoint, {
method: "POST",
data: newformData
}).then((data) => {
setLoader(false)
setLoader(false);
if ("errors" in data) {
return showNotificationError('Аккаунт с таким логином или email уже существуе');
return showNotificationError(
"Аккаунт с таким логином или email уже существуе"
);
}
if (!data.id) {
return showNotificationError('Ошибка');
return showNotificationError("Ошибка");
}
handleClearForm();
showNotificationTrue();

View File

@ -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";
@ -15,8 +17,6 @@ import authImg from "assets/images/partnerProfile/authCandidateFormImg.png";
import registrationImg from "assets/images/trackerRegistrationImg.png";
import "./trackerRegistration.scss";
import { Loader } from "@components/Common/Loader/Loader";
import BaseButton from "@components/Common/BaseButton/BaseButton";
export const TrackerRegistration = () => {
const [modalConfirmOpen, setModalConfirm] = useState(false);
@ -47,18 +47,14 @@ export const TrackerRegistration = () => {
});
};
const {
formData,
validationErrors,
handleChange,
handleSubmit,
} = useFormValidation(
const { formData, validationErrors, handleChange, handleSubmit } =
useFormValidation(
apiEndpoint,
fields,
showNotificationError,
showNotificationTrue,
isPartner,
setLoader,
setLoader
);
return (
<div className="tracker-registration">