MainRouter.tsx 2.2 KB
Newer Older
Yoon, Daeki's avatar
Yoon, Daeki committed
1
2
import React from "react";
import { BrowserRouter, Route, Routes } from "react-router-dom";
3
import { Login, SignUp, RequireAuth } from "./auth";
Yoon, Daeki's avatar
Yoon, Daeki committed
4
5
6
7
8
import { NotFound } from "./commons";
import {
  CreateSurvey,
  EditSurvey,
  AnswerSurvey,
9
  ResultSurvey,
Yoon, Daeki's avatar
Yoon, Daeki committed
10
11
  SurveysList,
  AnswerPreview,
Yoon, Daeki's avatar
Yoon, Daeki committed
12
} from "./surveys";
13
14
15
import {
  AnswerLayout,
  BaseLayout,
Yoon, Daeki's avatar
Yoon, Daeki committed
16
17
  SurveyLayout,
  SurveysLayout,
18
  ResultLayout,
Jiwon Yoon's avatar
Jiwon Yoon committed
19
  AdminLayout,
20
} from "./layouts";
Yoon, Daeki's avatar
Yoon, Daeki committed
21
import { Home } from "./home";
22
23
import { OAuthRedirectHandler } from "./auth/OAuthRedirectHandler";
import { LoginSuccess } from "./commons/LoginSuccess";
Jiwon Yoon's avatar
Jiwon Yoon committed
24
import { Admin, SocialLogin } from "./admin";
Yoon, Daeki's avatar
Yoon, Daeki committed
25
26
27
28
29
30
31
32

export const MainRouter = () => {
  return (
    <BrowserRouter>
      <Routes>
        <Route element={<BaseLayout />}>
          <Route path="/" element={<Home />}></Route>
          <Route path="/login" element={<Login />} />
33
34
          <Route path="/login/success" element={<LoginSuccess />} />
          <Route path="/oauth/kakao" element={<OAuthRedirectHandler />} />
Yoon, Daeki's avatar
Yoon, Daeki committed
35
          <Route path="/signup" element={<SignUp />} />
36
37
38
39
          <Route element={<ResultLayout />}>
            <Route path="/results/:surveyId" element={<ResultSurvey />} />
          </Route>

Jiwon Yoon's avatar
Jiwon Yoon committed
40
41
42
43
44
          <Route element={<AdminLayout />}>
            <Route path="/admin" element={<Admin />}></Route>
            <Route path="/admin/social-login" element={<SocialLogin />}></Route>
          </Route>

Yoon, Daeki's avatar
Yoon, Daeki committed
45
46
47
48
49
50
51
          <Route element={<AnswerLayout />}>
            <Route path="/answers/:surveyId" element={<AnswerSurvey />} />
          </Route>
          <Route
            path="/surveys"
            element={
              <RequireAuth>
Yoon, Daeki's avatar
Yoon, Daeki committed
52
                <SurveysLayout />
Yoon, Daeki's avatar
Yoon, Daeki committed
53
54
55
              </RequireAuth>
            }
          >
Yoon, Daeki's avatar
Yoon, Daeki committed
56
            <Route index element={<SurveysList />} />
Yoon, Daeki's avatar
Yoon, Daeki committed
57
            <Route path="create" element={<CreateSurvey />} />
Yoon, Daeki's avatar
Yoon, Daeki committed
58
59
60
61
62
            <Route path=":surveyId" element={<SurveyLayout />}>
              <Route index element={<AnswerPreview />} />
              <Route path="edit" element={<EditSurvey />} />
              <Route path="result" element={<ResultSurvey />} />
            </Route>
Yoon, Daeki's avatar
Yoon, Daeki committed
63
64
65
66
67
68
69
          </Route>
          <Route path="*" element={<NotFound />} />
        </Route>
      </Routes>
    </BrowserRouter>
  );
};