@bigbinary/neeto-message-templates-frontend 0.7.0 → 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 +836 -685
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +806 -669
- package/dist/index.js.map +1 -1
- package/package.json +13 -12
- package/types.d.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
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';
|
|
5
5
|
import NeetoHeader from '@bigbinary/neeto-molecules/Header';
|
|
6
6
|
import SubHeader from '@bigbinary/neeto-molecules/SubHeader';
|
|
7
|
-
import
|
|
7
|
+
import Button from '@bigbinary/neetoui/Button';
|
|
8
|
+
import Typography from '@bigbinary/neetoui/Typography';
|
|
8
9
|
import { isEmpty, equals, prop, includes, pick, omit, assoc, mergeAll, pluck, whereAny, reject, modify } from 'ramda';
|
|
9
10
|
import { useTranslation, Trans } from 'react-i18next';
|
|
10
11
|
import { t as t$1 } from 'i18next';
|
|
@@ -15,13 +16,26 @@ import { useQuery } from 'react-query';
|
|
|
15
16
|
import axios from 'axios';
|
|
16
17
|
import require$$0 from 'util';
|
|
17
18
|
import { create } from 'zustand';
|
|
19
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
20
|
+
import Pane from '@bigbinary/neetoui/Pane';
|
|
18
21
|
import { FormikEditor } from '@bigbinary/neeto-editor';
|
|
19
|
-
import
|
|
22
|
+
import NeetoUIForm from '@bigbinary/neetoui/formik/Form';
|
|
23
|
+
import Input from '@bigbinary/neetoui/formik/Input';
|
|
24
|
+
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
|
|
20
25
|
import { useFormikContext, FieldArray } from 'formik';
|
|
26
|
+
import Textarea from '@bigbinary/neetoui/formik/Textarea';
|
|
21
27
|
import { isPhoneNumberValid } from '@bigbinary/neeto-molecules/PhoneNumber';
|
|
22
28
|
import * as yup from 'yup';
|
|
23
29
|
import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
|
|
30
|
+
import Alert from '@bigbinary/neetoui/Alert';
|
|
31
|
+
import Table from '@bigbinary/neetoui/Table';
|
|
32
|
+
import NoData from '@bigbinary/neetoui/NoData';
|
|
33
|
+
import Spinner from '@bigbinary/neetoui/Spinner';
|
|
34
|
+
import Select from '@bigbinary/neetoui/Select';
|
|
35
|
+
import Textarea$1 from '@bigbinary/neetoui/Textarea';
|
|
36
|
+
import Select$1 from '@bigbinary/neetoui/formik/Select';
|
|
24
37
|
import { Delete } from '@bigbinary/neeto-icons';
|
|
38
|
+
import Label from '@bigbinary/neetoui/Label';
|
|
25
39
|
|
|
26
40
|
function _typeof$1(o) {
|
|
27
41
|
"@babel/helpers - typeof";
|
|
@@ -140,6 +154,11 @@ var MESSAGE_TEMPLATES = {
|
|
|
140
154
|
addText: t$1("neetoMessageTemplate.template.addWhatsappTemplate"),
|
|
141
155
|
labelSingular: t$1("neetoMessageTemplate.template.whatsappTemplate"),
|
|
142
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")
|
|
143
162
|
}
|
|
144
163
|
};
|
|
145
164
|
var MESSAGE_TYPES = {
|
|
@@ -2263,8 +2282,8 @@ var QUERY_KEYS = {
|
|
|
2263
2282
|
NEETO_MESSAGE_TEMPLATES: "neeto-message-templates"
|
|
2264
2283
|
};
|
|
2265
2284
|
|
|
2266
|
-
function ownKeys$
|
|
2267
|
-
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; }
|
|
2268
2287
|
var ownerIdValue = function ownerIdValue(ownerId) {
|
|
2269
2288
|
return isEmpty(ownerId) ? undefined : ownerId;
|
|
2270
2289
|
};
|
|
@@ -2279,7 +2298,7 @@ var useCreateTemplate = function useCreateTemplate(ownerId, options) {
|
|
|
2279
2298
|
messageTemplate: messageTemplate,
|
|
2280
2299
|
ownerId: ownerIdValue(ownerId)
|
|
2281
2300
|
});
|
|
2282
|
-
}, _objectSpread$
|
|
2301
|
+
}, _objectSpread$d({
|
|
2283
2302
|
keysToInvalidate: [QUERY_KEYS.NEETO_MESSAGE_TEMPLATES]
|
|
2284
2303
|
}, options));
|
|
2285
2304
|
};
|
|
@@ -2346,8 +2365,8 @@ var getMenuItems = function getMenuItems(_ref) {
|
|
|
2346
2365
|
}];
|
|
2347
2366
|
};
|
|
2348
2367
|
|
|
2349
|
-
function ownKeys$
|
|
2350
|
-
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; }
|
|
2351
2370
|
var RowActions = function RowActions(_ref) {
|
|
2352
2371
|
var template = _ref.template,
|
|
2353
2372
|
setManageTemplatePane = _ref.setManageTemplatePane,
|
|
@@ -2359,14 +2378,14 @@ var RowActions = function RowActions(_ref) {
|
|
|
2359
2378
|
id = template.id;
|
|
2360
2379
|
var templateType = useTemplateStore(prop("templateType"));
|
|
2361
2380
|
var handleEditTemplate = function handleEditTemplate() {
|
|
2362
|
-
return setManageTemplatePane(_objectSpread$
|
|
2381
|
+
return setManageTemplatePane(_objectSpread$c(_objectSpread$c({}, MESSAGE_TEMPLATE_INITIAL_STATE), {}, {
|
|
2363
2382
|
isOpen: true,
|
|
2364
2383
|
isEdit: true,
|
|
2365
2384
|
template: template
|
|
2366
2385
|
}));
|
|
2367
2386
|
};
|
|
2368
2387
|
var handleDeleteTemplate = function handleDeleteTemplate() {
|
|
2369
|
-
return setManageTemplatePane(_objectSpread$
|
|
2388
|
+
return setManageTemplatePane(_objectSpread$c(_objectSpread$c({}, MESSAGE_TEMPLATE_INITIAL_STATE), {}, {
|
|
2370
2389
|
isDelete: true,
|
|
2371
2390
|
template: template
|
|
2372
2391
|
}));
|
|
@@ -2383,7 +2402,7 @@ var RowActions = function RowActions(_ref) {
|
|
|
2383
2402
|
onSuccess: onMutationSuccess
|
|
2384
2403
|
});
|
|
2385
2404
|
};
|
|
2386
|
-
return /*#__PURE__*/
|
|
2405
|
+
return /*#__PURE__*/jsx(MoreDropdown, {
|
|
2387
2406
|
dropdownButtonProps: {
|
|
2388
2407
|
"data-cy": "message-template-dropdown"
|
|
2389
2408
|
},
|
|
@@ -2399,10 +2418,10 @@ var RowActions = function RowActions(_ref) {
|
|
|
2399
2418
|
});
|
|
2400
2419
|
};
|
|
2401
2420
|
|
|
2402
|
-
function ownKeys$
|
|
2403
|
-
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; }
|
|
2404
2423
|
var handleEditTemplate = function handleEditTemplate(setManageTemplatePane, template) {
|
|
2405
|
-
return setManageTemplatePane(_objectSpread$
|
|
2424
|
+
return setManageTemplatePane(_objectSpread$b(_objectSpread$b({}, MESSAGE_TEMPLATE_INITIAL_STATE), {}, {
|
|
2406
2425
|
isOpen: true,
|
|
2407
2426
|
isEdit: true,
|
|
2408
2427
|
template: template
|
|
@@ -2426,20 +2445,21 @@ var buildTableColumnData$1 = function buildTableColumnData(setManageTemplatePane
|
|
|
2426
2445
|
label: t$1("neetoMessageTemplate.template.name"),
|
|
2427
2446
|
type: "text",
|
|
2428
2447
|
render: function render(name, template) {
|
|
2429
|
-
return /*#__PURE__*/
|
|
2430
|
-
className: "flex items-center justify-between gap-x-3"
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
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
|
+
});
|
|
2443
2463
|
}
|
|
2444
2464
|
}, {
|
|
2445
2465
|
dataIndex: "status",
|
|
@@ -2462,21 +2482,6 @@ var buildTableColumnData$1 = function buildTableColumnData(setManageTemplatePane
|
|
|
2462
2482
|
}];
|
|
2463
2483
|
};
|
|
2464
2484
|
|
|
2465
|
-
function _extends() {
|
|
2466
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
2467
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
2468
|
-
var source = arguments[i];
|
|
2469
|
-
for (var key in source) {
|
|
2470
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
2471
|
-
target[key] = source[key];
|
|
2472
|
-
}
|
|
2473
|
-
}
|
|
2474
|
-
}
|
|
2475
|
-
return target;
|
|
2476
|
-
};
|
|
2477
|
-
return _extends.apply(this, arguments);
|
|
2478
|
-
}
|
|
2479
|
-
|
|
2480
2485
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
2481
2486
|
if (source == null) return {};
|
|
2482
2487
|
var target = {};
|
|
@@ -2507,6 +2512,8 @@ function _objectWithoutProperties(source, excluded) {
|
|
|
2507
2512
|
}
|
|
2508
2513
|
|
|
2509
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; }
|
|
2510
2517
|
var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
|
|
2511
2518
|
var label = _ref.label,
|
|
2512
2519
|
name = _ref.name,
|
|
@@ -2518,7 +2525,7 @@ var FormikAdaptiveInput = function FormikAdaptiveInput(_ref) {
|
|
|
2518
2525
|
event.preventDefault();
|
|
2519
2526
|
submitForm();
|
|
2520
2527
|
};
|
|
2521
|
-
return /*#__PURE__*/
|
|
2528
|
+
return /*#__PURE__*/jsx(Textarea, _objectSpread$a({
|
|
2522
2529
|
label: label,
|
|
2523
2530
|
name: name,
|
|
2524
2531
|
className: "neeto-message-templates-nano-adaptive-input",
|
|
@@ -2941,6 +2948,8 @@ try {
|
|
|
2941
2948
|
|
|
2942
2949
|
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
2943
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; }
|
|
2944
2953
|
var TestMessage = function TestMessage(_ref) {
|
|
2945
2954
|
var isEmailTemplate = _ref.isEmailTemplate,
|
|
2946
2955
|
handleSubmitTestTemplate = _ref.handleSubmitTestTemplate,
|
|
@@ -3001,34 +3010,38 @@ var TestMessage = function TestMessage(_ref) {
|
|
|
3001
3010
|
event.preventDefault();
|
|
3002
3011
|
!isTestTemplateButtonDisabled && handleSubmitTestTemplate(values);
|
|
3003
3012
|
};
|
|
3004
|
-
return /*#__PURE__*/
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
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
|
+
});
|
|
3028
3041
|
};
|
|
3029
3042
|
|
|
3030
|
-
function ownKeys$
|
|
3031
|
-
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; }
|
|
3032
3045
|
var Form$1 = function Form(_ref) {
|
|
3033
3046
|
var onClose = _ref.onClose,
|
|
3034
3047
|
isEdit = _ref.isEdit,
|
|
@@ -3049,7 +3062,7 @@ var Form$1 = function Form(_ref) {
|
|
|
3049
3062
|
var templateType = useTemplateStore(prop("templateType"));
|
|
3050
3063
|
var isEmailTemplate = equals(templateType, "email_template");
|
|
3051
3064
|
var isTestTemplateVisible = includes(templateType, ["sms_template", "email_template"]) && shouldIncludeTestTemplate;
|
|
3052
|
-
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],
|
|
3053
3066
|
_ref3 = _slicedToArray(_ref2, 2),
|
|
3054
3067
|
TEMPLATE_INITIAL_VALUES = _ref3[0],
|
|
3055
3068
|
TEMPLATE_FORM_SCHEMA = _ref3[1];
|
|
@@ -3072,7 +3085,7 @@ var Form$1 = function Form(_ref) {
|
|
|
3072
3085
|
});
|
|
3073
3086
|
};
|
|
3074
3087
|
var messageBodyLabel = isEmailTemplate ? t("neetoMessageTemplate.template.emailBody") : t("neetoMessageTemplate.template.smsBody");
|
|
3075
|
-
return /*#__PURE__*/
|
|
3088
|
+
return /*#__PURE__*/jsxs(NeetoUIForm, {
|
|
3076
3089
|
formProps: {
|
|
3077
3090
|
noValidate: true,
|
|
3078
3091
|
className: "flex w-full flex-col gap-y-4 pb-6"
|
|
@@ -3083,43 +3096,45 @@ var Form$1 = function Form(_ref) {
|
|
|
3083
3096
|
validateOnBlur: true,
|
|
3084
3097
|
validateOnChange: true,
|
|
3085
3098
|
onSubmit: handleSubmit
|
|
3086
|
-
}
|
|
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: {
|
|
3116
|
-
"data-cy": "message-template-reset-button",
|
|
3117
|
-
onClick: onClose
|
|
3118
3099
|
},
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
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
|
+
});
|
|
3123
3138
|
};
|
|
3124
3139
|
|
|
3125
3140
|
var AddEdit = function AddEdit(_ref) {
|
|
@@ -3143,27 +3158,33 @@ var AddEdit = function AddEdit(_ref) {
|
|
|
3143
3158
|
isEdit = manageTemplatePane.isEdit,
|
|
3144
3159
|
template = manageTemplatePane.template;
|
|
3145
3160
|
var label = isEdit ? editText : addText;
|
|
3146
|
-
return /*#__PURE__*/
|
|
3161
|
+
return /*#__PURE__*/jsxs(Pane, {
|
|
3147
3162
|
isOpen: isOpen,
|
|
3148
3163
|
onClose: onClose,
|
|
3149
|
-
initialFocusRef: initialFocusField
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
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
|
+
});
|
|
3167
3188
|
};
|
|
3168
3189
|
|
|
3169
3190
|
function _arrayWithoutHoles(arr) {
|
|
@@ -3255,6 +3276,8 @@ var useTemplates = function useTemplates(_ref) {
|
|
|
3255
3276
|
};
|
|
3256
3277
|
};
|
|
3257
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; }
|
|
3258
3281
|
var List = function List(_ref) {
|
|
3259
3282
|
var setManageTemplatePane = _ref.setManageTemplatePane,
|
|
3260
3283
|
templatesData = _ref.templatesData,
|
|
@@ -3291,62 +3314,66 @@ var List = function List(_ref) {
|
|
|
3291
3314
|
}
|
|
3292
3315
|
});
|
|
3293
3316
|
};
|
|
3294
|
-
return /*#__PURE__*/
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
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
|
-
|
|
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
|
+
});
|
|
3346
3373
|
};
|
|
3347
3374
|
|
|
3348
|
-
function ownKeys$
|
|
3349
|
-
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; }
|
|
3350
3377
|
var MessageTemplates = function MessageTemplates(_ref) {
|
|
3351
3378
|
var _ref$breadcrumbs = _ref.breadcrumbs,
|
|
3352
3379
|
breadcrumbs = _ref$breadcrumbs === void 0 ? [] : _ref$breadcrumbs,
|
|
@@ -3404,7 +3431,7 @@ var MessageTemplates = function MessageTemplates(_ref) {
|
|
|
3404
3431
|
editText = _MESSAGE_TEMPLATES$ty.editText;
|
|
3405
3432
|
var isFilterApplied = isNotEmpty(filters) || isNotEmpty(searchTerm);
|
|
3406
3433
|
var handleActionClick = function handleActionClick() {
|
|
3407
|
-
return setManageTemplatePane(_objectSpread$
|
|
3434
|
+
return setManageTemplatePane(_objectSpread$6(_objectSpread$6({}, MESSAGE_TEMPLATE_INITIAL_STATE), {}, {
|
|
3408
3435
|
isOpen: true
|
|
3409
3436
|
}));
|
|
3410
3437
|
};
|
|
@@ -3418,70 +3445,116 @@ var MessageTemplates = function MessageTemplates(_ref) {
|
|
|
3418
3445
|
templateType: value
|
|
3419
3446
|
});
|
|
3420
3447
|
}, [value]);
|
|
3421
|
-
return /*#__PURE__*/
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
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));
|
|
3448
3512
|
}
|
|
3449
|
-
})
|
|
3450
|
-
})
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
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
|
+
});
|
|
3485
3558
|
};
|
|
3486
3559
|
|
|
3487
3560
|
var formatEditorContent = function formatEditorContent(value) {
|
|
@@ -3508,12 +3581,12 @@ var WHATSAPP_MESSAGE_FORM_VALIDATIONS_SCHEMA = yup.object().shape({
|
|
|
3508
3581
|
})
|
|
3509
3582
|
});
|
|
3510
3583
|
|
|
3511
|
-
function ownKeys$
|
|
3512
|
-
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; }
|
|
3513
3586
|
var EmailAndSms = function EmailAndSms(_ref) {
|
|
3514
3587
|
var onClose = _ref.onClose,
|
|
3515
3588
|
templates = _ref.templates,
|
|
3516
|
-
|
|
3589
|
+
setFocusField = _ref.setFocusField,
|
|
3517
3590
|
templateVariables = _ref.templateVariables,
|
|
3518
3591
|
customFields = _ref.customFields,
|
|
3519
3592
|
customFieldsInitialValues = _ref.customFieldsInitialValues,
|
|
@@ -3529,9 +3602,9 @@ var EmailAndSms = function EmailAndSms(_ref) {
|
|
|
3529
3602
|
INITIAL_VALUES = _ref3[0],
|
|
3530
3603
|
SEND_MESSAGE_FORM_SCHEMA = _ref3[1];
|
|
3531
3604
|
var updatedInitialValues = mergeAll([INITIAL_VALUES, customFieldsInitialValues]);
|
|
3532
|
-
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));
|
|
3533
3606
|
var initialValueKeys = Object.keys(INITIAL_VALUES);
|
|
3534
|
-
return /*#__PURE__*/
|
|
3607
|
+
return /*#__PURE__*/jsx(NeetoUIForm, {
|
|
3535
3608
|
formProps: {
|
|
3536
3609
|
noValidate: true,
|
|
3537
3610
|
className: "flex w-full flex-col gap-y-4 pb-6"
|
|
@@ -3540,61 +3613,65 @@ var EmailAndSms = function EmailAndSms(_ref) {
|
|
|
3540
3613
|
initialValues: updatedInitialValues,
|
|
3541
3614
|
validationSchema: updatedValidationSchema,
|
|
3542
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
|
+
});
|
|
3543
3669
|
}
|
|
3544
|
-
}, function (_ref4) {
|
|
3545
|
-
var setValues = _ref4.setValues,
|
|
3546
|
-
values = _ref4.values;
|
|
3547
|
-
var handleTemplateChange = function handleTemplateChange(value) {
|
|
3548
|
-
if (!value) return;
|
|
3549
|
-
var customFieldValues = omit(initialValueKeys, values);
|
|
3550
|
-
var template = findBy({
|
|
3551
|
-
id: value === null || value === void 0 ? void 0 : value.value
|
|
3552
|
-
}, templates);
|
|
3553
|
-
setValues(_objectSpread$3(_objectSpread$3({}, template), customFieldValues));
|
|
3554
|
-
editorRef.current.editor.commands.setContent(template.body);
|
|
3555
|
-
};
|
|
3556
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Select, {
|
|
3557
|
-
isClearable: true,
|
|
3558
|
-
isSearchable: true,
|
|
3559
|
-
innerRef: setInitialFocusField,
|
|
3560
|
-
label: t("neetoMessageTemplate.template.title"),
|
|
3561
|
-
options: renameKeys({
|
|
3562
|
-
name: "label",
|
|
3563
|
-
id: "value"
|
|
3564
|
-
}, templates),
|
|
3565
|
-
placeholder: t("neetoMessageTemplate.sendMessage.selectTemplate"),
|
|
3566
|
-
onChange: handleTemplateChange
|
|
3567
|
-
}), customFields, isEmailTemplate && /*#__PURE__*/React.createElement(Input, {
|
|
3568
|
-
required: true,
|
|
3569
|
-
label: t("neetoMessageTemplate.template.subject"),
|
|
3570
|
-
name: "subject"
|
|
3571
|
-
}), /*#__PURE__*/React.createElement(FormikEditor, {
|
|
3572
|
-
hideSlashCommands: true,
|
|
3573
|
-
required: true,
|
|
3574
|
-
contentClassName: "max-h-40",
|
|
3575
|
-
defaults: isEmailTemplate ? undefined : [],
|
|
3576
|
-
label: t("neetoMessageTemplate.template.body"),
|
|
3577
|
-
name: "body",
|
|
3578
|
-
ref: editorRef,
|
|
3579
|
-
rows: DEFAULT_EDITOR_ROW_COUNT,
|
|
3580
|
-
variables: templateVariables
|
|
3581
|
-
}), /*#__PURE__*/React.createElement(Pane.Footer, {
|
|
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
|
-
}
|
|
3592
|
-
})));
|
|
3593
3670
|
});
|
|
3594
3671
|
};
|
|
3595
3672
|
|
|
3596
|
-
function ownKeys$
|
|
3597
|
-
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; }
|
|
3598
3675
|
var Whatsapp = function Whatsapp(_ref) {
|
|
3599
3676
|
var _templates$, _templates$2, _templates$3, _templates$4;
|
|
3600
3677
|
var templates = _ref.templates,
|
|
@@ -3602,9 +3679,7 @@ var Whatsapp = function Whatsapp(_ref) {
|
|
|
3602
3679
|
handleSubmit = _ref.handleSubmit,
|
|
3603
3680
|
customFields = _ref.customFields,
|
|
3604
3681
|
customFieldsInitialValues = _ref.customFieldsInitialValues,
|
|
3605
|
-
customFieldsValidationSchema = _ref.customFieldsValidationSchema
|
|
3606
|
-
_ref$helpDocUrl = _ref.helpDocUrl,
|
|
3607
|
-
helpDocUrl = _ref$helpDocUrl === void 0 ? "" : _ref$helpDocUrl;
|
|
3682
|
+
customFieldsValidationSchema = _ref.customFieldsValidationSchema;
|
|
3608
3683
|
var _useTranslation = useTranslation(),
|
|
3609
3684
|
t = _useTranslation.t;
|
|
3610
3685
|
var getInitialVariableComponents = function getInitialVariableComponents(variables) {
|
|
@@ -3629,27 +3704,9 @@ var Whatsapp = function Whatsapp(_ref) {
|
|
|
3629
3704
|
variableContents: getInitialVariableComponents((_templates$4 = templates[0]) === null || _templates$4 === void 0 ? void 0 : _templates$4.variableCount)
|
|
3630
3705
|
};
|
|
3631
3706
|
var updatedInitialValues = mergeAll([initialFormValues, customFieldsInitialValues]);
|
|
3632
|
-
var updatedValidationSchema = yup.object().shape(_objectSpread$
|
|
3633
|
-
|
|
3634
|
-
|
|
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
|
-
}
|
|
3645
|
-
})), /*#__PURE__*/React.createElement(Pane.Footer, {
|
|
3646
|
-
className: "absolute bottom-0 left-0"
|
|
3647
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
|
3648
|
-
label: t("neetoMessageTemplate.template.close"),
|
|
3649
|
-
onClick: onClose
|
|
3650
|
-
})));
|
|
3651
|
-
}
|
|
3652
|
-
return /*#__PURE__*/React.createElement(Form$2, {
|
|
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));
|
|
3708
|
+
var initialValueKeys = Object.keys(initialFormValues);
|
|
3709
|
+
return /*#__PURE__*/jsx(NeetoUIForm, {
|
|
3653
3710
|
formProps: {
|
|
3654
3711
|
noValidate: true,
|
|
3655
3712
|
className: "flex w-full flex-col gap-y-4 pb-6"
|
|
@@ -3658,76 +3715,96 @@ var Whatsapp = function Whatsapp(_ref) {
|
|
|
3658
3715
|
initialValues: updatedInitialValues,
|
|
3659
3716
|
validationSchema: updatedValidationSchema,
|
|
3660
3717
|
onSubmit: handleSubmit
|
|
3661
|
-
}
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
label: t("neetoMessageTemplate.template.title"),
|
|
3683
|
-
name: "selectedTemplate",
|
|
3684
|
-
options: renameKeys({
|
|
3685
|
-
name: "label",
|
|
3686
|
-
id: "value"
|
|
3687
|
-
}, templates),
|
|
3688
|
-
onChange: handleTemplateChange
|
|
3689
|
-
}), customFields, /*#__PURE__*/React.createElement(Textarea$1, {
|
|
3690
|
-
disabled: true,
|
|
3691
|
-
nakedTextarea: true,
|
|
3692
|
-
label: t("neetoMessageTemplate.template.preview"),
|
|
3693
|
-
value: values.templateMessage
|
|
3694
|
-
}), isNotEmpty(values.variableContents) && /*#__PURE__*/React.createElement(React.Fragment, null, Object.keys(values.variableContents).map(function (group) {
|
|
3695
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
3696
|
-
className: "flex flex-col gap-y-2",
|
|
3697
|
-
key: group
|
|
3698
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
3699
|
-
style: "h4"
|
|
3700
|
-
}, t("neetoMessageTemplate.template.resolveVariable", {
|
|
3701
|
-
type: capitalize(group)
|
|
3702
|
-
})), values.variableContents[group].map(function (_, index) {
|
|
3703
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
3704
|
-
key: "".concat(group, "-").concat(index)
|
|
3705
|
-
}, /*#__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, {
|
|
3706
3739
|
required: true,
|
|
3707
|
-
|
|
3708
|
-
label: "
|
|
3709
|
-
name: "
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
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
|
+
}
|
|
3724
3788
|
});
|
|
3725
3789
|
};
|
|
3726
3790
|
|
|
3727
|
-
var
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
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,
|
|
3731
3808
|
type = _ref$type === void 0 ? "" : _ref$type,
|
|
3732
3809
|
_ref$handleSubmit = _ref.handleSubmit,
|
|
3733
3810
|
handleSubmit = _ref$handleSubmit === void 0 ? noop : _ref$handleSubmit,
|
|
@@ -3744,13 +3821,12 @@ var SendMessagePane = function SendMessagePane(_ref) {
|
|
|
3744
3821
|
_ref$ownerId = _ref.ownerId,
|
|
3745
3822
|
ownerId = _ref$ownerId === void 0 ? "" : _ref$ownerId,
|
|
3746
3823
|
_ref$helpDocUrl = _ref.helpDocUrl,
|
|
3747
|
-
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;
|
|
3748
3828
|
var _useTranslation = useTranslation(),
|
|
3749
3829
|
t = _useTranslation.t;
|
|
3750
|
-
var initialFocusField = useRef();
|
|
3751
|
-
var setInitialFocusField = function setInitialFocusField(fieldRef) {
|
|
3752
|
-
return initialFocusField.current = fieldRef;
|
|
3753
|
-
};
|
|
3754
3830
|
var value = MESSAGE_TEMPLATES[type].value;
|
|
3755
3831
|
var isWhatsappTemplate = type === "whatsapp";
|
|
3756
3832
|
var templateParams = {
|
|
@@ -3762,33 +3838,49 @@ var SendMessagePane = function SendMessagePane(_ref) {
|
|
|
3762
3838
|
_useFetchTemplates$da = _useFetchTemplates.data,
|
|
3763
3839
|
_useFetchTemplates$da2 = _useFetchTemplates$da === void 0 ? {} : _useFetchTemplates$da,
|
|
3764
3840
|
_useFetchTemplates$da3 = _useFetchTemplates$da2.templates,
|
|
3765
|
-
templates = _useFetchTemplates$da3 === void 0 ? [] : _useFetchTemplates$da3
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
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
|
+
});
|
|
3792
3884
|
};
|
|
3793
3885
|
|
|
3794
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}}
|
|
@@ -3877,46 +3969,50 @@ var KeyValuePairs = withT(function (_ref) {
|
|
|
3877
3969
|
name = _ref.name,
|
|
3878
3970
|
_ref$label = _ref.label,
|
|
3879
3971
|
label = _ref$label === void 0 ? "" : _ref$label;
|
|
3880
|
-
return /*#__PURE__*/
|
|
3881
|
-
name: name
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
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",
|
|
3903
4010
|
onClick: function onClick() {
|
|
3904
|
-
return
|
|
3905
|
-
arrayHelpers: arrayHelpers,
|
|
3906
|
-
index: index,
|
|
3907
|
-
data: data
|
|
3908
|
-
});
|
|
4011
|
+
return addOption(arrayHelpers);
|
|
3909
4012
|
}
|
|
3910
|
-
})
|
|
3911
|
-
})
|
|
3912
|
-
}
|
|
3913
|
-
className: "w-full justify-center",
|
|
3914
|
-
label: t("neetoMessageTemplate.api.addKeyValuePair"),
|
|
3915
|
-
style: "secondary",
|
|
3916
|
-
onClick: function onClick() {
|
|
3917
|
-
return addOption(arrayHelpers);
|
|
3918
|
-
}
|
|
3919
|
-
}));
|
|
4013
|
+
})]
|
|
4014
|
+
});
|
|
4015
|
+
}
|
|
3920
4016
|
});
|
|
3921
4017
|
});
|
|
3922
4018
|
|
|
@@ -3925,8 +4021,8 @@ var rejectEmptyKeyValuePairs = reject(whereAny({
|
|
|
3925
4021
|
value: isEmpty
|
|
3926
4022
|
}));
|
|
3927
4023
|
|
|
3928
|
-
function ownKeys$
|
|
3929
|
-
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; }
|
|
3930
4026
|
var buildApiTemplatePayload = function buildApiTemplatePayload(values) {
|
|
3931
4027
|
return {
|
|
3932
4028
|
entity: {
|
|
@@ -3946,38 +4042,39 @@ var buildTableColumnData = function buildTableColumnData(_ref) {
|
|
|
3946
4042
|
key: "name",
|
|
3947
4043
|
title: t$1("neetoMessageTemplate.template.name"),
|
|
3948
4044
|
render: function render(name, apiTemplate) {
|
|
3949
|
-
return /*#__PURE__*/
|
|
3950
|
-
className: "flex items-center justify-between gap-x-3"
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
onClick: function onClick() {
|
|
3955
|
-
return handleOpenEditPane(apiTemplate);
|
|
3956
|
-
}
|
|
3957
|
-
}), /*#__PURE__*/React.createElement(MoreDropdown, {
|
|
3958
|
-
dropdownProps: {
|
|
3959
|
-
strategy: "fixed"
|
|
3960
|
-
},
|
|
3961
|
-
menuItems: [{
|
|
3962
|
-
key: "edit",
|
|
3963
|
-
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",
|
|
3964
4050
|
onClick: function onClick() {
|
|
3965
4051
|
return handleOpenEditPane(apiTemplate);
|
|
3966
4052
|
}
|
|
3967
|
-
}, {
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
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
|
+
});
|
|
3981
4078
|
}
|
|
3982
4079
|
}, {
|
|
3983
4080
|
dataIndex: "status",
|
|
@@ -3992,7 +4089,7 @@ var buildTableColumnData = function buildTableColumnData(_ref) {
|
|
|
3992
4089
|
var buildApiTemplateInitialValues = function buildApiTemplateInitialValues(isEdit, apiTemplate) {
|
|
3993
4090
|
if (!isEdit) return API_TEMPLATE_INITIAL_VALUES;
|
|
3994
4091
|
var additionalData = isEmpty(apiTemplate.additionalData) ? [ADDITIONAL_DATA_INITIAL_VALUE] : apiTemplate.additionalData;
|
|
3995
|
-
return _objectSpread$
|
|
4092
|
+
return _objectSpread$2(_objectSpread$2({}, pick(["name", "endpoint"], apiTemplate)), {}, {
|
|
3996
4093
|
additionalData: additionalData
|
|
3997
4094
|
});
|
|
3998
4095
|
};
|
|
@@ -4034,38 +4131,51 @@ var Form = function Form(_ref) {
|
|
|
4034
4131
|
createApiTemplate(payload, options);
|
|
4035
4132
|
};
|
|
4036
4133
|
var isMutating = isUpdating || isCreating;
|
|
4037
|
-
return /*#__PURE__*/
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
|
-
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
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
|
+
});
|
|
4067
4175
|
};
|
|
4068
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; }
|
|
4069
4179
|
var ApiTemplates = function ApiTemplates(_ref) {
|
|
4070
4180
|
var ownerId = _ref.ownerId,
|
|
4071
4181
|
_ref$breadcrumbs = _ref.breadcrumbs,
|
|
@@ -4166,107 +4276,113 @@ var ApiTemplates = function ApiTemplates(_ref) {
|
|
|
4166
4276
|
}
|
|
4167
4277
|
});
|
|
4168
4278
|
};
|
|
4169
|
-
return /*#__PURE__*/
|
|
4170
|
-
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
|
|
4175
|
-
|
|
4176
|
-
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
}), /*#__PURE__*/React.createElement(SubHeader, {
|
|
4183
|
-
leftActionBlock: /*#__PURE__*/React.createElement(Typography, {
|
|
4184
|
-
component: "h4"
|
|
4185
|
-
}, t("neetoMessageTemplate.template.messageTemplatesWithCount", {
|
|
4186
|
-
type: t("messageType.api"),
|
|
4187
|
-
count: totalCount
|
|
4188
|
-
})),
|
|
4189
|
-
rightActionBlock: /*#__PURE__*/React.createElement(SubHeader.RightBlock, {
|
|
4190
|
-
dataProps: {
|
|
4191
|
-
totalCount: isFilterApplied ? null : totalCount
|
|
4192
|
-
},
|
|
4193
|
-
filterProps: {
|
|
4194
|
-
columns: FILTER_COLUMNS,
|
|
4195
|
-
isOpen: isFiltersPaneOpen,
|
|
4196
|
-
keyword: searchKeywordProps,
|
|
4197
|
-
setIsOpen: setIsFiltersPaneOpen,
|
|
4198
|
-
onChange: handleFiltersChange
|
|
4199
|
-
}
|
|
4200
|
-
})
|
|
4201
|
-
}), /*#__PURE__*/React.createElement(Bar, {
|
|
4202
|
-
columns: FILTER_COLUMNS,
|
|
4203
|
-
keyword: searchKeywordProps,
|
|
4204
|
-
setIsPaneOpen: setIsFiltersPaneOpen,
|
|
4205
|
-
onChange: handleFiltersChange
|
|
4206
|
-
}), isNotEmpty(templates) ? /*#__PURE__*/React.createElement(TableWrapper, {
|
|
4207
|
-
hasPagination: totalCount > pageParams.size
|
|
4208
|
-
}, /*#__PURE__*/React.createElement(Table, {
|
|
4209
|
-
totalCount: totalCount,
|
|
4210
|
-
fixedHeight: true,
|
|
4211
|
-
currentPageNumber: pageParams.index,
|
|
4212
|
-
defaultPageSize: pageParams.size,
|
|
4213
|
-
handlePageChange: function handlePageChange(index, size) {
|
|
4214
|
-
return setPageParams({
|
|
4215
|
-
index: index,
|
|
4216
|
-
size: size
|
|
4217
|
-
});
|
|
4218
|
-
},
|
|
4219
|
-
loading: isLoading || isFetching,
|
|
4220
|
-
rowData: templates,
|
|
4221
|
-
scroll: {
|
|
4222
|
-
x: "100%"
|
|
4223
|
-
},
|
|
4224
|
-
columnData: buildTableColumnData({
|
|
4225
|
-
handleMarkAsActiveOrInactive: handleMarkAsActiveOrInactive,
|
|
4226
|
-
handleOpenDeleteAlert: handleOpenDeleteAlert,
|
|
4227
|
-
handleOpenEditPane: handleOpenEditPane
|
|
4228
|
-
})
|
|
4229
|
-
})) : /*#__PURE__*/React.createElement("div", {
|
|
4230
|
-
className: "flex h-full w-full items-center justify-center"
|
|
4231
|
-
}, /*#__PURE__*/React.createElement(NoData, _extends({}, !isFilterApplied && {
|
|
4232
|
-
primaryButtonProps: {
|
|
4233
|
-
label: t("neetoMessageTemplate.api.addApiTemplate"),
|
|
4234
|
-
onClick: function onClick() {
|
|
4235
|
-
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")
|
|
4236
4292
|
}
|
|
4237
|
-
}
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
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
|
+
});
|
|
4265
4370
|
}
|
|
4266
|
-
}),
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
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
|
+
});
|
|
4270
4386
|
};
|
|
4271
4387
|
|
|
4272
4388
|
var SEND_TO_API_FORM_INITIAL_VALUES = {
|
|
@@ -4286,13 +4402,14 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4286
4402
|
var SendToApiPane = function SendToApiPane(props) {
|
|
4287
4403
|
var isOpen = props.isOpen,
|
|
4288
4404
|
onClose = props.onClose;
|
|
4289
|
-
return /*#__PURE__*/
|
|
4405
|
+
return /*#__PURE__*/jsx(Pane, {
|
|
4290
4406
|
isOpen: isOpen,
|
|
4291
|
-
onClose: onClose
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4407
|
+
onClose: onClose,
|
|
4408
|
+
children: function children(paneProps) {
|
|
4409
|
+
return /*#__PURE__*/jsx(SendToApiForm, _objectSpread({}, _objectSpread(_objectSpread({}, props), {}, {
|
|
4410
|
+
paneProps: paneProps
|
|
4411
|
+
})));
|
|
4412
|
+
}
|
|
4296
4413
|
});
|
|
4297
4414
|
};
|
|
4298
4415
|
var SendToApiForm = function SendToApiForm(_ref) {
|
|
@@ -4300,6 +4417,7 @@ var SendToApiForm = function SendToApiForm(_ref) {
|
|
|
4300
4417
|
onClose = _ref.onClose,
|
|
4301
4418
|
onSubmit = _ref.onSubmit,
|
|
4302
4419
|
isSubmitting = _ref.isSubmitting,
|
|
4420
|
+
addNewTemplateRoute = _ref.addNewTemplateRoute,
|
|
4303
4421
|
setFocusField = _ref.paneProps.setFocusField;
|
|
4304
4422
|
var _useTranslation = useTranslation(),
|
|
4305
4423
|
t = _useTranslation.t;
|
|
@@ -4321,49 +4439,68 @@ var SendToApiForm = function SendToApiForm(_ref) {
|
|
|
4321
4439
|
var additionalDataModifiedFormValues = modify("additionalData", rejectEmptyKeyValuePairs, formValues);
|
|
4322
4440
|
onSubmit(additionalDataModifiedFormValues);
|
|
4323
4441
|
};
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
}, /*#__PURE__*/
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
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
|
|
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
|
|
4361
4460
|
},
|
|
4362
|
-
|
|
4363
|
-
|
|
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
|
+
});
|
|
4364
4501
|
}
|
|
4365
|
-
})
|
|
4366
|
-
})
|
|
4502
|
+
})]
|
|
4503
|
+
});
|
|
4367
4504
|
};
|
|
4368
4505
|
|
|
4369
4506
|
export { ApiTemplates, MessageTemplates, SendMessagePane, SendToApiPane };
|