MainRouter.tsx 1.93 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
19
  ResultLayout,
} from "./layouts";
Yoon, Daeki's avatar
Yoon, Daeki committed
20
import { Home } from "./home";
21
22
import { OAuthRedirectHandler } from "./auth/OAuthRedirectHandler";
import { LoginSuccess } from "./commons/LoginSuccess";
Yoon, Daeki's avatar
Yoon, Daeki committed
23
24
25
26
27
28
29
30

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

Yoon, Daeki's avatar
Yoon, Daeki committed
38
39
40
41
42
43
44
          <Route element={<AnswerLayout />}>
            <Route path="/answers/:surveyId" element={<AnswerSurvey />} />
          </Route>
          <Route
            path="/surveys"
            element={
              <RequireAuth>
Yoon, Daeki's avatar
Yoon, Daeki committed
45
                <SurveysLayout />
Yoon, Daeki's avatar
Yoon, Daeki committed
46
47
48
              </RequireAuth>
            }
          >
Yoon, Daeki's avatar
Yoon, Daeki committed
49
            <Route index element={<SurveysList />} />
Yoon, Daeki's avatar
Yoon, Daeki committed
50
            <Route path="create" element={<CreateSurvey />} />
Yoon, Daeki's avatar
Yoon, Daeki committed
51
52
53
54
55
            <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
56
57
58
59
60
61
62
          </Route>
          <Route path="*" element={<NotFound />} />
        </Route>
      </Routes>
    </BrowserRouter>
  );
};