fix: SMS notification types.

This commit is contained in:
a.bouhuolia
2021-11-11 17:20:53 +02:00
parent 2e34df5d63
commit 4c58e49169
7 changed files with 37 additions and 17 deletions

View File

@@ -13,7 +13,7 @@ import { compose } from 'utils';
const notificationType = { const notificationType = {
key: 'sale-estimate-details', key: 'sale-estimate-details',
label: 'Sale estimate details', label: intl.get('sms_notification.estimate_details.type'),
}; };
function NotifyEstimateViaSMSForm({ function NotifyEstimateViaSMSForm({
@@ -60,6 +60,7 @@ function NotifyEstimateViaSMSForm({
const initialValues = { const initialValues = {
...estimateSMSDetail, ...estimateSMSDetail,
notification_key: notificationType.key,
}; };
// Handle the form cancel. // Handle the form cancel.
const handleFormCancel = () => { const handleFormCancel = () => {
@@ -69,7 +70,7 @@ function NotifyEstimateViaSMSForm({
return ( return (
<NotifyViaSMSForm <NotifyViaSMSForm
initialValues={initialValues} initialValues={initialValues}
notificationTypes={notificationType} notificationTypes={[notificationType]}
onCancel={handleFormCancel} onCancel={handleFormCancel}
onSubmit={handleFormSubmit} onSubmit={handleFormSubmit}
calloutCodes={calloutCode} calloutCodes={calloutCode}

View File

@@ -15,6 +15,18 @@ const transformFormValuesToRequest = (values) => {
return pick(values, ['notification_key']); return pick(values, ['notification_key']);
}; };
// Momerize the notification types.
const notificationTypes = [
{
key: 'details',
label: intl.get('sms_notification.invoice_details.type'),
},
{
key: 'reminder',
label: intl.get('sms_notification.invoice_reminder.type'),
},
];
/** /**
* Notify Invoice Via SMS Form. * Notify Invoice Via SMS Form.
*/ */
@@ -80,14 +92,7 @@ function NotifyInvoiceViaSMSForm({
setNotificationType(values.notification_key); setNotificationType(values.notification_key);
} }
}; };
// Momerize the notification types.
const notificationTypes = React.useMemo(
() => [
{ key: 'details', label: 'Invoice details' },
{ key: 'reminder', label: 'Invoice reminder' },
],
[],
);
return ( return (
<NotifyViaSMSForm <NotifyViaSMSForm
initialValues={initialValues} initialValues={initialValues}

View File

@@ -13,7 +13,7 @@ import { compose } from 'utils';
const notificationType = { const notificationType = {
key: 'payment-receive-details', key: 'payment-receive-details',
label: 'Payment receive thank you.', label: intl.get('sms_notification.payment_details.type'),
}; };
/** /**
@@ -67,7 +67,10 @@ function NotifyPaymentReceiveViaSMSForm({
// Form initial values. // Form initial values.
const initialValues = React.useMemo( const initialValues = React.useMemo(
() => ({ ...paymentReceiveMSDetail }), () => ({
...paymentReceiveMSDetail,
notification_key: notificationType.key,
}),
[paymentReceiveMSDetail], [paymentReceiveMSDetail],
); );

View File

@@ -13,7 +13,7 @@ import { compose } from 'utils';
const notificationType = { const notificationType = {
key: 'sale-receipt-details', key: 'sale-receipt-details',
label: 'Sale receipt details', label: intl.get('sms_notification.receipt_details.type'),
}; };
/** /**
@@ -66,6 +66,7 @@ function NotifyReceiptViaSMSForm({
const initialValues = React.useMemo( const initialValues = React.useMemo(
() => ({ () => ({
...receiptSMSDetail, ...receiptSMSDetail,
notification_key: notificationType.key,
}), }),
[receiptSMSDetail], [receiptSMSDetail],
); );

View File

@@ -16,7 +16,7 @@ export default function NotifyViaSMSFormFields({ notificationTypes }) {
return ( return (
<NotifyViaSMSFormFieldsRoot> <NotifyViaSMSFormFieldsRoot>
<FastField name={'notification_key'}> <FastField name={'notification_key'}>
{({ form, meta: { error, touched } }) => ( {({ form, field: { value }, meta: { error, touched } }) => (
<FormGroup <FormGroup
label={<T id={'notify_via_sms.dialog.notification_type'} />} label={<T id={'notify_via_sms.dialog.notification_type'} />}
className={classNames(CLASSES.FILL)} className={classNames(CLASSES.FILL)}
@@ -26,7 +26,7 @@ export default function NotifyViaSMSFormFields({ notificationTypes }) {
<ListSelect <ListSelect
items={notificationTypes} items={notificationTypes}
selectedItemProp={'key'} selectedItemProp={'key'}
selectedItem={'details'} selectedItem={value}
textProp={'label'} textProp={'label'}
popoverProps={{ minimal: true }} popoverProps={{ minimal: true }}
filterable={false} filterable={false}

View File

@@ -1473,5 +1473,10 @@
"send_sms": "إرسال رسالة قصيرة", "send_sms": "إرسال رسالة قصيرة",
"save_sms_message": "حفظ رسالة قصيرة", "save_sms_message": "حفظ رسالة قصيرة",
"sms_message.edit_form.reset_to_default_message": "إعادة التعيين إلى الرسالة الافتراضية.", "sms_message.edit_form.reset_to_default_message": "إعادة التعيين إلى الرسالة الافتراضية.",
"report.compute_running.refresh": "تحديث" "report.compute_running.refresh": "تحديث",
"sms_notification.invoice_details.type": "تفاصيل الفاتورة",
"sms_notification.invoice_reminder.type": "تذكير بالفاتورة",
"sms_notification.estimate_details.type": "تفاصيل فاتورة عرض الاسعار",
"sms_notification.payment_details.type": "شكر علي عملية الدفع",
"sms_notification.receipt_details.type": "تفاصيل إيصال البيع"
} }

View File

@@ -1460,5 +1460,10 @@
"send_sms": "Send SMS", "send_sms": "Send SMS",
"save_sms_message": "Save SMS Message", "save_sms_message": "Save SMS Message",
"sms_message.edit_form.reset_to_default_message": "Reset to default message.", "sms_message.edit_form.reset_to_default_message": "Reset to default message.",
"report.compute_running.refresh": "Refresh" "report.compute_running.refresh": "Refresh",
"sms_notification.invoice_details.type": "Invoice details",
"sms_notification.invoice_reminder.type": "Invoice reminder",
"sms_notification.estimate_details.type": "Sale estimate details",
"sms_notification.payment_details.type": "Payment receive thank you.",
"sms_notification.receipt_details.type": "Sale receipt details"
} }