Tracker Auth

This commit is contained in:
2023-07-07 01:20:57 +03:00
parent c3ef01ee35
commit 49729ddd6b
8 changed files with 250 additions and 146 deletions

View File

@ -13,6 +13,7 @@ import AuthHeader from "@components/Common/AuthHeader/AuthHeader";
import { Footer } from "@components/Common/Footer/Footer";
import SideBar from "@components/SideBar/SideBar";
import StepsForCandidate from "@components/StepsForCandidate/StepsForCandidate";
import AuthBlock from "@components/AuthBlock/AuthBlock";
import arrowBtn from "assets/icons/arrows/arrowRight.svg";
import AdminImg from "assets/images/partnerProfile/PersonalAdmin.svg";
@ -112,68 +113,42 @@ export const AuthForCandidate = () => {
}
}, [getToken]);
const submitHandler = () => {
let formData = new FormData(ref.current);
if (!isLoading) {
dispatch(loading(true));
apiRequest("/user/login", {
method: "POST",
data: formData,
}).then((res) => {
if (!res.access_token) {
dispatch(loading(false));
} else {
localStorage.setItem("auth_token", res.access_token);
localStorage.setItem("id", res.id);
localStorage.setItem("cardId", res.card_id);
localStorage.setItem("role_status", res.status);
localStorage.setItem(
"access_token_expired_at",
res.access_token_expired_at
);
dispatch(auth(true));
dispatch(setUserInfo(res));
dispatch(loading(false));
dispatch(setRole("ROLE_PARTNER"));
}
});
}
};
// const submitHandler = () => {
// let formData = new FormData(ref.current);
// if (!isLoading) {
// dispatch(loading(true));
// apiRequest("/user/login", {
// method: "POST",
// data: formData,
// }).then((res) => {
// if (!res.access_token) {
// dispatch(loading(false));
// } else {
// localStorage.setItem("auth_token", res.access_token);
// localStorage.setItem("id", res.id);
// localStorage.setItem("cardId", res.card_id);
// localStorage.setItem("role_status", res.status);
// localStorage.setItem(
// "access_token_expired_at",
// res.access_token_expired_at
// );
// dispatch(auth(true));
// dispatch(setUserInfo(res));
// dispatch(loading(false));
// dispatch(setRole("ROLE_PARTNER"));
// }
// });
// }
// };
return (
<div className="auth-candidate">
<AuthHeader />
<div className="container">
<div className="auth__wrapper">
<div className="auth__info">
<h3>Войти, уже есть доступ</h3>
<img src={authImg} alt="img" />
<p>
если вы получили доступ пройдя 2 шага для входа или хотите узнать
свои результаты в кабинете
</p>
</div>
<form ref={ref} className="auth__form">
<label htmlFor="login">Ваш email *</label>
<input id="login" type="text" name="username" placeholder="Email" />
<label htmlFor="password">Ваш пароль*</label>
<input
id="password"
type="password"
name="password"
placeholder="Пароль"
/>
<button
onClick={(e) => {
e.preventDefault();
submitHandler();
}}
>
Войти
</button>
</form>
</div>
<AuthBlock title="Войти, уже есть доступ"
description="если вы получили доступ пройдя
2 шага для входа или хотите узнать
свои результаты в кабинете" />
<div className="auth-candidate__start">
<h2 className="auth-candidate__start__title">
Хочу в команду <span>Айти специалистов</span>

View File

@ -4,95 +4,6 @@
position: relative;
background-color: #f1f1f1;
.auth {
&__wrapper {
background: #ffffff;
border-radius: 12px;
padding: 50px 0 35px 56px;
margin-top: 40px;
display: flex;
@media (max-width: 1024px) {
margin-top: 100px;
}
@media (max-width: 870px) {
flex-direction: column;
padding: 25px;
}
}
&__info {
margin-right: 115px;
h3 {
font-weight: 500;
font-size: 30px;
line-height: 32px;
margin-bottom: 20px;
}
p {
max-width: 310px;
margin-top: 17px;
font-weight: 400;
font-size: 16px;
line-height: 30px;
@media (max-width: 870px) {
max-width: none;
margin-bottom: 15px;
}
}
@media (max-width: 870px) {
margin-right: 0;
}
}
&__form {
display: flex;
flex-direction: column;
input {
margin-bottom: 30px;
background: #eff2f7;
border-radius: 8px;
min-width: 300px;
width: 100%;
padding: 8px 12px;
border: none;
outline: none;
font-weight: 400;
font-size: 15px;
line-height: 18px;
@media (max-width: 870px) {
max-width: 350px;
}
}
label {
margin-bottom: 15px;
font-weight: 400;
font-size: 15px;
line-height: 18px;
color: #000000;
}
button {
background: #52b709;
border-radius: 44px;
max-width: 130px;
border: none;
font-weight: 500;
font-size: 18px;
line-height: 32px;
color: white;
height: 45px;
}
}
}
&__start {
margin-top: 60px;
display: flex;