-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.tsx
49 lines (47 loc) · 1.28 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
import React from 'react';
import NavBar from './components/NavBar/NavBar';
import {
BrowserRouter as Router,
Switch,
Route,
Redirect,
} from 'react-router-dom';
import FridgePage from './pages/FridgePage/FridgePage';
import RecipePage from './pages/RecipePage/RecipePage';
import LoginPage from './pages/LoginPage/LoginPage';
import SettingsPage from './pages/SettingsPage/SettingsPage';
import { UserContext } from './components/UserContext/UserContext';
import NewRecipe from './components/NewRecipe/NewRecipe';
function App() {
const { user } = React.useContext(UserContext);
return (
<Router>
{user === null ? (
<LoginPage />
) : (
<>
<NavBar />
<Switch>
<Route path="/" exact>
<Redirect to="/fridge" />
<FridgePage />
</Route>
<Route exact path="/fridge">
<FridgePage />
</Route>
<Route excact path="/settings">
<SettingsPage />
</Route>
<Route excact path="/newRecipe">
<NewRecipe />
</Route>
<Route excact path="/recipes">
<RecipePage />
</Route>
</Switch>
</>
)}
</Router>
);
}
export default App;