From 321b84a80ef3ea22d26fe3caf80e1695edd25ad7 Mon Sep 17 00:00:00 2001 From: Mikola Date: Sun, 5 Nov 2023 20:41:40 +0300 Subject: [PATCH] registration --- .../Modal/ModalRegistration/ModalRegistration.jsx | 13 ++++++++++++- src/components/Navigation/Navigation.jsx | 9 ++++++--- src/components/ProfileCalendar/ProfileCalendar.jsx | 7 +++++-- src/components/ProfileHeader/ProfileHeader.jsx | 9 ++++++--- src/pages/Profile/Profile.js | 6 +++--- src/pages/Summary/Summary.js | 7 +++++-- 6 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/components/Modal/ModalRegistration/ModalRegistration.jsx b/src/components/Modal/ModalRegistration/ModalRegistration.jsx index 2fc4150e..1c6fba03 100644 --- a/src/components/Modal/ModalRegistration/ModalRegistration.jsx +++ b/src/components/Modal/ModalRegistration/ModalRegistration.jsx @@ -26,6 +26,14 @@ export const ModalRegistration = ({ active, setActive }) => { // возвращаем true, если email проходит проверку, и false, если нет return re.test(email); + }; + + const resetInputsValue = () => { + setInputsValue({ + userName: "", + email: "", + password: "", + }) } const { showNotification } = useNotification(); @@ -39,6 +47,7 @@ export const ModalRegistration = ({ active, setActive }) => { }, }).then(() => { setActive(false); + resetInputsValue() showNotification({ show: true, text: "Аккаунт успешно создан", @@ -105,7 +114,9 @@ export const ModalRegistration = ({ active, setActive }) => { submitHandler(); }} styles={ - inputsValue.userName && validateEmail(inputsValue.email) && inputsValue.password + inputsValue.userName && + validateEmail(inputsValue.email) && + inputsValue.password ? "button-box__submit" : "button-box__submit disable" } diff --git a/src/components/Navigation/Navigation.jsx b/src/components/Navigation/Navigation.jsx index cbac4365..cac1c4ae 100644 --- a/src/components/Navigation/Navigation.jsx +++ b/src/components/Navigation/Navigation.jsx @@ -73,8 +73,11 @@ export const Navigation = () => { if (localStorage.getItem("role_status") === "18") { return; } + if (Object.keys(profileInfo).length) { + return; + } apiRequest(`/user/me`).then((profileInfo) => - dispatch(setProfileInfo(profileInfo.userCard)) + dispatch(setProfileInfo(profileInfo.userCard ? profileInfo.userCard : profileInfo)) ); }, [dispatch]); @@ -93,12 +96,12 @@ export const Navigation = () => {

- {user === "developer" ? profileInfo?.fio : ""} + {profileInfo?.fio ? profileInfo?.fio : profileInfo?.username}

avatar { @@ -94,12 +95,14 @@ export const ProfileCalendar = () => {
avatar

- {profileInfo.fio}, {profileInfo.specification} разработчик + {profileInfo?.fio ? profileInfo?.fio : profileInfo?.username}, {profileInfo.specification} разработчик

diff --git a/src/components/ProfileHeader/ProfileHeader.jsx b/src/components/ProfileHeader/ProfileHeader.jsx index 96daa0fe..dce0506f 100644 --- a/src/components/ProfileHeader/ProfileHeader.jsx +++ b/src/components/ProfileHeader/ProfileHeader.jsx @@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; 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 { apiRequest } from "@api/request"; @@ -14,7 +14,7 @@ import "./profileHeader.scss"; export const ProfileHeader = () => { const navigate = useNavigate(); const dispatch = useDispatch(); - + const profileInfo = useSelector(getProfileInfo); const userRole = useSelector(getRole); const [user] = useState( localStorage.getItem("role_status") === "18" ? "partner" : "developer" @@ -26,8 +26,11 @@ export const ProfileHeader = () => { if (localStorage.getItem("role_status") === "18") { return; } + if (Object.keys(profileInfo).length) { + return; + } apiRequest(`/user/me`).then((profileInfo) => { - dispatch(setProfileInfo(profileInfo.userCard)); + dispatch(setProfileInfo(profileInfo.userCard ? profileInfo.userCard : profileInfo)) }); }, [dispatch]); diff --git a/src/pages/Profile/Profile.js b/src/pages/Profile/Profile.js index da2af30b..6ba757d1 100644 --- a/src/pages/Profile/Profile.js +++ b/src/pages/Profile/Profile.js @@ -103,7 +103,7 @@ export const Profile = () => { {user === "developer" ? (

Добрый день, 

- {profileInfo.fio} + {profileInfo?.fio ? profileInfo?.fio : profileInfo?.username}
) : ( "ООО НДВ Консалтинг" @@ -113,7 +113,7 @@ export const Profile = () => {
avatar {

{user === "developer" ? ( - {profileInfo.fio}, {profileInfo.specification} разработчик + {profileInfo?.fio ? profileInfo?.fio : profileInfo?.username}, {profileInfo?.specification} разработчик ) : ( "ООО НДВ Консалтинг" diff --git a/src/pages/Summary/Summary.js b/src/pages/Summary/Summary.js index 5e00d31d..8144a31c 100644 --- a/src/pages/Summary/Summary.js +++ b/src/pages/Summary/Summary.js @@ -18,6 +18,7 @@ import arrow from "assets/icons/arrows/left-arrow.png"; import gitImgItem from "assets/icons/gitItemImg.svg"; import "./summary.scss"; +import avatarMok from "assets/images/avatarMok.png"; export const Summary = () => { if (localStorage.getItem("role_status") === "18") { @@ -56,12 +57,14 @@ export const Summary = () => {

avatar

- {profileInfo.fio}, {profileInfo.specification} разработчик + {profileInfo?.fio ? profileInfo?.fio : profileInfo?.username}, {profileInfo.specification} разработчик

{!openGit && (