From 5c847be42079d482bd6a565d66ab798b6f8d6cb7 Mon Sep 17 00:00:00 2001
From: elforjani13 <39470382+elforjani13@users.noreply.github.com>
Date: Sun, 9 Jan 2022 21:18:45 +0200
Subject: [PATCH] BIG-277 Separate customer and vendor.
---
.../Alerts/Customers/CustomerActivateAlert.js | 67 ++++++++++++++++++
.../Customers/CustomerInactivateAlert.js | 69 +++++++++++++++++++
.../Alerts/Vendors/VendorActivateAlert.js | 69 +++++++++++++++++++
.../Alerts/Vendors/VendorInactivateAlert.js | 68 ++++++++++++++++++
src/containers/Customers/CustomersAlerts.js | 12 ++--
.../CustomersLanding/CustomersTable.js | 10 +--
src/containers/Vendors/VendorsAlerts.js | 12 ++--
.../Vendors/VendorsLanding/VendorsTable.js | 8 +--
src/lang/ar/index.json | 14 +++-
src/lang/en/index.json | 13 +++-
10 files changed, 318 insertions(+), 24 deletions(-)
create mode 100644 src/containers/Alerts/Customers/CustomerActivateAlert.js
create mode 100644 src/containers/Alerts/Customers/CustomerInactivateAlert.js
create mode 100644 src/containers/Alerts/Vendors/VendorActivateAlert.js
create mode 100644 src/containers/Alerts/Vendors/VendorInactivateAlert.js
diff --git a/src/containers/Alerts/Customers/CustomerActivateAlert.js b/src/containers/Alerts/Customers/CustomerActivateAlert.js
new file mode 100644
index 000000000..ef86134a3
--- /dev/null
+++ b/src/containers/Alerts/Customers/CustomerActivateAlert.js
@@ -0,0 +1,67 @@
+import React from 'react';
+import { FormattedMessage as T } from 'components';
+import intl from 'react-intl-universal';
+import { Intent, Alert } from '@blueprintjs/core';
+import { AppToaster } from 'components';
+
+import { useActivateContact } from 'hooks/query';
+
+import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect';
+import withAlertActions from 'containers/Alert/withAlertActions';
+
+import { compose } from 'utils';
+
+/**
+ * Customer activate alert.
+ */
+function CustomerActivateAlert({
+ name,
+
+ // #withAlertStoreConnect
+ isOpen,
+ payload: { customerId, service },
+
+ // #withAlertActions
+ closeAlert,
+}) {
+ const { mutateAsync: activateContact, isLoading } = useActivateContact();
+
+ // Handle activate constomer alert cancel.
+ const handleCancelActivateCustomer = () => {
+ closeAlert(name);
+ };
+
+ // Handle confirm customer activated.
+ const handleConfirmCustomerActivate = () => {
+ activateContact(customerId)
+ .then(() => {
+ AppToaster.show({
+ message: intl.get('customer.alert.activated_message'),
+ intent: Intent.SUCCESS,
+ });
+ })
+ .catch((error) => {})
+ .finally(() => {
+ closeAlert(name);
+ });
+ };
+
+ return (
+
{intl.get('customer.alert.are_you_sure_want_to_activate_this_customer')}
+ + ); +} + +export default compose( + withAlertStoreConnect(), + withAlertActions, +)(CustomerActivateAlert); diff --git a/src/containers/Alerts/Customers/CustomerInactivateAlert.js b/src/containers/Alerts/Customers/CustomerInactivateAlert.js new file mode 100644 index 000000000..d86675c91 --- /dev/null +++ b/src/containers/Alerts/Customers/CustomerInactivateAlert.js @@ -0,0 +1,69 @@ +import React from 'react'; +import { FormattedMessage as T } from 'components'; +import intl from 'react-intl-universal'; +import { Intent, Alert } from '@blueprintjs/core'; +import { AppToaster } from 'components'; + +import { useInactivateContact } from 'hooks/query'; + +import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; +import withAlertActions from 'containers/Alert/withAlertActions'; + +import { compose } from 'utils'; + +/** + * customer inactivate alert. + */ +function CustomerInactivateAlert({ + name, + // #withAlertStoreConnect + isOpen, + payload: { customerId, service }, + + // #withAlertActions + closeAlert, +}) { + const { mutateAsync: inactivateContact, isLoading } = useInactivateContact(); + + // Handle cancel inactivate alert. + const handleCancelInactivateCustomer = () => { + closeAlert(name); + }; + + // Handle confirm contact Inactive. + const handleConfirmCustomerInactive = () => { + inactivateContact(customerId) + .then(() => { + AppToaster.show({ + message: intl.get('the_contact_has_been_inactivated_successfully'), + intent: Intent.SUCCESS, + }); + }) + .catch((error) => {}) + .finally(() => { + closeAlert(name); + }); + }; + + return ( ++ {intl.get( + 'customer.alert.are_you_sure_want_to_inactivate_this_customer', + )} +
+ + ); +} +export default compose( + withAlertStoreConnect(), + withAlertActions, +)(CustomerInactivateAlert); diff --git a/src/containers/Alerts/Vendors/VendorActivateAlert.js b/src/containers/Alerts/Vendors/VendorActivateAlert.js new file mode 100644 index 000000000..8e48ab34f --- /dev/null +++ b/src/containers/Alerts/Vendors/VendorActivateAlert.js @@ -0,0 +1,69 @@ +import React from 'react'; +import { FormattedMessage as T } from 'components'; +import intl from 'react-intl-universal'; +import { Intent, Alert } from '@blueprintjs/core'; +import { AppToaster } from 'components'; + +import { useActivateContact } from 'hooks/query'; + +import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; +import withAlertActions from 'containers/Alert/withAlertActions'; + +import { compose } from 'utils'; + +/** + * Vendor activate alert. + */ +function VendorActivateAlert({ + name, + + // #withAlertStoreConnect + isOpen, + payload: { vendorId }, + + // #withAlertActions + closeAlert, +}) { + const { mutateAsync: activateContact, isLoading } = useActivateContact(); + + // Handle activate vendor alert cancel. + const handleCancelActivateVendor = () => { + closeAlert(name); + }; + + // Handle confirm vendor activated. + const handleConfirmVendorActivate = () => { + activateContact(vendorId) + .then(() => { + AppToaster.show({ + message: intl.get('vendor.alert.activated_message'), + intent: Intent.SUCCESS, + }); + }) + .catch((error) => {}) + .finally(() => { + closeAlert(name); + }); + }; + + return ( ++ {intl.get('vendor.alert.are_you_sure_want_to_activate_this_vendor')} +
+ + ); +} + +export default compose( + withAlertStoreConnect(), + withAlertActions, +)(VendorActivateAlert); diff --git a/src/containers/Alerts/Vendors/VendorInactivateAlert.js b/src/containers/Alerts/Vendors/VendorInactivateAlert.js new file mode 100644 index 000000000..a5d48358d --- /dev/null +++ b/src/containers/Alerts/Vendors/VendorInactivateAlert.js @@ -0,0 +1,68 @@ +import React from 'react'; +import { FormattedMessage as T } from 'components'; +import intl from 'react-intl-universal'; +import { Intent, Alert } from '@blueprintjs/core'; +import { AppToaster } from 'components'; + +import { useInactivateContact } from 'hooks/query'; + +import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; +import withAlertActions from 'containers/Alert/withAlertActions'; + +import { compose } from 'utils'; + +/** + * Vendor inactivate alert. + */ +function VendorInactivateAlert({ + name, + // #withAlertStoreConnect + isOpen, + payload: { vendorId }, + + // #withAlertActions + closeAlert, +}) { + const { mutateAsync: inactivateContact, isLoading } = useInactivateContact(); + + // Handle cancel inactivate alert. + const handleCancelInactivateVendor = () => { + closeAlert(name); + }; + + // Handle confirm contact Inactive. + const handleConfirmVendorInactive = () => { + inactivateContact(vendorId) + .then(() => { + AppToaster.show({ + message: intl.get('vendor.alert.inactivated_message'), + intent: Intent.SUCCESS, + }); + }) + .catch((error) => {}) + .finally(() => { + closeAlert(name); + }); + }; + + return ( ++ {intl.get('vendor.alert.are_you_sure_want_to_inactivate_this_vendor')} +
+ + ); +} + +export default compose( + withAlertStoreConnect(), + withAlertActions, +)(VendorInactivateAlert); diff --git a/src/containers/Customers/CustomersAlerts.js b/src/containers/Customers/CustomersAlerts.js index a7bab20eb..7cd902d21 100644 --- a/src/containers/Customers/CustomersAlerts.js +++ b/src/containers/Customers/CustomersAlerts.js @@ -3,11 +3,11 @@ import React from 'react'; const CustomerDeleteAlert = React.lazy(() => import('../Alerts/Customers/CustomerDeleteAlert'), ); -const ContactActivateAlert = React.lazy(() => - import('../Alerts/Contacts/ContactActivateAlert'), +const CustomerActivateAlert = React.lazy(() => + import('../Alerts/Customers/CustomerActivateAlert'), ); -const ContactInactivateAlert = React.lazy(() => - import('../Alerts/Contacts/ContactInactivateAlert'), +const CustomerInactivateAlert = React.lazy(() => + import('../Alerts/Customers/CustomerInactivateAlert'), ); /** @@ -15,6 +15,6 @@ const ContactInactivateAlert = React.lazy(() => */ export default [ { name: 'customer-delete', component: CustomerDeleteAlert }, - { name: 'contact-activate', component: ContactActivateAlert }, - { name: 'contact-inactivate', component: ContactInactivateAlert }, + { name: 'customer-activate', component: CustomerActivateAlert }, + { name: 'customer-inactivate', component: CustomerInactivateAlert }, ]; diff --git a/src/containers/Customers/CustomersLanding/CustomersTable.js b/src/containers/Customers/CustomersLanding/CustomersTable.js index 7619936ac..9618ba4cf 100644 --- a/src/containers/Customers/CustomersLanding/CustomersTable.js +++ b/src/containers/Customers/CustomersLanding/CustomersTable.js @@ -89,15 +89,17 @@ function CustomersTable({ // Handle cancel/confirm inactive. const handleInactiveCustomer = ({ id, contact_service }) => { - openAlert('contact-inactivate', { - contactId: id, - service: contact_service, + openAlert('customer-inactivate', { + customerId: id, }); }; // Handle cancel/confirm activate. const handleActivateCustomer = ({ id, contact_service }) => { - openAlert('contact-activate', { contactId: id, service: contact_service }); + openAlert('customer-activate', { + customerId: id, + service: contact_service, + }); }; // Handle view detail contact. diff --git a/src/containers/Vendors/VendorsAlerts.js b/src/containers/Vendors/VendorsAlerts.js index 8c845e725..93714e3e8 100644 --- a/src/containers/Vendors/VendorsAlerts.js +++ b/src/containers/Vendors/VendorsAlerts.js @@ -3,15 +3,15 @@ import React from 'react'; const VendorDeleteAlert = React.lazy(() => import('../Alerts/Vendors/VendorDeleteAlert'), ); -const ContactActivateAlert = React.lazy(() => - import('../Alerts/Contacts/ContactActivateAlert'), +const VendorActivateAlert = React.lazy(() => + import('../Alerts/Vendors/VendorActivateAlert'), ); -const ContactInactivateAlert = React.lazy(() => - import('../Alerts/Contacts/ContactInactivateAlert'), +const VendorInactivateAlert = React.lazy(() => + import('../Alerts/Vendors/VendorInactivateAlert'), ); export default [ { name: 'vendor-delete', component: VendorDeleteAlert }, - { name: 'contact-activate', component: ContactActivateAlert }, - { name: 'contact-inactivate', component: ContactInactivateAlert }, + { name: 'vendor-activate', component: VendorActivateAlert }, + { name: 'vendor-inactivate', component: VendorInactivateAlert }, ]; diff --git a/src/containers/Vendors/VendorsLanding/VendorsTable.js b/src/containers/Vendors/VendorsLanding/VendorsTable.js index fc117d291..c57114864 100644 --- a/src/containers/Vendors/VendorsLanding/VendorsTable.js +++ b/src/containers/Vendors/VendorsLanding/VendorsTable.js @@ -67,15 +67,15 @@ function VendorsTable({ // Handle cancel/confirm inactive. const handleInactiveVendor = ({ id, contact_service }) => { - openAlert('contact-inactivate', { - contactId: id, + openAlert('vendor-inactivate', { + vendorId: id, service: contact_service, }); }; - // Handle cancel/confirm activate. + // Handle cancel/confirm activate. const handleActivateVendor = ({ id, contact_service }) => { - openAlert('contact-activate', { contactId: id, service: contact_service }); + openAlert('vendor-activate', { vendorId: id, service: contact_service }); }; // Handle click delete vendor. diff --git a/src/lang/ar/index.json b/src/lang/ar/index.json index e40e67091..e293d9e3c 100644 --- a/src/lang/ar/index.json +++ b/src/lang/ar/index.json @@ -1757,5 +1757,15 @@ "global_error.you_dont_have_permissions": "ليس لديك صلاحية الوصول إلى هذه الصفحة.", "global_error.transactions_locked": "تم قفل المعاملات التي تمت قبل {lockedToDate}. ومن ثم لا يمكن القيام بأي عمل.", - "global_error.authorized_user_inactive": "المستخدم المصرح له تم تعطيلة." -} \ No newline at end of file + "global_error.authorized_user_inactive": "المستخدم المصرح له تم تعطيلة.", + + "vendor.alert.activated_message": "تم تفعيل المورد بنجاح.", + "vendor.alert.are_you_sure_want_to_activate_this_vendor": "هل أنت متأكد أنك تريد تفعيل هذا المورد؟ ستتمكن من تعطيله لاحقًا", + "vendor.alert.inactivated_message": "تم إلغاء تنشيط المورد بنجاح.", + "vendor.alert.are_you_sure_want_to_inactivate_this_vendor":"هل أنت متأكد أنك تريد إلغاء تنشيط هذا المورد؟ ستكون قادرًا على تنشيطه لاحقًا", + + "customer.alert.activated_message":"تم تفعيل الزبون بنجاح.", + "customer.alert.are_you_sure_want_to_activate_this_customer": "هل أنت متأكد أنك تريد تفعيل هذا الزبون؟ ستتمكن من تعطيله لاحقًا", + "customer.alert.inactivated_message": "تم إلغاء تنشيط الزبون بنجاح.", + "customer.alert.are_you_sure_want_to_inactivate_this_customer":"هل أنت متأكد أنك تريد إلغاء تنشيط هذا الزبون؟ ستكون قادرًا على تنشيطه لاحقًا" +} diff --git a/src/lang/en/index.json b/src/lang/en/index.json index 51cc47d1d..0183c97e2 100644 --- a/src/lang/en/index.json +++ b/src/lang/en/index.json @@ -1734,8 +1734,17 @@ "payment_made.drawer.title": "Payment made details {number}", "manual_journal.drawer.title": "Manual journal details ({number})", "expense.drawer.title": "Expense details", - "global_error.you_dont_have_permissions": "You do not have permissions to access this page.", "global_error.transactions_locked": "Transactions before {lockedToDate} has been locked. Hence action cannot be performed.", - "global_error.authorized_user_inactive": "The authorized user is inactive." + "global_error.authorized_user_inactive": "The authorized user is inactive.", + "the_vendor_has_been_inactivated_successfully": "The contact has been inactivated successfully.", + "vendor.alert.activated_message": "The vendor has been activated successfully.", + "vendor.alert.are_you_sure_want_to_inactivate_this_vendor":"Are you sure want to inactivate this vendor? You will to able to activate it later.", + "vendor.alert.inactivated_message": "The vendor has been inactivated successfully.", + "vendor.alert.are_you_sure_want_to_activate_this_vendor": "Are you sure want to activate this vendor? You will to able to inactivate it later.", + + "customer.alert.activated_message":"The customer has been activated successfully.", + "customer.alert.are_you_sure_want_to_activate_this_customer": "Are you sure want to activate this customer? You will to able to inactivate it later.", + "customer.alert.inactivated_message": "The customer has been inactivated successfully.", + "customer.alert.are_you_sure_want_to_inactivate_this_customer":"Are you sure want to inactivate this customer? You will to able to activate it later." } \ No newline at end of file