diff --git a/src/containers/Dialogs/NotifyEstimateViaSMSDialog/NotifyEstimateViaSMSForm.js b/src/containers/Dialogs/NotifyEstimateViaSMSDialog/NotifyEstimateViaSMSForm.js
index 5019bad7e..851c9fcc1 100644
--- a/src/containers/Dialogs/NotifyEstimateViaSMSDialog/NotifyEstimateViaSMSForm.js
+++ b/src/containers/Dialogs/NotifyEstimateViaSMSDialog/NotifyEstimateViaSMSForm.js
@@ -14,32 +14,36 @@ function NotifyEstimateViaSMSForm({
// #withDialogActions
closeDialog,
}) {
- const { dialogName, estimateId } = useEstimateViaSMSContext();
+ const {
+ estimateId,
+ dialogName,
+ estimateSMSDetail,
+ createNotifyEstimateBySMSMutate,
+ } = useEstimateViaSMSContext();
// Handles the form submit.
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
// Handle request response success.
const onSuccess = (response) => {
AppToaster.show({
- message: intl.get('notify_via_sms.dialog.success_message'),
+ message: intl.get('notify_estimate_via_sms.dialog.success_message'),
intent: Intent.SUCCESS,
});
closeDialog(dialogName);
};
// Handle request response errors.
- const onError = ({
- response: {
- data: { errors },
- },
- }) => {
+ const onError = () => {
setSubmitting(false);
};
+ createNotifyEstimateBySMSMutate([estimateId, values])
+ .then(onSuccess)
+ .then(onError);
};
return (
diff --git a/src/containers/Dialogs/NotifyEstimateViaSMSDialog/NotifyEstimateViaSMSFormProvider.js b/src/containers/Dialogs/NotifyEstimateViaSMSDialog/NotifyEstimateViaSMSFormProvider.js
index 5f3d8d38e..f913bdc23 100644
--- a/src/containers/Dialogs/NotifyEstimateViaSMSDialog/NotifyEstimateViaSMSFormProvider.js
+++ b/src/containers/Dialogs/NotifyEstimateViaSMSDialog/NotifyEstimateViaSMSFormProvider.js
@@ -1,6 +1,9 @@
import React from 'react';
import { DialogContent } from 'components';
-// import { } from 'hooks/query';
+import {
+ useEstimateSMSDetail,
+ useCreateNotifyEstimateBySMS,
+} from 'hooks/query';
const NotifyEstimateViaSMSContext = React.createContext();
@@ -9,16 +12,25 @@ function NotifyEstimateViaSMSFormProvider({
dialogName,
...props
}) {
+ const { data: estimateSMSDetail, isLoading: isEstimateSMSDetailLoading } =
+ useEstimateSMSDetail(estimateId, {
+ enabled: !!estimateId,
+ });
+
+ // Create notfiy estimate by sms mutations.
+ const { mutateAsync: createNotifyEstimateBySMSMutate } =
+ useCreateNotifyEstimateBySMS();
+
// State provider.
const provider = {
estimateId,
dialogName,
+ estimateSMSDetail,
+ createNotifyEstimateBySMSMutate,
};
return (
-
+
);
diff --git a/src/containers/Dialogs/NotifyInvoiceViaSMSDialog/NotifyInvoiceViaSMSFormProvider.js b/src/containers/Dialogs/NotifyInvoiceViaSMSDialog/NotifyInvoiceViaSMSFormProvider.js
index 4793db09a..26faac775 100644
--- a/src/containers/Dialogs/NotifyInvoiceViaSMSDialog/NotifyInvoiceViaSMSFormProvider.js
+++ b/src/containers/Dialogs/NotifyInvoiceViaSMSDialog/NotifyInvoiceViaSMSFormProvider.js
@@ -1,12 +1,12 @@
import React from 'react';
import { DialogContent } from 'components';
-import { useCreateNotifyInvoiceBySMS, useInvocieSMSDetails } from 'hooks/query';
+import { useCreateNotifyInvoiceBySMS, useInvoiceSMSDetail } from 'hooks/query';
const NotifyInvoiceViaSMSContext = React.createContext();
function NotifyInvoiceViaSMSFormProvider({ invoiceId, dialogName, ...props }) {
const { data: invoiceSMSDetail, isLoading: isInvoiceSMSDetailLoading } =
- useInvocieSMSDetails(invoiceId, {
+ useInvoiceSMSDetail(invoiceId, {
enabled: !!invoiceId,
});
diff --git a/src/containers/Dialogs/NotifyPaymentReceiveViaSMSDialog/NotifyPaymentReceiveViaFormProvider.js b/src/containers/Dialogs/NotifyPaymentReceiveViaSMSDialog/NotifyPaymentReceiveViaFormProvider.js
index 9ee75ecf8..46c164a0f 100644
--- a/src/containers/Dialogs/NotifyPaymentReceiveViaSMSDialog/NotifyPaymentReceiveViaFormProvider.js
+++ b/src/containers/Dialogs/NotifyPaymentReceiveViaSMSDialog/NotifyPaymentReceiveViaFormProvider.js
@@ -1,6 +1,9 @@
import React from 'react';
import { DialogContent } from 'components';
-// import { useCreateNotifyInvoiceBySMS, useInvocieSMSDetails } from 'hooks/query';
+import {
+ useCreateNotifyPaymentReceiveBySMS,
+ usePaymentReceiveSMSDetail,
+} from 'hooks/query';
const NotifyPaymentReceiveViaSMSContext = React.createContext();
@@ -9,16 +12,27 @@ function NotifyPaymentReceiveViaFormProvider({
dialogName,
...props
}) {
+ // Create notfiy receipt via sms mutations.
+ const { mutateAsync: createNotifyPaymentReceivetBySMSMutate } =
+ useCreateNotifyPaymentReceiveBySMS();
+
+ const {
+ data: paymentReceiveMSDetail,
+ isLoading: isPaymentReceiveSMSDetailLoading,
+ } = usePaymentReceiveSMSDetail(paymentReceiveId, {
+ enabled: !!paymentReceiveId,
+ });
+
// State provider.
const provider = {
paymentReceiveId,
dialogName,
+ paymentReceiveMSDetail,
+ createNotifyPaymentReceivetBySMSMutate,
};
return (
-
+
);
diff --git a/src/containers/Dialogs/NotifyPaymentReceiveViaSMSDialog/NotifyPaymentReceiveViaSMSForm.js b/src/containers/Dialogs/NotifyPaymentReceiveViaSMSDialog/NotifyPaymentReceiveViaSMSForm.js
index 0db3d6100..de79deecb 100644
--- a/src/containers/Dialogs/NotifyPaymentReceiveViaSMSDialog/NotifyPaymentReceiveViaSMSForm.js
+++ b/src/containers/Dialogs/NotifyPaymentReceiveViaSMSDialog/NotifyPaymentReceiveViaSMSForm.js
@@ -17,33 +17,38 @@ function NotifyPaymentReceiveViaSMSForm({
// #withDialogActions
closeDialog,
}) {
- const { dialogName, paymentReceiveId } =
- useNotifyPaymentReceiveViaSMSContext();
+ const {
+ dialogName,
+ paymentReceiveId,
+ paymentReceiveMSDetail,
+ createNotifyPaymentReceivetBySMSMutate,
+ } = useNotifyPaymentReceiveViaSMSContext();
// Handles the form submit.
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
// Handle request response success.
const onSuccess = (response) => {
AppToaster.show({
- message: intl.get('notify_via_sms.dialog.success_message'),
+ message: intl.get(
+ 'notify_payment_receive_via_sms.dialog.success_message',
+ ),
intent: Intent.SUCCESS,
});
closeDialog(dialogName);
};
// Handle request response errors.
- const onError = ({
- response: {
- data: { errors },
- },
- }) => {
+ const onError = ({}) => {
setSubmitting(false);
};
+ createNotifyPaymentReceivetBySMSMutate([paymentReceiveId, values])
+ .then(onSuccess)
+ .catch(onError);
};
return (
diff --git a/src/containers/Dialogs/NotifyPaymentReceiveViaSMSDialog/index.js b/src/containers/Dialogs/NotifyPaymentReceiveViaSMSDialog/index.js
index 26f2a4df3..f9ce607f9 100644
--- a/src/containers/Dialogs/NotifyPaymentReceiveViaSMSDialog/index.js
+++ b/src/containers/Dialogs/NotifyPaymentReceiveViaSMSDialog/index.js
@@ -25,7 +25,7 @@ function NotifyPaymentReciveViaSMSDialog({
diff --git a/src/containers/Dialogs/NotifyReceiptViaSMSDialog/NotifyReceiptViaSMSForm.js b/src/containers/Dialogs/NotifyReceiptViaSMSDialog/NotifyReceiptViaSMSForm.js
index 5ca513ce9..c9ae06410 100644
--- a/src/containers/Dialogs/NotifyReceiptViaSMSDialog/NotifyReceiptViaSMSForm.js
+++ b/src/containers/Dialogs/NotifyReceiptViaSMSDialog/NotifyReceiptViaSMSForm.js
@@ -17,32 +17,36 @@ function NotifyReceiptViaSMSForm({
// #withDialogActions
closeDialog,
}) {
- const { dialogName, receiptId } = useNotifyReceiptViaSMSContext();
+ const {
+ dialogName,
+ receiptId,
+ receiptSMSDetail,
+ createNotifyReceiptBySMSMutate,
+ } = useNotifyReceiptViaSMSContext();
// Handles the form submit.
const handleFormSubmit = (values, { setSubmitting, setErrors }) => {
// Handle request response success.
const onSuccess = (response) => {
AppToaster.show({
- message: intl.get('notify_via_sms.dialog.success_message'),
+ message: intl.get('notify_receipt_via_sms.dialog.success_message'),
intent: Intent.SUCCESS,
});
closeDialog(dialogName);
};
// Handle request response errors.
- const onError = ({
- response: {
- data: { errors },
- },
- }) => {
+ const onError = ({}) => {
setSubmitting(false);
};
+ createNotifyReceiptBySMSMutate([receiptId, values])
+ .then(onSuccess)
+ .catch(onError);
};
return (
diff --git a/src/containers/Dialogs/NotifyReceiptViaSMSDialog/NotifyReceiptViaSMSFormProvider.js b/src/containers/Dialogs/NotifyReceiptViaSMSDialog/NotifyReceiptViaSMSFormProvider.js
index fa8dce2b9..3f2515319 100644
--- a/src/containers/Dialogs/NotifyReceiptViaSMSDialog/NotifyReceiptViaSMSFormProvider.js
+++ b/src/containers/Dialogs/NotifyReceiptViaSMSDialog/NotifyReceiptViaSMSFormProvider.js
@@ -1,22 +1,29 @@
import React from 'react';
import { DialogContent } from 'components';
-// import { useCreateNotifyInvoiceBySMS, useInvocieSMSDetails } from 'hooks/query';
+import { useCreateNotifyReceiptBySMS, useReceiptSMSDetail } from 'hooks/query';
const NotifyReceiptViaSMSContext = React.createContext();
function NotifyReceiptViaSMSFormProvider({ receiptId, dialogName, ...props }) {
// Create notfiy receipt via sms mutations.
+ const { mutateAsync: createNotifyReceiptBySMSMutate } =
+ useCreateNotifyReceiptBySMS();
+
+ const { data: receiptSMSDetail, isLoading: isReceiptSMSDetailLoading } =
+ useReceiptSMSDetail(receiptId, {
+ enabled: !!receiptId,
+ });
// State provider.
const provider = {
receiptId,
dialogName,
+ receiptSMSDetail,
+ createNotifyReceiptBySMSMutate,
};
return (
-
+
);
diff --git a/src/containers/NotifyViaSMS/NotifyViaSMSForm.js b/src/containers/NotifyViaSMS/NotifyViaSMSForm.js
index 021bd7724..93eb57375 100644
--- a/src/containers/NotifyViaSMS/NotifyViaSMSForm.js
+++ b/src/containers/NotifyViaSMS/NotifyViaSMSForm.js
@@ -11,7 +11,7 @@ import { transformToForm, saveInvoke } from 'utils';
const defaultInitialValues = {
customer_name: '',
- customer_personal_phone: '',
+ customer_phone_number: '',
sms_message: '',
};
diff --git a/src/containers/NotifyViaSMS/NotifyViaSMSForm.schema.js b/src/containers/NotifyViaSMS/NotifyViaSMSForm.schema.js
index f32e4a3a2..3e855eb49 100644
--- a/src/containers/NotifyViaSMS/NotifyViaSMSForm.schema.js
+++ b/src/containers/NotifyViaSMS/NotifyViaSMSForm.schema.js
@@ -4,7 +4,7 @@ import { DATATYPES_LENGTH } from 'common/dataTypes';
const Schema = Yup.object().shape({
customer_name: Yup.string().required(),
- customer_personal_phone: Yup.number().required(),
+ customer_phone_number: Yup.number().required(),
sms_message: Yup.string().required().trim().max(DATATYPES_LENGTH.TEXT),
});
diff --git a/src/containers/NotifyViaSMS/NotifyViaSMSFormFields.js b/src/containers/NotifyViaSMS/NotifyViaSMSFormFields.js
index 59d79cca3..37c88c1e7 100644
--- a/src/containers/NotifyViaSMS/NotifyViaSMSFormFields.js
+++ b/src/containers/NotifyViaSMS/NotifyViaSMSFormFields.js
@@ -31,15 +31,15 @@ function NotifyViaSMSFormFields() {
{/* ----------- Phone number ----------- */}
-
+
{({ form, field, meta: { error, touched } }) => (
}
labelInfo={}
intent={inputIntent({ error, touched })}
- helperText={}
+ helperText={}
className={classNames(
- 'form-group--customer_personal_phone',
+ 'form-group--customer_phone_number',
CLASSES.FILL,
)}
>
diff --git a/src/hooks/query/estimates.js b/src/hooks/query/estimates.js
index 2b6766329..0000e6120 100644
--- a/src/hooks/query/estimates.js
+++ b/src/hooks/query/estimates.js
@@ -195,30 +195,31 @@ export function useCreateNotifyEstimateBySMS(props) {
const apiRequest = useApiRequest();
return useMutation(
- (id) => apiRequest.post(`sales/estimates/${id}/notify-by-sms`),
+ ([id, values]) =>
+ apiRequest.post(`sales/estimates/${id}/notify-by-sms`, values),
{
- onSuccess: (res, id) => {
+ onSuccess: (res, [id, values]) => {
+ // Invalidate
+ queryClient.invalidateQueries([t.NOTIFY_SALE_ESTIMATE_BY_SMS, id]);
+
// Common invalidate queries.
commonInvalidateQueries(queryClient);
-
- // Invalidate sale estimate.
- queryClient.invalidateQueries([t.NOTIFY_SALE_ESTIMATE_BY_SMS, id]);
},
...props,
},
);
}
-export function useEstimateSMS(estimateId, props, requestProps) {
+export function useEstimateSMSDetail(estimateId, props, requestProps) {
return useRequestQuery(
- [t.SALE_ESTIMATE_SMS, estimateId],
+ [t.SALE_ESTIMATE_SMS_DETAIL, estimateId],
{
method: 'get',
url: `sales/estimates/${estimateId}/sms-details`,
...requestProps,
},
{
- select: (res) => res.data,
+ select: (res) => res.data.data,
defaultData: {},
...props,
},
diff --git a/src/hooks/query/invoices.js b/src/hooks/query/invoices.js
index 9948d6064..6c1c7f767 100644
--- a/src/hooks/query/invoices.js
+++ b/src/hooks/query/invoices.js
@@ -239,9 +239,10 @@ export function useCreateNotifyInvoiceBySMS(props) {
const apiRequest = useApiRequest();
return useMutation(
- (id) => apiRequest.post(`sales/invoices/${id}/notify-by-sms`),
+ ([id, values]) =>
+ apiRequest.post(`sales/invoices/${id}/notify-by-sms`, values),
{
- onSuccess: (res, id) => {
+ onSuccess: (res, [id, values]) => {
// Invalidate
queryClient.invalidateQueries([t.NOTIFY_SALE_INVOICE_BY_SMS, id]);
@@ -253,9 +254,9 @@ export function useCreateNotifyInvoiceBySMS(props) {
);
}
-export function useInvocieSMSDetails(invoiceId, props, requestProps) {
+export function useInvoiceSMSDetail(invoiceId, props, requestProps) {
return useRequestQuery(
- [t.SALE_INVOICE_SMS, invoiceId],
+ [t.SALE_INVOICE_SMS_DETAIL, invoiceId],
{
method: 'get',
url: `sales/invoices/${invoiceId}/sms-details`,
diff --git a/src/hooks/query/paymentReceives.js b/src/hooks/query/paymentReceives.js
index ea6ba6274..06e7b39cb 100644
--- a/src/hooks/query/paymentReceives.js
+++ b/src/hooks/query/paymentReceives.js
@@ -180,9 +180,10 @@ export function useCreateNotifyPaymentReceiveBySMS(props) {
const apiRequest = useApiRequest();
return useMutation(
- (id) => apiRequest.post(`sales/payment_receives/${id}/notify-by-sms`),
+ ([id, values]) =>
+ apiRequest.post(`sales/payment_receives/${id}/notify-by-sms`, values),
{
- onSuccess: (res, id) => {
+ onSuccess: (res, [id, values]) => {
// Invalidate
queryClient.invalidateQueries([t.NOTIFY_PAYMENT_RECEIVE_BY_SMS, id]);
@@ -194,12 +195,20 @@ export function useCreateNotifyPaymentReceiveBySMS(props) {
);
}
-export function usePaymentReceiveSMS(id, props, requestProps) {
+export function usePaymentReceiveSMSDetail(
+ paymentReceiveId,
+ props,
+ requestProps,
+) {
return useRequestQuery(
- [t.PAYMENT_RECEIVE_SMS, id],
- { method: 'get', url: `sales/payment_receives/${id}/sms-details`, ...requestProps },
+ [t.PAYMENT_RECEIVE_SMS_DETAIL, paymentReceiveId],
{
- select: (res) => res.data,
+ method: 'get',
+ url: `sales/payment_receives/${paymentReceiveId}/sms-details`,
+ ...requestProps,
+ },
+ {
+ select: (res) => res.data.data,
defaultData: {},
...props,
},
diff --git a/src/hooks/query/receipts.js b/src/hooks/query/receipts.js
index 6db29e4c3..a9b0c705b 100644
--- a/src/hooks/query/receipts.js
+++ b/src/hooks/query/receipts.js
@@ -168,9 +168,10 @@ export function useCreateNotifyReceiptBySMS(props) {
const queryClient = useQueryClient();
const apiRequest = useApiRequest();
return useMutation(
- (id) => apiRequest.post(`sales/receipts/${id}/notify-by-sms`),
+ ([id, values]) =>
+ apiRequest.post(`sales/receipts/${id}/notify-by-sms`, values),
{
- onSuccess: (res, id) => {
+ onSuccess: (res, [id, values]) => {
queryClient.invalidateQueries([t.NOTIFY_SALE_RECEIPT_BY_SMS, id]);
// Invalidate queries.
@@ -181,12 +182,16 @@ export function useCreateNotifyReceiptBySMS(props) {
);
}
-export function useReceiptSMS(receiptId, props, requestProps) {
+export function useReceiptSMSDetail(receiptId, props, requestProps) {
return useRequestQuery(
- [t.SALE_RECEIPT_SMS, receiptId],
- { method: 'get', url: `sales/receipts/${receiptId}/sms-details`, ...requestProps },
+ [t.SALE_RECEIPT_SMS_DETAIL, receiptId],
{
- select: (res) => res.data,
+ method: 'get',
+ url: `sales/receipts/${receiptId}/sms-details`,
+ ...requestProps,
+ },
+ {
+ select: (res) => res.data.data,
defaultData: {},
...props,
},
diff --git a/src/hooks/query/types.js b/src/hooks/query/types.js
index 9e233ab00..1aebbd8e1 100644
--- a/src/hooks/query/types.js
+++ b/src/hooks/query/types.js
@@ -51,14 +51,14 @@ const ITEMS = {
const SALE_ESTIMATES = {
SALE_ESTIMATES: 'SALE_ESTIMATES',
SALE_ESTIMATE: 'SALE_ESTIMATE',
- SALE_ESTIMATE_SMS: 'SALE_ESTIMATE_SMS',
+ SALE_ESTIMATE_SMS_DETAIL: 'SALE_ESTIMATE_SMS_DETAIL',
NOTIFY_SALE_ESTIMATE_BY_SMS: 'NOTIFY_SALE_ESTIMATE_BY_SMS',
};
const SALE_RECEIPTS = {
SALE_RECEIPTS: 'SALE_RECEIPTS',
SALE_RECEIPT: 'SALE_RECEIPT',
- SALE_RECEIPT_SMS: 'SALE_RECEIPT_SMS',
+ SALE_RECEIPT_SMS_DETAIL: 'SALE_RECEIPT_SMS_DETAIL',
NOTIFY_SALE_RECEIPT_BY_SMS: 'NOTIFY_SALE_RECEIPT_BY_SMS',
};
@@ -83,7 +83,7 @@ const PAYMENT_RECEIVES = {
PAYMENT_RECEIVE: 'PAYMENT_RECEIVE',
PAYMENT_RECEIVE_NEW_ENTRIES: 'PAYMENT_RECEIVE_NEW_ENTRIES',
PAYMENT_RECEIVE_EDIT_PAGE: 'PAYMENT_RECEIVE_EDIT_PAGE',
- PAYMENT_RECEIVE_SMS: 'PAYMENT_RECEIVE_SMS',
+ PAYMENT_RECEIVE_SMS_DETAIL: 'PAYMENT_RECEIVE_SMS_DETAIL',
NOTIFY_PAYMENT_RECEIVE_BY_SMS: 'NOTIFY_PAYMENT_RECEIVE_BY_SMS',
};
@@ -91,7 +91,7 @@ const SALE_INVOICES = {
SALE_INVOICES: 'SALE_INVOICES',
SALE_INVOICE: 'SALE_INVOICE',
SALE_INVOICES_DUE: 'SALE_INVOICES_DUE',
- SALE_INVOICE_SMS: 'SALE_INVOICE_SMS',
+ SALE_INVOICE_SMS_DETAIL: 'SALE_INVOICE_SMS_DETAIL',
NOTIFY_SALE_INVOICE_BY_SMS: 'NOTIFY_SALE_INVOICE_BY_SMS',
BAD_DEBT: 'BAD_DEBT',
CANCEL_BAD_DEBT: 'CANCEL_BAD_DEBT',
diff --git a/src/lang/en/index.json b/src/lang/en/index.json
index b61f78f99..267d1a00d 100644
--- a/src/lang/en/index.json
+++ b/src/lang/en/index.json
@@ -1430,7 +1430,10 @@
"notify_via_sms.dialog.send_notification_to":"Send notification to",
"notify_via_sms.dialog.message_text":"Message Text",
"notify_via_sms.dialog.notify_via_sms":"Notify vis SMS",
- "notify_via_sms.dialog.success_message":"To notify have been 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_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.",
"send": "Send",
"sms_integration.label":"SMS Integration",
"sms_integration.label.overview":"Overview",
@@ -1441,4 +1444,5 @@
"sms_message.label_auto":"Auto",
"sms_message":"SMS message",
"sms_message.dialog.success_message":"Sms notification settings has been updated successfully."
-}
\ No newline at end of file
+}
+