Skip to content

Commit a8a0b04

Browse files
authored
Merge pull request #260 from DDD-Community/feat/recent-login
hotfix: oauth 로그인 로딩 Ui 수정
2 parents bed903c + cd13565 commit a8a0b04

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/app/(auth)/oauth/callback/page.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
'use client';
22

33
import { useEffect, useState } from 'react';
4-
import { redirect } from 'next/navigation';
4+
import { useRouter } from 'next/navigation';
55
import Link from 'next/link';
66
import { KakaoSignupForm } from '@/composite/signup/signUpForm/KakaoSignupForm';
77
import { tokenController } from '@/shared/lib/token';
88
import { AuthMethod } from '@/shared/type/authToken';
99

1010
export default function OAuthCallbackPage() {
11+
const router = useRouter();
1112
const [isLoading, setIsLoading] = useState(true);
1213
const [hasTokens, setHasTokens] = useState(false);
1314
const [, setLastLoginMethod] = useState<AuthMethod | null>(null);
@@ -22,16 +23,15 @@ export default function OAuthCallbackPage() {
2223

2324
if (!accessToken || !refreshToken) {
2425
setIsLoading(false);
25-
redirect('/login');
26+
router.replace('/login');
27+
return;
2628
}
2729
if (accessToken && refreshToken) {
2830
setHasTokens(true);
2931
tokenController.setTokens(accessToken, refreshToken);
3032
// Oauth 로그인 성공 시 마지막 로그인 수단 저장
3133
setLastLoginMethod('KAKAO');
32-
setTimeout(() => {
33-
redirect('/home');
34-
}, 50);
34+
router.replace('/home');
3535
} else {
3636
setHasTokens(false);
3737
}
@@ -43,11 +43,11 @@ export default function OAuthCallbackPage() {
4343
}
4444
};
4545
handleTokenProcessing();
46-
}, []);
46+
}, [router]);
4747

4848
if (isLoading) {
4949
return (
50-
<div className="w-full h-full bg-normal-alternative items-center justify-center">
50+
<div className="w-full h-full flex flex-col bg-normal-alternative items-center justify-center">
5151
<div className="text-center">
5252
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-white mx-auto mb-4"></div>
5353
<p className="text-gray-100 font-medium">로그인 처리 중...</p>
@@ -59,7 +59,7 @@ export default function OAuthCallbackPage() {
5959
// 토큰이 있어서 로그인 성공한 경우
6060
if (hasTokens) {
6161
return (
62-
<div className="w-full h-full bg-normal-alternative items-center justify-center">
62+
<div className="w-full h-full flex flex-col bg-normal-alternative items-center justify-center">
6363
<div className="text-center">
6464
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-white mx-auto mb-4"></div>
6565
<p className="text-gray-100 font-medium">

src/app/(home)/advice/error.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import Button from '@/shared/components/input/Button';
55
import { getMsUntilEndOfDay } from '@/shared/lib/utils';
66
import { useQuery } from '@tanstack/react-query';
77
import Image from 'next/image';
8-
import { redirect } from 'next/navigation';
8+
import { useRouter } from 'next/navigation';
99
import { useMemo } from 'react';
1010

1111
export default function AdviceErrorPage() {
1212
const msUntilEndOfDay = useMemo(() => getMsUntilEndOfDay(), []);
13+
const router = useRouter();
1314
const { refetch } = useQuery(
1415
AdviceQuery.getAdviceChat({
1516
staleTime: msUntilEndOfDay,
@@ -19,7 +20,7 @@ export default function AdviceErrorPage() {
1920

2021
const handleRetry = () => {
2122
refetch();
22-
redirect('/advice');
23+
router.replace('/advice');
2324
};
2425

2526
return (

0 commit comments

Comments
 (0)