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;