This commit is contained in:
a.bouhuolia
2021-08-21 19:00:31 +02:00
29 changed files with 663 additions and 19 deletions

View File

@@ -10,6 +10,7 @@ import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton';
import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions';
import withDialogActions from 'containers/Dialog/withDialogActions';
import withReceipts from './withReceipts';
import withReceiptsActions from './withReceiptsActions';
import withSettings from 'containers/Settings/withSettings';
@@ -35,6 +36,9 @@ function ReceiptsDataTable({
// #withDrawerActions
openDrawer,
// #withDialogAction
openDialog,
}) {
const history = useHistory();
@@ -75,6 +79,11 @@ function ReceiptsDataTable({
openDrawer('receipt-detail-drawer', { receiptId: id });
};
// Handle print receipt.
const handlePrintInvoice = ({ id }) => {
openDialog('receipt-pdf-preview', { receiptId: id });
};
// Handles the datable fetch data once the state changing.
const handleDataTableFetchData = useCallback(
({ sortBy, pageIndex, pageSize }) => {
@@ -118,6 +127,7 @@ function ReceiptsDataTable({
onClose: handleCloseReceipt,
onDrawer: handleDrawerReceipt,
onViewDetails: handleViewDetailReceipt,
onPrint: handlePrintInvoice,
baseCurrency,
}}
/>
@@ -128,6 +138,7 @@ export default compose(
withAlertsActions,
withReceiptsActions,
withDrawerActions,
withDialogActions,
withReceipts(({ receiptTableState }) => ({
receiptTableState,
})),

View File

@@ -16,7 +16,7 @@ import { Choose, Money, Icon, If } from 'components';
import moment from 'moment';
export function ActionsMenu({
payload: { onEdit, onDelete, onClose, onDrawer, onViewDetails },
payload: { onEdit, onDelete, onClose, onDrawer, onViewDetails, onPrint },
row: { original: receipt },
}) {
return (
@@ -44,6 +44,11 @@ export function ActionsMenu({
text={intl.get('receipt_paper')}
onClick={safeCallback(onDrawer, receipt)}
/>
<MenuItem
icon={<Icon icon={'print-16'} iconSize={16} />}
text={intl.get('print')}
onClick={safeCallback(onPrint, receipt)}
/>
<MenuItem
text={intl.get('delete_receipt')}
intent={Intent.DANGER}