@@ -4,12 +4,15 @@ import { Spinner } from "@/components/ui/spinner";
44import { useCallback , useEffect , useState } from "react" ;
55
66import { postGoogleLogin } from "@/features/auth/api/auth" ;
7+ import { getPoint } from "@/features/reward/api/reward" ;
78import { useNavigate , useSearchParams } from "react-router" ;
89
910import { useAuthStore } from "@/stores/auth-store" ;
11+ import { useUserStore } from "@/stores/user" ;
1012import { paths } from "@/config/paths" ;
1113
1214const GoogleCallback = ( ) : JSX . Element | null => {
15+ const { setUserName, setPoint } = useUserStore ( ) ;
1316 const [ searchParams ] = useSearchParams ( ) ;
1417 const navigate = useNavigate ( ) ;
1518 const setTokens = useAuthStore ( ( state ) => state . setTokens ) ;
@@ -25,9 +28,13 @@ const GoogleCallback = (): JSX.Element | null => {
2528 throw new Error ( "구글 인증에 실패했습니다." ) ;
2629 }
2730
28- const { accessToken, refreshToken, userId } = response . data ;
31+ const { accessToken, refreshToken, username , userId } = response . data ;
2932
3033 setTokens ( accessToken , refreshToken , userId ) ;
34+ setUserName ( username ) ;
35+
36+ const { totalPoints } = await getPoint ( { pathParams : { userId } } ) ;
37+ setPoint ( totalPoints ) ;
3138
3239 navigate ( paths . home . path ) ;
3340 } catch ( error ) {
@@ -37,7 +44,7 @@ const GoogleCallback = (): JSX.Element | null => {
3744 setIsLoading ( false ) ;
3845 }
3946 } ,
40- [ navigate , setTokens ]
47+ [ navigate , setTokens , setUserName , setPoint ]
4148 ) ;
4249
4350 useEffect ( ( ) => {
0 commit comments