Fix: 훅에서 쿼리 안가져온 부분 수정

This commit is contained in:
정현조 2024-09-18 17:24:37 +09:00
parent 3e1e9bb23f
commit 04755eb526

View File

@ -1,6 +1,5 @@
import useAuthStore from '@/stores/useAuthStore';
import { useSuspenseQuery } from '@tanstack/react-query';
import { getProfile } from '@/api/authApi';
import useProfileQuery from '@/queries/useProfileQuery';
export function useHandleOAuthCallback() {
const queryParams = new URLSearchParams(window.location.search);
@ -8,12 +7,13 @@ export function useHandleOAuthCallback() {
const setLoggedIn = useAuthStore((state) => state.setLoggedIn);
const setProfile = useAuthStore((state) => state.setProfile);
accessToken && setLoggedIn(true, accessToken);
if (accessToken) {
setLoggedIn(true, accessToken);
}
const { data: profile } = useSuspenseQuery({
queryKey: ['profile'],
queryFn: getProfile,
});
const { data: profile } = useProfileQuery();
if (profile) {
setProfile(profile);
}
}