-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAuthCallback.tsx
More file actions
35 lines (31 loc) · 1.03 KB
/
AuthCallback.tsx
File metadata and controls
35 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { useNavigate, useSearchParams } from 'react-router-dom';
import useAuthStore from '../../app/provider/authStore';
import { useEffect } from 'react';
import { useUserInfo } from '../../features/join/hooks/useUserHook';
const AuthCallback = () => {
const navigate = useNavigate();
const [searchParams] = useSearchParams();
const status = searchParams.get('status'); // 'new' or 'existing'
const { login, setName, closeModal } = useAuthStore();
const { data } = useUserInfo();
useEffect(() => {
const handleAuth = async () => {
if (!data) return;
try {
closeModal();
if (status === 'new') {
navigate('/join/agreement');
} else {
login();
setName(data?.name || '사용자');
navigate('/');
}
} catch {
navigate('/');
}
};
handleAuth();
}, [data, navigate, login, status, setName, closeModal]);
return <div className="text-center mt-32 text-lg font-bold">로그인 중입니다...</div>;
};
export default AuthCallback;