Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️ refactor : Update Google Login page for client-side rendering #179

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/app/googleLogin/page.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
'use client';
import {useEffect} from 'react';
import Image from 'next/image';
import {useRouter, useSearchParams} from 'next/navigation';
import {useRouter} from 'next/navigation';
import Cookies from 'js-cookie';
import {useSetRecoilState} from 'recoil';
import userState from '@/src/recoil/atoms/userState';
import postGoogleLogin from '@/src/api/auth/postGoogleLogin';
import gifs from '@/public/gif';
import '@/src/styles/variable.css';

export const dynamic = 'force-dynamic'; // 이 페이지는 클라이언트 측에서만 렌더링됨

const Page = () => {
const code: string | null = useSearchParams().get('code');
const setUser = useSetRecoilState(userState);
const router = useRouter();

useEffect(() => {
const params = new URLSearchParams(window.location.search);
const code = params.get('code');

if (code) {
postGoogleLogin(code).then(res => {
if (res.user) {
Expand All @@ -26,7 +31,7 @@ const Page = () => {
router.push('/classes');
});
}
}, []);
}, [router, setUser]);

return (
<div className="absolute top-0 opacity-50 w-full h-[100vh] flex justify-center items-center bg-[#8c8c8c]">
Expand Down
Loading