fix: toggle display filter drawer of financial statements.

This commit is contained in:
a.bouhuolia
2021-02-22 15:38:17 +02:00
parent 1e3b8df702
commit 2750d64fac
49 changed files with 716 additions and 1075 deletions

View File

@@ -1,7 +1,6 @@
import React, { useState, useEffect } from 'react';
import React, { useState } from 'react';
import moment from 'moment';
import { compose } from 'utils';
import { useIntl } from 'react-intl';
import ProfitLossSheetHeader from './ProfitLossSheetHeader';
import ProfitLossSheetTable from './ProfitLossSheetTable';
@@ -20,13 +19,11 @@ import { ProfitLossSheetProvider } from './ProfitLossProvider';
* Profit/Loss financial statement sheet.
*/
function ProfitLossSheet({
// #withDashboardActions
changePageTitle,
setDashboardBackLink,
setSidebarShrink,
// #withPreferences
organizationName,
// #withProfitLossActions
toggleProfitLossFilterDrawer: toggleDisplayFilterDrawer
}) {
const [filter, setFilter] = useState({
basis: 'cash',
@@ -35,24 +32,7 @@ function ProfitLossSheet({
displayColumnsType: 'total',
accountsFilter: 'all-accounts',
});
const { formatMessage } = useIntl();
// Change page title of the dashboard.
useEffect(() => {
changePageTitle(formatMessage({ id: 'profit_loss_sheet' }));
}, [changePageTitle, formatMessage]);
useEffect(() => {
setSidebarShrink();
// Show the back link on dashboard topbar.
setDashboardBackLink(true);
return () => {
// Hide the back link on dashboard topbar.
setDashboardBackLink(false);
};
}, [setDashboardBackLink, setSidebarShrink]);
// Handle submit filter.
const handleSubmitFilter = (filter) => {
const _filter = {
@@ -71,6 +51,11 @@ function ProfitLossSheet({
});
};
// Hide the filter drawer once the page unmount.
React.useEffect(() => () => {
toggleDisplayFilterDrawer(false);
}, [toggleDisplayFilterDrawer])
return (
<ProfitLossSheetProvider query={filter}>
<ProfitLossActionsBar