Total Complexity | 1 |
Complexity/F | 0 |
Lines of Code | 41 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 85.71% |
Changes | 0 |
1 | import React, { useEffect } from 'react'; |
||
2 | import PropTypes from 'prop-types'; |
||
3 | import { Route, Switch } from 'react-router-dom'; |
||
4 | import NotFound from './common/NotFound'; |
||
5 | import './App.scss'; |
||
6 | |||
7 | 1 | const propTypes = { |
|
8 | fetchServers: PropTypes.func, |
||
9 | servers: PropTypes.object, |
||
10 | }; |
||
11 | |||
12 | 2 | const App = (MainHeader, Home, MenuLayout, CreateServer, EditServer, Settings) => ({ fetchServers, servers }) => { |
|
13 | // On first load, try to fetch the remote servers if the list is empty |
||
14 | 2 | useEffect(() => { |
|
15 | 2 | if (Object.keys(servers).length === 0) { |
|
16 | fetchServers(); |
||
17 | } |
||
18 | }, []); |
||
19 | |||
20 | 2 | return ( |
|
21 | <div className="container-fluid app-container"> |
||
22 | <MainHeader /> |
||
23 | |||
24 | <div className="app"> |
||
25 | <Switch> |
||
26 | <Route exact path="/" component={Home} /> |
||
27 | <Route exact path="/settings" component={Settings} /> |
||
28 | <Route exact path="/server/create" component={CreateServer} /> |
||
29 | <Route exact path="/server/:serverId/edit" component={EditServer} /> |
||
30 | <Route path="/server/:serverId" component={MenuLayout} /> |
||
31 | <Route component={NotFound} /> |
||
32 | </Switch> |
||
33 | </div> |
||
34 | </div> |
||
35 | ); |
||
36 | }; |
||
37 | |||
38 | 1 | App.propTypes = propTypes; |
|
39 | |||
40 | export default App; |
||
41 |