fix api /me
This commit is contained in:
		| @@ -1,9 +1,10 @@ | |||||||
|  | import { store } from "@store/store"; | ||||||
| import axios from "axios"; | import axios from "axios"; | ||||||
|  |  | ||||||
| import { getToken, urlHasParams } from "@utils/helper"; |  | ||||||
| import { store } from "@store/store"; |  | ||||||
| import { setProfileInfo } from "@redux/outstaffingSlice"; | import { setProfileInfo } from "@redux/outstaffingSlice"; | ||||||
|  |  | ||||||
|  | import { getToken, urlHasParams } from "@utils/helper"; | ||||||
|  |  | ||||||
| const instance = axios.create({ | const instance = axios.create({ | ||||||
|   baseURL: process.env.REACT_APP_API_URL, |   baseURL: process.env.REACT_APP_API_URL, | ||||||
|   validateStatus(status) { |   validateStatus(status) { | ||||||
| @@ -41,7 +42,7 @@ export const apiRequest = ( | |||||||
|             window.location.replace("/auth"); |             window.location.replace("/auth"); | ||||||
|             localStorage.clear(); |             localStorage.clear(); | ||||||
|             // dispatch(auth(false)); |             // dispatch(auth(false)); | ||||||
|             store.dispatch(setProfileInfo({})) |             store.dispatch(setProfileInfo({})); | ||||||
|           } |           } | ||||||
|           return resolve(response); |           return resolve(response); | ||||||
|         }) |         }) | ||||||
|   | |||||||
| @@ -273,15 +273,15 @@ export const ProfileCalendarComponent = React.memo( | |||||||
|                 ? `${getCorrectDate(startDate)} - ${getCorrectDate(endDate)}` |                 ? `${getCorrectDate(startDate)} - ${getCorrectDate(endDate)}` | ||||||
|                 : `${getCorrectDate(endDate)} - ${getCorrectDate(startDate)}` |                 : `${getCorrectDate(endDate)} - ${getCorrectDate(startDate)}` | ||||||
|               : activePeriod |               : activePeriod | ||||||
|                 ? "Выберите диапазон на календаре" |               ? "Выберите диапазон на календаре" | ||||||
|                 : "Выбрать диапазон"} |               : "Выбрать диапазон"} | ||||||
|           </span> |           </span> | ||||||
|           <span> |           <span> | ||||||
|             {totalRangeHours |             {totalRangeHours | ||||||
|               ? `${totalRangeHours} ${hourOfNum(totalRangeHours)}` |               ? `${totalRangeHours} ${hourOfNum(totalRangeHours)}` | ||||||
|               : endDate |               : endDate | ||||||
|                 ? "0 часов" |               ? "0 часов" | ||||||
|                 : ""} |               : ""} | ||||||
|           </span> |           </span> | ||||||
|           {endDate && ( |           {endDate && ( | ||||||
|             <BaseButton |             <BaseButton | ||||||
|   | |||||||
| @@ -34,13 +34,14 @@ export const ProfileHeader = () => { | |||||||
|   // }, [dispatch]); |   // }, [dispatch]); | ||||||
|  |  | ||||||
|   useEffect(() => { |   useEffect(() => { | ||||||
|     if (!Object.keys(profileInfo).length) apiRequest(`/user/me`).then((profileInfo) => { |     if (!Object.keys(profileInfo).length) | ||||||
|       dispatch( |       apiRequest(`/user/me`).then((profileInfo) => { | ||||||
|         setProfileInfo( |         dispatch( | ||||||
|           profileInfo.userCard ? profileInfo.userCard : profileInfo |           setProfileInfo( | ||||||
|         ) |             profileInfo.userCard ? profileInfo.userCard : profileInfo | ||||||
|       ); |           ) | ||||||
|     }); |         ); | ||||||
|  |       }); | ||||||
|   }, []); |   }, []); | ||||||
|  |  | ||||||
|   const handler = () => { |   const handler = () => { | ||||||
| @@ -49,7 +50,7 @@ export const ProfileHeader = () => { | |||||||
|     dispatch(auth(false)); |     dispatch(auth(false)); | ||||||
|     setIsLoggingOut(false); |     setIsLoggingOut(false); | ||||||
|     navigate("/auth"); |     navigate("/auth"); | ||||||
|     dispatch(setProfileInfo({})) |     dispatch(setProfileInfo({})); | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   return ( |   return ( | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Mikola
					Mikola