Compare commits
2 Commits
5e7c9dec79
...
ce6c2d965a
Author | SHA1 | Date | |
---|---|---|---|
|
ce6c2d965a | ||
|
80ebf85347 |
@ -1,5 +1,8 @@
|
||||
import { store } from "@store/store";
|
||||
import axios from "axios";
|
||||
|
||||
import { setProfileInfo } from "@redux/outstaffingSlice";
|
||||
|
||||
import { getToken, urlHasParams } from "@utils/helper";
|
||||
|
||||
const instance = axios.create({
|
||||
@ -39,6 +42,7 @@ export const apiRequest = (
|
||||
window.location.replace("/auth");
|
||||
localStorage.clear();
|
||||
// dispatch(auth(false));
|
||||
store.dispatch(setProfileInfo({}));
|
||||
}
|
||||
return resolve(response);
|
||||
})
|
||||
|
@ -2,12 +2,10 @@ import React, { useEffect, useState } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { NavLink } from "react-router-dom";
|
||||
|
||||
import { getProfileInfo, setProfileInfo } from "@redux/outstaffingSlice";
|
||||
import { getProfileInfo } from "@redux/outstaffingSlice";
|
||||
|
||||
import { urlForLocal } from "@utils/helper";
|
||||
|
||||
import { apiRequest } from "@api/request";
|
||||
|
||||
import avatarMok from "assets/images/avatarMok.png";
|
||||
|
||||
export const Navigation = () => {
|
||||
@ -77,17 +75,17 @@ 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 ? profileInfo.userCard : profileInfo
|
||||
)
|
||||
)
|
||||
);
|
||||
}, [dispatch]);
|
||||
// if (Object.keys(profileInfo).length) {
|
||||
// return;
|
||||
// }
|
||||
// apiRequest(`/user/me`).then((profileInfo) =>
|
||||
// dispatch(
|
||||
// setProfileInfo(
|
||||
// profileInfo.userCard ? profileInfo.userCard : profileInfo
|
||||
// )
|
||||
// )
|
||||
// );
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="profileHeader__info">
|
||||
|
@ -20,20 +20,21 @@ export const ProfileHeader = () => {
|
||||
|
||||
const [isLoggingOut, setIsLoggingOut] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (Object.keys(profileInfo).length) {
|
||||
return;
|
||||
}
|
||||
apiRequest(`/user/me`).then((profileInfo) => {
|
||||
dispatch(
|
||||
setProfileInfo(
|
||||
profileInfo.userCard ? profileInfo.userCard : profileInfo
|
||||
)
|
||||
);
|
||||
});
|
||||
}, [dispatch]);
|
||||
// useEffect(() => {
|
||||
// if (Object.keys(profileInfo).length) {
|
||||
// return;
|
||||
// }
|
||||
// apiRequest(`/user/me`).then((profileInfo) => {
|
||||
// dispatch(
|
||||
// setProfileInfo(
|
||||
// profileInfo.userCard ? profileInfo.userCard : profileInfo
|
||||
// )
|
||||
// );
|
||||
// });
|
||||
// }, [dispatch]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!Object.keys(profileInfo).length)
|
||||
apiRequest(`/user/me`).then((profileInfo) => {
|
||||
dispatch(
|
||||
setProfileInfo(
|
||||
@ -49,6 +50,7 @@ export const ProfileHeader = () => {
|
||||
dispatch(auth(false));
|
||||
setIsLoggingOut(false);
|
||||
navigate("/auth");
|
||||
dispatch(setProfileInfo({}));
|
||||
};
|
||||
|
||||
return (
|
||||
|
Loading…
Reference in New Issue
Block a user