Completed
Push — master ( 05e3e8...72dd2b )
by Alejandro
16s queued 12s
created

src/App.js   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 41
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 1
eloc 36
mnd 1
bc 1
fnc 0
dl 0
loc 41
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
ccs 6
cts 7
cp 0.8571
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