diff --git a/components/Loading.tsx b/components/Loading.tsx index 5082ec2..2325a73 100644 --- a/components/Loading.tsx +++ b/components/Loading.tsx @@ -1,11 +1,11 @@ -import { type ReactElement } from 'react'; +import type { ReactElement } from 'react'; export default function Loading(): ReactElement { return ( -
-
👀
+
+
👀
로딩중...💻
-
현재 API를 요청하고 있는 것 같네요...
+
현재 API를 요청하고 있는 것 같네요...
); } diff --git a/pages/_app.tsx b/pages/_app.tsx index 2277c8a..00e5f1d 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -2,12 +2,11 @@ import Loading from '@/components/Loading'; import Layout from '@/components/layout/Layout'; import { type AppProps } from 'next/app'; import Head from 'next/head'; -// import axios from 'axios'; import { Router } from 'next/router'; -import React, { type ReactElement, useEffect, useState } from 'react'; +import React, { useEffect, useState } from 'react'; +import type { ReactElement } from 'react'; import '../styles/globals.css'; -import Login from './login'; export default function MyApp({ Component, pageProps }: AppProps): ReactElement { // const router = useRouter(); @@ -34,28 +33,6 @@ export default function MyApp({ Component, pageProps }: AppProps): ReactElement // }; // }, []); - // useEffect(() => { - // const url = new URL(window.location.href); - - // const postData = async () => { - // const code = url.searchParams.get('code'); - // try { - // await axios - // .post('/api/auth/42login', null, { - // params: { code: code }, - // }) - // .then(() => setLoading(false)) - // .then(() => router.push('/')); - // } catch (error) { - // console.error(error); - // } - // }; - - // if (url.asPath === '/auth/callback') { - // void postData(); - // setLoading(true); - // } - // }); const login = false; return ( <> diff --git a/pages/login.tsx b/pages/login.tsx index 7b64ae2..79950aa 100644 --- a/pages/login.tsx +++ b/pages/login.tsx @@ -1,14 +1,8 @@ -import Btn from '@/components/common/Btn'; import Image from 'next/image'; import Link from 'next/link'; -import { useRouter } from 'next/router'; import type { ReactElement } from 'react'; export default function Login(): ReactElement { - const router = useRouter(); - const onSignIn = (): void => { - router.push('/'); - }; return (
@@ -31,7 +25,12 @@ export default function Login(): ReactElement { className='lg:animate-bounce' />
- + +

Sign in

+
42 Check - in
diff --git a/pages/oauth/login/index.tsx b/pages/oauth/login/index.tsx new file mode 100644 index 0000000..c938019 --- /dev/null +++ b/pages/oauth/login/index.tsx @@ -0,0 +1,23 @@ +import Loading from '@/components/Loading'; +import useCallApi from '@/utils/useCallApi'; +import { useRouter } from 'next/router'; +import { useEffect } from 'react'; +import type { ReactElement } from 'react'; + +export default function Login(): ReactElement { + const callApi = useCallApi(); + const router = useRouter(); + + useEffect(() => { + const fetchData = async (): Promise => { + const config = { + url: router.asPath, + }; + await callApi(config); + await router.push('/'); + }; + void fetchData(); + }, []); + + return ; +} diff --git a/styles/globals.css b/styles/globals.css index ab8d701..89ef3fb 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -10,6 +10,10 @@ div#__next > div { height: 100%; } +.button { + @apply rounded-[20px] bg-[#6A70FF] font-bold text-white hover:bg-[#6AA6FF]; +} + .category { @apply relative flex flex-col items-center justify-between rounded-3xl shadow-xl hover:scale-105; }