fix auth errors and add tracker-registration

This commit is contained in:
Mikola 2024-03-11 18:24:18 +03:00
parent 2ed0be6664
commit 176dd29625
2 changed files with 17 additions and 20 deletions

View File

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

View File

@ -5,7 +5,9 @@ import { useFormValidation } from "@hooks/useFormValidation";
import { useNotification } from "@hooks/useNotification"; import { useNotification } from "@hooks/useNotification";
import { AuthHeader } from "@components/Common/AuthHeader/AuthHeader"; import { AuthHeader } from "@components/Common/AuthHeader/AuthHeader";
import BaseButton from "@components/Common/BaseButton/BaseButton";
import { Footer } from "@components/Common/Footer/Footer"; import { Footer } from "@components/Common/Footer/Footer";
import { Loader } from "@components/Common/Loader/Loader";
import ModalLayout from "@components/Common/ModalLayout/ModalLayout"; import ModalLayout from "@components/Common/ModalLayout/ModalLayout";
import { ModalTrackerRegistration } from "@components/Modal/ModalTrackerRegistration/ModalTrackerRegistration"; import { ModalTrackerRegistration } from "@components/Modal/ModalTrackerRegistration/ModalTrackerRegistration";
import SideBar from "@components/SideBar/SideBar"; 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 registrationImg from "assets/images/trackerRegistrationImg.png";
import "./trackerRegistration.scss"; import "./trackerRegistration.scss";
import { Loader } from "@components/Common/Loader/Loader";
import BaseButton from "@components/Common/BaseButton/BaseButton";
export const TrackerRegistration = () => { export const TrackerRegistration = () => {
const [modalConfirmOpen, setModalConfirm] = useState(false); const [modalConfirmOpen, setModalConfirm] = useState(false);
@ -47,18 +47,14 @@ export const TrackerRegistration = () => {
}); });
}; };
const { const { formData, validationErrors, handleChange, handleSubmit } =
formData, useFormValidation(
validationErrors,
handleChange,
handleSubmit,
} = useFormValidation(
apiEndpoint, apiEndpoint,
fields, fields,
showNotificationError, showNotificationError,
showNotificationTrue, showNotificationTrue,
isPartner, isPartner,
setLoader, setLoader
); );
return ( return (
<div className="tracker-registration"> <div className="tracker-registration">