registration

This commit is contained in:
Mikola 2023-11-05 20:41:40 +03:00
parent 1e9ee3699d
commit 321b84a80e
6 changed files with 37 additions and 14 deletions

View File

@ -26,6 +26,14 @@ export const ModalRegistration = ({ active, setActive }) => {
// возвращаем true, если email проходит проверку, и false, если нет // возвращаем true, если email проходит проверку, и false, если нет
return re.test(email); return re.test(email);
};
const resetInputsValue = () => {
setInputsValue({
userName: "",
email: "",
password: "",
})
} }
const { showNotification } = useNotification(); const { showNotification } = useNotification();
@ -39,6 +47,7 @@ export const ModalRegistration = ({ active, setActive }) => {
}, },
}).then(() => { }).then(() => {
setActive(false); setActive(false);
resetInputsValue()
showNotification({ showNotification({
show: true, show: true,
text: "Аккаунт успешно создан", text: "Аккаунт успешно создан",
@ -105,7 +114,9 @@ export const ModalRegistration = ({ active, setActive }) => {
submitHandler(); submitHandler();
}} }}
styles={ styles={
inputsValue.userName && validateEmail(inputsValue.email) && inputsValue.password inputsValue.userName &&
validateEmail(inputsValue.email) &&
inputsValue.password
? "button-box__submit" ? "button-box__submit"
: "button-box__submit disable" : "button-box__submit disable"
} }

View File

@ -73,8 +73,11 @@ export const Navigation = () => {
if (localStorage.getItem("role_status") === "18") { if (localStorage.getItem("role_status") === "18") {
return; return;
} }
if (Object.keys(profileInfo).length) {
return;
}
apiRequest(`/user/me`).then((profileInfo) => apiRequest(`/user/me`).then((profileInfo) =>
dispatch(setProfileInfo(profileInfo.userCard)) dispatch(setProfileInfo(profileInfo.userCard ? profileInfo.userCard : profileInfo))
); );
}, [dispatch]); }, [dispatch]);
@ -93,12 +96,12 @@ export const Navigation = () => {
<div className="profileHeader__personalInfo"> <div className="profileHeader__personalInfo">
<h3 className="profileHeader__personalInfoName"> <h3 className="profileHeader__personalInfoName">
{user === "developer" ? profileInfo?.fio : ""} {profileInfo?.fio ? profileInfo?.fio : profileInfo?.username}
</h3> </h3>
<NavLink end to={"/profile"}> <NavLink end to={"/profile"}>
<img <img
src={ src={
profileInfo.photo ? urlForLocal(profileInfo.photo) : avatarMok profileInfo?.photo ? urlForLocal(profileInfo.photo) : avatarMok
} }
className="profileHeader__personalInfoAvatar" className="profileHeader__personalInfoAvatar"
alt="avatar" alt="avatar"

View File

@ -23,6 +23,7 @@ import { ProfileBreadcrumbs } from "@components/ProfileBreadcrumbs/ProfileBreadc
import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader"; import { ProfileHeader } from "@components/ProfileHeader/ProfileHeader";
import { ProfileCalendarComponent } from "./ProfileCalendarComponent"; import { ProfileCalendarComponent } from "./ProfileCalendarComponent";
import avatarMok from "assets/images/avatarMok.png";
import "./profileCalendar.scss"; import "./profileCalendar.scss";
export const ProfileCalendar = () => { export const ProfileCalendar = () => {
@ -94,12 +95,14 @@ export const ProfileCalendar = () => {
<div className="summary__info"> <div className="summary__info">
<div className="summary__person"> <div className="summary__person">
<img <img
src={urlForLocal(profileInfo.photo)} src={
profileInfo?.photo ? urlForLocal(profileInfo.photo) : avatarMok
}
className="summary__avatar" className="summary__avatar"
alt="avatar" alt="avatar"
/> />
<p className="summary__name"> <p className="summary__name">
{profileInfo.fio}, {profileInfo.specification} разработчик {profileInfo?.fio ? profileInfo?.fio : profileInfo?.username}, {profileInfo.specification} разработчик
</p> </p>
</div> </div>
<Link to="/report"> <Link to="/report">

View File

@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux"; import { useDispatch, useSelector } from "react-redux";
import { NavLink, useNavigate } from "react-router-dom"; import { NavLink, useNavigate } from "react-router-dom";
import { auth, setProfileInfo } from "@redux/outstaffingSlice"; import {auth, getProfileInfo, setProfileInfo} from "@redux/outstaffingSlice";
import { getRole } from "@redux/roleSlice"; import { getRole } from "@redux/roleSlice";
import { apiRequest } from "@api/request"; import { apiRequest } from "@api/request";
@ -14,7 +14,7 @@ import "./profileHeader.scss";
export const ProfileHeader = () => { export const ProfileHeader = () => {
const navigate = useNavigate(); const navigate = useNavigate();
const dispatch = useDispatch(); const dispatch = useDispatch();
const profileInfo = useSelector(getProfileInfo);
const userRole = useSelector(getRole); const userRole = useSelector(getRole);
const [user] = useState( const [user] = useState(
localStorage.getItem("role_status") === "18" ? "partner" : "developer" localStorage.getItem("role_status") === "18" ? "partner" : "developer"
@ -26,8 +26,11 @@ export const ProfileHeader = () => {
if (localStorage.getItem("role_status") === "18") { if (localStorage.getItem("role_status") === "18") {
return; return;
} }
if (Object.keys(profileInfo).length) {
return;
}
apiRequest(`/user/me`).then((profileInfo) => { apiRequest(`/user/me`).then((profileInfo) => {
dispatch(setProfileInfo(profileInfo.userCard)); dispatch(setProfileInfo(profileInfo.userCard ? profileInfo.userCard : profileInfo))
}); });
}, [dispatch]); }, [dispatch]);

View File

@ -103,7 +103,7 @@ export const Profile = () => {
{user === "developer" ? ( {user === "developer" ? (
<span> <span>
<p>Добрый день,&nbsp;</p> <p>Добрый день,&nbsp;</p>
{profileInfo.fio} {profileInfo?.fio ? profileInfo?.fio : profileInfo?.username}
</span> </span>
) : ( ) : (
"ООО НДВ Консалтинг" "ООО НДВ Консалтинг"
@ -113,7 +113,7 @@ export const Profile = () => {
<div className="summary__person"> <div className="summary__person">
<img <img
src={ src={
profileInfo.photo ? urlForLocal(profileInfo.photo) : avatarMok profileInfo?.photo ? urlForLocal(profileInfo.photo) : avatarMok
} }
className="summary__avatar" className="summary__avatar"
alt="avatar" alt="avatar"
@ -121,7 +121,7 @@ export const Profile = () => {
<p className="summary__name"> <p className="summary__name">
{user === "developer" ? ( {user === "developer" ? (
<span> <span>
{profileInfo.fio}, {profileInfo.specification} разработчик {profileInfo?.fio ? profileInfo?.fio : profileInfo?.username}, {profileInfo?.specification} разработчик
</span> </span>
) : ( ) : (
"ООО НДВ Консалтинг" "ООО НДВ Консалтинг"

View File

@ -18,6 +18,7 @@ import arrow from "assets/icons/arrows/left-arrow.png";
import gitImgItem from "assets/icons/gitItemImg.svg"; import gitImgItem from "assets/icons/gitItemImg.svg";
import "./summary.scss"; import "./summary.scss";
import avatarMok from "assets/images/avatarMok.png";
export const Summary = () => { export const Summary = () => {
if (localStorage.getItem("role_status") === "18") { if (localStorage.getItem("role_status") === "18") {
@ -56,12 +57,14 @@ export const Summary = () => {
<div className={openGit ? "summary__info openGit" : "summary__info"}> <div className={openGit ? "summary__info openGit" : "summary__info"}>
<div className="summary__person"> <div className="summary__person">
<img <img
src={urlForLocal(profileInfo.photo)} src={
profileInfo?.photo ? urlForLocal(profileInfo.photo) : avatarMok
}
className="summary__avatar" className="summary__avatar"
alt="avatar" alt="avatar"
/> />
<p className="summary__name"> <p className="summary__name">
{profileInfo.fio}, {profileInfo.specification} разработчик {profileInfo?.fio ? profileInfo?.fio : profileInfo?.username}, {profileInfo.specification} разработчик
</p> </p>
</div> </div>
{!openGit && ( {!openGit && (