import { isEmpty } from 'lodash' import { getUserInfo } from '../../apis' import { getUserData } from '../../utils' import { useCustomQuery } from '../customQuery/useCustomQuery' import { userKeys } from './userKeys' const fetchCurrentUser = async () => { let user = getUserData() if (!isEmpty(user)) { const response = await getUserInfo() user = response.data } return user } export const useCurrentUser = () => { const currentUserData = useCustomQuery(userKeys.currentUser(), fetchCurrentUser, { initialData: getUserData(), }) return { ...currentUserData, isLoggedIn: !isEmpty(currentUserData.data), } }