From c580e6a5c57c55f59d7c085c7a3a5da24c212f5a Mon Sep 17 00:00:00 2001 From: Hojin Date: Fri, 5 Jan 2024 17:49:44 +0900 Subject: [PATCH] =?UTF-8?q?Refator:=20=EB=9D=BC=EC=9A=B0=ED=84=B0=EA=B5=AC?= =?UTF-8?q?=EC=A1=B0=20=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 2 +- src/App.tsx | 2 ++ src/router/authRouter.tsx | 25 +++++++++++++++++++++++++ src/router/mainRouter.tsx | 28 ++-------------------------- src/router/routerLayout.tsx | 24 ++++++++++++++++++++++++ 5 files changed, 54 insertions(+), 27 deletions(-) create mode 100644 src/router/authRouter.tsx create mode 100644 src/router/routerLayout.tsx diff --git a/index.html b/index.html index ebf673eb..a13e0b4f 100644 --- a/index.html +++ b/index.html @@ -5,7 +5,7 @@ - 위플플 | 여정 공유 서비스 + 위플플 | 여정 공유 플랫폼 diff --git a/src/App.tsx b/src/App.tsx index bfa01682..d69b84b5 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -6,6 +6,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import { BrowserRouter } from 'react-router-dom'; import MainRouter from '@router/mainRouter'; +import AuthRouter from '@router/authRouter'; const queryClient = new QueryClient(); @@ -17,6 +18,7 @@ const App = () => { + diff --git a/src/router/authRouter.tsx b/src/router/authRouter.tsx new file mode 100644 index 00000000..ba252952 --- /dev/null +++ b/src/router/authRouter.tsx @@ -0,0 +1,25 @@ +import { Route, Routes } from 'react-router-dom'; +import { useLocation } from 'react-router-dom'; +import { useEffect } from 'react'; +import Signup from '@pages/signup/signup.page'; +import Signin from '@pages/signin/signin.page'; +import MainLayout from './routerLayout'; + +const AuthRouter = () => { + const location = useLocation(); + + useEffect(() => { + window.scrollTo(0, 0); + }, [location]); + + return ( + + }> + } /> + } /> + + + ); +}; + +export default AuthRouter; diff --git a/src/router/mainRouter.tsx b/src/router/mainRouter.tsx index a1f594eb..9a636293 100644 --- a/src/router/mainRouter.tsx +++ b/src/router/mainRouter.tsx @@ -1,33 +1,11 @@ -import { Outlet, Route, Routes } from 'react-router-dom'; -import { Header } from '@components/common/header'; -import { Nav } from '@components/common/nav'; +import { Route, Routes, useLocation } from 'react-router-dom'; import Main from '@pages/main/main.page'; import { Search } from '@pages/search/search.page'; import Detail from '@pages/detail/detail.page'; import ReviewPosting from '@pages/reviewPosting/reviewPosting.page'; import ReviewComment from '@pages/reviewComment/reviewComment.page'; -import { useLocation } from 'react-router-dom'; import { useEffect } from 'react'; -import Signup from '@pages/signup/signup.page'; -import Signin from '@pages/signin/signin.page'; - -export function MainLayout() { - const location = useLocation(); - const hideNavPaths = ['/signup', '/signin']; - const showNav = !hideNavPaths.some((path) => - location.pathname.includes(path), - ); - - return ( -
-
-
- -
- {showNav &&
- ); -} +import MainLayout from './routerLayout'; const MainRouter = () => { const location = useLocation(); @@ -45,8 +23,6 @@ const MainRouter = () => { } /> } /> } /> - } /> - } /> diff --git a/src/router/routerLayout.tsx b/src/router/routerLayout.tsx new file mode 100644 index 00000000..5825698b --- /dev/null +++ b/src/router/routerLayout.tsx @@ -0,0 +1,24 @@ +import { Outlet } from 'react-router-dom'; +import { Header } from '@components/common/header'; +import { Nav } from '@components/common/nav'; +import { useLocation } from 'react-router-dom'; + +const MainLayout = () => { + const location = useLocation(); + const hideNavPaths = ['/signup', '/signin']; + const showNav = !hideNavPaths.some((path) => + location.pathname.includes(path), + ); + + return ( +
+
+
+ +
+ {showNav &&
+ ); +}; + +export default MainLayout;