add adaptive registationForCandidate,

modalRegistration,
create hook useFormValidation,
add Validation in registationForCandidate
This commit is contained in:
2023-12-26 02:42:49 +03:00
parent ce6c2d965a
commit c345bdf5ca
8 changed files with 278 additions and 46 deletions

View File

@ -18,13 +18,15 @@ export const ModalRegistration = ({ active, setActive }) => {
const [inputsValue, setInputsValue] = useState({
userName: "",
email: "",
password: ""
password: "",
secondPassword: ""
});
const [inputsError, setInputsError] = useState({
name: false,
email: false,
password: false
password: false,
secondPassword: false
});
const [loader, setLoader] = useState(false);
@ -43,6 +45,9 @@ export const ModalRegistration = ({ active, setActive }) => {
if (inputsValue.password.length < 6) {
setInputsError((prevValue) => ({ ...prevValue, password: true }));
}
if (inputsValue.password !== inputsValue.secondPassword) {
setInputsError((prevValue) => ({ ...prevValue, secondPassword: true }));
}
if (inputsValue.userName.length < 2) {
setInputsError((prevValue) => ({ ...prevValue, name: true }));
}
@ -105,8 +110,8 @@ export const ModalRegistration = ({ active, setActive }) => {
return (
<ModalLayout active={active} setActive={closeModal} styles={"registration"}>
<div className="registration-body__main">
<h2>
Подключайтесь к <p>ITguild</p>
<h2 className="registration-body__main-title">
Подключайтесь к <span>ITguild</span>
</h2>
<p className="registration-body__main-desc">
Зарегистрируйтесь и начните работу уже сегодня
@ -182,23 +187,25 @@ export const ModalRegistration = ({ active, setActive }) => {
<div className="inputContainer">
<h5>Повторите пароль</h5>
<input
className={inputsError.password ? "error" : ""}
className={inputsError.secondPassword ? "error" : ""}
type="password"
onChange={(e) => {
setInputsError({
name: false,
email: false,
password: false
secondPassword: false
});
setInputsValue((prevValue) => ({
...prevValue,
password: e.target.value
secondPassword: e.target.value
}));
}}
value={inputsValue.password}
value={inputsValue.secondPassword}
placeholder="Пароль"
/>
{inputsError.password && <span>Минимум 6 символов</span>}
{inputsError.secondPassword && (
<span>Пароли должны совпадать</span>
)}
</div>
</div>
</div>