diff --git a/src/components/loginSignup/LoginForm/index.tsx b/src/components/loginSignup/LoginForm/index.tsx index 2a4e6f3..ff2ad44 100644 --- a/src/components/loginSignup/LoginForm/index.tsx +++ b/src/components/loginSignup/LoginForm/index.tsx @@ -45,7 +45,7 @@ export default function LoginForm() {

- 이미 회원이신가요?{' '} + 회원이 아닌가요?{' '} 회원가입 diff --git a/src/components/shared/GNB/index.tsx b/src/components/shared/GNB/index.tsx index b234e71..2f0e4e2 100644 --- a/src/components/shared/GNB/index.tsx +++ b/src/components/shared/GNB/index.tsx @@ -23,7 +23,7 @@ export default function GNB() { const userinfo = userStore((state) => state.user); const updateUser = userStore((state) => state.updateUser); - const { data, isPending, isError, error } = useQuery({ + const { data } = useQuery({ queryKey: ['queryUserInfo'], queryFn: getUserInfo, staleTime: 1000 * 60 * 5, diff --git a/src/pages/oauth/index.tsx b/src/pages/oauth/index.tsx index 82fd1bd..ebe0c21 100644 --- a/src/pages/oauth/index.tsx +++ b/src/pages/oauth/index.tsx @@ -26,25 +26,29 @@ export default function OAuth() { gcTime: 1000 * 60 * 6, }); - const { data: socialCode } = useQuery({ - queryKey: ['querySocialAccess'], - queryFn: () => getSocialAccess(code as string), - }); - - const saveSocialCode = useCallback(() => { - if (socialCode) { - loginStore(); - } else { - Toast('error', '새로고침 후 다시 시도해주세요.'); - void routerInternal.push('/login'); - } - }, [loginStore, routerInternal, socialCode]); - useEffect(() => { - if (!code) return; + async function handleOAuth() { + if (!code) return; - saveSocialCode(); - }, [code, saveSocialCode]); + const social = sessionStorage.getItem('social'); + try { + if (!social) { + throw new Error('Social is null'); + } + const result = await getSocialAccess(code as string); + if (result) { + loginStore(); + } else if (!result) { + await routerInternal.push('/login'); + } + } catch (error) { + Toast('error', '새로고침 후 다시 시도해주세요.'); + void routerInternal.push('/login'); + console.log(error); + } + } + void handleOAuth(); + }, [code, loginStore, routerInternal]); const saveUserInfo = useCallback(() => { void refetch();