This repository was archived by the owner on Jun 30, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathApp.tsx
More file actions
58 lines (51 loc) · 1.76 KB
/
App.tsx
File metadata and controls
58 lines (51 loc) · 1.76 KB
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 * as React from 'react';
import { connect } from 'react-redux';
import { BrowserRouter as Router, Redirect, Route, Switch } from 'react-router-dom';
import PrivateRoute from './components/PrivateRoute';
import { Store } from './reducers/rootReducer';
import { isAuthenticated } from './selectors/loginSelectors';
import Header from './components/Header';
import LoginPage from './components/LoginPage';
import NotFoundPage from './components/NotFoundPage';
import RegisterPage from './components/RegisterPage';
import MedicationPage from './components/MedicationPage'
import UserPage from './components/UserPage';
import UsersPage from './components/UsersPage';
interface AppProps {
isAuth: boolean;
}
class App extends React.Component<AppProps> {
render() {
const { isAuth } = this.props;
return (
<Router>
<div>
{isAuth && <Header />}
<Switch>
<Route exact={true} path="/login" component={LoginPage} />
<PrivateRoute exact={true} path="/users" component={UsersPage} />
<PrivateRoute
exact={true}
path="/user/:userID"
component={(props: any) => <UserPage {...props} />}
/>
<PrivateRoute exact={true} path="/register" component={RegisterPage} />
<PrivateRoute
exact={true}
path="/user/:userID/medication"
component={(props: any) => <MedicationPage {...props} />}
/>
<Redirect exact={true} from="/" to="/users" />
<Route component={NotFoundPage} />
</Switch>
</div>
</Router>
);
}
}
function mapStateToProps(state: Store) {
return {
isAuth: isAuthenticated(state),
};
}
export default connect(mapStateToProps)(App);