Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FE] router 리팩터링 #806

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions frontend/src/router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CategoryProvider from '@/contexts/CategoryContext';
import NotFoundPage from '@/pages/NotFoundPage';

const router = createBrowserRouter([
/** 로그인이 안되었다면 로그인 페이지로 리다이렉트 */
{
path: '/',
element: (
Expand Down Expand Up @@ -53,6 +54,28 @@ const router = createBrowserRouter([
},
],
},
/** 로그인이 안되었다면 로그인 페이지로 리다이렉트하면서 헤더만 있는 레이아웃 */
{
path: '/',
element: (
<AuthLayout>
<App layout="headerOnly" />
</AuthLayout>
),
errorElement: <Navigate to={PATH.LOGIN} replace />,
children: [
{
path: `${PATH.RECIPE}/:recipeId`,
async lazy() {
const { RecipeDetailPage } = await import(
/* webpackChunkName: "RecipeDetailPage" */ '@/pages/RecipeDetailPage'
);
return { Component: RecipeDetailPage };
},
},
],
},
/** 헤더와 네비게이션 바가 있는 기본 레이아웃 */
Comment on lines +57 to +78
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

{
path: '/',
element: (
Expand Down Expand Up @@ -80,6 +103,7 @@ const router = createBrowserRouter([
},
],
},
/** 헤더, 네비게이션 모두 없는 레이아웃 */
{
path: '/',
element: <App layout="minimal" />,
Expand All @@ -101,6 +125,7 @@ const router = createBrowserRouter([
},
],
},
/** 네비게이션 바 없이 헤더만 있는 레이아웃 */
{
path: '/',
element: (
Expand All @@ -119,17 +144,9 @@ const router = createBrowserRouter([
return { Component: ProductDetailPage };
},
},
{
path: `${PATH.RECIPE}/:recipeId`,
async lazy() {
const { RecipeDetailPage } = await import(
/* webpackChunkName: "RecipeDetailPage" */ '@/pages/RecipeDetailPage'
);
return { Component: RecipeDetailPage };
},
},
],
},
/** 네비게이션과 헤더(검색 아이콘이 없는)가 있는 레이아웃 */
{
path: '/',
element: (
Expand Down
Loading