From 266f07ca8153c2e2a29f43f42afaec2df0b6c960 Mon Sep 17 00:00:00 2001 From: seung365 Date: Wed, 7 Aug 2024 16:57:43 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20authpage=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Login/AuthPage.tsx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/pages/Login/AuthPage.tsx diff --git a/src/pages/Login/AuthPage.tsx b/src/pages/Login/AuthPage.tsx new file mode 100644 index 0000000..0124f2f --- /dev/null +++ b/src/pages/Login/AuthPage.tsx @@ -0,0 +1,23 @@ +import React, { useEffect } from 'react'; +import { useLocation, useNavigate } from 'react-router-dom'; +import { useGetLogin } from '@/api/hooks/useGetLogin'; +import { RouterPath } from '@/routes/path'; + +export const AuthPage = () => { + const location = useLocation(); + const navigate = useNavigate(); + + const query = new URLSearchParams(location.search); + const code = query.get('code'); + + const { data, error, isLoading } = useGetLogin({ code: code || '' }); + + useEffect(() => { + if (data && !error) { + sessionStorage.setItem('authToken', data.accessToken); + navigate(RouterPath.home); + } + }, [data, error, navigate]); + + return
{isLoading ?

Logging in...

: error ?

Login failed!

: null}
; +};