@@ -5,12 +5,13 @@ import { SWRConfig } from "swr";
5
5
6
6
import "./global.scss" ;
7
7
import "./app.scss" ;
8
+ import { Loading } from "./common/Icons" ;
9
+ import ErrorBoundary from "./common/ErrorBoundary/ErrorBoundary" ;
8
10
9
11
export function App ( ) {
10
12
const token = useToken ( ) ;
11
13
const tenant = useTenant ( token ?? undefined ) ;
12
14
useTheme ( ) ;
13
-
14
15
return (
15
16
< >
16
17
< div className = "layout" >
@@ -35,35 +36,40 @@ export function App() {
35
36
Back to { ORGANIZATION_NAME } { "->" }
36
37
</ a >
37
38
</ header >
38
- { /* TODO: Add loading state */ }
39
- { tenant ? (
40
- < SWRConfig
41
- value = { {
42
- fetcher : ( path : string ) =>
43
- fetch ( `http://localhost:3333/api/v1/${ tenant . id } /${ path } ` , {
44
- headers : {
45
- Authorization : `Bearer ${ token } ` ,
46
- } ,
47
- } ) . then ( ( res ) => res . json ( ) ) ,
48
- } }
49
- >
50
- < BrowserRouter
51
- future = { {
52
- v7_startTransition : true ,
53
- v7_relativeSplatPath : true ,
39
+ < ErrorBoundary >
40
+ { tenant ? (
41
+ < SWRConfig
42
+ value = { {
43
+ fetcher : ( path : string ) =>
44
+ fetch ( `http://localhost:3333/api/v1/${ tenant . id } /${ path } ` , {
45
+ headers : {
46
+ Authorization : `Bearer ${ token } ` ,
47
+ } ,
48
+ } ) . then ( ( res ) => res . json ( ) ) ,
54
49
} }
55
50
>
56
- < Routes >
57
- < Route path = "/" Component = { DestinationList } />
58
- < Route path = "/new" element = { < div > New Destination</ div > } />
59
- < Route
60
- path = "/destinations/:destination_id"
61
- element = { < div > Specific Destination</ div > }
62
- />
63
- </ Routes >
64
- </ BrowserRouter >
65
- </ SWRConfig >
66
- ) : null }
51
+ < BrowserRouter
52
+ future = { {
53
+ v7_startTransition : true ,
54
+ v7_relativeSplatPath : true ,
55
+ } }
56
+ >
57
+ < Routes >
58
+ < Route path = "/" Component = { DestinationList } />
59
+ < Route path = "/new" element = { < div > New Destination</ div > } />
60
+ < Route
61
+ path = "/destinations/:destination_id"
62
+ element = { < div > Specific Destination</ div > }
63
+ />
64
+ </ Routes >
65
+ </ BrowserRouter >
66
+ </ SWRConfig >
67
+ ) : (
68
+ < div className = "fullscreen-loading" >
69
+ < Loading />
70
+ </ div >
71
+ ) }
72
+ </ ErrorBoundary >
67
73
</ div >
68
74
< div className = "powered-by subtitle-s" >
69
75
Powered by{ " " }
@@ -157,7 +163,7 @@ function useTheme() {
157
163
useEffect ( ( ) => {
158
164
const searchParams = new URLSearchParams ( window . location . search ) ;
159
165
const queryTheme = searchParams . get ( "theme" ) ;
160
-
166
+
161
167
if ( queryTheme === "dark" || queryTheme === "light" ) {
162
168
// Save new theme preference
163
169
localStorage . setItem ( "theme" , queryTheme ) ;
0 commit comments