-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.tsx
78 lines (65 loc) · 2.2 KB
/
App.tsx
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import "./env";
import React, { Suspense } from "react";
import { FirebaseAppProvider, AuthCheck } from "reactfire";
import { IonApp, IonRouterOutlet, IonLoading } from "@ionic/react";
import { Route, Redirect } from "react-router-dom";
import { IonReactRouter } from "@ionic/react-router";
/* Core CSS required for Ionic components to work properly */
import "@ionic/react/css/core.css";
/* Basic CSS for apps built with Ionic */
import "@ionic/react/css/normalize.css";
import "@ionic/react/css/structure.css";
import "@ionic/react/css/typography.css";
/* Optional CSS utils that can be commented out */
import "@ionic/react/css/padding.css";
import "@ionic/react/css/float-elements.css";
import "@ionic/react/css/text-alignment.css";
import "@ionic/react/css/text-transformation.css";
import "@ionic/react/css/flex-utils.css";
import "@ionic/react/css/display.css";
import { FIREBASE_CONFIG } from "./env";
import Login from "./pages/Login";
import Home from "./pages/Home";
import { Plugins } from "@capacitor/core";
import CreateAccount from "./pages/CreateAccount";
import { DataProvider } from "./DataContext";
const { SplashScreen } = Plugins;
// Hide the splash (you should do this on app launch)
SplashScreen.hide();
const PublicRoutes: React.FunctionComponent = () => {
return (
<IonRouterOutlet>
<Route exact path="/login" component={Login} />
<Route exact path="/create-account" component={CreateAccount} />
<Redirect exact path="/" to="/login" />
</IonRouterOutlet>
);
};
const PrivateRoutes: React.FunctionComponent = () => {
return (
<IonRouterOutlet>
<Route exact path="/home">
<DataProvider>
<Home />
</DataProvider>
</Route>
<Redirect exact path="/" to="/home" />
</IonRouterOutlet>
);
};
const App: React.FunctionComponent = () => {
return (
<FirebaseAppProvider firebaseConfig={FIREBASE_CONFIG}>
<IonApp>
<IonReactRouter>
<Suspense fallback={<IonLoading isOpen={true} />}>
<AuthCheck fallback={<PublicRoutes />}>
<PrivateRoutes />
</AuthCheck>
</Suspense>
</IonReactRouter>
</IonApp>
</FirebaseAppProvider>
);
};
export default App;