Skip to content

Commit

Permalink
feat: authpage 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
seung365 committed Aug 7, 2024
1 parent 1485258 commit 266f07c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/pages/Login/AuthPage.tsx
Original file line number Diff line number Diff line change
@@ -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 <div>{isLoading ? <h1>Logging in...</h1> : error ? <h1>Login failed!</h1> : null}</div>;
};

0 comments on commit 266f07c

Please sign in to comment.