mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-21 07:10:33 +00:00
Merge branch 'feature/notify-via-SMS' of https://github.com/bigcapitalhq/client into feature/notify-via-SMS
This commit is contained in:
@@ -41,12 +41,14 @@ function NotifyEstimateViaSMSForm({
|
|||||||
data: { errors },
|
data: { errors },
|
||||||
},
|
},
|
||||||
}) => {
|
}) => {
|
||||||
transformErrors(errors);
|
if (errors) {
|
||||||
|
transformErrors(errors, { setErrors });
|
||||||
|
}
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
};
|
};
|
||||||
createNotifyEstimateBySMSMutate([estimateId, values])
|
createNotifyEstimateBySMSMutate([estimateId, values])
|
||||||
.then(onSuccess)
|
.then(onSuccess)
|
||||||
.then(onError);
|
.catch(onError);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -53,7 +53,9 @@ function NotifyInvoiceViaSMSForm({
|
|||||||
data: { errors },
|
data: { errors },
|
||||||
},
|
},
|
||||||
}) => {
|
}) => {
|
||||||
transformErrors(errors);
|
if (errors) {
|
||||||
|
transformErrors(errors, { setErrors });
|
||||||
|
}
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
};
|
};
|
||||||
// Transformes the form values to request.
|
// Transformes the form values to request.
|
||||||
|
|||||||
@@ -44,7 +44,10 @@ function NotifyPaymentReceiveViaSMSForm({
|
|||||||
data: { errors },
|
data: { errors },
|
||||||
},
|
},
|
||||||
}) => {
|
}) => {
|
||||||
transformErrors(errors);
|
if (errors) {
|
||||||
|
transformErrors(errors, { setErrors });
|
||||||
|
}
|
||||||
|
setSubmitting(false);
|
||||||
};
|
};
|
||||||
createNotifyPaymentReceivetBySMSMutate([paymentReceiveId, values])
|
createNotifyPaymentReceivetBySMSMutate([paymentReceiveId, values])
|
||||||
.then(onSuccess)
|
.then(onSuccess)
|
||||||
|
|||||||
@@ -42,7 +42,10 @@ function NotifyReceiptViaSMSForm({
|
|||||||
data: { errors },
|
data: { errors },
|
||||||
},
|
},
|
||||||
}) => {
|
}) => {
|
||||||
transformErrors(errors);
|
if (errors) {
|
||||||
|
transformErrors(errors, { setErrors });
|
||||||
|
}
|
||||||
|
setSubmitting(false);
|
||||||
};
|
};
|
||||||
createNotifyReceiptBySMSMutate([receiptId, values])
|
createNotifyReceiptBySMSMutate([receiptId, values])
|
||||||
.then(onSuccess)
|
.then(onSuccess)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { AppToaster } from 'components';
|
|||||||
import SMSMessageFormContent from './SMSMessageFormContent';
|
import SMSMessageFormContent from './SMSMessageFormContent';
|
||||||
import { CreateSMSMessageFormSchema } from './SMSMessageForm.schema';
|
import { CreateSMSMessageFormSchema } from './SMSMessageForm.schema';
|
||||||
import { useSMSMessageDialogContext } from './SMSMessageDialogProvider';
|
import { useSMSMessageDialogContext } from './SMSMessageDialogProvider';
|
||||||
|
import { transformErrors } from './utils';
|
||||||
|
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
|
|
||||||
@@ -58,6 +59,9 @@ function SMSMessageForm({
|
|||||||
data: { errors },
|
data: { errors },
|
||||||
},
|
},
|
||||||
}) => {
|
}) => {
|
||||||
|
if (errors) {
|
||||||
|
transformErrors(errors, { setErrors });
|
||||||
|
}
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
};
|
};
|
||||||
debugger;
|
debugger;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ function SMSMessageDialog({
|
|||||||
return (
|
return (
|
||||||
<Dialog
|
<Dialog
|
||||||
name={dialogName}
|
name={dialogName}
|
||||||
title={intl.get('sms_message')}
|
title={intl.get('sms_message.dialog.label')}
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
canEscapeJeyClose={true}
|
canEscapeJeyClose={true}
|
||||||
autoFocus={true}
|
autoFocus={true}
|
||||||
|
|||||||
15
src/containers/Dialogs/SMSMessageDialog/utils.js
Normal file
15
src/containers/Dialogs/SMSMessageDialog/utils.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { Intent } from '@blueprintjs/core';
|
||||||
|
import { AppToaster } from 'components';
|
||||||
|
import intl from 'react-intl-universal';
|
||||||
|
|
||||||
|
export const transformErrors = (errors, { setErrors }) => {
|
||||||
|
if (
|
||||||
|
errors.find((error) => error.type === 'UNSUPPORTED_SMS_MESSAGE_VARIABLES')
|
||||||
|
) {
|
||||||
|
setErrors({
|
||||||
|
message_text: intl.get(
|
||||||
|
'sms_message.dialog.unsupported_variables_error_message',
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -2,13 +2,21 @@ import { Intent } from '@blueprintjs/core';
|
|||||||
import { AppToaster } from 'components';
|
import { AppToaster } from 'components';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
|
|
||||||
export const transformErrors = (errors) => {
|
export const transformErrors = (errors, { setErrors }) => {
|
||||||
if (errors.some((e) => e.type === 'CUSTOMER_SMS_NOTIFY_PHONE_INVALID')) {
|
if (errors.some((e) => e.type === 'CUSTOMER_SMS_NOTIFY_PHONE_INVALID')) {
|
||||||
AppToaster.show({
|
AppToaster.show({
|
||||||
message: intl.get('notify_via_sms.dialog.error_message'),
|
message: intl.get('notify_via_sms.dialog.error_message'),
|
||||||
intent: Intent.DANGER,
|
intent: Intent.DANGER,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (errors.find((error) => error.type === 'CUSTOMER_HAS_NO_PHONE_NUMBER')) {
|
||||||
|
setErrors({
|
||||||
|
customer_phone_number: intl.get(
|
||||||
|
'notify_via_sms.dialog.customer_no_phone_error_message',
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import styled from 'styled-components';
|
|||||||
import { DataTable } from 'components';
|
import { DataTable } from 'components';
|
||||||
import TableSkeletonRows from 'components/Datatable/TableSkeletonRows';
|
import TableSkeletonRows from 'components/Datatable/TableSkeletonRows';
|
||||||
|
|
||||||
import { useSMSIntegrationTableColumns } from './components';
|
import { useSMSIntegrationTableColumns, ActionsMenu } from './components';
|
||||||
import { useSMSIntegrationContext } from './SMSIntegrationProvider';
|
import { useSMSIntegrationContext } from './SMSIntegrationProvider';
|
||||||
|
|
||||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||||
@@ -20,10 +20,12 @@ function SMSMessagesDataTable({
|
|||||||
const { notifications, isSMSNotificationsLoading } =
|
const { notifications, isSMSNotificationsLoading } =
|
||||||
useSMSIntegrationContext();
|
useSMSIntegrationContext();
|
||||||
|
|
||||||
const handleEditSMSMessage = ({ key }) => {
|
const handleEditMessageText = ({ key }) => {
|
||||||
openDialog('sms-message-form', { notificationkey: key });
|
openDialog('sms-message-form', { notificationkey: key });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleEnableNotification = () => {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SMSNotificationsTable
|
<SMSNotificationsTable
|
||||||
columns={columns}
|
columns={columns}
|
||||||
@@ -32,8 +34,10 @@ function SMSMessagesDataTable({
|
|||||||
progressBarLoading={isSMSNotificationsLoading}
|
progressBarLoading={isSMSNotificationsLoading}
|
||||||
TableLoadingRenderer={TableSkeletonRows}
|
TableLoadingRenderer={TableSkeletonRows}
|
||||||
noInitialFetch={true}
|
noInitialFetch={true}
|
||||||
|
ContextMenu={ActionsMenu}
|
||||||
payload={{
|
payload={{
|
||||||
onEditSMSMessage: handleEditSMSMessage,
|
onEditMessageText: handleEditMessageText,
|
||||||
|
onEnableNotification: handleEnableNotification,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import { Menu, MenuItem } from '@blueprintjs/core';
|
||||||
|
|
||||||
import { ButtonLink } from 'components';
|
import { ButtonLink } from 'components';
|
||||||
import { SwitchFieldCell } from 'components/DataTableCells';
|
import { SwitchFieldCell } from 'components/DataTableCells';
|
||||||
@@ -24,19 +25,40 @@ export const NotificationAccessor = (row) => {
|
|||||||
* SMS notification message cell.
|
* SMS notification message cell.
|
||||||
*/
|
*/
|
||||||
export const SMSMessageCell = ({
|
export const SMSMessageCell = ({
|
||||||
payload: { onEditSMSMessage },
|
payload: { onEditMessageText },
|
||||||
row: { original },
|
row: { original },
|
||||||
}) => (
|
}) => (
|
||||||
<div>
|
<div>
|
||||||
<MessageBox>{original.sms_message}</MessageBox>
|
<MessageBox>{original.sms_message}</MessageBox>
|
||||||
<MessageBoxActions>
|
<MessageBoxActions>
|
||||||
<ButtonLink onClick={() => safeInvoke(onEditSMSMessage, original)}>
|
<ButtonLink onClick={() => safeInvoke(onEditMessageText, original)}>
|
||||||
Edit message
|
Edit message
|
||||||
</ButtonLink>
|
</ButtonLink>
|
||||||
</MessageBoxActions>
|
</MessageBoxActions>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Context menu of SMS notification messages.
|
||||||
|
*/
|
||||||
|
export function ActionsMenu({
|
||||||
|
payload: { onEditMessageText, onEnableNotification },
|
||||||
|
row: { original },
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<Menu>
|
||||||
|
<MenuItem
|
||||||
|
text={intl.get('edit_message_text')}
|
||||||
|
onClick={safeInvoke(onEditMessageText, original)}
|
||||||
|
/>
|
||||||
|
<MenuItem
|
||||||
|
text={intl.get('enable_notification')}
|
||||||
|
onClick={safeInvoke(onEnableNotification, original)}
|
||||||
|
/>
|
||||||
|
</Menu>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve SMS notifications messages table columns
|
* Retrieve SMS notifications messages table columns
|
||||||
* @returns
|
* @returns
|
||||||
@@ -49,12 +71,14 @@ export function useSMSIntegrationTableColumns() {
|
|||||||
accessor: NotificationAccessor,
|
accessor: NotificationAccessor,
|
||||||
className: 'notification',
|
className: 'notification',
|
||||||
width: '180',
|
width: '180',
|
||||||
|
disableSortBy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: intl.get('service'),
|
Header: intl.get('service'),
|
||||||
accessor: 'module_formatted',
|
accessor: 'module_formatted',
|
||||||
className: 'service',
|
className: 'service',
|
||||||
width: '80',
|
width: '80',
|
||||||
|
disableSortBy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: intl.get('sms_message.label_mesage'),
|
Header: intl.get('sms_message.label_mesage'),
|
||||||
@@ -63,14 +87,15 @@ export function useSMSIntegrationTableColumns() {
|
|||||||
className: 'sms_message',
|
className: 'sms_message',
|
||||||
clickable: true,
|
clickable: true,
|
||||||
width: '180',
|
width: '180',
|
||||||
|
disableSortBy: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: intl.get('sms_message.label_auto'),
|
Header: intl.get('sms_message.label_auto'),
|
||||||
accessor: 'is_notification_enabled',
|
accessor: 'is_notification_enabled',
|
||||||
Cell: SwitchFieldCell,
|
Cell: SwitchFieldCell,
|
||||||
className: 'is_notification_enabled',
|
className: 'is_notification_enabled',
|
||||||
disableSortBy: true,
|
|
||||||
disableResizing: true,
|
disableResizing: true,
|
||||||
|
disableSortBy: true,
|
||||||
width: '80',
|
width: '80',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ const commonInvalidateQueries = (queryClient) => {
|
|||||||
|
|
||||||
// Invalidate the financial reports.
|
// Invalidate the financial reports.
|
||||||
queryClient.invalidateQueries(t.FINANCIAL_REPORT);
|
queryClient.invalidateQueries(t.FINANCIAL_REPORT);
|
||||||
|
|
||||||
|
// Invalidate SMS details.
|
||||||
|
queryClient.invalidateQueries(t.SALE_ESTIMATE_SMS_DETAIL);
|
||||||
|
queryClient.invalidateQueries(t.SALE_INVOICE_SMS_DETAIL);
|
||||||
|
queryClient.invalidateQueries(t.SALE_RECEIPT_SMS_DETAIL);
|
||||||
|
queryClient.invalidateQueries(t.PAYMENT_RECEIVE_SMS_DETAIL);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Customers response selector.
|
// Customers response selector.
|
||||||
|
|||||||
@@ -1444,6 +1444,8 @@
|
|||||||
"notify_via_sms.dialog.message_text":"نص رسالة ",
|
"notify_via_sms.dialog.message_text":"نص رسالة ",
|
||||||
"notify_via_sms.dialog.notify_via_sms":"Notify vis SMS",
|
"notify_via_sms.dialog.notify_via_sms":"Notify vis SMS",
|
||||||
"notify_via_sms.dialog.error_message":"Notify vis SMS",
|
"notify_via_sms.dialog.error_message":"Notify vis SMS",
|
||||||
|
"notify_via_sms.dialog.phone_invalid_error_message":"Sms notification cannot be sent, customer personal phone number is invalid, please enter a valid one and try again.",
|
||||||
|
"notify_via_sms.dialog.customer_no_phone_error_message":"الزبون ليس لديه رقم هاتف.",
|
||||||
"notify_invoice_via_sms.dialog.success_message":"The sale invoice sms notification has been sent successfully",
|
"notify_invoice_via_sms.dialog.success_message":"The sale invoice sms notification has been sent successfully",
|
||||||
"notify_estimate_via_sms.dialog.success_message":"تم إرسال إشعار الرسائل القصيرة الخاصة بتقدير المبيعات بنجاح. ",
|
"notify_estimate_via_sms.dialog.success_message":"تم إرسال إشعار الرسائل القصيرة الخاصة بتقدير المبيعات بنجاح. ",
|
||||||
"notify_receipt_via_sms.dialog.success_message":"The sale receipt sms notification has been sent successfully",
|
"notify_receipt_via_sms.dialog.success_message":"The sale receipt sms notification has been sent successfully",
|
||||||
@@ -1453,9 +1455,11 @@
|
|||||||
"sms_integration.label.overview":"نظرة عامة",
|
"sms_integration.label.overview":"نظرة عامة",
|
||||||
"sms_integration.label.sms_messages":"رسائل SMS ",
|
"sms_integration.label.sms_messages":"رسائل SMS ",
|
||||||
"sms_message.label.sms_messages_template":" إشعارات رسائل قصيرة ",
|
"sms_message.label.sms_messages_template":" إشعارات رسائل قصيرة ",
|
||||||
"sms_message.label_mesage":"رسالة ",
|
"sms_messages.label_mesage":"رسالة ",
|
||||||
"sms_message.label_Notification":"إشعار",
|
"sms_messages.label_notification":"إشعار",
|
||||||
"sms_message.label_auto":"Auto",
|
"sms_messages.label_auto":"Auto",
|
||||||
"sms_message":"رسالة SMS" ,
|
"sms_message":"رسالة SMS" ,
|
||||||
"sms_message.dialog.success_message":"Sms notification settings has been updated successfully."
|
"sms_message.dialog.success_message":"Sms notification settings has been updated successfully.",
|
||||||
|
"edit_message_text":"تعديل نص رسالة",
|
||||||
|
"enable_notification":"تفعيل الإشعارات"
|
||||||
}
|
}
|
||||||
@@ -1427,23 +1427,26 @@
|
|||||||
"bad_debt.dialog.success_message": "The given sale invoice has been writte-off successfully.",
|
"bad_debt.dialog.success_message": "The given sale invoice has been writte-off successfully.",
|
||||||
"bad_debt.cancel_alert.success_message": "The given sale invoice has been canceled write-off successfully.",
|
"bad_debt.cancel_alert.success_message": "The given sale invoice has been canceled write-off successfully.",
|
||||||
"bad_debt.cancel_alert.message": "Are you sure you want to write off this invoice?",
|
"bad_debt.cancel_alert.message": "Are you sure you want to write off this invoice?",
|
||||||
"notify_via_sms.dialog.send_notification_to": "Send notification to",
|
"notify_via_sms.dialog.send_notification_to":"Send notification to",
|
||||||
"notify_via_sms.dialog.message_text": "Message Text",
|
"notify_via_sms.dialog.message_text":"Message Text",
|
||||||
"notify_via_sms.dialog.notify_via_sms": "Notify vis SMS",
|
"notify_via_sms.dialog.notify_via_sms":"Notify vis SMS",
|
||||||
"notify_via_sms.dialog.success_message": "SMS notification has been sent successfully.",
|
"notify_via_sms.dialog.phone_invalid_error_message":"Sms notification cannot be sent, customer personal phone number is invalid, please enter a valid one and try again.",
|
||||||
"notify_via_sms.dialog.error_message": "Sms notification cannot be sent, customer personal phone number is invalid, please enter a valid one and try again.",
|
"notify_via_sms.dialog.customer_no_phone_error_message":"The customer has no phone number.",
|
||||||
"notify_invoice_via_sms.dialog.success_message": "The sale invoice sms notification has been sent successfully",
|
"notify_invoice_via_sms.dialog.success_message":"The sale invoice sms notification has been sent successfully",
|
||||||
"notify_estimate_via_sms.dialog.success_message": "The sale estimate sms notification has been sent successfully",
|
"notify_estimate_via_sms.dialog.success_message":"The sale estimate sms notification has been sent successfully",
|
||||||
"notify_receipt_via_sms.dialog.success_message": "The sale receipt sms notification has been sent successfully",
|
"notify_receipt_via_sms.dialog.success_message":"The sale receipt sms notification has been sent successfully",
|
||||||
"notify_payment_receive_via_sms.dialog.success_message": "The payment notification has been sent successfully.",
|
"notify_payment_receive_via_sms.dialog.success_message":"The payment notification has been sent successfully.",
|
||||||
"send": "Send",
|
"send": "Send",
|
||||||
"sms_integration.label": "SMS Integration",
|
"sms_integration.label":"SMS Integration",
|
||||||
"sms_integration.label.overview": "Overview",
|
"sms_integration.label.overview":"Overview",
|
||||||
"sms_integration.label.sms_messages": "SMS Messages",
|
"sms_integration.label.sms_messages":"SMS Messages",
|
||||||
"sms_message.label.sms_messages_template": "SMS Notifications ",
|
"sms_messages.label_notification":"Notification",
|
||||||
"sms_message.label_mesage": "Message",
|
"sms_messages.label_mesage":"Message",
|
||||||
"sms_message.label_Notification": "Notification",
|
"sms_messages.label_auto":"Auto",
|
||||||
"sms_message.label_auto": "Auto",
|
"sms_message.dialog.label":"SMS message",
|
||||||
"sms_message": "SMS message",
|
"sms_message.dialog.success_message":"Sms notification settings has been updated successfully.",
|
||||||
"sms_message.dialog.success_message": "Sms notification settings has been updated successfully."
|
"sms_message.dialog.unsupported_variables_error_message":"Unsupported variables",
|
||||||
|
"edit_message_text":"Edit message text",
|
||||||
|
"enable_notification":"Enable notification"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user