From 6ec86d3cf70a35ba9f3eeb7a42c193d336d4c8fa Mon Sep 17 00:00:00 2001
From: elforjani13 <39470382+elforjani13@users.noreply.github.com>
Date: Tue, 23 Nov 2021 21:26:34 +0200
Subject: [PATCH] feat: add customer & vendor ability.
---
.../CustomersLanding/CustomersActionsBar.js | 35 +++++---
.../Customers/CustomersLanding/components.js | 69 ++++++++------
.../CustomerDetailsActionsBar.js | 90 ++++++++++++-------
.../VendorDetailsActionsBar.js | 66 ++++++++------
src/containers/Items/components.js | 5 +-
.../VendorsLanding/VendorActionsBar.js | 22 +++--
.../Vendors/VendorsLanding/components.js | 68 ++++++++------
7 files changed, 214 insertions(+), 141 deletions(-)
diff --git a/src/containers/Customers/CustomersLanding/CustomersActionsBar.js b/src/containers/Customers/CustomersLanding/CustomersActionsBar.js
index 8ca0e6750..8cc194533 100644
--- a/src/containers/Customers/CustomersLanding/CustomersActionsBar.js
+++ b/src/containers/Customers/CustomersLanding/CustomersActionsBar.js
@@ -14,6 +14,7 @@ import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
import {
If,
Icon,
+ Can,
FormattedMessage as T,
DashboardActionViewsList,
AdvancedFilterPopover,
@@ -29,6 +30,10 @@ import withCustomersActions from './withCustomersActions';
import withAlertActions from 'containers/Alert/withAlertActions';
import withSettingsActions from '../../Settings/withSettingsActions';
import withSettings from '../../Settings/withSettings';
+import {
+ Customer_Abilities,
+ AbilitySubject,
+} from '../../../common/abilityOption';
import { compose } from 'utils';
@@ -103,15 +108,15 @@ function CustomerActionsBar({
onChange={handleTabChange}
/>
-
- }
- text={}
- onClick={onClickNewCustomer}
- />
-
-
+
+ }
+ text={}
+ onClick={onClickNewCustomer}
+ />
+
+
- }
- defaultChecked={accountsInactiveMode}
- onChange={handleInactiveSwitchChange}
- />
+
+ }
+ defaultChecked={accountsInactiveMode}
+ onChange={handleInactiveSwitchChange}
+ />
+
-
- }
- text={intl.get('edit_customer')}
- onClick={safeCallback(onEdit, original)}
- />
- }
- text={intl.get('duplicate')}
- onClick={safeCallback(onDuplicate, original)}
- />
-
+
+
+
}
- onClick={safeCallback(onInactivate, original)}
+ icon={}
+ text={intl.get('edit_customer')}
+ onClick={safeCallback(onEdit, original)}
/>
-
-
+
+
}
- onClick={safeCallback(onActivate, original)}
+ icon={}
+ text={intl.get('duplicate')}
+ onClick={safeCallback(onDuplicate, original)}
/>
-
- }
- text={intl.get('delete_customer')}
- intent={Intent.DANGER}
- onClick={safeCallback(onDelete, original)}
- />
+
+
+
+ }
+ onClick={safeCallback(onInactivate, original)}
+ />
+
+
+ }
+ onClick={safeCallback(onActivate, original)}
+ />
+
+
+
+ }
+ text={intl.get('delete_customer')}
+ intent={Intent.DANGER}
+ onClick={safeCallback(onDelete, original)}
+ />
+
);
}
diff --git a/src/containers/Drawers/CustomerDetailsDrawer/CustomerDetailsActionsBar.js b/src/containers/Drawers/CustomerDetailsDrawer/CustomerDetailsActionsBar.js
index 504d3f366..f6cade1da 100644
--- a/src/containers/Drawers/CustomerDetailsDrawer/CustomerDetailsActionsBar.js
+++ b/src/containers/Drawers/CustomerDetailsDrawer/CustomerDetailsActionsBar.js
@@ -21,8 +21,15 @@ import { useCustomerDetailsDrawerContext } from './CustomerDetailsDrawerProvider
import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions';
-import { Icon, FormattedMessage as T } from 'components';
-
+import { Can, Icon, FormattedMessage as T } from 'components';
+import {
+ AbilitySubject,
+ Invoice_Abilities,
+ Estimate_Abilities,
+ Receipt_Abilities,
+ Payment_Receive_Abilities,
+ Customer_Abilities,
+} from '../../../common/abilityOption';
import { compose } from 'utils';
/**
@@ -62,7 +69,7 @@ function CustomerDetailsActionsBar({
const handleDeleteCustomer = () => {
openAlert(`customer-delete`, { contactId: customerId });
};
-
+
const handleEditContact = () => {
history.push(`/customers/${customerId}/edit`);
closeDrawer('customer-details-drawer');
@@ -74,22 +81,34 @@ function CustomerDetailsActionsBar({
- }
- onClick={handleNewInvoiceClick}
- />
- }
- onClick={handleNewEstimateClick}
- />
- }
- onClick={handleNewReceiptClick}
- />
- }
- onClick={handleNewPaymentClick}
- />
+
+ }
+ onClick={handleNewInvoiceClick}
+ />
+
+
+ }
+ onClick={handleNewEstimateClick}
+ />
+
+
+ }
+ onClick={handleNewReceiptClick}
+ />
+
+
+
+ }
+ onClick={handleNewPaymentClick}
+ />
+
}
minimal={true}
@@ -104,21 +123,24 @@ function CustomerDetailsActionsBar({
-
- }
- text={intl.get('customer.drawer.action.edit')}
- onClick={handleEditContact}
- />
-
- }
- text={}
- intent={Intent.DANGER}
- onClick={handleDeleteCustomer}
- />
+
+ }
+ text={intl.get('customer.drawer.action.edit')}
+ onClick={handleEditContact}
+ />
+
+
+
+ }
+ text={}
+ intent={Intent.DANGER}
+ onClick={handleDeleteCustomer}
+ />
+
);
diff --git a/src/containers/Drawers/VendorDetailsDrawer/VendorDetailsActionsBar.js b/src/containers/Drawers/VendorDetailsDrawer/VendorDetailsActionsBar.js
index 5ed4a1c28..c488f457e 100644
--- a/src/containers/Drawers/VendorDetailsDrawer/VendorDetailsActionsBar.js
+++ b/src/containers/Drawers/VendorDetailsDrawer/VendorDetailsActionsBar.js
@@ -20,8 +20,13 @@ import { useVendorDetailsDrawerContext } from './VendorDetailsDrawerProvider';
import withAlertsActions from 'containers/Alert/withAlertActions';
import withDrawerActions from 'containers/Drawer/withDrawerActions';
-import { Icon, FormattedMessage as T } from 'components';
-
+import { Can, Icon, FormattedMessage as T } from 'components';
+import {
+ AbilitySubject,
+ Invoice_Abilities,
+ Payment_Made_Abilities,
+ Vendor_Abilities,
+} from '../../../common/abilityOption';
import { safeCallback, compose } from 'utils';
/**
@@ -64,14 +69,21 @@ function VendorDetailsActionsBar({
- }
- onClick={handleNewInvoiceClick}
- />
- }
- onClick={handleNewPaymentClick}
- />
+
+ }
+ onClick={handleNewInvoiceClick}
+ />
+
+
+ }
+ onClick={handleNewPaymentClick}
+ />
+
}
minimal={true}
@@ -84,23 +96,25 @@ function VendorDetailsActionsBar({
icon={}
/>
-
-
- }
- text={}
- onClick={safeCallback(onEditContact)}
- />
-
- }
- text={}
- intent={Intent.DANGER}
- onClick={safeCallback(onDeleteContact)}
- />
+
+ }
+ text={}
+ onClick={safeCallback(onEditContact)}
+ />
+
+
+
+ }
+ text={}
+ intent={Intent.DANGER}
+ onClick={safeCallback(onDeleteContact)}
+ />
+
);
diff --git a/src/containers/Items/components.js b/src/containers/Items/components.js
index dd26ba711..3e3a8840c 100644
--- a/src/containers/Items/components.js
+++ b/src/containers/Items/components.js
@@ -110,7 +110,7 @@ export function ItemsActionMenuList({
onClick={safeCallback(onDuplicate, original)}
/>
-
+
-
-
+
- }
- text={}
- onClick={onClickNewVendor}
- />
-
+
+ }
+ text={}
+ onClick={onClickNewVendor}
+ />
+
+
-
- }
- text={intl.get('edit_vendor')}
- onClick={safeCallback(onEdit, original)}
- />
- }
- text={intl.get('duplicate')}
- onClick={safeCallback(onDuplicate, original)}
- />
-
+
+
}
- onClick={safeCallback(onInactivate, original)}
+ icon={}
+ text={intl.get('edit_vendor')}
+ onClick={safeCallback(onEdit, original)}
/>
-
-
+
+
}
- onClick={safeCallback(onActivate, original)}
+ icon={}
+ text={intl.get('duplicate')}
+ onClick={safeCallback(onDuplicate, original)}
/>
-
- }
- text={intl.get('delete_vendor')}
- intent={Intent.DANGER}
- onClick={safeCallback(onDelete, original)}
- />
+
+
+
+ }
+ onClick={safeCallback(onInactivate, original)}
+ />
+
+
+ }
+ onClick={safeCallback(onActivate, original)}
+ />
+
+
+
+ }
+ text={intl.get('delete_vendor')}
+ intent={Intent.DANGER}
+ onClick={safeCallback(onDelete, original)}
+ />
+
);
}