mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
feat: add delete reconcile & handle error.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import React from 'react';
|
||||
import { DataTable, Card } from 'components';
|
||||
|
||||
import '../../../../style/pages/RefundCreditNote/List.scss';
|
||||
|
||||
import withAlertsActions from 'containers/Alert/withAlertActions';
|
||||
import { useVendorCreditDetailDrawerContext } from '../VendorCreditDetailDrawerProvider';
|
||||
import {
|
||||
useReconcileVendorCreditTransactionsTableColumns,
|
||||
ActionsMenu,
|
||||
} from './components';
|
||||
import { compose } from 'utils';
|
||||
|
||||
/**
|
||||
* Reconcile vendor credit transactions table.
|
||||
*/
|
||||
function ReconcileVendorCreditTransactionsTable({
|
||||
// #withAlertsActions
|
||||
openAlert,
|
||||
}) {
|
||||
const columns = useReconcileVendorCreditTransactionsTableColumns();
|
||||
|
||||
const { reconcileVendorCredits } = useVendorCreditDetailDrawerContext();
|
||||
|
||||
// Handle delete reconile credit.
|
||||
const handleDeleteReconcileVendorCredit = ({ id }) => {
|
||||
openAlert('reconcile-vendor-delete', { vendorCreditId: id });
|
||||
};
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={reconcileVendorCredits}
|
||||
ContextMenu={ActionsMenu}
|
||||
payload={{
|
||||
onDelete: handleDeleteReconcileVendorCredit,
|
||||
}}
|
||||
className={'datatable--refund-transactions'}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withAlertsActions)(
|
||||
ReconcileVendorCreditTransactionsTable,
|
||||
);
|
||||
@@ -0,0 +1,49 @@
|
||||
import React from 'react';
|
||||
import { Intent, MenuItem, Menu } from '@blueprintjs/core';
|
||||
import intl from 'react-intl-universal';
|
||||
import { FormatDateCell, Icon } from 'components';
|
||||
import { safeCallback } from 'utils';
|
||||
|
||||
/**
|
||||
* Actions menu.
|
||||
*/
|
||||
export function ActionsMenu({ payload: { onDelete }, row: { original } }) {
|
||||
return (
|
||||
<Menu>
|
||||
<MenuItem
|
||||
icon={<Icon icon="trash-16" iconSize={16} />}
|
||||
text={intl.get('delete_transaction')}
|
||||
intent={Intent.DANGER}
|
||||
onClick={safeCallback(onDelete, original)}
|
||||
/>
|
||||
</Menu>
|
||||
);
|
||||
}
|
||||
|
||||
export function useReconcileVendorCreditTransactionsTableColumns() {
|
||||
return React.useMemo(
|
||||
() => [
|
||||
{
|
||||
Header: intl.get('date'),
|
||||
accessor: 'formatted_bill_date',
|
||||
Cell: FormatDateCell,
|
||||
width: 100,
|
||||
className: 'date',
|
||||
},
|
||||
{
|
||||
Header: intl.get('bill_number'),
|
||||
accessor: 'bill_reference_no',
|
||||
width: 100,
|
||||
className: 'bill_number',
|
||||
},
|
||||
{
|
||||
Header: intl.get('amount'),
|
||||
accessor: 'formatted_amount',
|
||||
width: 100,
|
||||
className: 'amount',
|
||||
align: 'right',
|
||||
},
|
||||
],
|
||||
[],
|
||||
);
|
||||
}
|
||||
@@ -39,9 +39,9 @@ export function useRefundCreditTransactionsTableColumns() {
|
||||
},
|
||||
{
|
||||
Header: intl.get('refund_vendor_credit.column.withdrawal_account'),
|
||||
accessor: ({ from_account }) => from_account.name,
|
||||
accessor: ({ deposit_account }) => deposit_account.name,
|
||||
width: 100,
|
||||
className: 'from_account',
|
||||
className: 'deposit_account',
|
||||
},
|
||||
{
|
||||
id: 'reference_no',
|
||||
|
||||
Reference in New Issue
Block a user