@@ -3,107 +3,39 @@ import CssBaseline from "@material-ui/core/CssBaseline"
3
3
import ThemeProvider from "@material-ui/styles/ThemeProvider"
4
4
import { SWRConfig } from "swr"
5
5
import { light } from "./theme"
6
- import { Route , Routes } from "react-router-dom"
6
+ import { BrowserRouter as Router } from "react-router-dom"
7
7
8
- import { CliAuthenticationPage } from "./pages/cli-auth"
9
- import { NotFoundPage } from "./pages/404"
10
- import { IndexPage } from "./pages/index"
11
- import { SignInPage } from "./pages/login"
12
- import { ProjectsPage } from "./pages/projects"
13
- import { ProjectPage } from "./pages/projects/[organization]/[project]"
14
- import { CreateWorkspacePage } from "./pages/projects/[organization]/[project]/create"
15
- import { WorkspacePage } from "./pages/workspaces/[workspace]"
16
- import { HealthzPage } from "./pages/healthz"
17
- import { AuthAndNav , RequireAuth } from "./components/Page"
18
8
import { XServiceProvider } from "./xServices/StateContext"
9
+ import { AppRouter } from "./AppRouter"
19
10
20
11
export const App : React . FC = ( ) => {
21
12
return (
22
- < SWRConfig
23
- value = { {
24
- // This code came from the SWR documentation:
25
- // https://swr.vercel.app/docs/error-handling#status-code-and-error-object
26
- fetcher : async ( url : string ) => {
27
- const res = await fetch ( url )
28
-
29
- // By default, `fetch` won't treat 4xx or 5xx response as errors.
30
- // However, we want SWR to treat these as errors - so if `res.ok` is false,
31
- // we want to throw an error to bubble that up to SWR.
32
- if ( ! res . ok ) {
33
- const err = new Error ( ( await res . json ( ) ) . error ?. message || res . statusText )
34
- throw err
35
- }
36
- return res . json ( )
37
- } ,
38
- } }
39
- >
40
- < XServiceProvider >
41
- < ThemeProvider theme = { light } >
42
- < CssBaseline />
43
-
44
- < Routes >
45
- < Route path = "/" >
46
- < Route
47
- index
48
- element = {
49
- < RequireAuth >
50
- < IndexPage />
51
- </ RequireAuth >
52
- }
53
- />
54
-
55
- < Route path = "login" element = { < SignInPage /> } />
56
- < Route path = "healthz" element = { < HealthzPage /> } />
57
- < Route path = "cli-auth" element = { < CliAuthenticationPage /> } />
58
-
59
- < Route path = "projects" >
60
- < Route
61
- index
62
- element = {
63
- < AuthAndNav >
64
- < ProjectsPage />
65
- </ AuthAndNav >
66
- }
67
- />
68
- < Route path = ":organization/:project" >
69
- < Route
70
- index
71
- element = {
72
- < AuthAndNav >
73
- < ProjectPage />
74
- </ AuthAndNav >
75
- }
76
- />
77
- < Route
78
- path = "create"
79
- element = {
80
- < RequireAuth >
81
- < CreateWorkspacePage />
82
- </ RequireAuth >
83
- }
84
- />
85
- </ Route >
86
- </ Route >
87
-
88
- < Route path = "workspaces" >
89
- < Route
90
- path = ":workspace"
91
- element = {
92
- < AuthAndNav >
93
- < WorkspacePage />
94
- </ AuthAndNav >
95
- }
96
- />
97
- </ Route >
98
-
99
- { /* Using path="*"" means "match anything", so this route
100
- acts like a catch-all for URLs that we don't have explicit
101
- routes for. */ }
102
- < Route path = "*" element = { < NotFoundPage /> } />
103
- </ Route >
104
- </ Routes >
105
- </ ThemeProvider >
106
- </ XServiceProvider >
107
- </ SWRConfig >
13
+ < Router >
14
+ < SWRConfig
15
+ value = { {
16
+ // This code came from the SWR documentation:
17
+ // https://swr.vercel.app/docs/error-handling#status-code-and-error-object
18
+ fetcher : async ( url : string ) => {
19
+ const res = await fetch ( url )
20
+
21
+ // By default, `fetch` won't treat 4xx or 5xx response as errors.
22
+ // However, we want SWR to treat these as errors - so if `res.ok` is false,
23
+ // we want to throw an error to bubble that up to SWR.
24
+ if ( ! res . ok ) {
25
+ const err = new Error ( ( await res . json ( ) ) . error ?. message || res . statusText )
26
+ throw err
27
+ }
28
+ return res . json ( )
29
+ } ,
30
+ } }
31
+ >
32
+ < XServiceProvider >
33
+ < ThemeProvider theme = { light } >
34
+ < CssBaseline />
35
+ < AppRouter />
36
+ </ ThemeProvider >
37
+ </ XServiceProvider >
38
+ </ SWRConfig >
39
+ </ Router >
108
40
)
109
41
}
0 commit comments