feat: add convert to vendor credit in drawer.

This commit is contained in:
elforjani13
2021-12-26 17:11:04 +02:00
parent 2a9c1a9833
commit d5acb3696e
5 changed files with 61 additions and 8 deletions

View File

@@ -27,6 +27,7 @@ import {
PaymentMadeAction,
AbilitySubject,
} from '../../../common/abilityOption';
import { BillMenuItem } from './utils';
import { safeCallback, compose } from 'utils';
@@ -50,6 +51,14 @@ function BillDetailActionsBar({
closeDrawer('bill-drawer');
};
// Handle convert to vendor credit.
const handleConvertToVendorCredit = () => {
history.push(`/vendor-credits/new?from_bill_id=${billId}`, {
billId: billId,
});
closeDrawer('bill-drawer');
};
// Handle delete bill.
const onDeleteBill = () => {
openAlert('bill-delete', { billId });
@@ -92,6 +101,14 @@ function BillDetailActionsBar({
onClick={safeCallback(onDeleteBill)}
/>
</Can>
<Can I={BillAction.Edit} a={AbilitySubject.Bill}>
<NavbarDivider />
<BillMenuItem
payload={{
onConvert: handleConvertToVendorCredit,
}}
/>
</Can>
</NavbarGroup>
</DrawerActionsBar>
);