fix api /me

This commit is contained in:
Mikola 2023-12-25 20:59:25 +03:00
parent 80ebf85347
commit ce6c2d965a
3 changed files with 17 additions and 15 deletions

View File

@ -1,9 +1,10 @@
import { store } from "@store/store";
import axios from "axios";
import { getToken, urlHasParams } from "@utils/helper";
import { store } from "@store/store";
import { setProfileInfo } from "@redux/outstaffingSlice";
import { getToken, urlHasParams } from "@utils/helper";
const instance = axios.create({
baseURL: process.env.REACT_APP_API_URL,
validateStatus(status) {
@ -41,7 +42,7 @@ export const apiRequest = (
window.location.replace("/auth");
localStorage.clear();
// dispatch(auth(false));
store.dispatch(setProfileInfo({}))
store.dispatch(setProfileInfo({}));
}
return resolve(response);
})

View File

@ -34,7 +34,8 @@ export const ProfileHeader = () => {
// }, [dispatch]);
useEffect(() => {
if (!Object.keys(profileInfo).length) apiRequest(`/user/me`).then((profileInfo) => {
if (!Object.keys(profileInfo).length)
apiRequest(`/user/me`).then((profileInfo) => {
dispatch(
setProfileInfo(
profileInfo.userCard ? profileInfo.userCard : profileInfo
@ -49,7 +50,7 @@ export const ProfileHeader = () => {
dispatch(auth(false));
setIsLoggingOut(false);
navigate("/auth");
dispatch(setProfileInfo({}))
dispatch(setProfileInfo({}));
};
return (