@bigbinary/neeto-message-templates-frontend 0.6.6 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/javascript/src/translations/en.json +8 -2
- package/dist/index.cjs.js +147 -144
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +148 -145
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
- package/types.d.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import NeetoHeader from '@bigbinary/neeto-molecules/Header';
|
|
|
6
6
|
import SubHeader from '@bigbinary/neeto-molecules/SubHeader';
|
|
7
7
|
import { Button, Typography, Pane, Table, NoData, Alert, Select, Textarea as Textarea$1, Label } from '@bigbinary/neetoui';
|
|
8
8
|
import { isEmpty, equals, prop, includes, pick, omit, assoc, mergeAll, pluck, whereAny, reject, modify } from 'ramda';
|
|
9
|
+
import { useTranslation, Trans } from 'react-i18next';
|
|
9
10
|
import { t as t$1 } from 'i18next';
|
|
10
11
|
import { DEFAULT_PAGE_SIZE, DEFAULT_PAGE_INDEX } from '@bigbinary/neeto-commons-frontend/constants';
|
|
11
12
|
import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
|
|
@@ -15,8 +16,7 @@ import axios from 'axios';
|
|
|
15
16
|
import require$$0 from 'util';
|
|
16
17
|
import { create } from 'zustand';
|
|
17
18
|
import { FormikEditor } from '@bigbinary/neeto-editor';
|
|
18
|
-
import { Textarea, Input, Form as Form$2, Select as Select$1
|
|
19
|
-
import { useTranslation, Trans } from 'react-i18next';
|
|
19
|
+
import { Textarea, Input, Form as Form$2, ActionBlock, Select as Select$1 } from '@bigbinary/neetoui/formik';
|
|
20
20
|
import { useFormikContext, FieldArray } from 'formik';
|
|
21
21
|
import { isPhoneNumberValid } from '@bigbinary/neeto-molecules/PhoneNumber';
|
|
22
22
|
import * as yup from 'yup';
|
|
@@ -3084,51 +3084,42 @@ var Form$1 = function Form(_ref) {
|
|
|
3084
3084
|
validateOnChange: true,
|
|
3085
3085
|
onSubmit: handleSubmit
|
|
3086
3086
|
}
|
|
3087
|
-
},
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
}), /*#__PURE__*/React.createElement(Pane.Footer, {
|
|
3117
|
-
className: "absolute bottom-0 left-0 flex gap-x-2"
|
|
3118
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
3119
|
-
"data-cy": "message-template-submit-button",
|
|
3120
|
-
disabled: !(dirty && isValid) || isSubmitting,
|
|
3121
|
-
label: t("neetoMessageTemplate.template.saveChanges"),
|
|
3122
|
-
loading: isSubmitting,
|
|
3123
|
-
type: "submit"
|
|
3124
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
|
3087
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
3088
|
+
required: true,
|
|
3089
|
+
label: t("neetoMessageTemplate.template.templateName"),
|
|
3090
|
+
name: "name",
|
|
3091
|
+
ref: setInitialFocusField
|
|
3092
|
+
}), isEmailTemplate && /*#__PURE__*/React.createElement(FormikAdaptiveInput, {
|
|
3093
|
+
required: true,
|
|
3094
|
+
label: t("neetoMessageTemplate.template.emailSubject"),
|
|
3095
|
+
name: "subject"
|
|
3096
|
+
}), /*#__PURE__*/React.createElement(FormikEditor, {
|
|
3097
|
+
hideSlashCommands: true,
|
|
3098
|
+
required: true,
|
|
3099
|
+
contentClassName: "max-h-40",
|
|
3100
|
+
defaults: isEmailTemplate ? undefined : [],
|
|
3101
|
+
label: messageBodyLabel,
|
|
3102
|
+
name: "body",
|
|
3103
|
+
ref: editorRef,
|
|
3104
|
+
rows: DEFAULT_EDITOR_ROW_COUNT,
|
|
3105
|
+
variables: templateVariables
|
|
3106
|
+
}), isTestTemplateVisible && /*#__PURE__*/React.createElement(TestMessage, {
|
|
3107
|
+
customFields: customFields,
|
|
3108
|
+
handleSubmitTestTemplate: handleSubmitTestTemplate,
|
|
3109
|
+
isEmailTemplate: isEmailTemplate,
|
|
3110
|
+
isTestMessageLoading: isTestMessageLoading,
|
|
3111
|
+
isTestingTemplateDisabled: isTestingTemplateDisabled
|
|
3112
|
+
}), /*#__PURE__*/React.createElement(Pane.Footer, {
|
|
3113
|
+
className: "absolute bottom-0 left-0"
|
|
3114
|
+
}, /*#__PURE__*/React.createElement(ActionBlock, {
|
|
3115
|
+
cancelButtonProps: {
|
|
3125
3116
|
"data-cy": "message-template-reset-button",
|
|
3126
|
-
label: t("neetoMessageTemplate.template.cancel"),
|
|
3127
|
-
style: "text",
|
|
3128
|
-
type: "reset",
|
|
3129
3117
|
onClick: onClose
|
|
3130
|
-
}
|
|
3131
|
-
|
|
3118
|
+
},
|
|
3119
|
+
submitButtonProps: {
|
|
3120
|
+
"data-cy": "message-template-submit-button"
|
|
3121
|
+
}
|
|
3122
|
+
})));
|
|
3132
3123
|
};
|
|
3133
3124
|
|
|
3134
3125
|
var AddEdit = function AddEdit(_ref) {
|
|
@@ -3321,19 +3312,20 @@ var List = function List(_ref) {
|
|
|
3321
3312
|
}
|
|
3322
3313
|
})) : /*#__PURE__*/React.createElement("div", {
|
|
3323
3314
|
className: "flex h-full w-full items-center justify-center"
|
|
3324
|
-
}, /*#__PURE__*/React.createElement(NoData, {
|
|
3315
|
+
}, /*#__PURE__*/React.createElement(NoData, _extends({}, !isFilterApplied && {
|
|
3325
3316
|
primaryButtonProps: {
|
|
3326
3317
|
label: addText,
|
|
3327
3318
|
onClick: function onClick() {
|
|
3328
3319
|
return setManageTemplatePane(assoc("isOpen", true));
|
|
3329
3320
|
}
|
|
3330
|
-
}
|
|
3321
|
+
}
|
|
3322
|
+
}, {
|
|
3331
3323
|
title: isFilterApplied ? t("neetoMessageTemplate.template.filtersEmptyState", {
|
|
3332
3324
|
type: emptyStateLabel
|
|
3333
3325
|
}) : t("neetoMessageTemplate.template.emptyState", {
|
|
3334
3326
|
type: emptyStateLabel
|
|
3335
3327
|
})
|
|
3336
|
-
})), /*#__PURE__*/React.createElement(Alert, {
|
|
3328
|
+
}))), /*#__PURE__*/React.createElement(Alert, {
|
|
3337
3329
|
isOpen: isDelete,
|
|
3338
3330
|
isSubmitting: isDeleting,
|
|
3339
3331
|
submitButtonLabel: t("neetoMessageTemplate.template.delete"),
|
|
@@ -3384,6 +3376,8 @@ var MessageTemplates = function MessageTemplates(_ref) {
|
|
|
3384
3376
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
3385
3377
|
isFilterPaneOpen = _useState4[0],
|
|
3386
3378
|
setIsFilterPaneOpen = _useState4[1];
|
|
3379
|
+
var _useTranslation = useTranslation(),
|
|
3380
|
+
t = _useTranslation.t;
|
|
3387
3381
|
var _useFilters = useFilters(),
|
|
3388
3382
|
searchKeywordProps = _useFilters.searchKeywordProps,
|
|
3389
3383
|
filterColumns = _useFilters.filterColumns,
|
|
@@ -3435,12 +3429,12 @@ var MessageTemplates = function MessageTemplates(_ref) {
|
|
|
3435
3429
|
onClick: handleActionClick
|
|
3436
3430
|
})
|
|
3437
3431
|
}), /*#__PURE__*/React.createElement(SubHeader, {
|
|
3438
|
-
leftActionBlock: /*#__PURE__*/React.createElement(
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
}),
|
|
3432
|
+
leftActionBlock: /*#__PURE__*/React.createElement(Typography, {
|
|
3433
|
+
component: "h4"
|
|
3434
|
+
}, t("neetoMessageTemplate.template.messageTemplatesWithCount", {
|
|
3435
|
+
type: MESSAGE_TYPES[type],
|
|
3436
|
+
count: templatesCount
|
|
3437
|
+
})),
|
|
3444
3438
|
rightActionBlock: /*#__PURE__*/React.createElement(SubHeader.RightBlock, {
|
|
3445
3439
|
dataProps: {
|
|
3446
3440
|
totalCount: isFilterApplied ? null : templatesCount
|
|
@@ -3453,6 +3447,11 @@ var MessageTemplates = function MessageTemplates(_ref) {
|
|
|
3453
3447
|
onChange: handleChange
|
|
3454
3448
|
}
|
|
3455
3449
|
})
|
|
3450
|
+
}), /*#__PURE__*/React.createElement(Bar, {
|
|
3451
|
+
columns: filterColumns,
|
|
3452
|
+
keyword: searchKeywordProps,
|
|
3453
|
+
setIsPaneOpen: setIsFilterPaneOpen,
|
|
3454
|
+
onChange: handleChange
|
|
3456
3455
|
}), /*#__PURE__*/React.createElement(List, {
|
|
3457
3456
|
addText: addText,
|
|
3458
3457
|
isFilterApplied: isFilterApplied,
|
|
@@ -3543,8 +3542,7 @@ var EmailAndSms = function EmailAndSms(_ref) {
|
|
|
3543
3542
|
onSubmit: handleSubmit
|
|
3544
3543
|
}
|
|
3545
3544
|
}, function (_ref4) {
|
|
3546
|
-
var
|
|
3547
|
-
setValues = _ref4.setValues,
|
|
3545
|
+
var setValues = _ref4.setValues,
|
|
3548
3546
|
values = _ref4.values;
|
|
3549
3547
|
var handleTemplateChange = function handleTemplateChange(value) {
|
|
3550
3548
|
if (!value) return;
|
|
@@ -3581,19 +3579,16 @@ var EmailAndSms = function EmailAndSms(_ref) {
|
|
|
3581
3579
|
rows: DEFAULT_EDITOR_ROW_COUNT,
|
|
3582
3580
|
variables: templateVariables
|
|
3583
3581
|
}), /*#__PURE__*/React.createElement(Pane.Footer, {
|
|
3584
|
-
className: "absolute bottom-0 left-0
|
|
3585
|
-
}, /*#__PURE__*/React.createElement(
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
style: "text",
|
|
3595
|
-
type: "reset",
|
|
3596
|
-
onClick: onClose
|
|
3582
|
+
className: "absolute bottom-0 left-0"
|
|
3583
|
+
}, /*#__PURE__*/React.createElement(ActionBlock, {
|
|
3584
|
+
cancelButtonProps: {
|
|
3585
|
+
"data-cy": "message-template-cancel-button",
|
|
3586
|
+
onClick: onClose
|
|
3587
|
+
},
|
|
3588
|
+
submitButtonProps: {
|
|
3589
|
+
"data-cy": "message-template-send-button",
|
|
3590
|
+
label: t("neetoMessageTemplate.template.send")
|
|
3591
|
+
}
|
|
3597
3592
|
})));
|
|
3598
3593
|
});
|
|
3599
3594
|
};
|
|
@@ -3607,7 +3602,9 @@ var Whatsapp = function Whatsapp(_ref) {
|
|
|
3607
3602
|
handleSubmit = _ref.handleSubmit,
|
|
3608
3603
|
customFields = _ref.customFields,
|
|
3609
3604
|
customFieldsInitialValues = _ref.customFieldsInitialValues,
|
|
3610
|
-
customFieldsValidationSchema = _ref.customFieldsValidationSchema
|
|
3605
|
+
customFieldsValidationSchema = _ref.customFieldsValidationSchema,
|
|
3606
|
+
_ref$helpDocUrl = _ref.helpDocUrl,
|
|
3607
|
+
helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl;
|
|
3611
3608
|
var _useTranslation = useTranslation(),
|
|
3612
3609
|
t = _useTranslation.t;
|
|
3613
3610
|
var getInitialVariableComponents = function getInitialVariableComponents(variables) {
|
|
@@ -3636,6 +3633,15 @@ var Whatsapp = function Whatsapp(_ref) {
|
|
|
3636
3633
|
if (isEmpty(templates)) {
|
|
3637
3634
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, null, t("neetoMessageTemplate.template.emptyState", {
|
|
3638
3635
|
type: t("neetoMessageTemplate.template.whatsappTemplates")
|
|
3636
|
+
}), " ", helpDocUrl && /*#__PURE__*/React.createElement(Trans, {
|
|
3637
|
+
i18nKey: "neetoMessageTemplate.template.whatsapp.helpDocText",
|
|
3638
|
+
components: {
|
|
3639
|
+
Link: /*#__PURE__*/React.createElement(Button, {
|
|
3640
|
+
size: "large",
|
|
3641
|
+
style: "link",
|
|
3642
|
+
to: helpDocUrl
|
|
3643
|
+
})
|
|
3644
|
+
}
|
|
3639
3645
|
})), /*#__PURE__*/React.createElement(Pane.Footer, {
|
|
3640
3646
|
className: "absolute bottom-0 left-0"
|
|
3641
3647
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
@@ -3654,8 +3660,7 @@ var Whatsapp = function Whatsapp(_ref) {
|
|
|
3654
3660
|
onSubmit: handleSubmit
|
|
3655
3661
|
}
|
|
3656
3662
|
}, function (_ref3) {
|
|
3657
|
-
var
|
|
3658
|
-
values = _ref3.values,
|
|
3663
|
+
var values = _ref3.values,
|
|
3659
3664
|
setValues = _ref3.setValues;
|
|
3660
3665
|
var handleTemplateChange = function handleTemplateChange(value) {
|
|
3661
3666
|
if (!value) return;
|
|
@@ -3705,19 +3710,16 @@ var Whatsapp = function Whatsapp(_ref) {
|
|
|
3705
3710
|
}));
|
|
3706
3711
|
}));
|
|
3707
3712
|
})), /*#__PURE__*/React.createElement(Pane.Footer, {
|
|
3708
|
-
className: "absolute bottom-0 left-0
|
|
3709
|
-
}, /*#__PURE__*/React.createElement(
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
style: "text",
|
|
3719
|
-
type: "reset",
|
|
3720
|
-
onClick: onClose
|
|
3713
|
+
className: "absolute bottom-0 left-0"
|
|
3714
|
+
}, /*#__PURE__*/React.createElement(ActionBlock, {
|
|
3715
|
+
cancelButtonProps: {
|
|
3716
|
+
"data-cy": "message-template-cancel-button",
|
|
3717
|
+
onClick: onClose
|
|
3718
|
+
},
|
|
3719
|
+
submitButtonProps: {
|
|
3720
|
+
"data-cy": "message-template-send-button",
|
|
3721
|
+
label: t("neetoMessageTemplate.template.send")
|
|
3722
|
+
}
|
|
3721
3723
|
})));
|
|
3722
3724
|
});
|
|
3723
3725
|
};
|
|
@@ -3740,7 +3742,9 @@ var SendMessagePane = function SendMessagePane(_ref) {
|
|
|
3740
3742
|
_ref$templateVariable = _ref.templateVariables,
|
|
3741
3743
|
templateVariables = _ref$templateVariable === void 0 ? {} : _ref$templateVariable,
|
|
3742
3744
|
_ref$ownerId = _ref.ownerId,
|
|
3743
|
-
ownerId = _ref$ownerId === void 0 ? "" : _ref$ownerId
|
|
3745
|
+
ownerId = _ref$ownerId === void 0 ? "" : _ref$ownerId,
|
|
3746
|
+
_ref$helpDocUrl = _ref.helpDocUrl,
|
|
3747
|
+
helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl;
|
|
3744
3748
|
var _useTranslation = useTranslation(),
|
|
3745
3749
|
t = _useTranslation.t;
|
|
3746
3750
|
var initialFocusField = useRef();
|
|
@@ -3771,6 +3775,7 @@ var SendMessagePane = function SendMessagePane(_ref) {
|
|
|
3771
3775
|
customFieldsInitialValues: customFieldsInitialValues,
|
|
3772
3776
|
customFieldsValidationSchema: customFieldsValidationSchema,
|
|
3773
3777
|
handleSubmit: handleSubmit,
|
|
3778
|
+
helpDocUrl: helpDocUrl,
|
|
3774
3779
|
onClose: onClose,
|
|
3775
3780
|
templates: templates
|
|
3776
3781
|
}) : /*#__PURE__*/React.createElement(EmailAndSms, {
|
|
@@ -4055,10 +4060,9 @@ var Form = function Form(_ref) {
|
|
|
4055
4060
|
name: "additionalData"
|
|
4056
4061
|
}))), /*#__PURE__*/React.createElement(Pane.Footer, null, /*#__PURE__*/React.createElement(ActionBlock, {
|
|
4057
4062
|
cancelButtonProps: {
|
|
4058
|
-
onClick: onClose
|
|
4059
|
-
disabled: isMutating
|
|
4063
|
+
onClick: onClose
|
|
4060
4064
|
},
|
|
4061
|
-
|
|
4065
|
+
isSubmitting: isMutating
|
|
4062
4066
|
}))));
|
|
4063
4067
|
};
|
|
4064
4068
|
|
|
@@ -4176,15 +4180,15 @@ var ApiTemplates = function ApiTemplates(_ref) {
|
|
|
4176
4180
|
placeholder: t("neetoMessageTemplate.template.searchApiTemplates")
|
|
4177
4181
|
}
|
|
4178
4182
|
}), /*#__PURE__*/React.createElement(SubHeader, {
|
|
4179
|
-
leftActionBlock: /*#__PURE__*/React.createElement(
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
}),
|
|
4183
|
+
leftActionBlock: /*#__PURE__*/React.createElement(Typography, {
|
|
4184
|
+
component: "h4"
|
|
4185
|
+
}, t("neetoMessageTemplate.template.messageTemplatesWithCount", {
|
|
4186
|
+
type: t("messageType.api"),
|
|
4187
|
+
count: totalCount
|
|
4188
|
+
})),
|
|
4185
4189
|
rightActionBlock: /*#__PURE__*/React.createElement(SubHeader.RightBlock, {
|
|
4186
4190
|
dataProps: {
|
|
4187
|
-
totalCount: totalCount
|
|
4191
|
+
totalCount: isFilterApplied ? null : totalCount
|
|
4188
4192
|
},
|
|
4189
4193
|
filterProps: {
|
|
4190
4194
|
columns: FILTER_COLUMNS,
|
|
@@ -4194,6 +4198,11 @@ var ApiTemplates = function ApiTemplates(_ref) {
|
|
|
4194
4198
|
onChange: handleFiltersChange
|
|
4195
4199
|
}
|
|
4196
4200
|
})
|
|
4201
|
+
}), /*#__PURE__*/React.createElement(Bar, {
|
|
4202
|
+
columns: FILTER_COLUMNS,
|
|
4203
|
+
keyword: searchKeywordProps,
|
|
4204
|
+
setIsPaneOpen: setIsFiltersPaneOpen,
|
|
4205
|
+
onChange: handleFiltersChange
|
|
4197
4206
|
}), isNotEmpty(templates) ? /*#__PURE__*/React.createElement(TableWrapper, {
|
|
4198
4207
|
hasPagination: totalCount > pageParams.size
|
|
4199
4208
|
}, /*#__PURE__*/React.createElement(Table, {
|
|
@@ -4219,19 +4228,20 @@ var ApiTemplates = function ApiTemplates(_ref) {
|
|
|
4219
4228
|
})
|
|
4220
4229
|
})) : /*#__PURE__*/React.createElement("div", {
|
|
4221
4230
|
className: "flex h-full w-full items-center justify-center"
|
|
4222
|
-
}, /*#__PURE__*/React.createElement(NoData, {
|
|
4231
|
+
}, /*#__PURE__*/React.createElement(NoData, _extends({}, !isFilterApplied && {
|
|
4223
4232
|
primaryButtonProps: {
|
|
4224
4233
|
label: t("neetoMessageTemplate.api.addApiTemplate"),
|
|
4225
4234
|
onClick: function onClick() {
|
|
4226
4235
|
return setIsFormPaneOpen(true);
|
|
4227
4236
|
}
|
|
4228
|
-
}
|
|
4237
|
+
}
|
|
4238
|
+
}, {
|
|
4229
4239
|
title: isFilterApplied ? t("neetoMessageTemplate.template.filtersEmptyState", {
|
|
4230
4240
|
type: t("neetoMessageTemplate.template.apiTemplates")
|
|
4231
4241
|
}) : t("neetoMessageTemplate.template.emptyState", {
|
|
4232
4242
|
type: t("neetoMessageTemplate.template.apiTemplates")
|
|
4233
4243
|
})
|
|
4234
|
-
})), /*#__PURE__*/React.createElement(Pane, {
|
|
4244
|
+
}))), /*#__PURE__*/React.createElement(Pane, {
|
|
4235
4245
|
isOpen: isFormPaneOpen,
|
|
4236
4246
|
onClose: handleCloseDeleteAlertAndFormPane
|
|
4237
4247
|
}, function (_ref3) {
|
|
@@ -4271,15 +4281,6 @@ var SEND_TO_API_FORM_VALIDATION_SCHEMA = yup.object({
|
|
|
4271
4281
|
}))
|
|
4272
4282
|
});
|
|
4273
4283
|
|
|
4274
|
-
var buildSendToApiFormInitialValues = function buildSendToApiFormInitialValues(template) {
|
|
4275
|
-
if (isEmpty(template)) return SEND_TO_API_FORM_INITIAL_VALUES;
|
|
4276
|
-
var additionalData = isEmpty(template.additionalData) ? [ADDITIONAL_DATA_INITIAL_VALUE] : template.additionalData;
|
|
4277
|
-
return {
|
|
4278
|
-
endpoint: template.endpoint,
|
|
4279
|
-
additionalData: additionalData
|
|
4280
|
-
};
|
|
4281
|
-
};
|
|
4282
|
-
|
|
4283
4284
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4284
4285
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4285
4286
|
var SendToApiPane = function SendToApiPane(props) {
|
|
@@ -4302,10 +4303,6 @@ var SendToApiForm = function SendToApiForm(_ref) {
|
|
|
4302
4303
|
setFocusField = _ref.paneProps.setFocusField;
|
|
4303
4304
|
var _useTranslation = useTranslation(),
|
|
4304
4305
|
t = _useTranslation.t;
|
|
4305
|
-
var _useState = useState({}),
|
|
4306
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
4307
|
-
selectedTemplate = _useState2[0],
|
|
4308
|
-
setSelectedTemplate = _useState2[1];
|
|
4309
4306
|
var _useFetchTemplates = useFetchTemplates({
|
|
4310
4307
|
status: "active",
|
|
4311
4308
|
templateType: API_TEMPLATE_TYPE,
|
|
@@ -4316,6 +4313,10 @@ var SendToApiForm = function SendToApiForm(_ref) {
|
|
|
4316
4313
|
_useFetchTemplates$da3 = _useFetchTemplates$da2.templates,
|
|
4317
4314
|
templates = _useFetchTemplates$da3 === void 0 ? [] : _useFetchTemplates$da3,
|
|
4318
4315
|
isLoadingTemplates = _useFetchTemplates.isLoading;
|
|
4316
|
+
var handleTemplateChange = function handleTemplateChange(setFieldValue, template) {
|
|
4317
|
+
setFieldValue("endpoint", template.endpoint);
|
|
4318
|
+
setFieldValue("additionalData", template.additionalData);
|
|
4319
|
+
};
|
|
4319
4320
|
var handleSubmit = function handleSubmit(formValues) {
|
|
4320
4321
|
var additionalDataModifiedFormValues = modify("additionalData", rejectEmptyKeyValuePairs, formValues);
|
|
4321
4322
|
onSubmit(additionalDataModifiedFormValues);
|
|
@@ -4325,42 +4326,44 @@ var SendToApiForm = function SendToApiForm(_ref) {
|
|
|
4325
4326
|
weight: "semibold"
|
|
4326
4327
|
}, t("neetoMessageTemplate.api.sendToApi"))), /*#__PURE__*/React.createElement(Form$2, {
|
|
4327
4328
|
formikProps: {
|
|
4328
|
-
initialValues:
|
|
4329
|
-
enableReinitialize: true,
|
|
4329
|
+
initialValues: SEND_TO_API_FORM_INITIAL_VALUES,
|
|
4330
4330
|
validationSchema: SEND_TO_API_FORM_VALIDATION_SCHEMA,
|
|
4331
4331
|
onSubmit: handleSubmit
|
|
4332
4332
|
}
|
|
4333
|
-
},
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4333
|
+
}, function (_ref2) {
|
|
4334
|
+
var setFieldValue = _ref2.setFieldValue;
|
|
4335
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Pane.Body, null, /*#__PURE__*/React.createElement("div", {
|
|
4336
|
+
className: "w-full space-y-5"
|
|
4337
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
4338
|
+
innerRef: setFocusField,
|
|
4339
|
+
isLoading: isLoadingTemplates,
|
|
4340
|
+
label: t("neetoMessageTemplate.template.title"),
|
|
4341
|
+
options: renameKeys({
|
|
4342
|
+
name: "label",
|
|
4343
|
+
id: "value"
|
|
4344
|
+
}, templates),
|
|
4345
|
+
placeholder: t("neetoMessageTemplate.sendMessage.selectTemplate"),
|
|
4346
|
+
onChange: function onChange(template) {
|
|
4347
|
+
return handleTemplateChange(setFieldValue, template);
|
|
4348
|
+
}
|
|
4349
|
+
}), /*#__PURE__*/React.createElement(Input, {
|
|
4350
|
+
required: true,
|
|
4351
|
+
label: t("neetoMessageTemplate.api.endpoint"),
|
|
4352
|
+
name: "endpoint",
|
|
4353
|
+
placeholder: SAMPLE_URL
|
|
4354
|
+
}), /*#__PURE__*/React.createElement(KeyValuePairs, {
|
|
4355
|
+
label: t("neetoMessageTemplate.api.additionalData"),
|
|
4356
|
+
name: "additionalData"
|
|
4357
|
+
}))), /*#__PURE__*/React.createElement(Pane.Footer, null, /*#__PURE__*/React.createElement(ActionBlock, {
|
|
4358
|
+
isSubmitting: isSubmitting,
|
|
4359
|
+
cancelButtonProps: {
|
|
4360
|
+
onClick: onClose
|
|
4361
|
+
},
|
|
4362
|
+
submitButtonProps: {
|
|
4363
|
+
label: t("neetoMessageTemplate.template.send")
|
|
4364
|
+
}
|
|
4365
|
+
})));
|
|
4366
|
+
}));
|
|
4364
4367
|
};
|
|
4365
4368
|
|
|
4366
4369
|
export { ApiTemplates, MessageTemplates, SendMessagePane, SendToApiPane };
|