mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
128 lines
3.4 KiB
JavaScript
128 lines
3.4 KiB
JavaScript
import React from 'react';
|
|
import {
|
|
NavbarGroup,
|
|
Button,
|
|
Classes,
|
|
NavbarDivider,
|
|
Popover,
|
|
Position,
|
|
PopoverInteractionKind,
|
|
} from '@blueprintjs/core';
|
|
import { FormattedMessage as T } from 'react-intl';
|
|
import classNames from 'classnames';
|
|
|
|
import Icon from 'components/Icon';
|
|
import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
|
|
import NumberFormatDropdown from 'components/NumberFormatDropdown';
|
|
|
|
import withProfitLossActions from './withProfitLossActions';
|
|
import withProfitLoss from './withProfitLoss';
|
|
|
|
import { compose, saveInvoke } from 'utils';
|
|
import { useProfitLossSheetContext } from './ProfitLossProvider';
|
|
|
|
/**
|
|
* Profit/Loss sheet actions bar.
|
|
*/
|
|
function ProfitLossActionsBar({
|
|
// #withProfitLoss
|
|
profitLossDrawerFilter,
|
|
|
|
// #withProfitLossActions
|
|
toggleProfitLossFilterDrawer: toggleFilterDrawer,
|
|
|
|
// #ownProps
|
|
numberFormat,
|
|
onNumberFormatSubmit,
|
|
}) {
|
|
const { sheetRefetch, isLoading } = useProfitLossSheetContext();
|
|
|
|
const handleFilterClick = () => {
|
|
toggleFilterDrawer();
|
|
};
|
|
|
|
const handleRecalcReport = () => {
|
|
sheetRefetch();
|
|
};
|
|
// Handle number format submit.
|
|
const handleNumberFormatSubmit = (values) => {
|
|
saveInvoke(onNumberFormatSubmit, values);
|
|
};
|
|
|
|
return (
|
|
<DashboardActionsBar>
|
|
<NavbarGroup>
|
|
<Button
|
|
className={classNames(Classes.MINIMAL, 'button--gray-highlight')}
|
|
text={<T id={'recalc_report'} />}
|
|
onClick={handleRecalcReport}
|
|
icon={<Icon icon="refresh-16" iconSize={16} />}
|
|
/>
|
|
<NavbarDivider />
|
|
|
|
<Button
|
|
className={classNames(Classes.MINIMAL, 'button--table-views')}
|
|
icon={<Icon icon="cog-16" iconSize={16} />}
|
|
text={
|
|
profitLossDrawerFilter ? (
|
|
<T id={'hide_customizer'} />
|
|
) : (
|
|
<T id={'customize_report'} />
|
|
)
|
|
}
|
|
onClick={handleFilterClick}
|
|
active={profitLossDrawerFilter}
|
|
/>
|
|
<NavbarDivider />
|
|
|
|
<Popover
|
|
content={
|
|
<NumberFormatDropdown
|
|
numberFormat={numberFormat}
|
|
onSubmit={handleNumberFormatSubmit}
|
|
submitDisabled={isLoading}
|
|
/>
|
|
}
|
|
minimal={true}
|
|
interactionKind={PopoverInteractionKind.CLICK}
|
|
position={Position.BOTTOM_LEFT}
|
|
>
|
|
<Button
|
|
className={classNames(Classes.MINIMAL, 'button--filter')}
|
|
text={<T id={'format'} />}
|
|
icon={<Icon icon="numbers" width={23} height={16} />}
|
|
/>
|
|
</Popover>
|
|
|
|
<Popover
|
|
// content={}
|
|
interactionKind={PopoverInteractionKind.CLICK}
|
|
position={Position.BOTTOM_LEFT}
|
|
>
|
|
<Button
|
|
className={classNames(Classes.MINIMAL, 'button--filter')}
|
|
text={<T id={'filter'} />}
|
|
icon={<Icon icon="filter-16" iconSize={16} />}
|
|
/>
|
|
</Popover>
|
|
|
|
<Button
|
|
className={Classes.MINIMAL}
|
|
icon={<Icon icon="print-16" iconSize={16} />}
|
|
text={<T id={'print'} />}
|
|
/>
|
|
<Button
|
|
className={Classes.MINIMAL}
|
|
icon={<Icon icon="file-export-16" iconSize={16} />}
|
|
text={<T id={'export'} />}
|
|
/>
|
|
</NavbarGroup>
|
|
</DashboardActionsBar>
|
|
);
|
|
}
|
|
|
|
export default compose(
|
|
withProfitLoss(({ profitLossDrawerFilter }) => ({ profitLossDrawerFilter })),
|
|
withProfitLossActions,
|
|
)(ProfitLossActionsBar);
|