2023-11-03 16:23:21 +03:00
|
|
|
|
import React, { useState } from "react";
|
2023-03-28 20:42:18 +03:00
|
|
|
|
|
2023-12-29 12:23:54 +03:00
|
|
|
|
import { useFormValidation } from "@hooks/useFormValidation";
|
2023-11-04 02:44:40 +03:00
|
|
|
|
import { useNotification } from "@hooks/useNotification";
|
|
|
|
|
|
2023-05-30 10:10:34 +03:00
|
|
|
|
import BaseButton from "@components/Common/BaseButton/BaseButton";
|
2023-11-23 16:48:45 +03:00
|
|
|
|
import { Loader } from "@components/Common/Loader/Loader";
|
2023-05-31 08:36:15 +03:00
|
|
|
|
import ModalLayout from "@components/Common/ModalLayout/ModalLayout";
|
2023-05-29 09:37:18 +03:00
|
|
|
|
|
2023-05-30 10:10:34 +03:00
|
|
|
|
import anyMoment from "assets/icons/anyMoment.svg";
|
2023-05-31 08:36:15 +03:00
|
|
|
|
import doc from "assets/icons/doc.svg";
|
|
|
|
|
import telegramLogo from "assets/icons/tgLogo.svg";
|
2024-02-09 17:59:19 +03:00
|
|
|
|
import accept from "assets/images/accept.png";
|
2023-03-28 20:42:18 +03:00
|
|
|
|
|
|
|
|
|
import "./modalRegistration.scss";
|
|
|
|
|
|
|
|
|
|
export const ModalRegistration = ({ active, setActive }) => {
|
2023-12-29 12:23:54 +03:00
|
|
|
|
const [loader, setLoader] = useState(false);
|
2024-02-09 17:59:19 +03:00
|
|
|
|
const [isPartner, setIsPartner] = useState(false);
|
2023-12-29 12:23:54 +03:00
|
|
|
|
|
|
|
|
|
const fields = {
|
|
|
|
|
username: "",
|
2023-11-03 16:23:49 +03:00
|
|
|
|
email: "",
|
2023-12-26 02:42:49 +03:00
|
|
|
|
password: "",
|
|
|
|
|
secondPassword: ""
|
2023-11-05 20:41:40 +03:00
|
|
|
|
};
|
2023-12-29 12:23:54 +03:00
|
|
|
|
const closeModal = () => {
|
|
|
|
|
setActive(false);
|
|
|
|
|
handleClearForm();
|
2023-11-19 18:50:04 +03:00
|
|
|
|
};
|
2023-11-19 18:49:52 +03:00
|
|
|
|
|
2023-12-29 12:23:54 +03:00
|
|
|
|
const apiEndpoint = "/register/sign-up";
|
2023-11-23 16:48:45 +03:00
|
|
|
|
|
2023-12-29 12:23:54 +03:00
|
|
|
|
const { showNotification } = useNotification();
|
|
|
|
|
const showNotificationError = () => {
|
|
|
|
|
showNotification({
|
|
|
|
|
show: true,
|
|
|
|
|
text: "Аккаунт с таким логином или email уже существует",
|
|
|
|
|
type: "error"
|
2023-11-23 16:48:45 +03:00
|
|
|
|
});
|
2023-12-29 12:23:54 +03:00
|
|
|
|
};
|
|
|
|
|
const showNotificationTrue = () => {
|
|
|
|
|
showNotification({
|
|
|
|
|
show: true,
|
|
|
|
|
text: "Аккаунт успешно создан",
|
|
|
|
|
type: "success"
|
2023-11-23 16:48:45 +03:00
|
|
|
|
});
|
2023-11-23 16:48:56 +03:00
|
|
|
|
};
|
2023-12-29 12:23:54 +03:00
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
formData,
|
|
|
|
|
validationErrors,
|
|
|
|
|
handleChange,
|
|
|
|
|
handleSubmit,
|
|
|
|
|
handleClearForm
|
|
|
|
|
} = useFormValidation(
|
|
|
|
|
apiEndpoint,
|
|
|
|
|
fields,
|
|
|
|
|
showNotificationError,
|
|
|
|
|
showNotificationTrue,
|
2024-02-09 17:58:52 +03:00
|
|
|
|
isPartner
|
2023-12-29 12:23:54 +03:00
|
|
|
|
);
|
|
|
|
|
|
2023-03-28 20:42:18 +03:00
|
|
|
|
return (
|
2023-11-23 16:48:45 +03:00
|
|
|
|
<ModalLayout active={active} setActive={closeModal} styles={"registration"}>
|
2023-12-05 14:22:45 +03:00
|
|
|
|
<div className="registration-body__main">
|
2023-12-26 02:42:49 +03:00
|
|
|
|
<h2 className="registration-body__main-title">
|
|
|
|
|
Подключайтесь к <span>ITguild</span>
|
2023-05-29 09:37:18 +03:00
|
|
|
|
</h2>
|
2023-12-05 14:22:45 +03:00
|
|
|
|
<p className="registration-body__main-desc">
|
2023-11-23 18:15:46 +03:00
|
|
|
|
Зарегистрируйтесь и начните работу уже сегодня
|
2023-05-29 09:37:18 +03:00
|
|
|
|
</p>
|
2023-03-28 20:42:18 +03:00
|
|
|
|
|
2023-05-29 09:37:18 +03:00
|
|
|
|
<div className="input-body">
|
|
|
|
|
<div className="input-body__box">
|
2024-02-09 18:17:15 +03:00
|
|
|
|
<div className="input-container">
|
2023-11-19 18:49:52 +03:00
|
|
|
|
<h5>Ваше имя</h5>
|
|
|
|
|
<input
|
2023-12-29 12:23:54 +03:00
|
|
|
|
className={validationErrors.username ? "error" : ""}
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
value={formData.username}
|
2023-11-21 16:53:05 +03:00
|
|
|
|
placeholder="Имя"
|
2023-12-29 12:23:54 +03:00
|
|
|
|
id="username"
|
2023-11-19 18:49:52 +03:00
|
|
|
|
/>
|
2023-12-29 12:23:54 +03:00
|
|
|
|
<span>{validationErrors.username}</span>
|
2023-11-19 18:49:52 +03:00
|
|
|
|
</div>
|
2024-02-09 18:17:15 +03:00
|
|
|
|
<div className="input-container">
|
2023-11-19 18:49:52 +03:00
|
|
|
|
<h5>E-mail</h5>
|
|
|
|
|
<input
|
|
|
|
|
type="email"
|
2023-12-29 12:23:54 +03:00
|
|
|
|
className={validationErrors.email ? "error" : ""}
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
value={formData.email}
|
2023-11-21 16:53:05 +03:00
|
|
|
|
placeholder="Почта"
|
2023-12-29 12:23:54 +03:00
|
|
|
|
id="email"
|
2023-11-19 18:49:52 +03:00
|
|
|
|
/>
|
2023-12-29 12:23:54 +03:00
|
|
|
|
<span>{validationErrors.email}</span>
|
2023-11-19 18:49:52 +03:00
|
|
|
|
</div>
|
2023-03-28 20:42:18 +03:00
|
|
|
|
</div>
|
2023-05-29 09:37:18 +03:00
|
|
|
|
|
|
|
|
|
<div className="input-body__box">
|
2024-02-09 18:17:15 +03:00
|
|
|
|
<div className="input-container">
|
2023-11-19 18:49:52 +03:00
|
|
|
|
<h5>Пароль</h5>
|
|
|
|
|
<input
|
2023-12-29 12:23:54 +03:00
|
|
|
|
className={validationErrors.password ? "error" : ""}
|
2023-11-19 18:49:52 +03:00
|
|
|
|
type="password"
|
2023-12-29 12:23:54 +03:00
|
|
|
|
onChange={handleChange}
|
|
|
|
|
value={formData.password}
|
2023-11-21 16:53:05 +03:00
|
|
|
|
placeholder="Пароль"
|
2023-12-29 12:23:54 +03:00
|
|
|
|
id="password"
|
2023-11-19 18:49:52 +03:00
|
|
|
|
/>
|
2023-12-29 12:23:54 +03:00
|
|
|
|
<span>{validationErrors.password}</span>
|
2023-11-19 18:49:52 +03:00
|
|
|
|
</div>
|
2024-02-09 18:17:15 +03:00
|
|
|
|
<div className="input-container">
|
2023-12-05 14:22:45 +03:00
|
|
|
|
<h5>Повторите пароль</h5>
|
|
|
|
|
<input
|
2023-12-29 12:23:54 +03:00
|
|
|
|
className={validationErrors.secondPassword ? "error" : ""}
|
2023-12-05 14:22:45 +03:00
|
|
|
|
type="password"
|
2023-12-29 12:23:54 +03:00
|
|
|
|
onChange={handleChange}
|
|
|
|
|
value={formData.secondPassword}
|
2023-12-05 14:22:45 +03:00
|
|
|
|
placeholder="Пароль"
|
2023-12-29 12:23:54 +03:00
|
|
|
|
id="secondPassword"
|
2023-12-05 14:22:45 +03:00
|
|
|
|
/>
|
2023-12-29 12:23:54 +03:00
|
|
|
|
<span>{validationErrors.secondPassword}</span>
|
2023-12-05 14:22:45 +03:00
|
|
|
|
</div>
|
2023-03-28 20:42:18 +03:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2024-02-09 17:59:19 +03:00
|
|
|
|
<div
|
|
|
|
|
className="input_checkbox"
|
|
|
|
|
onClick={() => setIsPartner(!isPartner)}
|
|
|
|
|
>
|
2024-02-09 17:58:52 +03:00
|
|
|
|
<p>Партнер:</p>
|
|
|
|
|
<span className={isPartner ? "checkbox--active" : ""}>
|
2024-02-09 17:59:19 +03:00
|
|
|
|
{isPartner ? <img src={accept} alt="accept" /> : ""}
|
2024-02-09 17:58:52 +03:00
|
|
|
|
</span>
|
|
|
|
|
</div>
|
2023-12-05 14:22:45 +03:00
|
|
|
|
|
2023-05-29 09:37:18 +03:00
|
|
|
|
<div className="button-box">
|
2023-11-23 16:48:56 +03:00
|
|
|
|
{loader ? (
|
2024-02-15 20:28:21 +03:00
|
|
|
|
<Loader />
|
2023-11-23 16:48:56 +03:00
|
|
|
|
) : (
|
2023-11-23 16:48:45 +03:00
|
|
|
|
<BaseButton
|
2024-01-09 20:13:51 +03:00
|
|
|
|
onClick={async (e) => {
|
2023-11-23 16:48:56 +03:00
|
|
|
|
e.preventDefault();
|
2023-12-29 12:23:54 +03:00
|
|
|
|
setLoader(true);
|
2024-01-09 20:13:51 +03:00
|
|
|
|
const result = await handleSubmit(e);
|
|
|
|
|
if (result === true) {
|
|
|
|
|
closeModal();
|
|
|
|
|
}
|
2023-12-29 12:23:54 +03:00
|
|
|
|
setLoader(false);
|
2023-11-23 16:48:56 +03:00
|
|
|
|
}}
|
|
|
|
|
styles="button-box__submit"
|
2023-11-23 16:48:45 +03:00
|
|
|
|
>
|
|
|
|
|
Отправить
|
|
|
|
|
</BaseButton>
|
2023-11-23 16:48:56 +03:00
|
|
|
|
)}
|
2023-11-03 16:23:21 +03:00
|
|
|
|
{/*<h5>*/}
|
|
|
|
|
{/* У вас уже есть аккаунт? <p>Войти</p>*/}
|
|
|
|
|
{/*</h5>*/}
|
2023-05-29 09:37:18 +03:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-12-05 14:22:45 +03:00
|
|
|
|
<div className="registration-body__about">
|
2023-05-29 09:37:18 +03:00
|
|
|
|
<h4>Отказ от специалиста в любой момент</h4>
|
2023-12-05 14:22:45 +03:00
|
|
|
|
<div className="registration-body__about-text">
|
2023-05-29 09:37:18 +03:00
|
|
|
|
<img src={anyMoment}></img>
|
|
|
|
|
<p>
|
|
|
|
|
Поменяйте, откажитесь или возьмите еще специалиста в любой момент
|
|
|
|
|
работы.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<h4>100% постоплата</h4>
|
2023-12-05 14:22:45 +03:00
|
|
|
|
<div className="registration-body__about-text">
|
2023-05-29 09:37:18 +03:00
|
|
|
|
<img src={doc}></img>
|
|
|
|
|
<p>
|
|
|
|
|
Договор не подразумевает какую‑либо оплату до того, как вы
|
|
|
|
|
арендовали специалиста
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<h4>Есть вопросы?</h4>
|
2023-12-05 14:22:45 +03:00
|
|
|
|
<div className="registration-body__about-text">
|
2023-05-29 09:37:18 +03:00
|
|
|
|
<img src={telegramLogo}></img>
|
|
|
|
|
<p>Напишите нам в Телеграм. Мы с удовольствием ответим!</p>
|
2023-03-28 20:42:18 +03:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-11-23 16:48:45 +03:00
|
|
|
|
<span onClick={() => closeModal()} className="exit"></span>
|
2023-05-29 09:37:18 +03:00
|
|
|
|
</ModalLayout>
|
2023-03-28 20:42:18 +03:00
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default ModalRegistration;
|