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

@ -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]);