Files
bigcapital/client/src/components/Dashboard/DashboardPage.js
a.bouhuolia 9e2c995813 fix: logo style.
fix: page forms style.
feat: auto-fill items entries from item details.
fix: hiding dashboard copyright bar.
2021-02-25 10:51:27 +02:00

67 lines
1.5 KiB
JavaScript

import React, { useEffect, Suspense } from 'react';
import { CLASSES } from 'common/classes';
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
import { compose } from 'utils';
/**
* Dashboard pages wrapper.
*/
function DashboardPage({
// #ownProps
pageTitle,
backLink,
sidebarShrink,
Component,
name,
// #withDashboardActions
changePageTitle,
setDashboardBackLink,
setSidebarShrink,
resetSidebarPreviousExpand,
}) {
useEffect(() => {
pageTitle && changePageTitle(pageTitle);
return () => {
pageTitle && changePageTitle('');
};
});
useEffect(() => {
backLink && setDashboardBackLink(backLink);
return () => {
backLink && setDashboardBackLink(false);
};
}, [backLink, setDashboardBackLink]);
// Handle sidebar shrink in mount and reset to the pervious state
// once the page unmount.
useEffect(() => {
sidebarShrink && setSidebarShrink();
return () => {
sidebarShrink && resetSidebarPreviousExpand();
};
}, [resetSidebarPreviousExpand, sidebarShrink, setSidebarShrink]);
useEffect(() => {
const className = `page-${name}`;
name && document.body.classList.add(className);
return () => {
name && document.body.classList.remove(className);
};
}, [name]);
return (
<div className={CLASSES.DASHBOARD_PAGE}>
<Suspense fallback={''}>
<Component />
</Suspense>
</div>
);
}
export default compose(withDashboardActions)(DashboardPage);