mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
BIG-277 Separate customer and vendor.
This commit is contained in:
67
src/containers/Alerts/Customers/CustomerActivateAlert.js
Normal file
67
src/containers/Alerts/Customers/CustomerActivateAlert.js
Normal file
@@ -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 (
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={<T id={'activate'} />}
|
||||
intent={Intent.WARNING}
|
||||
isOpen={isOpen}
|
||||
onCancel={handleCancelActivateCustomer}
|
||||
loading={isLoading}
|
||||
onConfirm={handleConfirmCustomerActivate}
|
||||
>
|
||||
<p>{intl.get('customer.alert.are_you_sure_want_to_activate_this_customer')}</p>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withAlertStoreConnect(),
|
||||
withAlertActions,
|
||||
)(CustomerActivateAlert);
|
||||
69
src/containers/Alerts/Customers/CustomerInactivateAlert.js
Normal file
69
src/containers/Alerts/Customers/CustomerInactivateAlert.js
Normal file
@@ -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 (
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={<T id={'inactivate'} />}
|
||||
intent={Intent.WARNING}
|
||||
isOpen={isOpen}
|
||||
onCancel={handleCancelInactivateCustomer}
|
||||
onConfirm={handleConfirmCustomerInactive}
|
||||
loading={isLoading}
|
||||
>
|
||||
<p>
|
||||
{intl.get(
|
||||
'customer.alert.are_you_sure_want_to_inactivate_this_customer',
|
||||
)}
|
||||
</p>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
export default compose(
|
||||
withAlertStoreConnect(),
|
||||
withAlertActions,
|
||||
)(CustomerInactivateAlert);
|
||||
69
src/containers/Alerts/Vendors/VendorActivateAlert.js
Normal file
69
src/containers/Alerts/Vendors/VendorActivateAlert.js
Normal file
@@ -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 (
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={<T id={'activate'} />}
|
||||
intent={Intent.WARNING}
|
||||
isOpen={isOpen}
|
||||
onCancel={handleCancelActivateVendor}
|
||||
loading={isLoading}
|
||||
onConfirm={handleConfirmVendorActivate}
|
||||
>
|
||||
<p>
|
||||
{intl.get('vendor.alert.are_you_sure_want_to_activate_this_vendor')}
|
||||
</p>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withAlertStoreConnect(),
|
||||
withAlertActions,
|
||||
)(VendorActivateAlert);
|
||||
68
src/containers/Alerts/Vendors/VendorInactivateAlert.js
Normal file
68
src/containers/Alerts/Vendors/VendorInactivateAlert.js
Normal file
@@ -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 (
|
||||
<Alert
|
||||
cancelButtonText={<T id={'cancel'} />}
|
||||
confirmButtonText={<T id={'inactivate'} />}
|
||||
intent={Intent.WARNING}
|
||||
isOpen={isOpen}
|
||||
onCancel={handleCancelInactivateVendor}
|
||||
onConfirm={handleConfirmVendorInactive}
|
||||
loading={isLoading}
|
||||
>
|
||||
<p>
|
||||
{intl.get('vendor.alert.are_you_sure_want_to_inactivate_this_vendor')}
|
||||
</p>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withAlertStoreConnect(),
|
||||
withAlertActions,
|
||||
)(VendorInactivateAlert);
|
||||
@@ -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 },
|
||||
];
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 },
|
||||
];
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user