aboutsummaryrefslogtreecommitdiffhomepage
path: root/frontend/app/App.tsx
blob: 2b095ab7d4dbaa35efed37cce9fa7d11171d5980 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { Route, Router, Switch } from "wouter";
import ProtectedRoute from "./components/ProtectedRoute";
import PublicOnlyRoute from "./components/PublicOnlyRoute";
import { BASE_PATH } from "./config";
import DashboardPage from "./pages/DashboardPage";
import GolfPlayPage from "./pages/GolfPlayPage";
import GolfProblemPreviewPage from "./pages/GolfProblemPreviewPage";
import GolfWatchPage from "./pages/GolfWatchPage";
import IndexPage from "./pages/IndexPage";
import LoginPage from "./pages/LoginPage";
import TournamentPage from "./pages/TournamentPage";

export default function App() {
  return (
    <Router base={BASE_PATH.replace(/\/$/, "")}>
      <Switch>
        <Route path="/">
          <PublicOnlyRoute>
            <IndexPage />
          </PublicOnlyRoute>
        </Route>
        <Route path="/login">
          <PublicOnlyRoute>
            <LoginPage />
          </PublicOnlyRoute>
        </Route>
        <Route path="/dashboard">
          <DashboardPage />
        </Route>
        <Route path="/golf/:gameId/preview">
          {(params) => (
            <ProtectedRoute>
              <GolfProblemPreviewPage gameId={params.gameId} />
            </ProtectedRoute>
          )}
        </Route>
        <Route path="/golf/:gameId/play">
          {(params) => (
            <ProtectedRoute>
              <GolfPlayPage gameId={params.gameId} />
            </ProtectedRoute>
          )}
        </Route>
        <Route path="/golf/:gameId/watch">
          {(params) => <GolfWatchPage gameId={params.gameId} />}
        </Route>
        <Route path="/tournament/:tournamentId">
          {(params) => <TournamentPage tournamentId={params.tournamentId} />}
        </Route>
        <Route>
          <div className="min-h-screen bg-gray-100 flex items-center justify-center">
            <p className="text-gray-500 text-xl">404 - Page not found</p>
          </div>
        </Route>
      </Switch>
    </Router>
  );
}