MainRouter.tsx 1.51 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
9
10
import { NotFound } from "./commons";
import {
  Profile,
  CreateSurvey,
  Preview,
  EditSurvey,
  AnswerSurvey,
11
  ResultSurvey,
Yoon, Daeki's avatar
Yoon, Daeki committed
12
} from "./surveys";
13
14
15
16
17
18
import {
  AnswerLayout,
  BaseLayout,
  ModifyLayout,
  ResultLayout,
} from "./layouts";
Yoon, Daeki's avatar
Yoon, Daeki committed
19
20
21
22
23
24
25
26
27
28
import { Home } from "./home";

export const MainRouter = () => {
  return (
    <BrowserRouter>
      <Routes>
        <Route element={<BaseLayout />}>
          <Route path="/" element={<Home />}></Route>
          <Route path="/login" element={<Login />} />
          <Route path="/signup" element={<SignUp />} />
29
30
31
32
          <Route element={<ResultLayout />}>
            <Route path="/results/:surveyId" element={<ResultSurvey />} />
          </Route>

Yoon, Daeki's avatar
Yoon, Daeki committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
          <Route element={<AnswerLayout />}>
            <Route path="/answers/:surveyId" element={<AnswerSurvey />} />
          </Route>
          <Route
            path="/surveys"
            element={
              <RequireAuth>
                <ModifyLayout />
              </RequireAuth>
            }
          >
            <Route path="create" element={<CreateSurvey />} />
            <Route path="profile" element={<Profile />} />
            <Route path=":surveyId" element={<Preview />} />
            <Route path=":surveyId/edit" element={<EditSurvey />} />
          </Route>
          <Route path="*" element={<NotFound />} />
        </Route>
      </Routes>
    </BrowserRouter>
  );
};