Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import "./App.css";
import { RouterProvider } from "react-router-dom";
import { Toaster } from "sonner";

import router from "./routes/routes";
import { router } from "@/routes/Router";

function App() {
return (
Expand Down
5 changes: 4 additions & 1 deletion src/layout/auth/AuthLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Suspense } from "react";
import { Outlet } from "react-router-dom";

import OnboardingIntro from "@/components/auth/common/OnboardingIntro";
Expand All @@ -11,7 +12,9 @@ export default function AuthLayout() {

<div className="flex w-full items-center justify-center bg-white 2xl:w-[65%]">
<div className="w-full max-w-md px-6">
<Outlet />
<Suspense fallback={<div>Loading...</div>}>
<Outlet />
</Suspense>
</div>
</div>
</div>
Expand Down
3 changes: 0 additions & 3 deletions src/layout/common/Layout.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Outlet } from "react-router-dom";

import ModalProvider from "@/components/modal/ModalProvider";

export default function RootLayout() {
export default function DefaultLayout() {
return (
<>
<Outlet />
Expand Down
12 changes: 12 additions & 0 deletions src/layout/main/MainLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Suspense } from "react";
import { Outlet } from "react-router-dom";

export default function MainLayout() {
return (
<div>
<Suspense fallback={<div>Loading...</div>}>
<Outlet />
</Suspense>
</div>
);
}
3 changes: 3 additions & 0 deletions src/pages/AdsCreatePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function AdsCreatePage() {
return <div>AdsCreatePage</div>;
}
3 changes: 3 additions & 0 deletions src/pages/ads/list/AdsListPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function AdsListPage() {
return <div>AdsListPage</div>;
}
3 changes: 0 additions & 3 deletions src/pages/ads/list/AdsManage.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions src/pages/ads/new/AdsCreate.tsx

This file was deleted.

28 changes: 28 additions & 0 deletions src/routes/AuthRoutes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { lazy } from "react";
import type { RouteObject } from "react-router-dom";

const FindEmail = lazy(() => import("@/pages/auth/FindEmail"));
const FindPw = lazy(() => import("@/pages/auth/FindPw"));
const Login = lazy(() => import("@/pages/auth/Login"));
const Signup = lazy(() => import("@/pages/auth/Signup"));

const AuthRoutes: RouteObject[] = [
{
path: "signup",
element: <Signup />,
},
{
path: "login",
element: <Login />,
},
{
path: "find-email",
element: <FindEmail />,
},
{
path: "find-pw",
element: <FindPw />,
},
];

export default AuthRoutes;
37 changes: 37 additions & 0 deletions src/routes/MainRoutes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { lazy } from "react";
import type { RouteObject } from "react-router-dom";

const OverviewDashboard = lazy(
() => import("@/pages/dashboard/overview/OverviewDashboard"),
);
const PlatformDashboard = lazy(
() => import("@/pages/dashboard/platform/PlatformDashboard"),
);
const Timeline = lazy(() => import("@/pages/dashboard/timeline/Timeline"));
const AdsListPage = lazy(() => import("@/pages/ads/list/AdsListPage"));
const AdsCreatePage = lazy(() => import("@/pages/AdsCreatePage"));

const MainRoutes: RouteObject[] = [
{
path: "/",
element: <OverviewDashboard />,
},
{
path: "platform",
element: <PlatformDashboard />,
},
{
path: "timeline",
element: <Timeline />,
},
{
path: "ads",
element: <AdsListPage />,
},
{
path: "ads/create",
element: <AdsCreatePage />,
},
];

export default MainRoutes;
41 changes: 41 additions & 0 deletions src/routes/Router.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from "react";
import { createBrowserRouter, Navigate } from "react-router-dom";

import AuthRoutes from "./AuthRoutes";
import MainRoutes from "./MainRoutes";
import UserRoutes from "./UserRoutes";

import AuthLayout from "@/layout/auth/AuthLayout";
import DefaultLayout from "@/layout/default/DefaultLayout";
import MainLayout from "@/layout/main/MainLayout";

function AuthGuard({ children }: { children: React.ReactNode }) {
// 실제 인증 상태 확인 로직으로 대체 예정
const isAuthenticated = false;

if (!isAuthenticated) {
return <Navigate to="/signup" replace />;
}

return <>{children}</>;
}

export const router = createBrowserRouter([
{
element: <DefaultLayout />,
children: [
{
element: <AuthLayout />,
children: AuthRoutes,
},
{
element: (
<AuthGuard>
<MainLayout />
</AuthGuard>
),
children: [...MainRoutes, ...UserRoutes],
},
],
},
]);
18 changes: 18 additions & 0 deletions src/routes/UserRoutes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { lazy } from "react";
import type { RouteObject } from "react-router-dom";

const Setting = lazy(() => import("@/pages/setting/Setting"));
const Workspace = lazy(() => import("@/pages/workspace/Workspace"));

const UserRoutes: RouteObject[] = [
{
path: "setting",
element: <Setting />,
},
{
path: "workspace",
element: <Workspace />,
},
];

export default UserRoutes;
132 changes: 0 additions & 132 deletions src/routes/routes.tsx

This file was deleted.