fix: add ability credit & vendor tabs.

This commit is contained in:
elforjani13
2021-12-29 14:37:03 +02:00
parent 1492c24cfb
commit 81c81bd09f
4 changed files with 32 additions and 21 deletions

View File

@@ -3,7 +3,8 @@ import { Tab } from '@blueprintjs/core';
import styled from 'styled-components'; import styled from 'styled-components';
import intl from 'react-intl-universal'; import intl from 'react-intl-universal';
import { Can, DrawerMainTabs } from 'components'; import { useAbilityContext } from 'hooks/utils';
import { DrawerMainTabs } from 'components';
import CreditNoteDetailActionsBar from './CreditNoteDetailActionsBar'; import CreditNoteDetailActionsBar from './CreditNoteDetailActionsBar';
import CreditNoteDetailPanel from './CreditNoteDetailPanel'; import CreditNoteDetailPanel from './CreditNoteDetailPanel';
import RefundCreditNoteTransactionsTable from './RefundCreditNoteTransactions/RefundCreditNoteTransactionsTable'; import RefundCreditNoteTransactionsTable from './RefundCreditNoteTransactions/RefundCreditNoteTransactionsTable';
@@ -32,6 +33,8 @@ export default function CreditNoteDetail() {
* @returns {React.JSX} * @returns {React.JSX}
*/ */
function CreditNoteDetailsTabs() { function CreditNoteDetailsTabs() {
const ability = useAbilityContext();
return ( return (
<DrawerMainTabs> <DrawerMainTabs>
<Tab <Tab
@@ -44,18 +47,21 @@ function CreditNoteDetailsTabs() {
id={'journal_entries'} id={'journal_entries'}
panel={<CreditNoteGLEntriesTable />} panel={<CreditNoteGLEntriesTable />}
/> />
{/* <Can I={CreditNoteAction.View} a={AbilitySubject.CreditNote}> */}
<Tab {ability.can(CreditNoteAction.View, AbilitySubject.CreditNote) && (
title={intl.get('credit_note.drawer.label_refund_transactions')} <Tab
id={'refund_transactions'} title={intl.get('credit_note.drawer.label_refund_transactions')}
panel={<RefundCreditNoteTransactionsTable />} id={'refund_transactions'}
/> panel={<RefundCreditNoteTransactionsTable />}
<Tab />
title={intl.get('credit_note.drawer.label_invoices_reconciled')} )}
id={'reconcile_transactions'} {ability.can(CreditNoteAction.View, AbilitySubject.CreditNote) && (
panel={<ReconcileCreditNoteTransactionsTable />} <Tab
/> title={intl.get('credit_note.drawer.label_invoices_reconciled')}
{/* </Can> */} id={'reconcile_transactions'}
panel={<ReconcileCreditNoteTransactionsTable />}
/>
)}
</DrawerMainTabs> </DrawerMainTabs>
); );
} }

View File

@@ -56,15 +56,15 @@ function CreditNoteDetailActionsBar({
openDialog('refund-credit-note', { creditNoteId }); openDialog('refund-credit-note', { creditNoteId });
}; };
const handleReconcileCreditNote = () => {
openDialog('reconcile-credit-note', { creditNoteId });
};
// Handle delete credit note. // Handle delete credit note.
const handleDeleteCreditNote = () => { const handleDeleteCreditNote = () => {
openAlert('credit-note-delete', { creditNoteId }); openAlert('credit-note-delete', { creditNoteId });
}; };
const handleReconcileCreditNote = () => {
openDialog('reconcile-credit-note', { creditNoteId });
};
return ( return (
<DrawerActionsBar> <DrawerActionsBar>
<NavbarGroup> <NavbarGroup>

View File

@@ -3,7 +3,8 @@ import { Tab } from '@blueprintjs/core';
import intl from 'react-intl-universal'; import intl from 'react-intl-universal';
import styled from 'styled-components'; import styled from 'styled-components';
import { Can, DrawerMainTabs } from 'components'; import { useAbilityContext } from 'hooks/utils';
import { DrawerMainTabs } from 'components';
import VendorCreditDetailActionsBar from './VendorCreditDetailActionsBar'; import VendorCreditDetailActionsBar from './VendorCreditDetailActionsBar';
import VendorCreditDetailPanel from './VendorCreditDetailPanel'; import VendorCreditDetailPanel from './VendorCreditDetailPanel';
import RefundVendorCreditTransactionsTable from './RefundVendorCreditTransactions/RefundVendorCreditTransactionsTable'; import RefundVendorCreditTransactionsTable from './RefundVendorCreditTransactions/RefundVendorCreditTransactionsTable';
@@ -32,6 +33,8 @@ export default function VendorCreditDetail() {
* @returns {React.JSX} * @returns {React.JSX}
*/ */
function VendorCreditDetailsTabs() { function VendorCreditDetailsTabs() {
const ability = useAbilityContext();
return ( return (
<DrawerMainTabs renderActiveTabPanelOnly={true}> <DrawerMainTabs renderActiveTabPanelOnly={true}>
<Tab <Tab
@@ -44,18 +47,20 @@ function VendorCreditDetailsTabs() {
id={'journal_entries'} id={'journal_entries'}
panel={<VendorCreditGLEntriesTable />} panel={<VendorCreditGLEntriesTable />}
/> />
{/* <Can I={VendorCreditAction.View} a={AbilitySubject.VendorCredit}> */} {ability.can(VendorCreditAction.View, AbilitySubject.VendorCredit) && (
<Tab <Tab
title={intl.get('vendor_credit.drawer.label_refund_transactions')} title={intl.get('vendor_credit.drawer.label_refund_transactions')}
id={'refund_transactions'} id={'refund_transactions'}
panel={<RefundVendorCreditTransactionsTable />} panel={<RefundVendorCreditTransactionsTable />}
/> />
)}
{ability.can(VendorCreditAction.View, AbilitySubject.VendorCredit) && (
<Tab <Tab
title={intl.get('vendor_credit.drawer.label_bills_reconciled')} title={intl.get('vendor_credit.drawer.label_bills_reconciled')}
id={'reconcile_transactions'} id={'reconcile_transactions'}
panel={<ReconcileVendorCreditTransactionsTable />} panel={<ReconcileVendorCreditTransactionsTable />}
/> />
{/* </Can> */} )}
</DrawerMainTabs> </DrawerMainTabs>
); );
} }

View File

@@ -1446,7 +1446,7 @@
"cash_flow_transaction.balance_in_bigcapital": "الرصيد في Bigcapital", "cash_flow_transaction.balance_in_bigcapital": "الرصيد في Bigcapital",
"bad_debt.dialog.written_off_amount": "المبلغ المشطوب", "bad_debt.dialog.written_off_amount": "المبلغ المشطوب",
"bad_debt.dialog.bad_debt": "دين معدوم", "bad_debt.dialog.bad_debt": "دين معدوم",
"bad_debt.dialog.cancel_bad_debt": "إلغاء الديون المعدومة", "bad_debt.dialog.cancel_bad_debt": "إلغاء الدين المعدوم",
"bad_debt.dialog.header_note": "يمكن للبائع تحميل مبلغ الفاتورة على حساب مصروفات الديون المعدومة عندما يكون من المؤكد أن الفاتورة لن يتم دفعها.", "bad_debt.dialog.header_note": "يمكن للبائع تحميل مبلغ الفاتورة على حساب مصروفات الديون المعدومة عندما يكون من المؤكد أن الفاتورة لن يتم دفعها.",
"bad_debt.dialog.success_message": "تم شطب فاتورة البيع المقدمة بنجاح.", "bad_debt.dialog.success_message": "تم شطب فاتورة البيع المقدمة بنجاح.",
"bad_debt.cancel_alert.success_message": "تم إلغاء شطب فاتورة البيع المقدمة بنجاح.", "bad_debt.cancel_alert.success_message": "تم إلغاء شطب فاتورة البيع المقدمة بنجاح.",