이미 사용자 계정이 있다면?
로그인하기
diff --git a/src/routes/AuthRoutes.tsx b/src/routes/AuthRoutes.tsx
new file mode 100644
index 0000000..09aa70d
--- /dev/null
+++ b/src/routes/AuthRoutes.tsx
@@ -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:
,
+ },
+ {
+ path: "login",
+ element:
,
+ },
+ {
+ path: "find-email",
+ element:
,
+ },
+ {
+ path: "find-pw",
+ element:
,
+ },
+];
+
+export default AuthRoutes;
diff --git a/src/routes/MainRoutes.tsx b/src/routes/MainRoutes.tsx
new file mode 100644
index 0000000..3a6be26
--- /dev/null
+++ b/src/routes/MainRoutes.tsx
@@ -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/ads/new/AdsCreatePage"));
+
+const MainRoutes: RouteObject[] = [
+ {
+ path: "/",
+ element:
,
+ },
+ {
+ path: "platform",
+ element:
,
+ },
+ {
+ path: "timeline",
+ element:
,
+ },
+ {
+ path: "ads",
+ element:
,
+ },
+ {
+ path: "ads/create",
+ element:
,
+ },
+];
+
+export default MainRoutes;
diff --git a/src/routes/Router.tsx b/src/routes/Router.tsx
new file mode 100644
index 0000000..183b68e
--- /dev/null
+++ b/src/routes/Router.tsx
@@ -0,0 +1,43 @@
+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";
+import Error from "@/pages/common/Error";
+
+function AuthGuard({ children }: { children: React.ReactNode }) {
+ // 실제 인증 상태 확인 로직으로 대체 예정
+ const isAuthenticated = false;
+
+ if (!isAuthenticated) {
+ return
;
+ }
+
+ return <>{children}>;
+}
+
+export const router = createBrowserRouter([
+ {
+ element:
,
+ errorElement:
,
+ children: [
+ {
+ element:
,
+ children: AuthRoutes,
+ },
+ {
+ element: (
+
+
+
+ ),
+ children: [...MainRoutes, ...UserRoutes],
+ },
+ ],
+ },
+]);
diff --git a/src/routes/UserRoutes.tsx b/src/routes/UserRoutes.tsx
new file mode 100644
index 0000000..4677d83
--- /dev/null
+++ b/src/routes/UserRoutes.tsx
@@ -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:
,
+ },
+ {
+ path: "workspace",
+ element:
,
+ },
+];
+
+export default UserRoutes;
diff --git a/src/routes/routes.tsx b/src/routes/routes.tsx
deleted file mode 100644
index b957f29..0000000
--- a/src/routes/routes.tsx
+++ /dev/null
@@ -1,132 +0,0 @@
-import type { PropsWithChildren } from "react";
-import { createBrowserRouter, Navigate } from "react-router-dom";
-
-import AuthLayout from "@/layout/auth/AuthLayout";
-import Layout from "@/layout/common/Layout";
-import RootLayout from "@/layout/common/RootLayout";
-import FindEmail from "@/pages/auth/FindEmail";
-import FindPw from "@/pages/auth/FindPw";
-import Login from "@/pages/auth/Login";
-import Signup from "@/pages/auth/Signup";
-import Error from "@/pages/common/Error";
-import OverviewDashboard from "@/pages/dashboard/overview/OverviewDashboard";
-import PlatformDashboard from "@/pages/dashboard/platform/PlatformDashboard";
-import Timeline from "@/pages/dashboard/timeline/Timeline";
-import Setting from "@/pages/setting/Setting";
-import Workspace from "@/pages/workspace/Workspace";
-
-const checkAuth = (): boolean => {
- // 실제 인증 로직으로 교체 필요합니다.
- return false;
-};
-
-function ProtectedRoute({ children }: PropsWithChildren) {
- const isLoggedIn = checkAuth();
-
- if (!isLoggedIn) {
- return
;
- }
-
- return <>{children}>;
-}
-
-function PublicRoute({ children }: PropsWithChildren) {
- const isLoggedIn = checkAuth();
-
- if (isLoggedIn) {
- return
;
- }
-
- return <>{children}>;
-}
-
-const router = createBrowserRouter([
- {
- element:
,
- children: [
- {
- path: "/",
- element:
,
- },
- {
- path: "/auth",
- element: (
-
-
-
- ),
- errorElement:
,
- children: [
- {
- index: true,
- element:
,
- },
- {
- path: "signup",
- element:
,
- },
- {
- path: "login",
- element:
,
- },
- {
- path: "find-email",
- element:
,
- },
- {
- path: "find-pw",
- element:
,
- },
- ],
- },
- {
- path: "/dashboard",
- element: (
-
-
-
- ),
- errorElement:
,
- children: [
- {
- index: true,
- element:
,
- },
- {
- path: "overview",
- element:
,
- },
- {
- path: "timeline",
- element:
,
- },
- {
- path: "platform",
- element:
,
- },
- ],
- },
- {
- path: "/user",
- element: (
-
-
-
- ),
- errorElement:
,
- children: [
- {
- path: "setting",
- element:
,
- },
- {
- path: "workspace",
- element:
,
- },
- ],
- },
- ],
- },
-]);
-
-export default router;