@bigbinary/neeto-message-templates-frontend 0.7.1 → 0.7.2
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/README.md +138 -69
- package/app/javascript/src/translations/en.json +1 -1
- package/dist/index.cjs.js +807 -684
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +791 -668
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/types.d.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useState, useRef, useEffect } from 'react';
|
|
2
2
|
import { hyphenate, noop, isNotEmpty, renameKeys, findBy, capitalize, nullSafe } from '@bigbinary/neeto-cist';
|
|
3
3
|
import { buildFiltersFromURL, Bar } from '@bigbinary/neeto-filters-frontend';
|
|
4
4
|
import Container from '@bigbinary/neeto-molecules/Container';
|
|
@@ -16,6 +16,7 @@ import { useQuery } from 'react-query';
|
|
|
16
16
|
import axios from 'axios';
|
|
17
17
|
import require$$0 from 'util';
|
|
18
18
|
import { create } from 'zustand';
|
|
19
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
19
20
|
import Pane from '@bigbinary/neetoui/Pane';
|
|
20
21
|
import { FormikEditor } from '@bigbinary/neeto-editor';
|
|
21
22
|
import NeetoUIForm from '@bigbinary/neetoui/formik/Form';
|
|
@@ -29,6 +30,7 @@ import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
|
|
|
29
30
|
import Alert from '@bigbinary/neetoui/Alert';
|
|
30
31
|
import Table from '@bigbinary/neetoui/Table';
|
|
31
32
|
import NoData from '@bigbinary/neetoui/NoData';
|
|
33
|
+
import Spinner from '@bigbinary/neetoui/Spinner';
|
|
32
34
|
import Select from '@bigbinary/neetoui/Select';
|
|
33
35
|
import Textarea$1 from '@bigbinary/neetoui/Textarea';
|
|
34
36
|
import Select$1 from '@bigbinary/neetoui/formik/Select';
|
|
@@ -152,6 +154,11 @@ var MESSAGE_TEMPLATES = {
|
|
|
152
154
|
addText: t$1("neetoMessageTemplate.template.addWhatsappTemplate"),
|
|
153
155
|
labelSingular: t$1("neetoMessageTemplate.template.whatsappTemplate"),
|
|
154
156
|
editText: t$1("neetoMessageTemplate.template.editWhatsappTemplate")
|
|
157
|
+
},
|
|
158
|
+
api: {
|
|
159
|
+
label: t$1("neetoMessageTemplate.template.apiTemplates"),
|
|
160
|
+
value: "api_template",
|
|
161
|
+
addText: t$1("neetoMessageTemplate.api.addApiTemplate")
|
|
155
162
|
}
|
|
156
163
|
};
|
|
157
164
|
var MESSAGE_TYPES = {
|
|
@@ -2275,8 +2282,8 @@ var QUERY_KEYS = {
|
|
|
2275
2282
|
NEETO_MESSAGE_TEMPLATES: "neeto-message-templates"
|
|
2276
2283
|
};
|
|
2277
2284
|
|
|
2278
|
-
function ownKeys$
|
|
2279
|
-
function _objectSpread$
|
|
2285
|
+
function ownKeys$d(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; }
|
|
2286
|
+
function _objectSpread$d(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$d(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$d(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2280
2287
|
var ownerIdValue = function ownerIdValue(ownerId) {
|
|
2281
2288
|
return isEmpty(ownerId) ? undefined : ownerId;
|
|
2282
2289
|
};
|
|
@@ -2291,7 +2298,7 @@ var useCreateTemplate = function useCreateTemplate(ownerId, options) {
|
|
|
2291
2298
|
messageTemplate: messageTemplate,
|
|
2292
2299
|
ownerId: ownerIdValue(ownerId)
|
|
2293
2300
|
});
|
|
2294
|
-
}, _objectSpread$
|
|
2301
|
+
}, _objectSpread$d({
|
|
2295
2302
|
keysToInvalidate: [QUERY_KEYS.NEETO_MESSAGE_TEMPLATES]
|
|
2296
2303
|
}, options));
|
|
2297
2304
|
};
|
|
@@ -2358,8 +2365,8 @@ var getMenuItems = function getMenuItems(_ref) {
|
|
|
2358
2365
|
}];
|
|
2359
2366
|
};
|
|
2360
2367
|
|
|
2361
|
-
function ownKeys$
|
|
2362
|
-
function _objectSpread$
|
|
2368
|
+
function ownKeys$c(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; }
|
|
2369
|
+
function _objectSpread$c(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$c(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$c(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2363
2370
|
var RowActions = function RowActions(_ref) {
|
|
2364
2371
|
var template = _ref.template,
|
|
2365
2372
|
setManageTemplatePane = _ref.setManageTemplatePane,
|
|
@@ -2371,14 +2378,14 @@ var RowActions = function RowActions(_ref) {
|
|
|
2371
2378
|
id = template.id;
|
|
2372
2379
|
var templateType = useTemplateStore(prop("templateType"));
|
|
2373
2380
|
var handleEditTemplate = function handleEditTemplate() {
|
|
2374
|
-
return setManageTemplatePane(_objectSpread$
|
|
2381
|
+
return setManageTemplatePane(_objectSpread$c(_objectSpread$c({}, MESSAGE_TEMPLATE_INITIAL_STATE), {}, {
|
|
2375
2382
|
isOpen: true,
|
|
2376
2383
|
isEdit: true,
|
|
2377
2384
|
template: template
|
|
2378
2385
|
}));
|
|
2379
2386
|
};
|
|
2380
2387
|
var handleDeleteTemplate = function handleDeleteTemplate() {
|
|
2381
|
-
return setManageTemplatePane(_objectSpread$
|
|
2388
|
+
return setManageTemplatePane(_objectSpread$c(_objectSpread$c({}, MESSAGE_TEMPLATE_INITIAL_STATE), {}, {
|
|
2382
2389
|
isDelete: true,
|
|
2383
2390
|
template: template
|
|
2384
2391
|
}));
|
|
@@ -2395,7 +2402,7 @@ var RowActions = function RowActions(_ref) {
|
|
|
2395
2402
|
onSuccess: onMutationSuccess
|
|
2396
2403
|
});
|
|
2397
2404
|
};
|
|
2398
|
-
return /*#__PURE__*/
|
|
2405
|
+
return /*#__PURE__*/jsx(MoreDropdown, {
|
|
2399
2406
|
dropdownButtonProps: {
|
|
2400
2407
|
"data-cy": "message-template-dropdown"
|
|
2401
2408
|
},
|
|
@@ -2411,10 +2418,10 @@ var RowActions = function RowActions(_ref) {
|
|
|
2411
2418
|
});
|
|
2412
2419
|
};
|
|
2413
2420
|
|
|
2414
|
-
function ownKeys$
|
|
2415
|
-
function _objectSpread$
|
|
2421
|
+
function ownKeys$b(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; }
|
|
2422
|
+
function _objectSpread$b(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$b(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$b(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2416
2423
|
var handleEditTemplate = function handleEditTemplate(setManageTemplatePane, template) {
|
|
2417
|
-
return setManageTemplatePane(_objectSpread$
|
|
2424
|
+
return setManageTemplatePane(_objectSpread$b(_objectSpread$b({}, MESSAGE_TEMPLATE_INITIAL_STATE), {}, {
|
|
2418
2425
|
isOpen: true,
|
|
2419
2426
|
isEdit: true,
|
|
2420
2427
|
template: template
|
|
@@ -2438,20 +2445,21 @@ var buildTableColumnData$1 = function buildTableColumnData(setManageTemplatePane
|
|
|
2438
2445
|
label: t$1("neetoMessageTemplate.template.name"),
|
|
2439
2446
|
type: "text",
|
|
2440
2447
|
render: function render(name, template) {
|
|
2441
|
-
return /*#__PURE__*/
|
|
2442
|
-
className: "flex items-center justify-between gap-x-3"
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2448
|
+
return /*#__PURE__*/jsxs("div", {
|
|
2449
|
+
className: "flex items-center justify-between gap-x-3",
|
|
2450
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
2451
|
+
label: name,
|
|
2452
|
+
style: "link",
|
|
2453
|
+
onClick: function onClick() {
|
|
2454
|
+
return handleEditTemplate(setManageTemplatePane, template);
|
|
2455
|
+
}
|
|
2456
|
+
}), /*#__PURE__*/jsx(RowActions, {
|
|
2457
|
+
onMutationSuccess: onMutationSuccess,
|
|
2458
|
+
ownerId: ownerId,
|
|
2459
|
+
setManageTemplatePane: setManageTemplatePane,
|
|
2460
|
+
template: template
|
|
2461
|
+
})]
|
|
2462
|
+
});
|
|
2455
2463
|
}
|
|
2456
2464
|
}, {
|
|
2457
2465
|
dataIndex: "status",
|
|
@@ -2474,21 +2482,6 @@ var buildTableColumnData$1 = function buildTableColumnData(setManageTemplatePane
|
|
|
2474
2482
|
}];
|
|
2475
2483
|
};
|
|
2476
2484
|
|
|
2477
|
-
function _extends() {
|
|
2478
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
2479
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
2480
|
-
var source = arguments[i];
|
|
2481
|
-
for (var key in source) {
|
|
2482
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2483
|
-
target[key] = source[key];
|
|
2484
|
-
}
|
|
2485
|
-
}
|
|
2486
|
-
}
|
|
2487
|
-
return target;
|
|
2488
|
-
};
|
|
2489
|
-
return _extends.apply(this, arguments);
|
|
2490
|
-
}
|
|
2491
|
-
|
|
2492
2485
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
2493
2486
|
if (source == null) return {};
|
|
2494
2487
|
var target = {};
|
|
@@ -2519,6 +2512,8 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
2519
2512
|
}
|
|
2520
2513
|
|
|
2521
2514
|
var _excluded = ["label", "name"];
|
|
2515
|
+
function ownKeys$a(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; }
|
|
2516
|
+
function _objectSpread$a(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2522
2517
|
var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
|
|
2523
2518
|
var label = _ref.label,
|
|
2524
2519
|
name = _ref.name,
|
|
@@ -2530,7 +2525,7 @@ var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
|
|
|
2530
2525
|
event.preventDefault();
|
|
2531
2526
|
submitForm();
|
|
2532
2527
|
};
|
|
2533
|
-
return /*#__PURE__*/
|
|
2528
|
+
return /*#__PURE__*/jsx(Textarea, _objectSpread$a({
|
|
2534
2529
|
label: label,
|
|
2535
2530
|
name: name,
|
|
2536
2531
|
className: "neeto-message-templates-nano-adaptive-input",
|
|
@@ -2953,6 +2948,8 @@ try {
|
|
|
2953
2948
|
|
|
2954
2949
|
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
2955
2950
|
|
|
2951
|
+
function ownKeys$9(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; }
|
|
2952
|
+
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2956
2953
|
var TestMessage = function TestMessage(_ref) {
|
|
2957
2954
|
var isEmailTemplate = _ref.isEmailTemplate,
|
|
2958
2955
|
handleSubmitTestTemplate = _ref.handleSubmitTestTemplate,
|
|
@@ -3013,34 +3010,38 @@ var TestMessage = function TestMessage(_ref) {
|
|
|
3013
3010
|
event.preventDefault();
|
|
3014
3011
|
!isTestTemplateButtonDisabled && handleSubmitTestTemplate(values);
|
|
3015
3012
|
};
|
|
3016
|
-
return /*#__PURE__*/
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3013
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
3014
|
+
children: [/*#__PURE__*/jsxs("div", {
|
|
3015
|
+
className: "neeto-ui-flex left-0 flex items-start gap-x-2",
|
|
3016
|
+
children: [/*#__PURE__*/jsx(Input, _objectSpread$9(_objectSpread$9({
|
|
3017
|
+
"data-cy": "message-template-test-input"
|
|
3018
|
+
}, !isEmailTemplate && {
|
|
3019
|
+
helpText: t("neetoMessageTemplate.template.phoneNumberHelpText")
|
|
3020
|
+
}), {}, {
|
|
3021
|
+
name: isEmailTemplate ? "testEmailAddress" : "testPhoneNumber",
|
|
3022
|
+
placeholder: t(isEmailTemplate ? "neetoMessageTemplate.template.emailAddress" : "neetoMessageTemplate.template.phoneNumber"),
|
|
3023
|
+
onKeyDown: handleKeyDown,
|
|
3024
|
+
onKeyUp: handleTestValidation
|
|
3025
|
+
})), /*#__PURE__*/jsx(Button, {
|
|
3026
|
+
"data-cy": "message-template-test-button",
|
|
3027
|
+
disabled: isTestTemplateButtonDisabled,
|
|
3028
|
+
loading: isTestMessageLoading,
|
|
3029
|
+
style: "primary",
|
|
3030
|
+
type: "button",
|
|
3031
|
+
label: isEmailTemplate ? t("neetoMessageTemplate.template.sendTestEmail") : t("neetoMessageTemplate.template.sendTestSms"),
|
|
3032
|
+
onClick: function onClick() {
|
|
3033
|
+
return handleSubmitTestTemplate(values);
|
|
3034
|
+
}
|
|
3035
|
+
})]
|
|
3036
|
+
}), !isEmailTemplate && /*#__PURE__*/jsx(Typography, {
|
|
3037
|
+
style: "body2",
|
|
3038
|
+
children: t("neetoMessageTemplate.sendMessage.testSmsNote")
|
|
3039
|
+
}), customFields]
|
|
3040
|
+
});
|
|
3040
3041
|
};
|
|
3041
3042
|
|
|
3042
|
-
function ownKeys$
|
|
3043
|
-
function _objectSpread$
|
|
3043
|
+
function ownKeys$8(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; }
|
|
3044
|
+
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3044
3045
|
var Form$1 = function Form(_ref) {
|
|
3045
3046
|
var onClose = _ref.onClose,
|
|
3046
3047
|
isEdit = _ref.isEdit,
|
|
@@ -3061,7 +3062,7 @@ var Form$1 = function Form(_ref) {
|
|
|
3061
3062
|
var templateType = useTemplateStore(prop("templateType"));
|
|
3062
3063
|
var isEmailTemplate = equals(templateType, "email_template");
|
|
3063
3064
|
var isTestTemplateVisible = includes(templateType, ["sms_template", "email_template"]) && shouldIncludeTestTemplate;
|
|
3064
|
-
var _ref2 = isEmailTemplate ? [_objectSpread$
|
|
3065
|
+
var _ref2 = isEmailTemplate ? [_objectSpread$8(_objectSpread$8({}, EMAIL_TEMPLATE_INITIAL_VALUES), pick(["name", "body", "subject", "active"], template)), EMAIL_TEMPLATE_FORM_SCHEMA] : [_objectSpread$8(_objectSpread$8({}, SMS_TEMPLATE_INITIAL_VALUES), pick(["name", "body", "active"], template)), SMS_TEMPLATE_FORM_VALIDATION_SCHEMA],
|
|
3065
3066
|
_ref3 = _slicedToArray(_ref2, 2),
|
|
3066
3067
|
TEMPLATE_INITIAL_VALUES = _ref3[0],
|
|
3067
3068
|
TEMPLATE_FORM_SCHEMA = _ref3[1];
|
|
@@ -3084,7 +3085,7 @@ var Form$1 = function Form(_ref) {
|
|
|
3084
3085
|
});
|
|
3085
3086
|
};
|
|
3086
3087
|
var messageBodyLabel = isEmailTemplate ? t("neetoMessageTemplate.template.emailBody") : t("neetoMessageTemplate.template.smsBody");
|
|
3087
|
-
return /*#__PURE__*/
|
|
3088
|
+
return /*#__PURE__*/jsxs(NeetoUIForm, {
|
|
3088
3089
|
formProps: {
|
|
3089
3090
|
noValidate: true,
|
|
3090
3091
|
className: "flex w-full flex-col gap-y-4 pb-6"
|
|
@@ -3095,43 +3096,45 @@ var Form$1 = function Form(_ref) {
|
|
|
3095
3096
|
validateOnBlur: true,
|
|
3096
3097
|
validateOnChange: true,
|
|
3097
3098
|
onSubmit: handleSubmit
|
|
3098
|
-
}
|
|
3099
|
-
}, /*#__PURE__*/React.createElement(Input, {
|
|
3100
|
-
required: true,
|
|
3101
|
-
label: t("neetoMessageTemplate.template.templateName"),
|
|
3102
|
-
name: "name",
|
|
3103
|
-
ref: setInitialFocusField
|
|
3104
|
-
}), isEmailTemplate && /*#__PURE__*/React.createElement(FormikAdaptiveInput, {
|
|
3105
|
-
required: true,
|
|
3106
|
-
label: t("neetoMessageTemplate.template.emailSubject"),
|
|
3107
|
-
name: "subject"
|
|
3108
|
-
}), /*#__PURE__*/React.createElement(FormikEditor, {
|
|
3109
|
-
hideSlashCommands: true,
|
|
3110
|
-
required: true,
|
|
3111
|
-
contentClassName: "max-h-40",
|
|
3112
|
-
defaults: isEmailTemplate ? undefined : [],
|
|
3113
|
-
label: messageBodyLabel,
|
|
3114
|
-
name: "body",
|
|
3115
|
-
ref: editorRef,
|
|
3116
|
-
rows: DEFAULT_EDITOR_ROW_COUNT,
|
|
3117
|
-
variables: templateVariables
|
|
3118
|
-
}), isTestTemplateVisible && /*#__PURE__*/React.createElement(TestMessage, {
|
|
3119
|
-
customFields: customFields,
|
|
3120
|
-
handleSubmitTestTemplate: handleSubmitTestTemplate,
|
|
3121
|
-
isEmailTemplate: isEmailTemplate,
|
|
3122
|
-
isTestMessageLoading: isTestMessageLoading,
|
|
3123
|
-
isTestingTemplateDisabled: isTestingTemplateDisabled
|
|
3124
|
-
}), /*#__PURE__*/React.createElement(Pane.Footer, {
|
|
3125
|
-
className: "absolute bottom-0 left-0"
|
|
3126
|
-
}, /*#__PURE__*/React.createElement(ActionBlock, {
|
|
3127
|
-
cancelButtonProps: {
|
|
3128
|
-
"data-cy": "message-template-reset-button",
|
|
3129
|
-
onClick: onClose
|
|
3130
3099
|
},
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3100
|
+
children: [/*#__PURE__*/jsx(Input, {
|
|
3101
|
+
required: true,
|
|
3102
|
+
label: t("neetoMessageTemplate.template.templateName"),
|
|
3103
|
+
name: "name",
|
|
3104
|
+
ref: setInitialFocusField
|
|
3105
|
+
}), isEmailTemplate && /*#__PURE__*/jsx(FormikAdaptiveInput, {
|
|
3106
|
+
required: true,
|
|
3107
|
+
label: t("neetoMessageTemplate.template.emailSubject"),
|
|
3108
|
+
name: "subject"
|
|
3109
|
+
}), /*#__PURE__*/jsx(FormikEditor, {
|
|
3110
|
+
hideSlashCommands: true,
|
|
3111
|
+
required: true,
|
|
3112
|
+
contentClassName: "max-h-40",
|
|
3113
|
+
defaults: isEmailTemplate ? undefined : [],
|
|
3114
|
+
label: messageBodyLabel,
|
|
3115
|
+
name: "body",
|
|
3116
|
+
ref: editorRef,
|
|
3117
|
+
rows: DEFAULT_EDITOR_ROW_COUNT,
|
|
3118
|
+
variables: templateVariables
|
|
3119
|
+
}), isTestTemplateVisible && /*#__PURE__*/jsx(TestMessage, {
|
|
3120
|
+
customFields: customFields,
|
|
3121
|
+
handleSubmitTestTemplate: handleSubmitTestTemplate,
|
|
3122
|
+
isEmailTemplate: isEmailTemplate,
|
|
3123
|
+
isTestMessageLoading: isTestMessageLoading,
|
|
3124
|
+
isTestingTemplateDisabled: isTestingTemplateDisabled
|
|
3125
|
+
}), /*#__PURE__*/jsx(Pane.Footer, {
|
|
3126
|
+
className: "absolute bottom-0 left-0",
|
|
3127
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
3128
|
+
cancelButtonProps: {
|
|
3129
|
+
"data-cy": "message-template-reset-button",
|
|
3130
|
+
onClick: onClose
|
|
3131
|
+
},
|
|
3132
|
+
submitButtonProps: {
|
|
3133
|
+
"data-cy": "message-template-submit-button"
|
|
3134
|
+
}
|
|
3135
|
+
})
|
|
3136
|
+
})]
|
|
3137
|
+
});
|
|
3135
3138
|
};
|
|
3136
3139
|
|
|
3137
3140
|
var AddEdit = function AddEdit(_ref) {
|
|
@@ -3155,27 +3158,33 @@ var AddEdit = function AddEdit(_ref) {
|
|
|
3155
3158
|
isEdit = manageTemplatePane.isEdit,
|
|
3156
3159
|
template = manageTemplatePane.template;
|
|
3157
3160
|
var label = isEdit ? editText : addText;
|
|
3158
|
-
return /*#__PURE__*/
|
|
3161
|
+
return /*#__PURE__*/jsxs(Pane, {
|
|
3159
3162
|
isOpen: isOpen,
|
|
3160
3163
|
onClose: onClose,
|
|
3161
|
-
initialFocusRef: initialFocusField
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3164
|
+
initialFocusRef: initialFocusField,
|
|
3165
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
3166
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
3167
|
+
style: "h2",
|
|
3168
|
+
weight: "semibold",
|
|
3169
|
+
children: label
|
|
3170
|
+
})
|
|
3171
|
+
}), /*#__PURE__*/jsx(Pane.Body, {
|
|
3172
|
+
children: /*#__PURE__*/jsx(Form$1, {
|
|
3173
|
+
createUpdateTemplate: createUpdateTemplate,
|
|
3174
|
+
customFields: customFields,
|
|
3175
|
+
handleSubmitTestTemplate: handleSubmitTestTemplate,
|
|
3176
|
+
isEdit: isEdit,
|
|
3177
|
+
isTestMessageLoading: isTestMessageLoading,
|
|
3178
|
+
isTestingTemplateDisabled: isTestingTemplateDisabled,
|
|
3179
|
+
onClose: onClose,
|
|
3180
|
+
onMutationSuccess: onMutationSuccess,
|
|
3181
|
+
setInitialFocusField: setInitialFocusField,
|
|
3182
|
+
shouldIncludeTestTemplate: shouldIncludeTestTemplate,
|
|
3183
|
+
template: template,
|
|
3184
|
+
templateVariables: templateVariables
|
|
3185
|
+
})
|
|
3186
|
+
})]
|
|
3187
|
+
});
|
|
3179
3188
|
};
|
|
3180
3189
|
|
|
3181
3190
|
function _arrayWithoutHoles(arr) {
|
|
@@ -3267,6 +3276,8 @@ var useTemplates = function useTemplates(_ref) {
|
|
|
3267
3276
|
};
|
|
3268
3277
|
};
|
|
3269
3278
|
|
|
3279
|
+
function ownKeys$7(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; }
|
|
3280
|
+
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$7(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$7(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3270
3281
|
var List = function List(_ref) {
|
|
3271
3282
|
var setManageTemplatePane = _ref.setManageTemplatePane,
|
|
3272
3283
|
templatesData = _ref.templatesData,
|
|
@@ -3303,62 +3314,66 @@ var List = function List(_ref) {
|
|
|
3303
3314
|
}
|
|
3304
3315
|
});
|
|
3305
3316
|
};
|
|
3306
|
-
return /*#__PURE__*/
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3317
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
3318
|
+
children: [!isEmpty(templates) ? /*#__PURE__*/jsx(TableWrapper, {
|
|
3319
|
+
hasPagination: totalCount > pageSize,
|
|
3320
|
+
children: /*#__PURE__*/jsx(Table, {
|
|
3321
|
+
totalCount: totalCount,
|
|
3322
|
+
fixedHeight: true,
|
|
3323
|
+
currentPageNumber: pageIndex,
|
|
3324
|
+
defaultPageSize: pageSize,
|
|
3325
|
+
loading: isLoading,
|
|
3326
|
+
rowData: templates,
|
|
3327
|
+
scroll: {
|
|
3328
|
+
x: "100%"
|
|
3329
|
+
},
|
|
3330
|
+
columnData: buildTableColumnData$1(setManageTemplatePane, ownerId, onMutationSuccess),
|
|
3331
|
+
handlePageChange: function handlePageChange(index, size) {
|
|
3332
|
+
return setPageProperties({
|
|
3333
|
+
index: index,
|
|
3334
|
+
size: size
|
|
3335
|
+
});
|
|
3336
|
+
}
|
|
3337
|
+
})
|
|
3338
|
+
}) : /*#__PURE__*/jsx("div", {
|
|
3339
|
+
className: "flex h-full w-full items-center justify-center",
|
|
3340
|
+
children: /*#__PURE__*/jsx(NoData, _objectSpread$7(_objectSpread$7({}, !isFilterApplied && {
|
|
3341
|
+
primaryButtonProps: {
|
|
3342
|
+
label: addText,
|
|
3343
|
+
onClick: function onClick() {
|
|
3344
|
+
return setManageTemplatePane(assoc("isOpen", true));
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
}), {}, {
|
|
3348
|
+
title: isFilterApplied ? t("neetoMessageTemplate.template.filtersEmptyState", {
|
|
3349
|
+
type: emptyStateLabel
|
|
3350
|
+
}) : t("neetoMessageTemplate.template.emptyState", {
|
|
3351
|
+
type: emptyStateLabel
|
|
3352
|
+
})
|
|
3353
|
+
}))
|
|
3354
|
+
}), /*#__PURE__*/jsx(Alert, {
|
|
3355
|
+
isOpen: isDelete,
|
|
3356
|
+
isSubmitting: isDeleting,
|
|
3357
|
+
submitButtonLabel: t("neetoMessageTemplate.template.delete"),
|
|
3358
|
+
message: /*#__PURE__*/jsx(Trans, {
|
|
3359
|
+
i18nKey: "neetoMessageTemplate.template.templateDeleteConfirmation",
|
|
3360
|
+
values: {
|
|
3361
|
+
name: template.name
|
|
3362
|
+
}
|
|
3363
|
+
}),
|
|
3364
|
+
title: t("neetoMessageTemplate.template.deleteTemplate", {
|
|
3365
|
+
label: typeLabelSingular
|
|
3366
|
+
}),
|
|
3367
|
+
onClose: function onClose() {
|
|
3368
|
+
return setManageTemplatePane(assoc("isDelete", false));
|
|
3369
|
+
},
|
|
3370
|
+
onSubmit: handleDelete
|
|
3371
|
+
})]
|
|
3372
|
+
});
|
|
3358
3373
|
};
|
|
3359
3374
|
|
|
3360
|
-
function ownKeys$
|
|
3361
|
-
function _objectSpread$
|
|
3375
|
+
function ownKeys$6(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; }
|
|
3376
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3362
3377
|
var MessageTemplates = function MessageTemplates(_ref) {
|
|
3363
3378
|
var _ref$breadcrumbs = _ref.breadcrumbs,
|
|
3364
3379
|
breadcrumbs = _ref$breadcrumbs === void 0 ? [] : _ref$breadcrumbs,
|
|
@@ -3416,7 +3431,7 @@ var MessageTemplates = function MessageTemplates(_ref) {
|
|
|
3416
3431
|
editText = _MESSAGE_TEMPLATES$ty.editText;
|
|
3417
3432
|
var isFilterApplied = isNotEmpty(filters) || isNotEmpty(searchTerm);
|
|
3418
3433
|
var handleActionClick = function handleActionClick() {
|
|
3419
|
-
return setManageTemplatePane(_objectSpread$
|
|
3434
|
+
return setManageTemplatePane(_objectSpread$6(_objectSpread$6({}, MESSAGE_TEMPLATE_INITIAL_STATE), {}, {
|
|
3420
3435
|
isOpen: true
|
|
3421
3436
|
}));
|
|
3422
3437
|
};
|
|
@@ -3430,70 +3445,116 @@ var MessageTemplates = function MessageTemplates(_ref) {
|
|
|
3430
3445
|
templateType: value
|
|
3431
3446
|
});
|
|
3432
3447
|
}, [value]);
|
|
3433
|
-
return /*#__PURE__*/
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3448
|
+
return /*#__PURE__*/jsxs(Container, {
|
|
3449
|
+
children: [/*#__PURE__*/jsx(NeetoHeader, {
|
|
3450
|
+
breadcrumbs: breadcrumbs,
|
|
3451
|
+
searchProps: renderSearchProps(label, value),
|
|
3452
|
+
size: "small",
|
|
3453
|
+
title: label,
|
|
3454
|
+
actionBlock: /*#__PURE__*/jsx(Button, {
|
|
3455
|
+
"data-cy": "add-".concat(hyphenate(value), "-button"),
|
|
3456
|
+
label: addText,
|
|
3457
|
+
onClick: handleActionClick
|
|
3458
|
+
})
|
|
3459
|
+
}), /*#__PURE__*/jsx(SubHeader, {
|
|
3460
|
+
leftActionBlock: /*#__PURE__*/jsx(Typography, {
|
|
3461
|
+
component: "h4",
|
|
3462
|
+
children: t("neetoMessageTemplate.template.messageTemplatesWithCount", {
|
|
3463
|
+
type: MESSAGE_TYPES[type],
|
|
3464
|
+
count: templatesCount
|
|
3465
|
+
})
|
|
3466
|
+
}),
|
|
3467
|
+
rightActionBlock: /*#__PURE__*/jsx(SubHeader.RightBlock, {
|
|
3468
|
+
dataProps: {
|
|
3469
|
+
totalCount: isFilterApplied ? null : templatesCount
|
|
3470
|
+
},
|
|
3471
|
+
filterProps: {
|
|
3472
|
+
columns: filterColumns,
|
|
3473
|
+
isOpen: isFilterPaneOpen,
|
|
3474
|
+
keyword: searchKeywordProps,
|
|
3475
|
+
setIsOpen: setIsFilterPaneOpen,
|
|
3476
|
+
onChange: handleChange
|
|
3477
|
+
}
|
|
3478
|
+
})
|
|
3479
|
+
}), /*#__PURE__*/jsx(Bar, {
|
|
3480
|
+
columns: filterColumns,
|
|
3481
|
+
keyword: searchKeywordProps,
|
|
3482
|
+
setIsPaneOpen: setIsFilterPaneOpen,
|
|
3483
|
+
onChange: handleChange
|
|
3484
|
+
}), /*#__PURE__*/jsx(List, {
|
|
3485
|
+
addText: addText,
|
|
3486
|
+
isFilterApplied: isFilterApplied,
|
|
3487
|
+
isLoading: isLoading,
|
|
3488
|
+
label: label,
|
|
3489
|
+
labelSingular: labelSingular,
|
|
3490
|
+
manageTemplatePane: manageTemplatePane,
|
|
3491
|
+
onMutationSuccess: onMutationSuccess,
|
|
3492
|
+
ownerId: ownerId,
|
|
3493
|
+
pageProperties: pageProperties,
|
|
3494
|
+
setManageTemplatePane: setManageTemplatePane,
|
|
3495
|
+
setPageProperties: setPageProperties,
|
|
3496
|
+
templatesData: templatesData,
|
|
3497
|
+
type: type
|
|
3498
|
+
}), /*#__PURE__*/jsx(AddEdit, {
|
|
3499
|
+
addText: addText,
|
|
3500
|
+
createUpdateTemplate: createUpdateTemplate,
|
|
3501
|
+
editText: editText,
|
|
3502
|
+
handleSubmitTestTemplate: handleSubmitTestTemplate,
|
|
3503
|
+
isTestMessageLoading: isTestMessageLoading,
|
|
3504
|
+
isTestingTemplateDisabled: isTestingTemplateDisabled,
|
|
3505
|
+
manageTemplatePane: manageTemplatePane,
|
|
3506
|
+
onMutationSuccess: onMutationSuccess,
|
|
3507
|
+
shouldIncludeTestTemplate: shouldIncludeTestTemplate,
|
|
3508
|
+
templateVariables: templateVariables,
|
|
3509
|
+
customFields: manageTemplatesPaneCustomFields,
|
|
3510
|
+
onClose: function onClose() {
|
|
3511
|
+
return setManageTemplatePane(assoc("isOpen", false));
|
|
3460
3512
|
}
|
|
3461
|
-
})
|
|
3462
|
-
})
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3513
|
+
})]
|
|
3514
|
+
});
|
|
3515
|
+
};
|
|
3516
|
+
|
|
3517
|
+
var NoDataPage = function NoDataPage(_ref) {
|
|
3518
|
+
var type = _ref.type,
|
|
3519
|
+
addNewTemplateRoute = _ref.addNewTemplateRoute,
|
|
3520
|
+
_ref$helpDocUrl = _ref.helpDocUrl,
|
|
3521
|
+
helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl;
|
|
3522
|
+
var _useTranslation = useTranslation(),
|
|
3523
|
+
t = _useTranslation.t;
|
|
3524
|
+
var _MESSAGE_TEMPLATES$ty = MESSAGE_TEMPLATES[type],
|
|
3525
|
+
addText = _MESSAGE_TEMPLATES$ty.addText,
|
|
3526
|
+
label = _MESSAGE_TEMPLATES$ty.label;
|
|
3527
|
+
if (type === MESSAGE_TYPES.whatsapp) {
|
|
3528
|
+
return /*#__PURE__*/jsx("div", {
|
|
3529
|
+
className: "flex h-full w-full items-center justify-center px-6 text-center",
|
|
3530
|
+
children: /*#__PURE__*/jsxs(Typography, {
|
|
3531
|
+
children: [t("neetoMessageTemplate.template.emptyState", {
|
|
3532
|
+
type: t("neetoMessageTemplate.template.whatsappTemplates")
|
|
3533
|
+
}), " ", helpDocUrl && /*#__PURE__*/jsx(Trans, {
|
|
3534
|
+
i18nKey: "neetoMessageTemplate.template.whatsapp.helpDocText",
|
|
3535
|
+
components: {
|
|
3536
|
+
Link: /*#__PURE__*/jsx(Button, {
|
|
3537
|
+
href: helpDocUrl,
|
|
3538
|
+
size: "large",
|
|
3539
|
+
style: "link"
|
|
3540
|
+
})
|
|
3541
|
+
}
|
|
3542
|
+
})]
|
|
3543
|
+
})
|
|
3544
|
+
});
|
|
3545
|
+
}
|
|
3546
|
+
return /*#__PURE__*/jsxs("div", {
|
|
3547
|
+
className: "flex h-full w-full flex-col items-center justify-center",
|
|
3548
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
3549
|
+
children: t("neetoMessageTemplate.template.emptyState", {
|
|
3550
|
+
type: label
|
|
3551
|
+
})
|
|
3552
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
3553
|
+
className: "mt-4",
|
|
3554
|
+
label: addText,
|
|
3555
|
+
to: addNewTemplateRoute
|
|
3556
|
+
})]
|
|
3557
|
+
});
|
|
3497
3558
|
};
|
|
3498
3559
|
|
|
3499
3560
|
var formatEditorContent = function formatEditorContent(value) {
|
|
@@ -3520,12 +3581,12 @@ var WHATSAPP_MESSAGE_FORM_VALIDATIONS_SCHEMA = yup.object().shape({
|
|
|
3520
3581
|
})
|
|
3521
3582
|
});
|
|
3522
3583
|
|
|
3523
|
-
function ownKeys$
|
|
3524
|
-
function _objectSpread$
|
|
3584
|
+
function ownKeys$5(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; }
|
|
3585
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3525
3586
|
var EmailAndSms = function EmailAndSms(_ref) {
|
|
3526
3587
|
var onClose = _ref.onClose,
|
|
3527
3588
|
templates = _ref.templates,
|
|
3528
|
-
|
|
3589
|
+
setFocusField = _ref.setFocusField,
|
|
3529
3590
|
templateVariables = _ref.templateVariables,
|
|
3530
3591
|
customFields = _ref.customFields,
|
|
3531
3592
|
customFieldsInitialValues = _ref.customFieldsInitialValues,
|
|
@@ -3541,9 +3602,9 @@ var EmailAndSms = function EmailAndSms(_ref) {
|
|
|
3541
3602
|
INITIAL_VALUES = _ref3[0],
|
|
3542
3603
|
SEND_MESSAGE_FORM_SCHEMA = _ref3[1];
|
|
3543
3604
|
var updatedInitialValues = mergeAll([INITIAL_VALUES, customFieldsInitialValues]);
|
|
3544
|
-
var updatedValidationSchema = yup.object().shape(_objectSpread$
|
|
3605
|
+
var updatedValidationSchema = yup.object().shape(_objectSpread$5(_objectSpread$5({}, SEND_MESSAGE_FORM_SCHEMA === null || SEND_MESSAGE_FORM_SCHEMA === void 0 ? void 0 : SEND_MESSAGE_FORM_SCHEMA.fields), customFieldsValidationSchema === null || customFieldsValidationSchema === void 0 ? void 0 : customFieldsValidationSchema.fields));
|
|
3545
3606
|
var initialValueKeys = Object.keys(INITIAL_VALUES);
|
|
3546
|
-
return /*#__PURE__*/
|
|
3607
|
+
return /*#__PURE__*/jsx(NeetoUIForm, {
|
|
3547
3608
|
formProps: {
|
|
3548
3609
|
noValidate: true,
|
|
3549
3610
|
className: "flex w-full flex-col gap-y-4 pb-6"
|
|
@@ -3552,61 +3613,65 @@ var EmailAndSms = function EmailAndSms(_ref) {
|
|
|
3552
3613
|
initialValues: updatedInitialValues,
|
|
3553
3614
|
validationSchema: updatedValidationSchema,
|
|
3554
3615
|
onSubmit: handleSubmit
|
|
3616
|
+
},
|
|
3617
|
+
children: function children(_ref4) {
|
|
3618
|
+
var setValues = _ref4.setValues,
|
|
3619
|
+
values = _ref4.values;
|
|
3620
|
+
var handleTemplateChange = function handleTemplateChange(value) {
|
|
3621
|
+
if (!value) return;
|
|
3622
|
+
var customFieldValues = omit(initialValueKeys, values);
|
|
3623
|
+
var template = findBy({
|
|
3624
|
+
id: value === null || value === void 0 ? void 0 : value.value
|
|
3625
|
+
}, templates);
|
|
3626
|
+
setValues(_objectSpread$5(_objectSpread$5({}, template), customFieldValues));
|
|
3627
|
+
editorRef.current.editor.commands.setContent(template.body);
|
|
3628
|
+
};
|
|
3629
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
3630
|
+
children: [/*#__PURE__*/jsx(Select, {
|
|
3631
|
+
isClearable: true,
|
|
3632
|
+
isSearchable: true,
|
|
3633
|
+
innerRef: setFocusField,
|
|
3634
|
+
label: t("neetoMessageTemplate.template.title"),
|
|
3635
|
+
options: renameKeys({
|
|
3636
|
+
name: "label",
|
|
3637
|
+
id: "value"
|
|
3638
|
+
}, templates),
|
|
3639
|
+
placeholder: t("neetoMessageTemplate.sendMessage.selectTemplate"),
|
|
3640
|
+
onChange: handleTemplateChange
|
|
3641
|
+
}), customFields, isEmailTemplate && /*#__PURE__*/jsx(Input, {
|
|
3642
|
+
required: true,
|
|
3643
|
+
label: t("neetoMessageTemplate.template.subject"),
|
|
3644
|
+
name: "subject"
|
|
3645
|
+
}), /*#__PURE__*/jsx(FormikEditor, {
|
|
3646
|
+
hideSlashCommands: true,
|
|
3647
|
+
required: true,
|
|
3648
|
+
contentClassName: "max-h-40",
|
|
3649
|
+
defaults: isEmailTemplate ? undefined : [],
|
|
3650
|
+
label: t("neetoMessageTemplate.template.body"),
|
|
3651
|
+
name: "body",
|
|
3652
|
+
ref: editorRef,
|
|
3653
|
+
rows: DEFAULT_EDITOR_ROW_COUNT,
|
|
3654
|
+
variables: templateVariables
|
|
3655
|
+
}), /*#__PURE__*/jsx(Pane.Footer, {
|
|
3656
|
+
className: "absolute bottom-0 left-0",
|
|
3657
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
3658
|
+
cancelButtonProps: {
|
|
3659
|
+
"data-cy": "message-template-cancel-button",
|
|
3660
|
+
onClick: onClose
|
|
3661
|
+
},
|
|
3662
|
+
submitButtonProps: {
|
|
3663
|
+
"data-cy": "message-template-send-button",
|
|
3664
|
+
label: t("neetoMessageTemplate.template.send")
|
|
3665
|
+
}
|
|
3666
|
+
})
|
|
3667
|
+
})]
|
|
3668
|
+
});
|
|
3555
3669
|
}
|
|
3556
|
-
}, function (_ref4) {
|
|
3557
|
-
var setValues = _ref4.setValues,
|
|
3558
|
-
values = _ref4.values;
|
|
3559
|
-
var handleTemplateChange = function handleTemplateChange(value) {
|
|
3560
|
-
if (!value) return;
|
|
3561
|
-
var customFieldValues = omit(initialValueKeys, values);
|
|
3562
|
-
var template = findBy({
|
|
3563
|
-
id: value === null || value === void 0 ? void 0 : value.value
|
|
3564
|
-
}, templates);
|
|
3565
|
-
setValues(_objectSpread$3(_objectSpread$3({}, template), customFieldValues));
|
|
3566
|
-
editorRef.current.editor.commands.setContent(template.body);
|
|
3567
|
-
};
|
|
3568
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Select, {
|
|
3569
|
-
isClearable: true,
|
|
3570
|
-
isSearchable: true,
|
|
3571
|
-
innerRef: setInitialFocusField,
|
|
3572
|
-
label: t("neetoMessageTemplate.template.title"),
|
|
3573
|
-
options: renameKeys({
|
|
3574
|
-
name: "label",
|
|
3575
|
-
id: "value"
|
|
3576
|
-
}, templates),
|
|
3577
|
-
placeholder: t("neetoMessageTemplate.sendMessage.selectTemplate"),
|
|
3578
|
-
onChange: handleTemplateChange
|
|
3579
|
-
}), customFields, isEmailTemplate && /*#__PURE__*/React.createElement(Input, {
|
|
3580
|
-
required: true,
|
|
3581
|
-
label: t("neetoMessageTemplate.template.subject"),
|
|
3582
|
-
name: "subject"
|
|
3583
|
-
}), /*#__PURE__*/React.createElement(FormikEditor, {
|
|
3584
|
-
hideSlashCommands: true,
|
|
3585
|
-
required: true,
|
|
3586
|
-
contentClassName: "max-h-40",
|
|
3587
|
-
defaults: isEmailTemplate ? undefined : [],
|
|
3588
|
-
label: t("neetoMessageTemplate.template.body"),
|
|
3589
|
-
name: "body",
|
|
3590
|
-
ref: editorRef,
|
|
3591
|
-
rows: DEFAULT_EDITOR_ROW_COUNT,
|
|
3592
|
-
variables: templateVariables
|
|
3593
|
-
}), /*#__PURE__*/React.createElement(Pane.Footer, {
|
|
3594
|
-
className: "absolute bottom-0 left-0"
|
|
3595
|
-
}, /*#__PURE__*/React.createElement(ActionBlock, {
|
|
3596
|
-
cancelButtonProps: {
|
|
3597
|
-
"data-cy": "message-template-cancel-button",
|
|
3598
|
-
onClick: onClose
|
|
3599
|
-
},
|
|
3600
|
-
submitButtonProps: {
|
|
3601
|
-
"data-cy": "message-template-send-button",
|
|
3602
|
-
label: t("neetoMessageTemplate.template.send")
|
|
3603
|
-
}
|
|
3604
|
-
})));
|
|
3605
3670
|
});
|
|
3606
3671
|
};
|
|
3607
3672
|
|
|
3608
|
-
function ownKeys$
|
|
3609
|
-
function _objectSpread$
|
|
3673
|
+
function ownKeys$4(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; }
|
|
3674
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3610
3675
|
var Whatsapp = function Whatsapp(_ref) {
|
|
3611
3676
|
var _templates$, _templates$2, _templates$3, _templates$4;
|
|
3612
3677
|
var templates = _ref.templates,
|
|
@@ -3614,9 +3679,7 @@ var Whatsapp = function Whatsapp(_ref) {
|
|
|
3614
3679
|
handleSubmit = _ref.handleSubmit,
|
|
3615
3680
|
customFields = _ref.customFields,
|
|
3616
3681
|
customFieldsInitialValues = _ref.customFieldsInitialValues,
|
|
3617
|
-
customFieldsValidationSchema = _ref.customFieldsValidationSchema
|
|
3618
|
-
_ref$helpDocUrl = _ref.helpDocUrl,
|
|
3619
|
-
helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl;
|
|
3682
|
+
customFieldsValidationSchema = _ref.customFieldsValidationSchema;
|
|
3620
3683
|
var _useTranslation = useTranslation(),
|
|
3621
3684
|
t = _useTranslation.t;
|
|
3622
3685
|
var getInitialVariableComponents = function getInitialVariableComponents(variables) {
|
|
@@ -3641,28 +3704,9 @@ var Whatsapp = function Whatsapp(_ref) {
|
|
|
3641
3704
|
variableContents: getInitialVariableComponents((_templates$4 = templates[0]) === null || _templates$4 === void 0 ? void 0 : _templates$4.variableCount)
|
|
3642
3705
|
};
|
|
3643
3706
|
var updatedInitialValues = mergeAll([initialFormValues, customFieldsInitialValues]);
|
|
3644
|
-
var updatedValidationSchema = yup.object().shape(_objectSpread$
|
|
3707
|
+
var updatedValidationSchema = yup.object().shape(_objectSpread$4(_objectSpread$4({}, WHATSAPP_MESSAGE_FORM_VALIDATIONS_SCHEMA === null || WHATSAPP_MESSAGE_FORM_VALIDATIONS_SCHEMA === void 0 ? void 0 : WHATSAPP_MESSAGE_FORM_VALIDATIONS_SCHEMA.fields), customFieldsValidationSchema === null || customFieldsValidationSchema === void 0 ? void 0 : customFieldsValidationSchema.fields));
|
|
3645
3708
|
var initialValueKeys = Object.keys(initialFormValues);
|
|
3646
|
-
|
|
3647
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Typography, null, t("neetoMessageTemplate.template.emptyState", {
|
|
3648
|
-
type: t("neetoMessageTemplate.template.whatsappTemplates")
|
|
3649
|
-
}), " ", helpDocUrl && /*#__PURE__*/React.createElement(Trans, {
|
|
3650
|
-
i18nKey: "neetoMessageTemplate.template.whatsapp.helpDocText",
|
|
3651
|
-
components: {
|
|
3652
|
-
Link: /*#__PURE__*/React.createElement(Button, {
|
|
3653
|
-
size: "large",
|
|
3654
|
-
style: "link",
|
|
3655
|
-
to: helpDocUrl
|
|
3656
|
-
})
|
|
3657
|
-
}
|
|
3658
|
-
})), /*#__PURE__*/React.createElement(Pane.Footer, {
|
|
3659
|
-
className: "absolute bottom-0 left-0"
|
|
3660
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
3661
|
-
label: t("neetoMessageTemplate.template.close"),
|
|
3662
|
-
onClick: onClose
|
|
3663
|
-
})));
|
|
3664
|
-
}
|
|
3665
|
-
return /*#__PURE__*/React.createElement(NeetoUIForm, {
|
|
3709
|
+
return /*#__PURE__*/jsx(NeetoUIForm, {
|
|
3666
3710
|
formProps: {
|
|
3667
3711
|
noValidate: true,
|
|
3668
3712
|
className: "flex w-full flex-col gap-y-4 pb-6"
|
|
@@ -3671,77 +3715,96 @@ var Whatsapp = function Whatsapp(_ref) {
|
|
|
3671
3715
|
initialValues: updatedInitialValues,
|
|
3672
3716
|
validationSchema: updatedValidationSchema,
|
|
3673
3717
|
onSubmit: handleSubmit
|
|
3674
|
-
}
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
defaultValue: initialFormValues.selectedTemplate,
|
|
3696
|
-
label: t("neetoMessageTemplate.template.title"),
|
|
3697
|
-
name: "selectedTemplate",
|
|
3698
|
-
options: renameKeys({
|
|
3699
|
-
name: "label",
|
|
3700
|
-
id: "value"
|
|
3701
|
-
}, templates),
|
|
3702
|
-
onChange: handleTemplateChange
|
|
3703
|
-
}), customFields, /*#__PURE__*/React.createElement(Textarea$1, {
|
|
3704
|
-
disabled: true,
|
|
3705
|
-
nakedTextarea: true,
|
|
3706
|
-
label: t("neetoMessageTemplate.template.preview"),
|
|
3707
|
-
value: values.templateMessage
|
|
3708
|
-
}), isNotEmpty(values.variableContents) && /*#__PURE__*/React.createElement(React.Fragment, null, Object.keys(values.variableContents).map(function (group) {
|
|
3709
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
3710
|
-
className: "flex flex-col gap-y-2",
|
|
3711
|
-
key: group
|
|
3712
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
3713
|
-
style: "h4"
|
|
3714
|
-
}, t("neetoMessageTemplate.template.resolveVariable", {
|
|
3715
|
-
type: capitalize(group)
|
|
3716
|
-
})), values.variableContents[group].map(function (_, index) {
|
|
3717
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
3718
|
-
key: "".concat(group, "-").concat(index)
|
|
3719
|
-
}, /*#__PURE__*/React.createElement(Input, {
|
|
3718
|
+
},
|
|
3719
|
+
children: function children(_ref3) {
|
|
3720
|
+
var values = _ref3.values,
|
|
3721
|
+
setValues = _ref3.setValues;
|
|
3722
|
+
var handleTemplateChange = function handleTemplateChange(value) {
|
|
3723
|
+
if (!value) return;
|
|
3724
|
+
var template = findBy({
|
|
3725
|
+
id: value === null || value === void 0 ? void 0 : value.value
|
|
3726
|
+
}, templates);
|
|
3727
|
+
var customFieldValues = omit(initialValueKeys, values);
|
|
3728
|
+
setValues(_objectSpread$4({
|
|
3729
|
+
selectedTemplate: {
|
|
3730
|
+
label: template.name,
|
|
3731
|
+
value: template.id
|
|
3732
|
+
},
|
|
3733
|
+
templateMessage: getTemplateMessage(template.components),
|
|
3734
|
+
variableContents: getInitialVariableComponents(template.variableCount)
|
|
3735
|
+
}, customFieldValues));
|
|
3736
|
+
};
|
|
3737
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
3738
|
+
children: [/*#__PURE__*/jsx(Select$1, {
|
|
3720
3739
|
required: true,
|
|
3721
|
-
|
|
3722
|
-
label: "
|
|
3723
|
-
name: "
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3740
|
+
defaultValue: initialFormValues.selectedTemplate,
|
|
3741
|
+
label: t("neetoMessageTemplate.template.title"),
|
|
3742
|
+
name: "selectedTemplate",
|
|
3743
|
+
options: renameKeys({
|
|
3744
|
+
name: "label",
|
|
3745
|
+
id: "value"
|
|
3746
|
+
}, templates),
|
|
3747
|
+
onChange: handleTemplateChange
|
|
3748
|
+
}), customFields, /*#__PURE__*/jsx(Textarea$1, {
|
|
3749
|
+
disabled: true,
|
|
3750
|
+
nakedTextarea: true,
|
|
3751
|
+
label: t("neetoMessageTemplate.template.preview"),
|
|
3752
|
+
value: values.templateMessage
|
|
3753
|
+
}), isNotEmpty(values.variableContents) && /*#__PURE__*/jsx(Fragment, {
|
|
3754
|
+
children: Object.keys(values.variableContents).map(function (group) {
|
|
3755
|
+
return /*#__PURE__*/jsxs("div", {
|
|
3756
|
+
className: "flex flex-col gap-y-2",
|
|
3757
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
3758
|
+
style: "h4",
|
|
3759
|
+
children: t("neetoMessageTemplate.template.resolveVariable", {
|
|
3760
|
+
type: capitalize(group)
|
|
3761
|
+
})
|
|
3762
|
+
}), values.variableContents[group].map(function (_, index) {
|
|
3763
|
+
return /*#__PURE__*/jsx("div", {
|
|
3764
|
+
children: /*#__PURE__*/jsx(Input, {
|
|
3765
|
+
required: true,
|
|
3766
|
+
label: "{{".concat(index + 1, "}}"),
|
|
3767
|
+
name: "variableContents.".concat(group, ".").concat(index)
|
|
3768
|
+
}, "".concat(group, "-").concat(index))
|
|
3769
|
+
}, "".concat(group, "-").concat(index));
|
|
3770
|
+
})]
|
|
3771
|
+
}, group);
|
|
3772
|
+
})
|
|
3773
|
+
}), /*#__PURE__*/jsx(Pane.Footer, {
|
|
3774
|
+
className: "absolute bottom-0 left-0",
|
|
3775
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
3776
|
+
cancelButtonProps: {
|
|
3777
|
+
"data-cy": "message-template-cancel-button",
|
|
3778
|
+
onClick: onClose
|
|
3779
|
+
},
|
|
3780
|
+
submitButtonProps: {
|
|
3781
|
+
"data-cy": "message-template-send-button",
|
|
3782
|
+
label: t("neetoMessageTemplate.template.send")
|
|
3783
|
+
}
|
|
3784
|
+
})
|
|
3785
|
+
})]
|
|
3786
|
+
});
|
|
3787
|
+
}
|
|
3738
3788
|
});
|
|
3739
3789
|
};
|
|
3740
3790
|
|
|
3741
|
-
var
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3791
|
+
function ownKeys$3(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; }
|
|
3792
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3793
|
+
var SendMessagePane = function SendMessagePane(props) {
|
|
3794
|
+
var isOpen = props.isOpen,
|
|
3795
|
+
onClose = props.onClose;
|
|
3796
|
+
return /*#__PURE__*/jsx(Pane, {
|
|
3797
|
+
isOpen: isOpen,
|
|
3798
|
+
onClose: onClose,
|
|
3799
|
+
children: function children(paneProps) {
|
|
3800
|
+
return /*#__PURE__*/jsx(SendMessageForm, _objectSpread$3({}, _objectSpread$3(_objectSpread$3({}, props), {}, {
|
|
3801
|
+
paneProps: paneProps
|
|
3802
|
+
})));
|
|
3803
|
+
}
|
|
3804
|
+
});
|
|
3805
|
+
};
|
|
3806
|
+
var SendMessageForm = function SendMessageForm(_ref) {
|
|
3807
|
+
var _ref$type = _ref.type,
|
|
3745
3808
|
type = _ref$type === void 0 ? "" : _ref$type,
|
|
3746
3809
|
_ref$handleSubmit = _ref.handleSubmit,
|
|
3747
3810
|
handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
|
|
@@ -3758,13 +3821,12 @@ var SendMessagePane = function SendMessagePane(_ref) {
|
|
|
3758
3821
|
_ref$ownerId = _ref.ownerId,
|
|
3759
3822
|
ownerId = _ref$ownerId === void 0 ? "" : _ref$ownerId,
|
|
3760
3823
|
_ref$helpDocUrl = _ref.helpDocUrl,
|
|
3761
|
-
helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl
|
|
3824
|
+
helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl,
|
|
3825
|
+
_ref$addNewTemplateRo = _ref.addNewTemplateRoute,
|
|
3826
|
+
addNewTemplateRoute = _ref$addNewTemplateRo === void 0 ? "" : _ref$addNewTemplateRo,
|
|
3827
|
+
setFocusField = _ref.paneProps.setFocusField;
|
|
3762
3828
|
var _useTranslation = useTranslation(),
|
|
3763
3829
|
t = _useTranslation.t;
|
|
3764
|
-
var initialFocusField = useRef();
|
|
3765
|
-
var setInitialFocusField = function setInitialFocusField(fieldRef) {
|
|
3766
|
-
return initialFocusField.current = fieldRef;
|
|
3767
|
-
};
|
|
3768
3830
|
var value = MESSAGE_TEMPLATES[type].value;
|
|
3769
3831
|
var isWhatsappTemplate = type === "whatsapp";
|
|
3770
3832
|
var templateParams = {
|
|
@@ -3776,33 +3838,49 @@ var SendMessagePane = function SendMessagePane(_ref) {
|
|
|
3776
3838
|
_useFetchTemplates$da = _useFetchTemplates.data,
|
|
3777
3839
|
_useFetchTemplates$da2 = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da,
|
|
3778
3840
|
_useFetchTemplates$da3 = _useFetchTemplates$da2.templates,
|
|
3779
|
-
templates = _useFetchTemplates$da3 === void 0 ? [] : _useFetchTemplates$da3
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3841
|
+
templates = _useFetchTemplates$da3 === void 0 ? [] : _useFetchTemplates$da3,
|
|
3842
|
+
isLoading = _useFetchTemplates.isLoading;
|
|
3843
|
+
if (isLoading) {
|
|
3844
|
+
return /*#__PURE__*/jsx("div", {
|
|
3845
|
+
className: "flex h-full w-full items-center justify-center",
|
|
3846
|
+
children: /*#__PURE__*/jsx(Spinner, {})
|
|
3847
|
+
});
|
|
3848
|
+
}
|
|
3849
|
+
if (isEmpty(templates)) {
|
|
3850
|
+
return /*#__PURE__*/jsx(NoDataPage, {
|
|
3851
|
+
addNewTemplateRoute: addNewTemplateRoute,
|
|
3852
|
+
helpDocUrl: helpDocUrl,
|
|
3853
|
+
type: type
|
|
3854
|
+
});
|
|
3855
|
+
}
|
|
3856
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
3857
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
3858
|
+
children: /*#__PURE__*/jsxs(Typography, {
|
|
3859
|
+
style: "h2",
|
|
3860
|
+
weight: "semibold",
|
|
3861
|
+
children: [t("neetoMessageTemplate.common.send"), " ", MESSAGE_TYPES[type]]
|
|
3862
|
+
})
|
|
3863
|
+
}), /*#__PURE__*/jsx(Pane.Body, {
|
|
3864
|
+
children: isWhatsappTemplate ? /*#__PURE__*/jsx(Whatsapp, {
|
|
3865
|
+
customFields: customFields,
|
|
3866
|
+
customFieldsInitialValues: customFieldsInitialValues,
|
|
3867
|
+
customFieldsValidationSchema: customFieldsValidationSchema,
|
|
3868
|
+
handleSubmit: handleSubmit,
|
|
3869
|
+
onClose: onClose,
|
|
3870
|
+
templates: templates
|
|
3871
|
+
}) : /*#__PURE__*/jsx(EmailAndSms, {
|
|
3872
|
+
customFields: customFields,
|
|
3873
|
+
customFieldsInitialValues: customFieldsInitialValues,
|
|
3874
|
+
customFieldsValidationSchema: customFieldsValidationSchema,
|
|
3875
|
+
handleSubmit: handleSubmit,
|
|
3876
|
+
onClose: onClose,
|
|
3877
|
+
setFocusField: setFocusField,
|
|
3878
|
+
templateVariables: templateVariables,
|
|
3879
|
+
templates: templates,
|
|
3880
|
+
type: type
|
|
3881
|
+
})
|
|
3882
|
+
})]
|
|
3883
|
+
});
|
|
3806
3884
|
};
|
|
3807
3885
|
|
|
3808
3886
|
var e=[],t=[];function n(n,r){if(n&&"undefined"!=typeof document){var a,s=!0===r.prepend?"prepend":"append",d=!0===r.singleTag,i="string"==typeof r.container?document.querySelector(r.container):document.getElementsByTagName("head")[0];if(d){var u=e.indexOf(i);-1===u&&(u=e.push(i)-1,t[u]={}),a=t[u]&&t[u][s]?t[u][s]:t[u][s]=c();}else a=c();65279===n.charCodeAt(0)&&(n=n.substring(1)),a.styleSheet?a.styleSheet.cssText+=n:a.appendChild(document.createTextNode(n));}function c(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),r.attributes)for(var t=Object.keys(r.attributes),n=0;n<t.length;n++)e.setAttribute(t[n],r.attributes[t[n]]);var a="prepend"===s?"afterbegin":"beforeend";return i.insertAdjacentElement(a,e),e}}
|
|
@@ -3891,46 +3969,50 @@ var KeyValuePairs = withT(function (_ref) {
|
|
|
3891
3969
|
name = _ref.name,
|
|
3892
3970
|
_ref$label = _ref.label,
|
|
3893
3971
|
label = _ref$label === void 0 ? "" : _ref$label;
|
|
3894
|
-
return /*#__PURE__*/
|
|
3895
|
-
name: name
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3972
|
+
return /*#__PURE__*/jsx(FieldArray, {
|
|
3973
|
+
name: name,
|
|
3974
|
+
children: function children(arrayHelpers) {
|
|
3975
|
+
var data = arrayHelpers.form.values[name];
|
|
3976
|
+
var showDeleteButton = data.length > 1 || isKeyOrValueNotEmpty(data[0]);
|
|
3977
|
+
return /*#__PURE__*/jsxs("div", {
|
|
3978
|
+
className: "space-y-2",
|
|
3979
|
+
children: [/*#__PURE__*/jsx(Label, {
|
|
3980
|
+
children: label
|
|
3981
|
+
}), data.map(function (_, index) {
|
|
3982
|
+
return /*#__PURE__*/jsxs("div", {
|
|
3983
|
+
className: "flex h-8 space-x-3",
|
|
3984
|
+
children: [/*#__PURE__*/jsx(Input, {
|
|
3985
|
+
className: "w-2/5",
|
|
3986
|
+
name: "".concat(name, ".").concat(index, ".key"),
|
|
3987
|
+
placeholder: t("neetoMessageTemplate.api.key")
|
|
3988
|
+
}), /*#__PURE__*/jsx(Input, {
|
|
3989
|
+
className: "w-3/5",
|
|
3990
|
+
name: "".concat(name, ".").concat(index, ".value"),
|
|
3991
|
+
placeholder: t("neetoMessageTemplate.api.value"),
|
|
3992
|
+
suffix: showDeleteButton && /*#__PURE__*/jsx(Button, {
|
|
3993
|
+
icon: Delete,
|
|
3994
|
+
size: "small",
|
|
3995
|
+
style: "text",
|
|
3996
|
+
onClick: function onClick() {
|
|
3997
|
+
return removeOption({
|
|
3998
|
+
arrayHelpers: arrayHelpers,
|
|
3999
|
+
index: index,
|
|
4000
|
+
data: data
|
|
4001
|
+
});
|
|
4002
|
+
}
|
|
4003
|
+
})
|
|
4004
|
+
})]
|
|
4005
|
+
}, index);
|
|
4006
|
+
}), /*#__PURE__*/jsx(Button, {
|
|
4007
|
+
className: "w-full justify-center",
|
|
4008
|
+
label: t("neetoMessageTemplate.api.addKeyValuePair"),
|
|
4009
|
+
style: "secondary",
|
|
3917
4010
|
onClick: function onClick() {
|
|
3918
|
-
return
|
|
3919
|
-
arrayHelpers: arrayHelpers,
|
|
3920
|
-
index: index,
|
|
3921
|
-
data: data
|
|
3922
|
-
});
|
|
4011
|
+
return addOption(arrayHelpers);
|
|
3923
4012
|
}
|
|
3924
|
-
})
|
|
3925
|
-
})
|
|
3926
|
-
}
|
|
3927
|
-
className: "w-full justify-center",
|
|
3928
|
-
label: t("neetoMessageTemplate.api.addKeyValuePair"),
|
|
3929
|
-
style: "secondary",
|
|
3930
|
-
onClick: function onClick() {
|
|
3931
|
-
return addOption(arrayHelpers);
|
|
3932
|
-
}
|
|
3933
|
-
}));
|
|
4013
|
+
})]
|
|
4014
|
+
});
|
|
4015
|
+
}
|
|
3934
4016
|
});
|
|
3935
4017
|
});
|
|
3936
4018
|
|
|
@@ -3939,8 +4021,8 @@ var rejectEmptyKeyValuePairs = reject(whereAny({
|
|
|
3939
4021
|
value: isEmpty
|
|
3940
4022
|
}));
|
|
3941
4023
|
|
|
3942
|
-
function ownKeys$
|
|
3943
|
-
function _objectSpread$
|
|
4024
|
+
function ownKeys$2(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; }
|
|
4025
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3944
4026
|
var buildApiTemplatePayload = function buildApiTemplatePayload(values) {
|
|
3945
4027
|
return {
|
|
3946
4028
|
entity: {
|
|
@@ -3960,38 +4042,39 @@ var buildTableColumnData = function buildTableColumnData(_ref) {
|
|
|
3960
4042
|
key: "name",
|
|
3961
4043
|
title: t$1("neetoMessageTemplate.template.name"),
|
|
3962
4044
|
render: function render(name, apiTemplate) {
|
|
3963
|
-
return /*#__PURE__*/
|
|
3964
|
-
className: "flex items-center justify-between gap-x-3"
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
onClick: function onClick() {
|
|
3969
|
-
return handleOpenEditPane(apiTemplate);
|
|
3970
|
-
}
|
|
3971
|
-
}), /*#__PURE__*/React.createElement(MoreDropdown, {
|
|
3972
|
-
dropdownProps: {
|
|
3973
|
-
strategy: "fixed"
|
|
3974
|
-
},
|
|
3975
|
-
menuItems: [{
|
|
3976
|
-
key: "edit",
|
|
3977
|
-
label: t$1("neetoMessageTemplate.template.edit"),
|
|
4045
|
+
return /*#__PURE__*/jsxs("div", {
|
|
4046
|
+
className: "flex items-center justify-between gap-x-3",
|
|
4047
|
+
children: [/*#__PURE__*/jsx(Button, {
|
|
4048
|
+
label: name,
|
|
4049
|
+
style: "link",
|
|
3978
4050
|
onClick: function onClick() {
|
|
3979
4051
|
return handleOpenEditPane(apiTemplate);
|
|
3980
4052
|
}
|
|
3981
|
-
}, {
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
4053
|
+
}), /*#__PURE__*/jsx(MoreDropdown, {
|
|
4054
|
+
dropdownProps: {
|
|
4055
|
+
strategy: "fixed"
|
|
4056
|
+
},
|
|
4057
|
+
menuItems: [{
|
|
4058
|
+
key: "edit",
|
|
4059
|
+
label: t$1("neetoMessageTemplate.template.edit"),
|
|
4060
|
+
onClick: function onClick() {
|
|
4061
|
+
return handleOpenEditPane(apiTemplate);
|
|
4062
|
+
}
|
|
4063
|
+
}, {
|
|
4064
|
+
key: "status",
|
|
4065
|
+
label: equals(apiTemplate.status, TEMPLATE_STATUS.ACTIVE) ? t$1("neetoMessageTemplate.template.markAsInactive") : t$1("neetoMessageTemplate.template.markAsActive"),
|
|
4066
|
+
onClick: function onClick() {
|
|
4067
|
+
return handleMarkAsActiveOrInactive(apiTemplate);
|
|
4068
|
+
}
|
|
4069
|
+
}, {
|
|
4070
|
+
key: "delete",
|
|
4071
|
+
label: t$1("neetoMessageTemplate.template.delete"),
|
|
4072
|
+
onClick: function onClick() {
|
|
4073
|
+
return handleOpenDeleteAlert(apiTemplate);
|
|
4074
|
+
}
|
|
4075
|
+
}]
|
|
4076
|
+
})]
|
|
4077
|
+
});
|
|
3995
4078
|
}
|
|
3996
4079
|
}, {
|
|
3997
4080
|
dataIndex: "status",
|
|
@@ -4006,7 +4089,7 @@ var buildTableColumnData = function buildTableColumnData(_ref) {
|
|
|
4006
4089
|
var buildApiTemplateInitialValues = function buildApiTemplateInitialValues(isEdit, apiTemplate) {
|
|
4007
4090
|
if (!isEdit) return API_TEMPLATE_INITIAL_VALUES;
|
|
4008
4091
|
var additionalData = isEmpty(apiTemplate.additionalData) ? [ADDITIONAL_DATA_INITIAL_VALUE] : apiTemplate.additionalData;
|
|
4009
|
-
return _objectSpread$
|
|
4092
|
+
return _objectSpread$2(_objectSpread$2({}, pick(["name", "endpoint"], apiTemplate)), {}, {
|
|
4010
4093
|
additionalData: additionalData
|
|
4011
4094
|
});
|
|
4012
4095
|
};
|
|
@@ -4048,38 +4131,51 @@ var Form = function Form(_ref) {
|
|
|
4048
4131
|
createApiTemplate(payload, options);
|
|
4049
4132
|
};
|
|
4050
4133
|
var isMutating = isUpdating || isCreating;
|
|
4051
|
-
return /*#__PURE__*/
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4134
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
4135
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
4136
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
4137
|
+
style: "h2",
|
|
4138
|
+
weight: "semibold",
|
|
4139
|
+
children: isEdit ? t("neetoMessageTemplate.api.editApiTemplate") : t("neetoMessageTemplate.api.addApiTemplate")
|
|
4140
|
+
})
|
|
4141
|
+
}), /*#__PURE__*/jsxs(NeetoUIForm, {
|
|
4142
|
+
formikProps: {
|
|
4143
|
+
initialValues: buildApiTemplateInitialValues(isEdit, selectedApiTemplate),
|
|
4144
|
+
validationSchema: API_TEMPLATE_FORM_VALIDATION_SCHEMA,
|
|
4145
|
+
onSubmit: handleSubmit
|
|
4146
|
+
},
|
|
4147
|
+
children: [/*#__PURE__*/jsx(Pane.Body, {
|
|
4148
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
4149
|
+
className: "w-full space-y-5",
|
|
4150
|
+
children: [/*#__PURE__*/jsx(Input, {
|
|
4151
|
+
required: true,
|
|
4152
|
+
label: t("neetoMessageTemplate.template.name"),
|
|
4153
|
+
name: "name",
|
|
4154
|
+
ref: setFocusField
|
|
4155
|
+
}), /*#__PURE__*/jsx(Input, {
|
|
4156
|
+
required: true,
|
|
4157
|
+
label: t("neetoMessageTemplate.api.endpoint"),
|
|
4158
|
+
name: "endpoint",
|
|
4159
|
+
placeholder: SAMPLE_URL
|
|
4160
|
+
}), /*#__PURE__*/jsx(KeyValuePairs, {
|
|
4161
|
+
label: t("neetoMessageTemplate.api.additionalData"),
|
|
4162
|
+
name: "additionalData"
|
|
4163
|
+
})]
|
|
4164
|
+
})
|
|
4165
|
+
}), /*#__PURE__*/jsx(Pane.Footer, {
|
|
4166
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
4167
|
+
cancelButtonProps: {
|
|
4168
|
+
onClick: onClose
|
|
4169
|
+
},
|
|
4170
|
+
isSubmitting: isMutating
|
|
4171
|
+
})
|
|
4172
|
+
})]
|
|
4173
|
+
})]
|
|
4174
|
+
});
|
|
4081
4175
|
};
|
|
4082
4176
|
|
|
4177
|
+
function ownKeys$1(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; }
|
|
4178
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4083
4179
|
var ApiTemplates = function ApiTemplates(_ref) {
|
|
4084
4180
|
var ownerId = _ref.ownerId,
|
|
4085
4181
|
_ref$breadcrumbs = _ref.breadcrumbs,
|
|
@@ -4180,107 +4276,113 @@ var ApiTemplates = function ApiTemplates(_ref) {
|
|
|
4180
4276
|
}
|
|
4181
4277
|
});
|
|
4182
4278
|
};
|
|
4183
|
-
return /*#__PURE__*/
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
}), /*#__PURE__*/React.createElement(SubHeader, {
|
|
4197
|
-
leftActionBlock: /*#__PURE__*/React.createElement(Typography, {
|
|
4198
|
-
component: "h4"
|
|
4199
|
-
}, t("neetoMessageTemplate.template.messageTemplatesWithCount", {
|
|
4200
|
-
type: t("messageType.api"),
|
|
4201
|
-
count: totalCount
|
|
4202
|
-
})),
|
|
4203
|
-
rightActionBlock: /*#__PURE__*/React.createElement(SubHeader.RightBlock, {
|
|
4204
|
-
dataProps: {
|
|
4205
|
-
totalCount: isFilterApplied ? null : totalCount
|
|
4206
|
-
},
|
|
4207
|
-
filterProps: {
|
|
4208
|
-
columns: FILTER_COLUMNS,
|
|
4209
|
-
isOpen: isFiltersPaneOpen,
|
|
4210
|
-
keyword: searchKeywordProps,
|
|
4211
|
-
setIsOpen: setIsFiltersPaneOpen,
|
|
4212
|
-
onChange: handleFiltersChange
|
|
4213
|
-
}
|
|
4214
|
-
})
|
|
4215
|
-
}), /*#__PURE__*/React.createElement(Bar, {
|
|
4216
|
-
columns: FILTER_COLUMNS,
|
|
4217
|
-
keyword: searchKeywordProps,
|
|
4218
|
-
setIsPaneOpen: setIsFiltersPaneOpen,
|
|
4219
|
-
onChange: handleFiltersChange
|
|
4220
|
-
}), isNotEmpty(templates) ? /*#__PURE__*/React.createElement(TableWrapper, {
|
|
4221
|
-
hasPagination: totalCount > pageParams.size
|
|
4222
|
-
}, /*#__PURE__*/React.createElement(Table, {
|
|
4223
|
-
totalCount: totalCount,
|
|
4224
|
-
fixedHeight: true,
|
|
4225
|
-
currentPageNumber: pageParams.index,
|
|
4226
|
-
defaultPageSize: pageParams.size,
|
|
4227
|
-
handlePageChange: function handlePageChange(index, size) {
|
|
4228
|
-
return setPageParams({
|
|
4229
|
-
index: index,
|
|
4230
|
-
size: size
|
|
4231
|
-
});
|
|
4232
|
-
},
|
|
4233
|
-
loading: isLoading || isFetching,
|
|
4234
|
-
rowData: templates,
|
|
4235
|
-
scroll: {
|
|
4236
|
-
x: "100%"
|
|
4237
|
-
},
|
|
4238
|
-
columnData: buildTableColumnData({
|
|
4239
|
-
handleMarkAsActiveOrInactive: handleMarkAsActiveOrInactive,
|
|
4240
|
-
handleOpenDeleteAlert: handleOpenDeleteAlert,
|
|
4241
|
-
handleOpenEditPane: handleOpenEditPane
|
|
4242
|
-
})
|
|
4243
|
-
})) : /*#__PURE__*/React.createElement("div", {
|
|
4244
|
-
className: "flex h-full w-full items-center justify-center"
|
|
4245
|
-
}, /*#__PURE__*/React.createElement(NoData, _extends({}, !isFilterApplied && {
|
|
4246
|
-
primaryButtonProps: {
|
|
4247
|
-
label: t("neetoMessageTemplate.api.addApiTemplate"),
|
|
4248
|
-
onClick: function onClick() {
|
|
4249
|
-
return setIsFormPaneOpen(true);
|
|
4279
|
+
return /*#__PURE__*/jsxs(Container, {
|
|
4280
|
+
children: [/*#__PURE__*/jsx(NeetoHeader, {
|
|
4281
|
+
breadcrumbs: breadcrumbs,
|
|
4282
|
+
size: "small",
|
|
4283
|
+
title: t("neetoMessageTemplate.template.apiTemplates"),
|
|
4284
|
+
actionBlock: /*#__PURE__*/jsx(Button, {
|
|
4285
|
+
label: t("neetoMessageTemplate.api.addApiTemplate"),
|
|
4286
|
+
onClick: function onClick() {
|
|
4287
|
+
return setIsFormPaneOpen(true);
|
|
4288
|
+
}
|
|
4289
|
+
}),
|
|
4290
|
+
searchProps: {
|
|
4291
|
+
placeholder: t("neetoMessageTemplate.template.searchApiTemplates")
|
|
4250
4292
|
}
|
|
4251
|
-
}
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4293
|
+
}), /*#__PURE__*/jsx(SubHeader, {
|
|
4294
|
+
leftActionBlock: /*#__PURE__*/jsx(Typography, {
|
|
4295
|
+
component: "h4",
|
|
4296
|
+
children: t("neetoMessageTemplate.template.messageTemplatesWithCount", {
|
|
4297
|
+
type: t("messageType.api"),
|
|
4298
|
+
count: totalCount
|
|
4299
|
+
})
|
|
4300
|
+
}),
|
|
4301
|
+
rightActionBlock: /*#__PURE__*/jsx(SubHeader.RightBlock, {
|
|
4302
|
+
dataProps: {
|
|
4303
|
+
totalCount: isFilterApplied ? null : totalCount
|
|
4304
|
+
},
|
|
4305
|
+
filterProps: {
|
|
4306
|
+
columns: FILTER_COLUMNS,
|
|
4307
|
+
isOpen: isFiltersPaneOpen,
|
|
4308
|
+
keyword: searchKeywordProps,
|
|
4309
|
+
setIsOpen: setIsFiltersPaneOpen,
|
|
4310
|
+
onChange: handleFiltersChange
|
|
4311
|
+
}
|
|
4312
|
+
})
|
|
4313
|
+
}), /*#__PURE__*/jsx(Bar, {
|
|
4314
|
+
columns: FILTER_COLUMNS,
|
|
4315
|
+
keyword: searchKeywordProps,
|
|
4316
|
+
setIsPaneOpen: setIsFiltersPaneOpen,
|
|
4317
|
+
onChange: handleFiltersChange
|
|
4318
|
+
}), isNotEmpty(templates) ? /*#__PURE__*/jsx(TableWrapper, {
|
|
4319
|
+
hasPagination: totalCount > pageParams.size,
|
|
4320
|
+
children: /*#__PURE__*/jsx(Table, {
|
|
4321
|
+
totalCount: totalCount,
|
|
4322
|
+
fixedHeight: true,
|
|
4323
|
+
currentPageNumber: pageParams.index,
|
|
4324
|
+
defaultPageSize: pageParams.size,
|
|
4325
|
+
handlePageChange: function handlePageChange(index, size) {
|
|
4326
|
+
return setPageParams({
|
|
4327
|
+
index: index,
|
|
4328
|
+
size: size
|
|
4329
|
+
});
|
|
4330
|
+
},
|
|
4331
|
+
loading: isLoading || isFetching,
|
|
4332
|
+
rowData: templates,
|
|
4333
|
+
scroll: {
|
|
4334
|
+
x: "100%"
|
|
4335
|
+
},
|
|
4336
|
+
columnData: buildTableColumnData({
|
|
4337
|
+
handleMarkAsActiveOrInactive: handleMarkAsActiveOrInactive,
|
|
4338
|
+
handleOpenDeleteAlert: handleOpenDeleteAlert,
|
|
4339
|
+
handleOpenEditPane: handleOpenEditPane
|
|
4340
|
+
})
|
|
4341
|
+
})
|
|
4342
|
+
}) : /*#__PURE__*/jsx("div", {
|
|
4343
|
+
className: "flex h-full w-full items-center justify-center",
|
|
4344
|
+
children: /*#__PURE__*/jsx(NoData, _objectSpread$1(_objectSpread$1({}, !isFilterApplied && {
|
|
4345
|
+
primaryButtonProps: {
|
|
4346
|
+
label: t("neetoMessageTemplate.api.addApiTemplate"),
|
|
4347
|
+
onClick: function onClick() {
|
|
4348
|
+
return setIsFormPaneOpen(true);
|
|
4349
|
+
}
|
|
4350
|
+
}
|
|
4351
|
+
}), {}, {
|
|
4352
|
+
title: isFilterApplied ? t("neetoMessageTemplate.template.filtersEmptyState", {
|
|
4353
|
+
type: t("neetoMessageTemplate.template.apiTemplates")
|
|
4354
|
+
}) : t("neetoMessageTemplate.template.emptyState", {
|
|
4355
|
+
type: t("neetoMessageTemplate.template.apiTemplates")
|
|
4356
|
+
})
|
|
4357
|
+
}))
|
|
4358
|
+
}), /*#__PURE__*/jsx(Pane, {
|
|
4359
|
+
isOpen: isFormPaneOpen,
|
|
4360
|
+
onClose: handleCloseDeleteAlertAndFormPane,
|
|
4361
|
+
children: function children(_ref3) {
|
|
4362
|
+
var setFocusField = _ref3.setFocusField;
|
|
4363
|
+
return /*#__PURE__*/jsx(Form, {
|
|
4364
|
+
onMutationSuccess: onMutationSuccess,
|
|
4365
|
+
ownerId: ownerId,
|
|
4366
|
+
selectedApiTemplate: selectedApiTemplate,
|
|
4367
|
+
setFocusField: setFocusField,
|
|
4368
|
+
onClose: handleCloseDeleteAlertAndFormPane
|
|
4369
|
+
});
|
|
4279
4370
|
}
|
|
4280
|
-
}),
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4371
|
+
}), /*#__PURE__*/jsx(Alert, {
|
|
4372
|
+
isOpen: isDeleteAlertOpen,
|
|
4373
|
+
isSubmitting: isDeleting,
|
|
4374
|
+
submitButtonLabel: t("neetoMessageTemplate.template.delete"),
|
|
4375
|
+
title: t("neetoMessageTemplate.api.deleteApiTemplate"),
|
|
4376
|
+
message: /*#__PURE__*/jsx(Trans, {
|
|
4377
|
+
i18nKey: "neetoMessageTemplate.template.templateDeleteConfirmation",
|
|
4378
|
+
values: {
|
|
4379
|
+
name: selectedApiTemplate.name
|
|
4380
|
+
}
|
|
4381
|
+
}),
|
|
4382
|
+
onClose: handleCloseDeleteAlertAndFormPane,
|
|
4383
|
+
onSubmit: handleDeleteApiTemplate
|
|
4384
|
+
})]
|
|
4385
|
+
});
|
|
4284
4386
|
};
|
|
4285
4387
|
|
|
4286
4388
|
var SEND_TO_API_FORM_INITIAL_VALUES = {
|
|
@@ -4300,13 +4402,14 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4300
4402
|
var SendToApiPane = function SendToApiPane(props) {
|
|
4301
4403
|
var isOpen = props.isOpen,
|
|
4302
4404
|
onClose = props.onClose;
|
|
4303
|
-
return /*#__PURE__*/
|
|
4405
|
+
return /*#__PURE__*/jsx(Pane, {
|
|
4304
4406
|
isOpen: isOpen,
|
|
4305
|
-
onClose: onClose
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4407
|
+
onClose: onClose,
|
|
4408
|
+
children: function children(paneProps) {
|
|
4409
|
+
return /*#__PURE__*/jsx(SendToApiForm, _objectSpread({}, _objectSpread(_objectSpread({}, props), {}, {
|
|
4410
|
+
paneProps: paneProps
|
|
4411
|
+
})));
|
|
4412
|
+
}
|
|
4310
4413
|
});
|
|
4311
4414
|
};
|
|
4312
4415
|
var SendToApiForm = function SendToApiForm(_ref) {
|
|
@@ -4314,6 +4417,7 @@ var SendToApiForm = function SendToApiForm(_ref) {
|
|
|
4314
4417
|
onClose = _ref.onClose,
|
|
4315
4418
|
onSubmit = _ref.onSubmit,
|
|
4316
4419
|
isSubmitting = _ref.isSubmitting,
|
|
4420
|
+
addNewTemplateRoute = _ref.addNewTemplateRoute,
|
|
4317
4421
|
setFocusField = _ref.paneProps.setFocusField;
|
|
4318
4422
|
var _useTranslation = useTranslation(),
|
|
4319
4423
|
t = _useTranslation.t;
|
|
@@ -4335,49 +4439,68 @@ var SendToApiForm = function SendToApiForm(_ref) {
|
|
|
4335
4439
|
var additionalDataModifiedFormValues = modify("additionalData", rejectEmptyKeyValuePairs, formValues);
|
|
4336
4440
|
onSubmit(additionalDataModifiedFormValues);
|
|
4337
4441
|
};
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
}, /*#__PURE__*/
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
name: "label",
|
|
4357
|
-
id: "value"
|
|
4358
|
-
}, templates),
|
|
4359
|
-
placeholder: t("neetoMessageTemplate.sendMessage.selectTemplate"),
|
|
4360
|
-
onChange: function onChange(template) {
|
|
4361
|
-
return handleTemplateChange(setFieldValue, template);
|
|
4362
|
-
}
|
|
4363
|
-
}), /*#__PURE__*/React.createElement(Input, {
|
|
4364
|
-
required: true,
|
|
4365
|
-
label: t("neetoMessageTemplate.api.endpoint"),
|
|
4366
|
-
name: "endpoint",
|
|
4367
|
-
placeholder: SAMPLE_URL
|
|
4368
|
-
}), /*#__PURE__*/React.createElement(KeyValuePairs, {
|
|
4369
|
-
label: t("neetoMessageTemplate.api.additionalData"),
|
|
4370
|
-
name: "additionalData"
|
|
4371
|
-
}))), /*#__PURE__*/React.createElement(Pane.Footer, null, /*#__PURE__*/React.createElement(ActionBlock, {
|
|
4372
|
-
isSubmitting: isSubmitting,
|
|
4373
|
-
cancelButtonProps: {
|
|
4374
|
-
onClick: onClose
|
|
4442
|
+
if (isEmpty(templates)) {
|
|
4443
|
+
return /*#__PURE__*/jsx(NoDataPage, {
|
|
4444
|
+
addNewTemplateRoute: addNewTemplateRoute,
|
|
4445
|
+
type: "api"
|
|
4446
|
+
});
|
|
4447
|
+
}
|
|
4448
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
4449
|
+
children: [/*#__PURE__*/jsx(Pane.Header, {
|
|
4450
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
4451
|
+
style: "h2",
|
|
4452
|
+
weight: "semibold",
|
|
4453
|
+
children: t("neetoMessageTemplate.api.sendToApi")
|
|
4454
|
+
})
|
|
4455
|
+
}), /*#__PURE__*/jsx(NeetoUIForm, {
|
|
4456
|
+
formikProps: {
|
|
4457
|
+
initialValues: SEND_TO_API_FORM_INITIAL_VALUES,
|
|
4458
|
+
validationSchema: SEND_TO_API_FORM_VALIDATION_SCHEMA,
|
|
4459
|
+
onSubmit: handleSubmit
|
|
4375
4460
|
},
|
|
4376
|
-
|
|
4377
|
-
|
|
4461
|
+
children: function children(_ref2) {
|
|
4462
|
+
var setFieldValue = _ref2.setFieldValue;
|
|
4463
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
4464
|
+
children: [/*#__PURE__*/jsx(Pane.Body, {
|
|
4465
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
4466
|
+
className: "w-full space-y-5",
|
|
4467
|
+
children: [/*#__PURE__*/jsx(Select, {
|
|
4468
|
+
innerRef: setFocusField,
|
|
4469
|
+
isLoading: isLoadingTemplates,
|
|
4470
|
+
label: t("neetoMessageTemplate.template.title"),
|
|
4471
|
+
options: renameKeys({
|
|
4472
|
+
name: "label",
|
|
4473
|
+
id: "value"
|
|
4474
|
+
}, templates),
|
|
4475
|
+
placeholder: t("neetoMessageTemplate.sendMessage.selectTemplate"),
|
|
4476
|
+
onChange: function onChange(template) {
|
|
4477
|
+
return handleTemplateChange(setFieldValue, template);
|
|
4478
|
+
}
|
|
4479
|
+
}), /*#__PURE__*/jsx(Input, {
|
|
4480
|
+
required: true,
|
|
4481
|
+
label: t("neetoMessageTemplate.api.endpoint"),
|
|
4482
|
+
name: "endpoint",
|
|
4483
|
+
placeholder: SAMPLE_URL
|
|
4484
|
+
}), /*#__PURE__*/jsx(KeyValuePairs, {
|
|
4485
|
+
label: t("neetoMessageTemplate.api.additionalData"),
|
|
4486
|
+
name: "additionalData"
|
|
4487
|
+
})]
|
|
4488
|
+
})
|
|
4489
|
+
}), /*#__PURE__*/jsx(Pane.Footer, {
|
|
4490
|
+
children: /*#__PURE__*/jsx(ActionBlock, {
|
|
4491
|
+
isSubmitting: isSubmitting,
|
|
4492
|
+
cancelButtonProps: {
|
|
4493
|
+
onClick: onClose
|
|
4494
|
+
},
|
|
4495
|
+
submitButtonProps: {
|
|
4496
|
+
label: t("neetoMessageTemplate.template.send")
|
|
4497
|
+
}
|
|
4498
|
+
})
|
|
4499
|
+
})]
|
|
4500
|
+
});
|
|
4378
4501
|
}
|
|
4379
|
-
})
|
|
4380
|
-
})
|
|
4502
|
+
})]
|
|
4503
|
+
});
|
|
4381
4504
|
};
|
|
4382
4505
|
|
|
4383
4506
|
export { ApiTemplates, MessageTemplates, SendMessagePane, SendToApiPane };
|