diff --git a/src/app/routes/components/index.ts b/src/app/routes/components/index.ts
index e69de29b..4acbc303 100644
--- a/src/app/routes/components/index.ts
+++ b/src/app/routes/components/index.ts
@@ -0,0 +1 @@
+export * from './protected-route';
diff --git a/src/app/routes/components/protected-route/ProtectedRoute.tsx b/src/app/routes/components/protected-route/ProtectedRoute.tsx
new file mode 100644
index 00000000..caebc46b
--- /dev/null
+++ b/src/app/routes/components/protected-route/ProtectedRoute.tsx
@@ -0,0 +1,37 @@
+import { Navigate, Outlet } from 'react-router-dom';
+
+import { RouterPath } from '../../path';
+
+type Props = {
+ requiresAuth?: boolean;
+ sinittoOnly?: boolean;
+ guardOnly?: boolean;
+};
+
+const ProtectedRoute = ({ requiresAuth, sinittoOnly, guardOnly }: Props) => {
+ const accessToken = localStorage.getItem('accessToken');
+ const isSinitto = localStorage.getItem('isSinitto') === 'true';
+
+ if (requiresAuth && !accessToken) {
+ return ;
+ }
+ if (accessToken) {
+ if (sinittoOnly && !isSinitto) {
+ return ;
+ }
+ if (guardOnly && isSinitto) {
+ return ;
+ }
+ if (!requiresAuth) {
+ return isSinitto ? (
+
+ ) : (
+
+ );
+ }
+ }
+
+ return ;
+};
+
+export default ProtectedRoute;
diff --git a/src/app/routes/components/protected-route/index.ts b/src/app/routes/components/protected-route/index.ts
new file mode 100644
index 00000000..4de35d06
--- /dev/null
+++ b/src/app/routes/components/protected-route/index.ts
@@ -0,0 +1 @@
+export { default as ProtectedRoute } from './ProtectedRoute';
diff --git a/src/app/routes/path.ts b/src/app/routes/path.ts
index 260efe46..51330b3d 100644
--- a/src/app/routes/path.ts
+++ b/src/app/routes/path.ts
@@ -1,9 +1,9 @@
export const RouterPath = {
ROOT: '/',
- LOGIN: '/login',
- SIGNUP: '/signup',
- REGISTER: '/register',
- REDIRECT: '/redirection',
+ LOGIN: 'login',
+ SIGNUP: 'signup',
+ REGISTER: 'register',
+ REDIRECT: 'redirection',
GUARD: '/guard',
MYPAGE: `mypage`,
GUARD_GUIDELINE: `:seniorId/:guidelineType`,
@@ -16,7 +16,7 @@ export const RouterPath = {
CALL_BACK_LIST: `call-back`,
CALL_BACK_DETAIL: `:callBackId`,
CALL_BACK_GUID_LINE: `:guideLineId`,
- SENIOR_REGISTER: `/senior-register`,
+ SENIOR_REGISTER: `senior-register`,
SINITTO_REVIEW: `review`,
DUMMY_LOGIN: `/dummy`,
diff --git a/src/app/routes/router.tsx b/src/app/routes/router.tsx
index a11600a4..76b4dc3d 100644
--- a/src/app/routes/router.tsx
+++ b/src/app/routes/router.tsx
@@ -1,5 +1,6 @@
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
+import { ProtectedRoute } from './components';
import { RouterPath } from './path';
import {
MainPage,
@@ -27,39 +28,41 @@ import { Layout } from '@/shared/components';
export const router = createBrowserRouter([
{
path: RouterPath.ROOT,
- element: ,
- },
- {
- path: RouterPath.SIGNUP,
- element: ,
+ element: ,
children: [
{
- index: true,
- element: ,
+ path: '',
+ children: [
+ {
+ index: true,
+ element: ,
+ },
+ ],
},
- ],
- },
- {
- path: RouterPath.REDIRECT,
- children: [
{
- index: true,
- element: ,
+ path: RouterPath.SIGNUP,
+ element: ,
+ children: [
+ {
+ index: true,
+ element: ,
+ },
+ ],
},
- ],
- },
- {
- path: RouterPath.DUMMY_LOGIN,
- element: ,
- children: [
{
- index: true,
- element: ,
+ path: RouterPath.REDIRECT,
+ children: [
+ {
+ index: true,
+ element: ,
+ },
+ ],
},
],
},
{
path: RouterPath.GUARD,
+ element: ,
children: [
{
path: '',
@@ -125,10 +128,36 @@ export const router = createBrowserRouter([
},
],
},
+ {
+ path: RouterPath.SENIOR_REGISTER,
+ element: ,
+ children: [
+ {
+ index: true,
+ element: ,
+ },
+ ],
+ },
+ {
+ path: RouterPath.CALL_BACK_LIST,
+ children: [
+ {
+ path: RouterPath.SINITTO_REVIEW,
+ element: ,
+ children: [
+ {
+ index: true,
+ element: ,
+ },
+ ],
+ },
+ ],
+ },
],
},
{
path: RouterPath.SINITTO,
+ element: ,
children: [
{
index: true,
@@ -182,16 +211,6 @@ export const router = createBrowserRouter([
},
],
},
- {
- path: RouterPath.SINITTO_REVIEW,
- element: ,
- children: [
- {
- index: true,
- element: ,
- },
- ],
- },
],
},
@@ -199,7 +218,10 @@ export const router = createBrowserRouter([
path: RouterPath.HELLO_CALL,
element: ,
children: [
- { index: true, element: },
+ {
+ index: true,
+ element: ,
+ },
{
path: RouterPath.HELLO_CALL_SERVICE,
element: ,
@@ -214,12 +236,12 @@ export const router = createBrowserRouter([
],
},
{
- path: RouterPath.SENIOR_REGISTER,
- element: ,
+ path: RouterPath.DUMMY_LOGIN,
+ element: ,
children: [
{
index: true,
- element: ,
+ element: ,
},
],
},