Total Complexity | 1 |
Complexity/F | 0 |
Lines of Code | 53 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 83.33% |
Changes | 0 |
1 | import { useEffect, FC } from 'react'; |
||
2 | import { Route, Switch } from 'react-router-dom'; |
||
3 | import NotFound from './common/NotFound'; |
||
4 | import { ServersMap } from './servers/data'; |
||
5 | import './App.scss'; |
||
6 | |||
7 | interface AppProps { |
||
8 | fetchServers: Function; |
||
9 | servers: ServersMap; |
||
10 | } |
||
11 | |||
12 | 1 | const App = ( |
|
13 | MainHeader: FC, |
||
14 | Home: FC, |
||
15 | MenuLayout: FC, |
||
16 | CreateServer: FC, |
||
17 | EditServer: FC, |
||
18 | Settings: FC, |
||
19 | ShlinkVersions: FC, |
||
20 | 2 | ) => ({ fetchServers, servers }: AppProps) => { |
|
21 | // On first load, try to fetch the remote servers if the list is empty |
||
22 | 2 | useEffect(() => { |
|
23 | 2 | if (Object.keys(servers).length === 0) { |
|
24 | fetchServers(); |
||
25 | } |
||
26 | }, []); |
||
27 | |||
28 | 2 | return ( |
|
29 | <div className="container-fluid app-container"> |
||
30 | <MainHeader /> |
||
31 | |||
32 | <div className="app"> |
||
33 | <div className="shlink-wrapper"> |
||
34 | <Switch> |
||
35 | <Route exact path="/" component={Home} /> |
||
36 | <Route exact path="/settings" component={Settings} /> |
||
37 | <Route exact path="/server/create" component={CreateServer} /> |
||
38 | <Route exact path="/server/:serverId/edit" component={EditServer} /> |
||
39 | <Route path="/server/:serverId" component={MenuLayout} /> |
||
40 | <Route component={NotFound} /> |
||
41 | </Switch> |
||
42 | </div> |
||
43 | |||
44 | <div className="shlink-footer text-center text-md-right"> |
||
45 | <ShlinkVersions /> |
||
46 | </div> |
||
47 | </div> |
||
48 | </div> |
||
49 | ); |
||
50 | }; |
||
51 | |||
52 | export default App; |
||
53 |