registration and reset warning text
This commit is contained in:
parent
185572cbf3
commit
3696ccb02c
@ -5,8 +5,8 @@ import { apiRequest } from "@api/request";
|
||||
import { useNotification } from "@hooks/useNotification";
|
||||
|
||||
import BaseButton from "@components/Common/BaseButton/BaseButton";
|
||||
import ModalLayout from "@components/Common/ModalLayout/ModalLayout";
|
||||
import { Loader } from "@components/Common/Loader/Loader";
|
||||
import ModalLayout from "@components/Common/ModalLayout/ModalLayout";
|
||||
|
||||
import anyMoment from "assets/icons/anyMoment.svg";
|
||||
import doc from "assets/icons/doc.svg";
|
||||
@ -27,7 +27,7 @@ export const ModalRegistration = ({ active, setActive }) => {
|
||||
password: false,
|
||||
});
|
||||
|
||||
const [loader, setLoader] = useState(false)
|
||||
const [loader, setLoader] = useState(false);
|
||||
|
||||
const validateEmail = (email) => {
|
||||
// регулярное выражение для проверки email
|
||||
@ -62,7 +62,7 @@ export const ModalRegistration = ({ active, setActive }) => {
|
||||
if (validateForm()) {
|
||||
return;
|
||||
}
|
||||
setLoader(true)
|
||||
setLoader(true);
|
||||
apiRequest("/register/sign-up", {
|
||||
method: "POST",
|
||||
data: {
|
||||
@ -71,7 +71,7 @@ export const ModalRegistration = ({ active, setActive }) => {
|
||||
password: inputsValue.password,
|
||||
},
|
||||
}).then((data) => {
|
||||
setLoader(false)
|
||||
setLoader(false);
|
||||
if (!data) {
|
||||
showNotification({
|
||||
show: true,
|
||||
@ -79,7 +79,7 @@ export const ModalRegistration = ({ active, setActive }) => {
|
||||
type: "error",
|
||||
});
|
||||
} else {
|
||||
closeModal()
|
||||
closeModal();
|
||||
showNotification({
|
||||
show: true,
|
||||
text: "Аккаунт успешно создан",
|
||||
@ -101,7 +101,7 @@ export const ModalRegistration = ({ active, setActive }) => {
|
||||
password: false,
|
||||
});
|
||||
setActive(false);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<ModalLayout active={active} setActive={closeModal} styles={"registration"}>
|
||||
<div className="registration-body__left">
|
||||
@ -185,8 +185,9 @@ export const ModalRegistration = ({ active, setActive }) => {
|
||||
</div>
|
||||
</div>
|
||||
<div className="button-box">
|
||||
{loader ?
|
||||
<Loader style={'green'} /> :
|
||||
{loader ? (
|
||||
<Loader style={"green"} />
|
||||
) : (
|
||||
<BaseButton
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
@ -196,7 +197,7 @@ export const ModalRegistration = ({ active, setActive }) => {
|
||||
>
|
||||
Отправить
|
||||
</BaseButton>
|
||||
}
|
||||
)}
|
||||
{/*<h5>*/}
|
||||
{/* У вас уже есть аккаунт? <p>Войти</p>*/}
|
||||
{/*</h5>*/}
|
||||
|
@ -4,8 +4,8 @@ import { apiRequest } from "@api/request";
|
||||
|
||||
import { useNotification } from "@hooks/useNotification";
|
||||
|
||||
import ModalLayout from "@components/Common/ModalLayout/ModalLayout";
|
||||
import { Loader } from "@components/Common/Loader/Loader";
|
||||
import ModalLayout from "@components/Common/ModalLayout/ModalLayout";
|
||||
|
||||
import arrow from "assets/icons/arrows/arrowCalendar.png";
|
||||
import close from "assets/icons/close.png";
|
||||
@ -23,7 +23,7 @@ export const ModalResetPassword = ({ active, setActive }) => {
|
||||
const [inputsError, setInputsError] = useState({
|
||||
email: false,
|
||||
password: false,
|
||||
token: false
|
||||
token: false,
|
||||
});
|
||||
|
||||
const validateEmail = (email) => {
|
||||
@ -34,7 +34,7 @@ export const ModalResetPassword = ({ active, setActive }) => {
|
||||
return re.test(email);
|
||||
};
|
||||
|
||||
const [loader, setLoader] = useState(false)
|
||||
const [loader, setLoader] = useState(false);
|
||||
|
||||
const resetInputsValue = () => {
|
||||
setInputsValue({
|
||||
@ -54,14 +54,14 @@ export const ModalResetPassword = ({ active, setActive }) => {
|
||||
type: "error",
|
||||
});
|
||||
}
|
||||
setLoader(true)
|
||||
setLoader(true);
|
||||
apiRequest("/register/request-password-reset", {
|
||||
method: "POST",
|
||||
data: {
|
||||
email: inputsValue.email,
|
||||
},
|
||||
}).then((data) => {
|
||||
setLoader(false)
|
||||
setLoader(false);
|
||||
if (data) {
|
||||
showNotification({
|
||||
show: true,
|
||||
@ -74,7 +74,11 @@ export const ModalResetPassword = ({ active, setActive }) => {
|
||||
};
|
||||
const resetPassword = () => {
|
||||
if (!inputsValue.password || !inputsValue.token) {
|
||||
setInputsError((prevValue) => ({ ...prevValue, password: true, token: true }));
|
||||
setInputsError((prevValue) => ({
|
||||
...prevValue,
|
||||
password: true,
|
||||
token: true,
|
||||
}));
|
||||
return showNotification({
|
||||
show: true,
|
||||
text: "Введите данные",
|
||||
@ -83,9 +87,9 @@ export const ModalResetPassword = ({ active, setActive }) => {
|
||||
}
|
||||
if (inputsValue.password.length < 6) {
|
||||
setInputsError((prevValue) => ({ ...prevValue, password: true }));
|
||||
return
|
||||
return;
|
||||
}
|
||||
setLoader(true)
|
||||
setLoader(true);
|
||||
apiRequest("/register/reset-password", {
|
||||
method: "POST",
|
||||
data: {
|
||||
@ -93,7 +97,7 @@ export const ModalResetPassword = ({ active, setActive }) => {
|
||||
password: inputsValue.password,
|
||||
},
|
||||
}).then((data) => {
|
||||
setLoader(false)
|
||||
setLoader(false);
|
||||
if (data.code === 0) {
|
||||
showNotification({
|
||||
show: true,
|
||||
@ -130,20 +134,23 @@ export const ModalResetPassword = ({ active, setActive }) => {
|
||||
setInputsValue((prevValue) => ({
|
||||
...prevValue,
|
||||
email: e.target.value,
|
||||
}))
|
||||
}));
|
||||
setInputsError({
|
||||
email: false,
|
||||
password: false,
|
||||
token: false
|
||||
token: false,
|
||||
});
|
||||
}}
|
||||
placeholder="Email"
|
||||
value={inputsValue.email}
|
||||
className={inputsError.email ? "error" : ""}
|
||||
/>
|
||||
{inputsError.email && <span className='warningText'>Введите коректный email</span>}
|
||||
{loader ?
|
||||
<Loader style={'green'} /> :
|
||||
{inputsError.email && (
|
||||
<span className="warningText">Введите коректный email</span>
|
||||
)}
|
||||
{loader ? (
|
||||
<Loader style={"green"} />
|
||||
) : (
|
||||
<button
|
||||
className="resetPassword__btn"
|
||||
onClick={(e) => {
|
||||
@ -153,7 +160,7 @@ export const ModalResetPassword = ({ active, setActive }) => {
|
||||
>
|
||||
Отправить
|
||||
</button>
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
) : (
|
||||
<div className="resetPassword__email">
|
||||
@ -169,18 +176,20 @@ export const ModalResetPassword = ({ active, setActive }) => {
|
||||
setInputsError({
|
||||
email: false,
|
||||
password: false,
|
||||
token: false
|
||||
token: false,
|
||||
});
|
||||
setInputsValue((prevValue) => ({
|
||||
...prevValue,
|
||||
token: e.target.value,
|
||||
}))
|
||||
}));
|
||||
}}
|
||||
value={inputsValue.token}
|
||||
className={inputsError.token ? "error" : ""}
|
||||
placeholder="token"
|
||||
/>
|
||||
{inputsError.token && <span className='warningText'>Введите данные</span>}
|
||||
{inputsError.token && (
|
||||
<span className="warningText">Введите данные</span>
|
||||
)}
|
||||
<h5>Введите новый пароль:</h5>
|
||||
<input
|
||||
type="password"
|
||||
@ -188,19 +197,23 @@ export const ModalResetPassword = ({ active, setActive }) => {
|
||||
setInputsValue((prevValue) => ({
|
||||
...prevValue,
|
||||
password: e.target.value,
|
||||
}))
|
||||
}));
|
||||
setInputsError({
|
||||
email: false,
|
||||
password: false,
|
||||
token: false
|
||||
token: false,
|
||||
});
|
||||
}}
|
||||
placeholder="password"
|
||||
value={inputsValue.password}
|
||||
className={inputsError.password ? "error" : ""}
|
||||
/>
|
||||
{inputsError.password && <span className='warningText'>Минимум 6 символов</span>}
|
||||
{loader ? <Loader style={'green'} /> :
|
||||
{inputsError.password && (
|
||||
<span className="warningText">Минимум 6 символов</span>
|
||||
)}
|
||||
{loader ? (
|
||||
<Loader style={"green"} />
|
||||
) : (
|
||||
<button
|
||||
className="resetPassword__btn"
|
||||
onClick={(e) => {
|
||||
@ -210,7 +223,7 @@ export const ModalResetPassword = ({ active, setActive }) => {
|
||||
>
|
||||
Отправить
|
||||
</button>
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user