diff --git a/client/src/containers/Alerts/Contacts/ContactActivateAlert.js b/client/src/containers/Alerts/Contacts/ContactActivateAlert.js new file mode 100644 index 000000000..965ed7384 --- /dev/null +++ b/client/src/containers/Alerts/Contacts/ContactActivateAlert.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'; + +/** + * Contact activate alert. + */ +function ContactActivateAlert({ + name, + + // #withAlertStoreConnect + isOpen, + payload: { contactId, service }, + + // #withAlertActions + closeAlert, +}) { + const { mutateAsync: activateContact, isLoading } = useActivateContact(); + + // Handle activate contact alert cancel. + const handleCancelActivateContact = () => { + closeAlert(name); + }; + + // Handle confirm contact activated. + const handleConfirmContactActivate = () => { + activateContact(contactId) + .then(() => { + AppToaster.show({ + message: intl.get('the_contact_has_been_activated_successfully'), + intent: Intent.SUCCESS, + }); + }) + .catch((error) => {}) + .finally(() => { + closeAlert(name); + }); + }; + + return ( + } + confirmButtonText={} + intent={Intent.WARNING} + isOpen={isOpen} + onCancel={handleCancelActivateContact} + loading={isLoading} + onConfirm={handleConfirmContactActivate} + > +

{intl.get('are_sure_to_activate_this_contact')}

+
+ ); +} + +export default compose( + withAlertStoreConnect(), + withAlertActions, +)(ContactActivateAlert); diff --git a/client/src/containers/Alerts/Contacts/ContactInactivateAlert.js b/client/src/containers/Alerts/Contacts/ContactInactivateAlert.js new file mode 100644 index 000000000..d0961c424 --- /dev/null +++ b/client/src/containers/Alerts/Contacts/ContactInactivateAlert.js @@ -0,0 +1,70 @@ +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'; + +/** + * Contact inactivate alert. + */ +function ContactInactivateAlert({ + name, + // #withAlertStoreConnect + isOpen, + payload: { contactId, service }, + + // #withAlertActions + closeAlert, +}) { + const { mutateAsync: inactivateContact, isLoading } = useInactivateContact(); + + // Handle cancel inactivate alert. + const handleCancelInactivateContact = () => { + closeAlert(name); + }; + + // Handle confirm contact Inactive. + const handleConfirmContactInactive = () => { + inactivateContact(contactId) + .then(() => { + AppToaster.show({ + message: intl.get('the_contact_has_been_inactivated_successfully'), + intent: Intent.SUCCESS, + }); + }) + .catch((error) => {}) + .finally(() => { + closeAlert(name); + }); + }; + + return ( + } + confirmButtonText={} + intent={Intent.WARNING} + isOpen={isOpen} + onCancel={handleCancelInactivateContact} + onConfirm={handleConfirmContactInactive} + loading={isLoading} + > +

+ {intl.get('are_sure_to_inactive_this_contact', { + name: service, + })} +

+
+ ); +} + +export default compose( + withAlertStoreConnect(), + withAlertActions, +)(ContactInactivateAlert); diff --git a/client/src/containers/Alerts/Items/InventoryAdjustmentPublishAlert.js b/client/src/containers/Alerts/Items/InventoryAdjustmentPublishAlert.js new file mode 100644 index 000000000..da9fecaf9 --- /dev/null +++ b/client/src/containers/Alerts/Items/InventoryAdjustmentPublishAlert.js @@ -0,0 +1,71 @@ +import React from 'react'; +import { Intent, Alert } from '@blueprintjs/core'; +import { FormattedMessage as T } from 'components'; +import intl from 'react-intl-universal'; +import { usePublishInventoryAdjustment } from 'hooks/query'; + +import { AppToaster } from 'components'; + +import withAlertActions from 'containers/Alert/withAlertActions'; +import withAlertStoreConnect from 'containers/Alert/withAlertStoreConnect'; + +import { compose } from 'utils'; + +/** + * Inventory Adjustment publish alert. + */ + +function InventoryAdjustmentPublishAlert({ + name, + + // #withAlertStoreConnect + isOpen, + payload: { inventoryId }, + + // #withAlertActions + closeAlert, +}) { + const { mutateAsync: publishInventoryAdjustmentMutate, isLoading } = + usePublishInventoryAdjustment(); + + // Handle cancel inventory adjustment alert. + const handleCancelPublish = () => { + closeAlert(name); + }; + + // Handle publish inventory adjustment confirm. + const handleConfirmPublish = () => { + publishInventoryAdjustmentMutate(inventoryId) + .then(() => { + AppToaster.show({ + message: intl.get('the_inventory_adjustment_has_been_published'), + intent: Intent.SUCCESS, + }); + closeAlert(name); + }) + .catch((error) => { + closeAlert(name); + }); + }; + + return ( + } + confirmButtonText={} + intent={Intent.WARNING} + isOpen={isOpen} + onCancel={handleCancelPublish} + onConfirm={handleConfirmPublish} + loading={isLoading} + > +

+ +

+
+ ); +} + +export default compose( + withAlertStoreConnect(), + withAlertActions, +)(InventoryAdjustmentPublishAlert); diff --git a/client/src/containers/Customers/CustomersAlerts.js b/client/src/containers/Customers/CustomersAlerts.js index d56acb26c..6a51cd7a0 100644 --- a/client/src/containers/Customers/CustomersAlerts.js +++ b/client/src/containers/Customers/CustomersAlerts.js @@ -1,6 +1,8 @@ import React from 'react'; import CustomerDeleteAlert from 'containers/Alerts/Customers/CustomerDeleteAlert'; // import CustomerBulkDeleteAlert from 'containers/Alerts/Customers/CustomerBulkDeleteAlert'; +import ContactActivateAlert from '../../containers/Alerts/Contacts/ContactActivateAlert'; +import ContactInactivateAlert from '../../containers/Alerts/Contacts/ContactInactivateAlert'; /** * Customers alert. @@ -9,6 +11,8 @@ export default function ItemsAlerts() { return (
+ + {/* */}
); diff --git a/client/src/containers/Customers/CustomersLanding/CustomersTable.js b/client/src/containers/Customers/CustomersLanding/CustomersTable.js index 817718599..cef76a13a 100644 --- a/client/src/containers/Customers/CustomersLanding/CustomersTable.js +++ b/client/src/containers/Customers/CustomersLanding/CustomersTable.js @@ -72,6 +72,19 @@ function CustomersTable({ openDialog('contact-duplicate', { contactId: id }); }; + // Handle cancel/confirm inactive. + const handleInactiveCustomer = ({ id, contact_service }) => { + openAlert('contact-inactivate', { + contactId: id, + service: contact_service, + }); + }; + + // Handle cancel/confirm activate. + const handleActivateCustomer = ({ id, contact_service }) => { + openAlert('contact-activate', { contactId: id, service: contact_service }); + }; + if (isEmptyStatus) { return ; } @@ -102,6 +115,8 @@ function CustomersTable({ onDelete: handleCustomerDelete, onEdit: handleCustomerEdit, onDuplicate: handleContactDuplicate, + onInactivate: handleInactiveCustomer, + onActivate: handleActivateCustomer, }} ContextMenu={ActionsMenu} /> diff --git a/client/src/containers/Customers/CustomersLanding/components.js b/client/src/containers/Customers/CustomersLanding/components.js index 33f070b38..8180b0ac2 100644 --- a/client/src/containers/Customers/CustomersLanding/components.js +++ b/client/src/containers/Customers/CustomersLanding/components.js @@ -8,7 +8,7 @@ import { Position, Intent, } from '@blueprintjs/core'; -import { Icon, Money } from 'components'; +import { Icon, Money, If } from 'components'; import { safeCallback } from 'utils'; import { firstLettersArgs } from 'utils'; import intl from 'react-intl-universal'; @@ -18,10 +18,8 @@ import intl from 'react-intl-universal'; */ export function ActionsMenu({ row: { original }, - payload: { onEdit, onDelete, onDuplicate }, + payload: { onEdit, onDelete, onDuplicate, onInactivate, onActivate }, }) { - - return ( + + } + onClick={safeCallback(onInactivate, original)} + /> + + + } + onClick={safeCallback(onActivate, original)} + /> + } text={intl.get('delete_customer')} @@ -74,8 +86,6 @@ export function BalanceAccessor(row) { * Retrieve customers table columns. */ export function useCustomersTableColumns() { - - return useMemo( () => [ { diff --git a/client/src/containers/InventoryAdjustments/InventoryAdjustmentTable.js b/client/src/containers/InventoryAdjustments/InventoryAdjustmentTable.js index 52cb0a08a..29662c98a 100644 --- a/client/src/containers/InventoryAdjustments/InventoryAdjustmentTable.js +++ b/client/src/containers/InventoryAdjustments/InventoryAdjustmentTable.js @@ -39,6 +39,11 @@ function InventoryAdjustmentDataTable({ openAlert('inventory-adjustment-delete', { inventoryId: id }); }; + // Handle the inventory adjustment publish action. + const handlePublishInventoryAdjustment = ({ id }) => { + openAlert('inventory-adjustment-publish', { inventoryId: id }); + }; + // Inventory adjustments columns. const columns = useInventoryAdjustmentsColumns(); @@ -72,6 +77,7 @@ function InventoryAdjustmentDataTable({ autoResetPage={false} payload={{ onDelete: handleDeleteAdjustment, + onPublish: handlePublishInventoryAdjustment, }} ContextMenu={ActionsMenu} noResults={intl.get('there_is_no_inventory_adjustments_transactions_yet')} diff --git a/client/src/containers/InventoryAdjustments/InventoryAdjustmentsAlerts.js b/client/src/containers/InventoryAdjustments/InventoryAdjustmentsAlerts.js index 87cb3f31f..cacdd8b36 100644 --- a/client/src/containers/InventoryAdjustments/InventoryAdjustmentsAlerts.js +++ b/client/src/containers/InventoryAdjustments/InventoryAdjustmentsAlerts.js @@ -1,10 +1,12 @@ import React from 'react'; import InventoryAdjustmentDeleteAlert from 'containers/Alerts/Items/InventoryAdjustmentDeleteAlert'; +import InventoryAdjustmentPublishAlert from 'containers/Alerts/Items/InventoryAdjustmentPublishAlert'; export default function InventoryAdjustmentsAlerts() { return (
+
); } diff --git a/client/src/containers/InventoryAdjustments/components.js b/client/src/containers/InventoryAdjustments/components.js index c21514ce0..d2aeee4e2 100644 --- a/client/src/containers/InventoryAdjustments/components.js +++ b/client/src/containers/InventoryAdjustments/components.js @@ -12,7 +12,7 @@ import { import intl from 'react-intl-universal'; import moment from 'moment'; -import { FormattedMessage as T } from 'components'; +import { FormattedMessage as T } from 'components'; import { isNumber } from 'lodash'; import { Icon, Money, If } from 'components'; import { isBlank, safeCallback } from 'utils'; @@ -93,7 +93,7 @@ export const ItemTypeAccessor = (row) => { export const ActionsMenu = ({ row: { original }, - payload: { onDelete }, + payload: { onDelete, onPublish }, }) => { return ( @@ -102,6 +102,13 @@ export const ActionsMenu = ({ text={intl.get('view_details')} /> + + } + text={intl.get('publish_expense')} + onClick={safeCallback(onPublish, original)} + /> + { - return (} - position={Position.RIGHT_BOTTOM} - > -