1
|
|
|
import React, { useContext, useEffect } from 'react';
|
2
|
|
|
import PropTypes from 'prop-types';
|
3
|
|
|
import { Route, Switch } from 'react-router-dom';
|
4
|
|
|
// import Dashboard from '../components/dashboard/Dashboard';
|
5
|
|
|
import Dashboard from '../components/MyEMS/dashboard/Dashboard';
|
6
|
|
|
import DashboardAlt from '../components/dashboard-alt/DashboardAlt';
|
7
|
|
|
import NavbarTop from '../components/navbar/NavbarTop';
|
8
|
|
|
import NavbarVertical from '../components/navbar/NavbarVertical';
|
9
|
|
|
import Footer from '../components/footer/Footer';
|
10
|
|
|
import loadable from '@loadable/component';
|
11
|
|
|
import AppContext from '../context/Context';
|
12
|
|
|
import ProductProvider from '../components/e-commerce/ProductProvider';
|
13
|
|
|
import SidePanelModal from '../components/side-panel/SidePanelModal';
|
14
|
|
|
import { getPageName } from '../helpers/utils';
|
15
|
|
|
|
16
|
|
|
// const DashboardRoutes = loadable(() => import('./DashboardRoutes'));
|
17
|
|
|
const DashboardRoutes = loadable(() => import('./MyEMSRoutes'));
|
18
|
|
|
|
19
|
|
|
const DashboardLayout = ({ location }) => {
|
20
|
|
|
const { isFluid, isTopNav, navbarStyle } = useContext(AppContext);
|
21
|
|
|
|
22
|
|
|
const isKanban = getPageName('kanban');
|
23
|
|
|
|
24
|
|
|
useEffect(() => {
|
25
|
|
|
DashboardRoutes.preload();
|
26
|
|
|
}, []);
|
27
|
|
|
|
28
|
|
|
useEffect(() => {
|
29
|
|
|
window.scrollTo(0, 0);
|
30
|
|
|
}, [location.pathname]);
|
31
|
|
|
|
32
|
|
|
return (
|
33
|
|
|
<div className={isFluid || isKanban ? 'container-fluid' : 'container'}>
|
34
|
|
|
{!isTopNav && <NavbarVertical isKanban={isKanban} navbarStyle={navbarStyle} />}
|
35
|
|
|
<ProductProvider>
|
36
|
|
|
<div className="content">
|
37
|
|
|
<NavbarTop />
|
38
|
|
|
<Switch>
|
39
|
|
|
{/* added one more route to avoid navlink active issue */}
|
40
|
|
|
<Route path="/" exact component={Dashboard} />
|
41
|
|
|
<Route path="/dashboard" exact component={Dashboard} />
|
42
|
|
|
<Route path="/dashboard-alt" exact component={DashboardAlt} />
|
43
|
|
|
<DashboardRoutes />
|
44
|
|
|
</Switch>
|
45
|
|
|
{!isKanban && <Footer />}
|
46
|
|
|
</div>
|
47
|
|
|
<SidePanelModal autoShow={false} path={location.pathname} />
|
48
|
|
|
</ProductProvider>
|
49
|
|
|
</div>
|
50
|
|
|
);
|
51
|
|
|
};
|
52
|
|
|
|
53
|
|
|
DashboardLayout.propTypes = { location: PropTypes.object.isRequired };
|
54
|
|
|
|
55
|
|
|
export default DashboardLayout;
|
56
|
|
|
|