mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40: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(() =>
|
const CustomerDeleteAlert = React.lazy(() =>
|
||||||
import('../Alerts/Customers/CustomerDeleteAlert'),
|
import('../Alerts/Customers/CustomerDeleteAlert'),
|
||||||
);
|
);
|
||||||
const ContactActivateAlert = React.lazy(() =>
|
const CustomerActivateAlert = React.lazy(() =>
|
||||||
import('../Alerts/Contacts/ContactActivateAlert'),
|
import('../Alerts/Customers/CustomerActivateAlert'),
|
||||||
);
|
);
|
||||||
const ContactInactivateAlert = React.lazy(() =>
|
const CustomerInactivateAlert = React.lazy(() =>
|
||||||
import('../Alerts/Contacts/ContactInactivateAlert'),
|
import('../Alerts/Customers/CustomerInactivateAlert'),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,6 +15,6 @@ const ContactInactivateAlert = React.lazy(() =>
|
|||||||
*/
|
*/
|
||||||
export default [
|
export default [
|
||||||
{ name: 'customer-delete', component: CustomerDeleteAlert },
|
{ name: 'customer-delete', component: CustomerDeleteAlert },
|
||||||
{ name: 'contact-activate', component: ContactActivateAlert },
|
{ name: 'customer-activate', component: CustomerActivateAlert },
|
||||||
{ name: 'contact-inactivate', component: ContactInactivateAlert },
|
{ name: 'customer-inactivate', component: CustomerInactivateAlert },
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -89,15 +89,17 @@ function CustomersTable({
|
|||||||
|
|
||||||
// Handle cancel/confirm inactive.
|
// Handle cancel/confirm inactive.
|
||||||
const handleInactiveCustomer = ({ id, contact_service }) => {
|
const handleInactiveCustomer = ({ id, contact_service }) => {
|
||||||
openAlert('contact-inactivate', {
|
openAlert('customer-inactivate', {
|
||||||
contactId: id,
|
customerId: id,
|
||||||
service: contact_service,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle cancel/confirm activate.
|
// Handle cancel/confirm activate.
|
||||||
const handleActivateCustomer = ({ id, contact_service }) => {
|
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.
|
// Handle view detail contact.
|
||||||
|
|||||||
@@ -3,15 +3,15 @@ import React from 'react';
|
|||||||
const VendorDeleteAlert = React.lazy(() =>
|
const VendorDeleteAlert = React.lazy(() =>
|
||||||
import('../Alerts/Vendors/VendorDeleteAlert'),
|
import('../Alerts/Vendors/VendorDeleteAlert'),
|
||||||
);
|
);
|
||||||
const ContactActivateAlert = React.lazy(() =>
|
const VendorActivateAlert = React.lazy(() =>
|
||||||
import('../Alerts/Contacts/ContactActivateAlert'),
|
import('../Alerts/Vendors/VendorActivateAlert'),
|
||||||
);
|
);
|
||||||
const ContactInactivateAlert = React.lazy(() =>
|
const VendorInactivateAlert = React.lazy(() =>
|
||||||
import('../Alerts/Contacts/ContactInactivateAlert'),
|
import('../Alerts/Vendors/VendorInactivateAlert'),
|
||||||
);
|
);
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{ name: 'vendor-delete', component: VendorDeleteAlert },
|
{ name: 'vendor-delete', component: VendorDeleteAlert },
|
||||||
{ name: 'contact-activate', component: ContactActivateAlert },
|
{ name: 'vendor-activate', component: VendorActivateAlert },
|
||||||
{ name: 'contact-inactivate', component: ContactInactivateAlert },
|
{ name: 'vendor-inactivate', component: VendorInactivateAlert },
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -67,15 +67,15 @@ function VendorsTable({
|
|||||||
|
|
||||||
// Handle cancel/confirm inactive.
|
// Handle cancel/confirm inactive.
|
||||||
const handleInactiveVendor = ({ id, contact_service }) => {
|
const handleInactiveVendor = ({ id, contact_service }) => {
|
||||||
openAlert('contact-inactivate', {
|
openAlert('vendor-inactivate', {
|
||||||
contactId: id,
|
vendorId: id,
|
||||||
service: contact_service,
|
service: contact_service,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handle cancel/confirm activate.
|
// Handle cancel/confirm activate.
|
||||||
const handleActivateVendor = ({ id, contact_service }) => {
|
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.
|
// Handle click delete vendor.
|
||||||
|
|||||||
@@ -1757,5 +1757,15 @@
|
|||||||
|
|
||||||
"global_error.you_dont_have_permissions": "ليس لديك صلاحية الوصول إلى هذه الصفحة.",
|
"global_error.you_dont_have_permissions": "ليس لديك صلاحية الوصول إلى هذه الصفحة.",
|
||||||
"global_error.transactions_locked": "تم قفل المعاملات التي تمت قبل {lockedToDate}. ومن ثم لا يمكن القيام بأي عمل.",
|
"global_error.transactions_locked": "تم قفل المعاملات التي تمت قبل {lockedToDate}. ومن ثم لا يمكن القيام بأي عمل.",
|
||||||
"global_error.authorized_user_inactive": "المستخدم المصرح له تم تعطيلة."
|
"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":"هل أنت متأكد أنك تريد إلغاء تنشيط هذا الزبون؟ ستكون قادرًا على تنشيطه لاحقًا"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1734,8 +1734,17 @@
|
|||||||
"payment_made.drawer.title": "Payment made details {number}",
|
"payment_made.drawer.title": "Payment made details {number}",
|
||||||
"manual_journal.drawer.title": "Manual journal details ({number})",
|
"manual_journal.drawer.title": "Manual journal details ({number})",
|
||||||
"expense.drawer.title": "Expense details",
|
"expense.drawer.title": "Expense details",
|
||||||
|
|
||||||
"global_error.you_dont_have_permissions": "You do not have permissions to access this page.",
|
"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.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."
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user