2020-04-27 12:54:52 +02:00
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2018-06-03 13:15:52 +02:00
|
|
|
import { Route, Switch } from 'react-router-dom';
|
2019-03-03 11:02:29 +01:00
|
|
|
import NotFound from './common/NotFound';
|
2020-04-18 20:31:20 +02:00
|
|
|
import './App.scss';
|
2018-05-13 08:57:47 +02:00
|
|
|
|
2020-04-27 12:54:52 +02:00
|
|
|
const propTypes = {
|
|
|
|
fetchServers: PropTypes.func,
|
|
|
|
servers: PropTypes.object,
|
|
|
|
};
|
2018-06-03 20:12:40 +02:00
|
|
|
|
2020-04-27 12:54:52 +02:00
|
|
|
const App = (MainHeader, Home, MenuLayout, CreateServer, EditServer, Settings) => ({ fetchServers, servers }) => {
|
|
|
|
// On first load, try to fetch the remote servers if the list is empty
|
|
|
|
useEffect(() => {
|
|
|
|
if (Object.keys(servers).length === 0) {
|
|
|
|
fetchServers();
|
|
|
|
}
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="container-fluid app-container">
|
|
|
|
<MainHeader />
|
|
|
|
|
|
|
|
<div className="app">
|
|
|
|
<Switch>
|
|
|
|
<Route exact path="/" component={Home} />
|
|
|
|
<Route exact path="/settings" component={Settings} />
|
|
|
|
<Route exact path="/server/create" component={CreateServer} />
|
|
|
|
<Route exact path="/server/:serverId/edit" component={EditServer} />
|
|
|
|
<Route path="/server/:serverId" component={MenuLayout} />
|
|
|
|
<Route component={NotFound} />
|
|
|
|
</Switch>
|
|
|
|
</div>
|
2018-08-25 23:39:27 +02:00
|
|
|
</div>
|
2020-04-27 12:54:52 +02:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
App.propTypes = propTypes;
|
2018-12-17 20:03:36 +01:00
|
|
|
|
|
|
|
export default App;
|