@bigbinary/neeto-rules-frontend 0.8.0-beta1 → 0.8.1

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/dist/index.cjs.js CHANGED
@@ -16,17 +16,26 @@ var ramda = require('ramda');
16
16
  var reactI18next = require('react-i18next');
17
17
  var jsxRuntime = require('react/jsx-runtime');
18
18
  var i18next = require('i18next');
19
+ var constants = require('@bigbinary/neeto-commons-frontend/constants');
20
+ var SubHeader = require('@bigbinary/neeto-molecules/SubHeader');
21
+ var TableWrapper = require('@bigbinary/neeto-molecules/TableWrapper');
22
+ var Alert = require('@bigbinary/neetoui/Alert');
23
+ var NoData = require('@bigbinary/neetoui/NoData');
24
+ var Table = require('@bigbinary/neetoui/Table');
25
+ var reactQuery = require('react-query');
26
+ var axios = require('axios');
27
+ var utils = require('@bigbinary/neeto-commons-frontend/utils');
28
+ var Switch = require('@bigbinary/neetoui/Switch');
29
+ var reactRouterDom = require('react-router-dom');
19
30
  var ReactDOM = require('react-dom');
20
31
  var Pagination = require('@bigbinary/neetoui/Pagination');
21
- var reactRouterDom = require('react-router-dom');
22
32
  var shallow = require('zustand/shallow');
23
33
  var classNames$1 = require('classnames');
24
34
  var formik = require('formik');
25
35
  var ActionBlock = require('@bigbinary/neetoui/formik/ActionBlock');
26
36
  var PhoneNumber = require('@bigbinary/neeto-molecules/PhoneNumber');
27
37
  var yup = require('yup');
28
- var neetoEditor = require('@bigbinary/neeto-editor');
29
- var utils = require('@bigbinary/neeto-commons-frontend/utils');
38
+ var utils$1 = require('@bigbinary/neeto-editor/utils');
30
39
  var Dropdown$1 = require('@bigbinary/neetoui/Dropdown');
31
40
  var Input$2 = require('@bigbinary/neetoui/Input');
32
41
  var Textarea = require('@bigbinary/neetoui/formik/Textarea');
@@ -34,6 +43,7 @@ var Label = require('@bigbinary/neetoui/Label');
34
43
  var Select$1 = require('@bigbinary/neetoui/Select');
35
44
  var dayjs = require('dayjs');
36
45
  var DatePicker = require('@bigbinary/neetoui/DatePicker');
46
+ var FormikEditor = require('@bigbinary/neeto-editor/FormikEditor');
37
47
  var MultiEmailInput = require('@bigbinary/neetoui/formik/MultiEmailInput');
38
48
  var Input$3 = require('@bigbinary/neetoui/formik/Input');
39
49
  var useHotkeys = require('@bigbinary/neeto-hotkeys');
@@ -70,6 +80,13 @@ var PageLoader__default = /*#__PURE__*/_interopDefaultLegacy(PageLoader);
70
80
  var Pane__default = /*#__PURE__*/_interopDefaultLegacy(Pane);
71
81
  var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
72
82
  var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
83
+ var SubHeader__default = /*#__PURE__*/_interopDefaultLegacy(SubHeader);
84
+ var TableWrapper__default = /*#__PURE__*/_interopDefaultLegacy(TableWrapper);
85
+ var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
86
+ var NoData__default = /*#__PURE__*/_interopDefaultLegacy(NoData);
87
+ var Table__default = /*#__PURE__*/_interopDefaultLegacy(Table);
88
+ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
89
+ var Switch__default = /*#__PURE__*/_interopDefaultLegacy(Switch);
73
90
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
74
91
  var Pagination__default = /*#__PURE__*/_interopDefaultLegacy(Pagination);
75
92
  var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames$1);
@@ -82,6 +99,7 @@ var Label__default = /*#__PURE__*/_interopDefaultLegacy(Label);
82
99
  var Select__default = /*#__PURE__*/_interopDefaultLegacy(Select$1);
83
100
  var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
84
101
  var DatePicker__default = /*#__PURE__*/_interopDefaultLegacy(DatePicker);
102
+ var FormikEditor__default = /*#__PURE__*/_interopDefaultLegacy(FormikEditor);
85
103
  var MultiEmailInput__default = /*#__PURE__*/_interopDefaultLegacy(MultiEmailInput);
86
104
  var Input__default$1 = /*#__PURE__*/_interopDefaultLegacy(Input$3);
87
105
  var useHotkeys__default = /*#__PURE__*/_interopDefaultLegacy(useHotkeys);
@@ -211,6 +229,24 @@ var Title = function Title(_ref) {
211
229
  });
212
230
  };
213
231
 
232
+ var PREVIEW_CONDITION_LIMIT = 3;
233
+ var ACTION_TYPE = {
234
+ TEXT: "text",
235
+ NUMBER: "number",
236
+ DECIMAL: "decimal",
237
+ REGEX: "regex",
238
+ DATE: "date",
239
+ EMAIL: "email",
240
+ EMAIL_TO: "emailTo",
241
+ EMAIL_TO_IDS: "emailToIds",
242
+ SMS_TO_NUMBERS: "smsToNumbers",
243
+ MULTI_SELECT: "multiSelect",
244
+ SEND_TO_API: "sendToApi",
245
+ DROPDOWN: "dropdown",
246
+ MULTISELECT: "multiSelect"
247
+ };
248
+ var TEXT_FIELDS = [ACTION_TYPE.TEXT, ACTION_TYPE.NUMBER, ACTION_TYPE.DECIMAL, ACTION_TYPE.REGEX, ACTION_TYPE.DATE];
249
+
214
250
  var MultiSelectValues = function MultiSelectValues(_ref) {
215
251
  var separator = _ref.separator,
216
252
  values = _ref.values;
@@ -239,6 +275,48 @@ var getEntityDisplayValue = function getEntityDisplayValue(entitiy, entitiyOptio
239
275
  value: entitiy.metadata.value
240
276
  }, entitiyOption.dropdownOptions)) === null || _findBy === void 0 || (_findBy = _findBy.label) === null || _findBy === void 0 ? void 0 : _findBy.toLowerCase();
241
277
  };
278
+ var getActionDisplayValue = function getActionDisplayValue(action, actionOption) {
279
+ var displayValueData = {
280
+ displayValue: null,
281
+ isBulk: false
282
+ };
283
+ if (TEXT_FIELDS.includes(actionOption.type)) {
284
+ var _action$metadata$valu;
285
+ displayValueData.displayValue = (_action$metadata$valu = action.metadata.value) === null || _action$metadata$valu === void 0 ? void 0 : _action$metadata$valu.toLowerCase();
286
+ return displayValueData;
287
+ }
288
+ switch (actionOption.type) {
289
+ case ACTION_TYPE.DROPDOWN:
290
+ {
291
+ displayValueData.displayValue = getEntityDisplayValue(action, actionOption);
292
+ return displayValueData;
293
+ }
294
+ case ACTION_TYPE.EMAIL_TO_IDS:
295
+ {
296
+ displayValueData.isBulk = true;
297
+ displayValueData.displayValue = action.metadata.emails;
298
+ return displayValueData;
299
+ }
300
+ case ACTION_TYPE.EMAIL_TO:
301
+ {
302
+ displayValueData.displayValue = action.displayValue;
303
+ return displayValueData;
304
+ }
305
+ case ACTION_TYPE.SMS_TO_NUMBERS:
306
+ {
307
+ displayValueData.isBulk = true;
308
+ displayValueData.displayValue = action.metadata.phoneNumbers;
309
+ return displayValueData;
310
+ }
311
+ case ACTION_TYPE.SEND_TO_API:
312
+ {
313
+ displayValueData.displayValue = action.metadata.endpoint;
314
+ return displayValueData;
315
+ }
316
+ default:
317
+ return null;
318
+ }
319
+ };
242
320
 
243
321
  var ActionsDetail = function ActionsDetail(_ref) {
244
322
  var actions = _ref.actions;
@@ -256,9 +334,26 @@ var ActionsDetail = function ActionsDetail(_ref) {
256
334
  }) : t("neetoRules.common.then");
257
335
  };
258
336
  var renderActionValues = function renderActionValues(action, actionOption) {
259
- if (actionOption.type === "dropdown") {
260
- var _actionOption$separat;
261
- var separator = (actionOption === null || actionOption === void 0 || (_actionOption$separat = actionOption.separator) === null || _actionOption$separat === void 0 ? void 0 : _actionOption$separat.toLowerCase()) || t("neetoRules.common.to");
337
+ var _actionOption$separat, _getActionDisplayValu;
338
+ var commonSeperator = actionOption.type === ACTION_TYPE.SEND_TO_API ? t("neetoRules.common.at") : t("neetoRules.common.to");
339
+ var separator = (actionOption === null || actionOption === void 0 || (_actionOption$separat = actionOption.separator) === null || _actionOption$separat === void 0 ? void 0 : _actionOption$separat.toLowerCase()) || commonSeperator;
340
+ var _ref2 = (_getActionDisplayValu = getActionDisplayValue(action, actionOption)) !== null && _getActionDisplayValu !== void 0 ? _getActionDisplayValu : {},
341
+ displayValue = _ref2.displayValue,
342
+ isBulk = _ref2.isBulk;
343
+ if (actionOption.type === ACTION_TYPE.MULTISELECT) {
344
+ var values = ramda.pluck("label", actionOption.dropdownOptions.filter(function (_ref3) {
345
+ var value = _ref3.value;
346
+ return action.metadata.value.includes(value);
347
+ }));
348
+ return /*#__PURE__*/jsxRuntime.jsx(MultiSelectValues, {
349
+ values: values,
350
+ separator: t("neetoRules.common.and", {
351
+ what: ""
352
+ })
353
+ });
354
+ }
355
+ if (!displayValue) return null;
356
+ if (!isBulk) {
262
357
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
263
358
  children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
264
359
  className: "neeto-ui-text-gray-700",
@@ -269,23 +364,20 @@ var ActionsDetail = function ActionsDetail(_ref) {
269
364
  className: "neeto-ui-text-gray-800",
270
365
  style: "h5",
271
366
  weight: "semibold",
272
- children: getEntityDisplayValue(action, actionOption)
367
+ children: displayValue === null || displayValue === void 0 ? void 0 : displayValue.toLowerCase()
273
368
  })]
274
369
  });
275
370
  }
276
- if (actionOption.type === "multiSelect") {
277
- var values = ramda.pluck("label", actionOption.dropdownOptions.filter(function (_ref2) {
278
- var value = _ref2.value;
279
- return action.metadata.value.includes(value);
280
- }));
281
- return /*#__PURE__*/jsxRuntime.jsx(MultiSelectValues, {
282
- values: values,
283
- separator: t("neetoRules.common.and", {
284
- what: ""
285
- })
286
- });
287
- }
288
- return null;
371
+ return displayValue.map(function (value, index) {
372
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
373
+ className: "mr-1 flex",
374
+ children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
375
+ style: "h5",
376
+ weight: "semibold",
377
+ children: value
378
+ }, index), index !== displayValue.length - 1 && ", "]
379
+ }, index);
380
+ });
289
381
  };
290
382
  var renderAction = function renderAction(action) {
291
383
  var actionOption = neetoCist.findBy({
@@ -306,6 +398,7 @@ var ActionsDetail = function ActionsDetail(_ref) {
306
398
  children: [allActions.map(function (action, index) {
307
399
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
308
400
  className: "mb-2 flex flex-wrap gap-x-1 gap-y-2",
401
+ "data-cy": "then-action-events",
309
402
  children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
310
403
  className: "neeto-ui-text-gray-700",
311
404
  style: "h5",
@@ -330,10 +423,68 @@ var ActionsDetail = function ActionsDetail(_ref) {
330
423
  });
331
424
  };
332
425
 
426
+ var OPERATORS$1 = {
427
+ or: "or_operator",
428
+ and: "and_operator"
429
+ };
430
+ var OPERATOR_LABELS = {
431
+ or_operator: i18next.t("neetoRules.operators.or"),
432
+ and_operator: i18next.t("neetoRules.operators.and")
433
+ };
434
+ var VERB_LABELS = {
435
+ is: i18next.t("neetoRules.conditionVerbs.is"),
436
+ is_not: i18next.t("neetoRules.conditionVerbs.isNot"),
437
+ contains: i18next.t("neetoRules.conditionVerbs.contains"),
438
+ does_not_contain: i18next.t("neetoRules.conditionVerbs.doesNotContain"),
439
+ contains_any_of: i18next.t("neetoRules.conditionVerbs.containsAnyOf"),
440
+ contains_all_of: i18next.t("neetoRules.conditionVerbs.containsAllOf"),
441
+ contains_none_of: i18next.t("neetoRules.conditionVerbs.containsNoneOf"),
442
+ starts_with: i18next.t("neetoRules.conditionVerbs.startsWith"),
443
+ ends_with: i18next.t("neetoRules.conditionVerbs.endsWith"),
444
+ less_than: i18next.t("neetoRules.conditionVerbs.lessThan"),
445
+ greater_than: i18next.t("neetoRules.conditionVerbs.greaterThan"),
446
+ any_time: i18next.t("neetoRules.conditionVerbs.anyTime"),
447
+ during: i18next.t("neetoRules.conditionVerbs.during"),
448
+ not_during: i18next.t("neetoRules.conditionVerbs.notDuring"),
449
+ any_of: i18next.t("neetoRules.conditionVerbs.anyOf"),
450
+ none_of: i18next.t("neetoRules.conditionVerbs.noneOf"),
451
+ is_before: i18next.t("neetoRules.conditionVerbs.isBefore"),
452
+ is_after: i18next.t("neetoRules.conditionVerbs.isAfter")
453
+ };
454
+ var CONDITION_VALUE_TYPES = {
455
+ text: "text",
456
+ number: "number",
457
+ decimal: "decimal",
458
+ url: "url",
459
+ email: "email",
460
+ dropdown: "dropdown",
461
+ multiSelect: "multi-select",
462
+ multiSelectCreate: "multi-select-create",
463
+ date: "date",
464
+ regex: "regex",
465
+ textarea: "textarea"
466
+ };
467
+ var INPUT_FIELD_TYPES = ["email", "text", "number", "decimal", "url", "regex"];
468
+ var MAXIMUM_OPTION_LENGTH$3 = 7;
469
+
470
+ function ownKeys$u(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; }
471
+ function _objectSpread$s(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$u(Object(t), !0).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$u(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
333
472
  var ConditionsDetail = function ConditionsDetail(_ref) {
334
473
  var conditions = _ref.conditions,
335
474
  conditionOptions = _ref.conditionOptions,
336
- conditionVerbs = _ref.conditionVerbs;
475
+ _ref$conditionVerbs = _ref.conditionVerbs,
476
+ conditionVerbs = _ref$conditionVerbs === void 0 ? {} : _ref$conditionVerbs,
477
+ _ref$hasEvent = _ref.hasEvent,
478
+ hasEvent = _ref$hasEvent === void 0 ? true : _ref$hasEvent;
479
+ var _useState = React.useState(false),
480
+ _useState2 = _slicedToArray$1(_useState, 2),
481
+ viewMore = _useState2[0],
482
+ setViewMore = _useState2[1];
483
+ var _useTranslation = reactI18next.useTranslation(),
484
+ t = _useTranslation.t;
485
+ var conditionsList = conditions.value;
486
+ var allConditions = viewMore && conditionsList.length > PREVIEW_CONDITION_LIMIT ? conditionsList : conditionsList.slice(0, PREVIEW_CONDITION_LIMIT);
487
+ var allConditionVerbs = _objectSpread$s(_objectSpread$s({}, VERB_LABELS), conditionVerbs);
337
488
  var getLogicOperator = function getLogicOperator(joinType) {
338
489
  return joinType === "or_operator" ? "or" : "and";
339
490
  };
@@ -354,7 +505,7 @@ var ConditionsDetail = function ConditionsDetail(_ref) {
354
505
  }));
355
506
  return /*#__PURE__*/jsxRuntime.jsx(MultiSelectValues, {
356
507
  values: values,
357
- separator: i18next.t("neetoRules.common.or")
508
+ separator: t("neetoRules.common.or")
358
509
  });
359
510
  }
360
511
  if (conditionOption.type === "dropdown") {
@@ -368,12 +519,12 @@ var ConditionsDetail = function ConditionsDetail(_ref) {
368
519
  return null;
369
520
  };
370
521
  var renderCondition = function renderCondition(condition) {
371
- var _conditionVerbs$condi;
522
+ var _allConditionVerbs$co;
372
523
  var conditionOption = neetoCist.findBy({
373
524
  value: condition.field
374
525
  }, conditionOptions);
375
526
  if (!conditionOption) return null;
376
- var conditionVerb = (_conditionVerbs$condi = conditionVerbs[condition.verb]) === null || _conditionVerbs$condi === void 0 ? void 0 : _conditionVerbs$condi.toLowerCase();
527
+ var conditionVerb = (_allConditionVerbs$co = allConditionVerbs[condition.verb]) === null || _allConditionVerbs$co === void 0 ? void 0 : _allConditionVerbs$co.toLowerCase();
377
528
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
378
529
  children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
379
530
  className: "neeto-ui-text-gray-800",
@@ -388,31 +539,46 @@ var ConditionsDetail = function ConditionsDetail(_ref) {
388
539
  }), renderConditionValues(condition, conditionOption)]
389
540
  });
390
541
  };
391
- return /*#__PURE__*/jsxRuntime.jsx("div", {
392
- className: "mt-2",
393
- children: conditions.map(function (condition, index) {
394
- return /*#__PURE__*/jsxRuntime.jsxs("div", {
395
- className: "mb-2 flex flex-wrap gap-x-2 gap-y-2",
396
- children: [!index && /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
397
- className: "neeto-ui-text-gray-700",
398
- style: "h5",
399
- weight: "normal",
400
- children: i18next.t("neetoRules.common.and", {
401
- what: ""
402
- })
403
- }), !!index && /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
404
- className: "neeto-ui-text-gray-800",
405
- style: "h5",
406
- weight: "semibold",
407
- children: getLogicOperator(condition.joinType)
408
- }), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
409
- className: "neeto-ui-text-gray-700",
410
- style: "h5",
411
- weight: "normal",
412
- children: i18next.t("neetoRules.common.when").toLowerCase()
413
- }), renderCondition(condition)]
414
- }, condition.id);
415
- })
542
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
543
+ children: [/*#__PURE__*/jsxRuntime.jsx("div", {
544
+ className: "mt-2",
545
+ children: allConditions.map(function (condition, index) {
546
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
547
+ className: "mb-2 flex flex-wrap gap-x-2 gap-y-2",
548
+ children: [!index && hasEvent && /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
549
+ className: "neeto-ui-text-gray-700",
550
+ style: "h5",
551
+ weight: "normal",
552
+ children: t("neetoRules.common.and", {
553
+ what: ""
554
+ })
555
+ }), !!index && /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
556
+ className: "neeto-ui-text-gray-800",
557
+ style: "h5",
558
+ weight: "semibold",
559
+ children: getLogicOperator(condition.joinType)
560
+ }), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
561
+ className: "neeto-ui-text-gray-700",
562
+ style: "h5",
563
+ weight: "normal",
564
+ children: t("neetoRules.common.when")
565
+ }), renderCondition(condition)]
566
+ }, condition.id);
567
+ })
568
+ }), conditionsList.length > 3 && /*#__PURE__*/jsxRuntime.jsx("div", {
569
+ className: "mt-3 w-full",
570
+ children: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
571
+ icon: !viewMore ? neetoIcons.Down : neetoIcons.Up,
572
+ size: "small",
573
+ style: "link",
574
+ label: !viewMore ? t("neetoRules.common.viewMore") : t("neetoRules.common.viewLess"),
575
+ onClick: function onClick() {
576
+ return setViewMore(function (prevState) {
577
+ return !prevState;
578
+ });
579
+ }
580
+ })
581
+ })]
416
582
  });
417
583
  };
418
584
 
@@ -421,23 +587,20 @@ var EventsDetail = function EventsDetail(_ref) {
421
587
  var events = _ref.events,
422
588
  performer = _ref.performer,
423
589
  conditions = _ref.conditions;
424
- var _useState = React.useState(false),
425
- _useState2 = _slicedToArray$1(_useState, 2),
426
- viewMore = _useState2[0],
427
- setViewMore = _useState2[1];
590
+ var _useTranslation = reactI18next.useTranslation(),
591
+ t = _useTranslation.t;
428
592
  var eventNames = ramda.pluck("name", events.value);
429
593
  var allEvents = events.eventOptions.filter(function (event) {
430
594
  return eventNames === null || eventNames === void 0 ? void 0 : eventNames.includes(event.value);
431
595
  });
432
- var conditionsList = conditions.value;
433
- var allConditions = viewMore && conditionsList.length > 3 ? conditionsList : conditionsList.slice(0, 3);
434
596
  var currentPerformer = neetoCist.findBy({
435
597
  value: performer.value
436
598
  }, performer.options);
437
599
  return /*#__PURE__*/jsxRuntime.jsxs(Title, {
438
- title: i18next.t("neetoRules.common.when"),
600
+ title: t("neetoRules.common.when"),
439
601
  children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
440
602
  className: "flex flex-wrap gap-x-2 gap-y-2",
603
+ "data-cy": "when-condition-events",
441
604
  children: [allEvents.map(function (event, index) {
442
605
  return /*#__PURE__*/jsxRuntime.jsxs("div", {
443
606
  className: "flex gap-x-2",
@@ -445,12 +608,12 @@ var EventsDetail = function EventsDetail(_ref) {
445
608
  className: "neeto-ui-text-gray-700 my-auto",
446
609
  style: "h5",
447
610
  weight: "normal",
448
- children: i18next.t("neetoRules.common.when")
611
+ children: t("neetoRules.common.when")
449
612
  }), !!index && /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
450
613
  className: "neeto-ui-text-gray-700 my-auto",
451
614
  style: "h5",
452
615
  weight: "normal",
453
- children: i18next.t("neetoRules.common.or")
616
+ children: t("neetoRules.common.or")
454
617
  }), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
455
618
  className: "neeto-ui-text-gray-800",
456
619
  style: "h5",
@@ -462,7 +625,7 @@ var EventsDetail = function EventsDetail(_ref) {
462
625
  className: "neeto-ui-text-gray-700",
463
626
  style: "h5",
464
627
  weight: "normal",
465
- children: i18next.t("neetoRules.common.by")
628
+ children: t("neetoRules.common.by")
466
629
  }), /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
467
630
  className: "neeto-ui-text-gray-800",
468
631
  style: "h5",
@@ -470,30 +633,18 @@ var EventsDetail = function EventsDetail(_ref) {
470
633
  children: currentPerformer === null || currentPerformer === void 0 || (_currentPerformer$lab = currentPerformer.label) === null || _currentPerformer$lab === void 0 ? void 0 : _currentPerformer$lab.toLowerCase()
471
634
  })]
472
635
  }), /*#__PURE__*/jsxRuntime.jsx(ConditionsDetail, {
636
+ conditions: conditions,
473
637
  conditionOptions: conditions.conditionOptions,
474
- conditionVerbs: conditions.verbs,
475
- conditions: allConditions
476
- }), conditionsList.length > 3 && /*#__PURE__*/jsxRuntime.jsx("div", {
477
- className: "mt-3 w-full",
478
- children: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
479
- icon: !viewMore ? neetoIcons.Down : neetoIcons.Up,
480
- size: "small",
481
- style: "link",
482
- label: !viewMore ? i18next.t("neetoRules.common.viewMore") : i18next.t("neetoRules.common.viewLess"),
483
- onClick: function onClick() {
484
- return setViewMore(function (prevState) {
485
- return !prevState;
486
- });
487
- }
488
- })
638
+ conditionVerbs: conditions.verbs
489
639
  })]
490
640
  });
491
641
  };
492
642
 
493
- function ownKeys$q(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; }
494
- function _objectSpread$o(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$q(Object(t), !0).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$q(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
495
- var RulePreview = function RulePreview(_ref) {
496
- var isLoading = _ref.isLoading,
643
+ function ownKeys$t(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; }
644
+ function _objectSpread$r(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$t(Object(t), !0).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$t(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
645
+ var RulePreview = reactUtils.withT(function (_ref) {
646
+ var t = _ref.t,
647
+ isLoading = _ref.isLoading,
497
648
  ruleDetails = _ref.ruleDetails,
498
649
  isOpen = _ref.isOpen,
499
650
  onClose = _ref.onClose,
@@ -511,7 +662,7 @@ var RulePreview = function RulePreview(_ref) {
511
662
  style: "h4",
512
663
  weight: "semibold",
513
664
  children: ruleDetails.name.value
514
- }), neetoCist.isNotEmpty(moreDropdownProps) && /*#__PURE__*/jsxRuntime.jsx(MoreDropdown__default["default"], _objectSpread$o({}, moreDropdownProps))]
665
+ }), neetoCist.isNotEmpty(moreDropdownProps) && /*#__PURE__*/jsxRuntime.jsx(MoreDropdown__default["default"], _objectSpread$r({}, moreDropdownProps))]
515
666
  })
516
667
  }), /*#__PURE__*/jsxRuntime.jsx(Pane__default["default"].Body, {
517
668
  children: /*#__PURE__*/jsxRuntime.jsxs("div", {
@@ -536,10 +687,18 @@ var RulePreview = function RulePreview(_ref) {
536
687
  children: ruleDetails.entity.value
537
688
  })]
538
689
  })]
539
- }), /*#__PURE__*/jsxRuntime.jsx(EventsDetail, {
690
+ }), ruleDetails.events && neetoCist.isNotEmpty(ruleDetails.events) ? /*#__PURE__*/jsxRuntime.jsx(EventsDetail, {
540
691
  conditions: ruleDetails.conditions,
541
692
  events: ruleDetails.events,
542
693
  performer: ruleDetails.performer
694
+ }) : /*#__PURE__*/jsxRuntime.jsx(Title, {
695
+ title: t("neetoRules.common.when"),
696
+ children: /*#__PURE__*/jsxRuntime.jsx(ConditionsDetail, {
697
+ conditionOptions: ruleDetails.conditions.conditionOptions,
698
+ conditionVerbs: ruleDetails.conditions.verbs,
699
+ conditions: ruleDetails.conditions,
700
+ hasEvent: false
701
+ })
543
702
  }), /*#__PURE__*/jsxRuntime.jsx(ActionsDetail, {
544
703
  actions: ruleDetails.actions
545
704
  })]
@@ -547,6 +706,419 @@ var RulePreview = function RulePreview(_ref) {
547
706
  })]
548
707
  })
549
708
  });
709
+ });
710
+
711
+ function _objectWithoutPropertiesLoose$2(source, excluded) {
712
+ if (source == null) return {};
713
+ var target = {};
714
+ var sourceKeys = Object.keys(source);
715
+ var key, i;
716
+ for (i = 0; i < sourceKeys.length; i++) {
717
+ key = sourceKeys[i];
718
+ if (excluded.indexOf(key) >= 0) continue;
719
+ target[key] = source[key];
720
+ }
721
+ return target;
722
+ }
723
+
724
+ function _objectWithoutProperties$1(source, excluded) {
725
+ if (source == null) return {};
726
+ var target = _objectWithoutPropertiesLoose$2(source, excluded);
727
+ var key, i;
728
+ if (Object.getOwnPropertySymbols) {
729
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
730
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
731
+ key = sourceSymbolKeys[i];
732
+ if (excluded.indexOf(key) >= 0) continue;
733
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
734
+ target[key] = source[key];
735
+ }
736
+ }
737
+ return target;
738
+ }
739
+
740
+ var _excluded$k = ["url"];
741
+ var fetch = function fetch(_ref) {
742
+ var url = _ref.url,
743
+ params = _objectWithoutProperties$1(_ref, _excluded$k);
744
+ return axios__default["default"].get(url, {
745
+ params: params
746
+ });
747
+ };
748
+ var update$1 = function update(_ref2) {
749
+ var url = _ref2.url,
750
+ id = _ref2.id,
751
+ payload = _ref2.payload;
752
+ return axios__default["default"].patch("".concat(url, "/").concat(id), payload);
753
+ };
754
+ var clone = function clone(_ref3) {
755
+ var url = _ref3.url,
756
+ id = _ref3.id;
757
+ return axios__default["default"].post("".concat(url, "/").concat(id, "/clone"));
758
+ };
759
+ var destroy = function destroy(_ref4) {
760
+ var url = _ref4.url,
761
+ id = _ref4.id;
762
+ return axios__default["default"]["delete"]("".concat(url, "/").concat(id));
763
+ };
764
+ var automationRulesApi = {
765
+ fetch: fetch,
766
+ update: update$1,
767
+ clone: clone,
768
+ destroy: destroy
769
+ };
770
+
771
+ //TODO: Remove if not used
772
+ var AUTOMATION_RULES = "automation-rules";
773
+ var STALE_TIME = 3200000;
774
+
775
+ function ownKeys$s(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; }
776
+ function _objectSpread$q(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$s(Object(t), !0).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$s(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
777
+ var useFetchAutomationRules = function useFetchAutomationRules(params) {
778
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
779
+ return reactQuery.useQuery([AUTOMATION_RULES, params], function () {
780
+ return automationRulesApi.fetch(params);
781
+ }, _objectSpread$q({
782
+ staleTime: STALE_TIME,
783
+ select: function select(response) {
784
+ return response.data || response;
785
+ },
786
+ keepPreviousData: true
787
+ }, options));
788
+ };
789
+ var useUpdateAutomationRule = function useUpdateAutomationRule() {
790
+ return reactUtils.useMutationWithInvalidation(automationRulesApi.update, {
791
+ keysToInvalidate: [AUTOMATION_RULES]
792
+ });
793
+ };
794
+ var useCloneAutomationRule = function useCloneAutomationRule() {
795
+ return reactUtils.useMutationWithInvalidation(automationRulesApi.clone, {
796
+ keysToInvalidate: [AUTOMATION_RULES]
797
+ });
798
+ };
799
+ var useDeleteAutomationRule = function useDeleteAutomationRule() {
800
+ return reactUtils.useMutationWithInvalidation(automationRulesApi.destroy, {
801
+ keysToInvalidate: [AUTOMATION_RULES]
802
+ });
803
+ };
804
+
805
+ var createRoutes = function createRoutes(basePath) {
806
+ return {
807
+ index: basePath,
808
+ "new": "".concat(basePath, "/new"),
809
+ edit: "".concat(basePath, "/:ruleId/edit")
810
+ };
811
+ };
812
+
813
+ var STATUS_KEYS = {
814
+ ENABLED: "enabled",
815
+ DISABLED: "disabled"
816
+ };
817
+ var DEFAULT_INIT_PAGE = 1;
818
+
819
+ function _arrayWithoutHoles$1(arr) {
820
+ if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
821
+ }
822
+
823
+ function _iterableToArray$1(iter) {
824
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
825
+ }
826
+
827
+ function _nonIterableSpread$1() {
828
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
829
+ }
830
+
831
+ function _toConsumableArray$1(arr) {
832
+ return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1();
833
+ }
834
+
835
+ var DisableMessage = reactUtils.withT(function (_ref) {
836
+ var t = _ref.t,
837
+ disabledReason = _ref.disabledReason;
838
+ return ramda.isNotNil(disabledReason) && /*#__PURE__*/jsxRuntime.jsx("div", {
839
+ children: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
840
+ "class": "text-red-600",
841
+ component: "span",
842
+ style: "body2",
843
+ children: t(disabledReason)
844
+ })
845
+ });
846
+ });
847
+
848
+ var _excluded$j = ["onClick"],
849
+ _excluded2 = ["handleChangeStatus", "additionalColumns", "onPreview"];
850
+ function ownKeys$r(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; }
851
+ function _objectSpread$p(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$r(Object(t), !0).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$r(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
852
+ var buildActionDropdownMenuItems = function buildActionDropdownMenuItems(_ref) {
853
+ var rule = _ref.rule,
854
+ onClone = _ref.onClone,
855
+ onDelete = _ref.onDelete,
856
+ _ref$moreDropdownItem = _ref.moreDropdownItems,
857
+ moreDropdownItems = _ref$moreDropdownItem === void 0 ? [] : _ref$moreDropdownItem,
858
+ automationRulesPath = _ref.automationRulesPath;
859
+ return [].concat(_toConsumableArray$1(moreDropdownItems.map(function (_ref2) {
860
+ var _onClick = _ref2.onClick,
861
+ others = _objectWithoutProperties$1(_ref2, _excluded$j);
862
+ return _objectSpread$p(_objectSpread$p({}, others), {}, {
863
+ onClick: function onClick() {
864
+ return _onClick(rule);
865
+ }
866
+ });
867
+ })), [{
868
+ key: "edit",
869
+ className: "neeto-ui-btn",
870
+ "data-test-id": "automation-rules-edit-link",
871
+ label: i18next.t("neetoRules.button.edit"),
872
+ to: utils.buildUrl(createRoutes(automationRulesPath).edit, {
873
+ ruleId: rule.id
874
+ })
875
+ }, {
876
+ key: "clone",
877
+ "data-test-id": "automation-rules-clone-link",
878
+ label: i18next.t("neetoRules.button.clone"),
879
+ onClick: function onClick() {
880
+ return onClone(rule.id);
881
+ }
882
+ }, {
883
+ key: "delete",
884
+ "data-test-id": "automation-rules-delete-link",
885
+ label: i18next.t("neetoRules.button.delete"),
886
+ onClick: function onClick() {
887
+ return onDelete(rule);
888
+ }
889
+ }]);
890
+ };
891
+ var getColumnData = function getColumnData(_ref3) {
892
+ var handleChangeStatus = _ref3.handleChangeStatus,
893
+ _ref3$additionalColum = _ref3.additionalColumns,
894
+ additionalColumns = _ref3$additionalColum === void 0 ? [] : _ref3$additionalColum,
895
+ onPreview = _ref3.onPreview,
896
+ otherProps = _objectWithoutProperties$1(_ref3, _excluded2);
897
+ return [{
898
+ title: i18next.t("neetoRules.labels.name"),
899
+ dataIndex: "name",
900
+ key: "name",
901
+ ellipsis: true,
902
+ width: 440,
903
+ render: function render(name, rule) {
904
+ return /*#__PURE__*/jsxRuntime.jsxs("div", {
905
+ children: [/*#__PURE__*/jsxRuntime.jsxs("div", {
906
+ className: "flex items-center justify-between gap-x-3",
907
+ children: [/*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
908
+ className: "whitespace-pre-line break-words text-left",
909
+ style: "link",
910
+ onClick: function onClick() {
911
+ return onPreview(rule.id);
912
+ },
913
+ children: name
914
+ }), /*#__PURE__*/jsxRuntime.jsx(MoreDropdown__default["default"], {
915
+ dropdownProps: {
916
+ strategy: "fixed"
917
+ },
918
+ menuItems: buildActionDropdownMenuItems(_objectSpread$p({
919
+ rule: rule
920
+ }, otherProps))
921
+ })]
922
+ }), /*#__PURE__*/jsxRuntime.jsx(DisableMessage, {
923
+ disabledReason: rule.disabledReason
924
+ })]
925
+ });
926
+ }
927
+ }, {
928
+ title: i18next.t("neetoRules.labels.description"),
929
+ dataIndex: "description",
930
+ key: "description",
931
+ width: 390,
932
+ render: function render(description) {
933
+ return /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
934
+ className: "whitespace-pre-line break-words",
935
+ style: "body2",
936
+ children: description
937
+ });
938
+ }
939
+ }, {
940
+ title: i18next.t("neetoRules.labels.active"),
941
+ key: "active",
942
+ width: 100,
943
+ align: "center",
944
+ render: function render(_, rule) {
945
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
946
+ className: "flex justify-center",
947
+ children: /*#__PURE__*/jsxRuntime.jsx(Switch__default["default"], {
948
+ checked: rule.status === STATUS_KEYS.ENABLED,
949
+ "data-test-id": "automation-rules-state-switch-row",
950
+ disabled: !!rule.disabledReason,
951
+ onChange: function onChange(e) {
952
+ handleChangeStatus(e, rule.id);
953
+ }
954
+ })
955
+ });
956
+ }
957
+ }].concat(_toConsumableArray$1(additionalColumns));
958
+ };
959
+ var renderNoDataHelpText = function renderNoDataHelpText(helpDocUrl) {
960
+ return /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
961
+ i18nKey: "neetoRules.noData.helpText",
962
+ components: {
963
+ a: /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Link, {
964
+ className: "neeto-ui-text-primary-600 underline",
965
+ target: "_blank",
966
+ to: {
967
+ pathname: helpDocUrl
968
+ }
969
+ })
970
+ }
971
+ });
972
+ };
973
+
974
+ function ownKeys$q(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; }
975
+ function _objectSpread$o(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$q(Object(t), !0).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$q(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
976
+ var RulesTable = function RulesTable(_ref) {
977
+ var url = _ref.automationRulesEndpoint,
978
+ additionalColumns = _ref.additionalColumns,
979
+ _ref$automationRulesP = _ref.automationRulesPath,
980
+ automationRulesPath = _ref$automationRulesP === void 0 ? "/" : _ref$automationRulesP,
981
+ onPreview = _ref.onPreview,
982
+ _ref$helpDocUrl = _ref.helpDocUrl,
983
+ helpDocUrl = _ref$helpDocUrl === void 0 ? null : _ref$helpDocUrl,
984
+ _ref$moreDropdownItem = _ref.moreDropdownItems,
985
+ moreDropdownItems = _ref$moreDropdownItem === void 0 ? [] : _ref$moreDropdownItem;
986
+ var _useState = React.useState(null),
987
+ _useState2 = _slicedToArray$1(_useState, 2),
988
+ selectedRule = _useState2[0],
989
+ setSelectedRule = _useState2[1];
990
+ var _useState3 = React.useState(DEFAULT_INIT_PAGE),
991
+ _useState4 = _slicedToArray$1(_useState3, 2),
992
+ page = _useState4[0],
993
+ setPage = _useState4[1];
994
+ var _useTranslation = reactI18next.useTranslation(),
995
+ t = _useTranslation.t;
996
+ var _useQueryParams = reactUtils.useQueryParams(),
997
+ _useQueryParams$searc = _useQueryParams.searchTerm,
998
+ searchTerm = _useQueryParams$searc === void 0 ? "" : _useQueryParams$searc;
999
+ var _useFetchAutomationRu = useFetchAutomationRules({
1000
+ url: url,
1001
+ page: page,
1002
+ pageSize: constants.DEFAULT_PAGE_SIZE,
1003
+ searchTerm: searchTerm
1004
+ }),
1005
+ _useFetchAutomationRu2 = _useFetchAutomationRu.data,
1006
+ _useFetchAutomationRu3 = _useFetchAutomationRu2 === void 0 ? {} : _useFetchAutomationRu2,
1007
+ _useFetchAutomationRu4 = _useFetchAutomationRu3.rules,
1008
+ rules = _useFetchAutomationRu4 === void 0 ? [] : _useFetchAutomationRu4,
1009
+ _useFetchAutomationRu5 = _useFetchAutomationRu3.totalCount,
1010
+ totalCount = _useFetchAutomationRu5 === void 0 ? 0 : _useFetchAutomationRu5,
1011
+ isLoading = _useFetchAutomationRu.isLoading;
1012
+ var _useUpdateAutomationR = useUpdateAutomationRule(),
1013
+ updateRule = _useUpdateAutomationR.mutate,
1014
+ isUpdating = _useUpdateAutomationR.isLoading;
1015
+ var _useCloneAutomationRu = useCloneAutomationRule(),
1016
+ cloneRule = _useCloneAutomationRu.mutate,
1017
+ isCloning = _useCloneAutomationRu.isLoading;
1018
+ var _useDeleteAutomationR = useDeleteAutomationRule(),
1019
+ deleteRule = _useDeleteAutomationR.mutate,
1020
+ isDeleting = _useDeleteAutomationR.isLoading;
1021
+ var handleChangeStatus = function handleChangeStatus(event, id) {
1022
+ var status = event.target.checked ? STATUS_KEYS.ENABLED : STATUS_KEYS.DISABLED;
1023
+ var payload = {
1024
+ rule: {
1025
+ status: status
1026
+ }
1027
+ };
1028
+ updateRule({
1029
+ id: id,
1030
+ url: url,
1031
+ payload: payload
1032
+ });
1033
+ };
1034
+ var columnData = getColumnData({
1035
+ handleChangeStatus: handleChangeStatus,
1036
+ additionalColumns: additionalColumns,
1037
+ onClone: function onClone(id) {
1038
+ return cloneRule({
1039
+ id: id,
1040
+ url: url
1041
+ });
1042
+ },
1043
+ onDelete: setSelectedRule,
1044
+ onPreview: onPreview,
1045
+ automationRulesPath: automationRulesPath,
1046
+ moreDropdownItems: moreDropdownItems
1047
+ });
1048
+ if (isLoading) {
1049
+ return /*#__PURE__*/jsxRuntime.jsx(PageLoader__default["default"], {});
1050
+ }
1051
+ if (ramda.isEmpty(rules)) {
1052
+ return /*#__PURE__*/jsxRuntime.jsx("div", {
1053
+ className: "flex h-full w-full items-center justify-center",
1054
+ children: /*#__PURE__*/jsxRuntime.jsx(NoData__default["default"], _objectSpread$o({
1055
+ title: t("neetoRules.noData.title")
1056
+ }, ramda.isEmpty(searchTerm) && {
1057
+ helpText: helpDocUrl ? renderNoDataHelpText(helpDocUrl) : null,
1058
+ primaryButtonProps: {
1059
+ label: t("neetoRules.button.addNew"),
1060
+ to: createRoutes(automationRulesPath)["new"]
1061
+ }
1062
+ }))
1063
+ });
1064
+ }
1065
+ return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
1066
+ children: [/*#__PURE__*/jsxRuntime.jsx(SubHeader__default["default"], {
1067
+ leftActionBlock: /*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
1068
+ className: "mr-4 font-semibold",
1069
+ style: "h4",
1070
+ children: t("neetoRules.common.automationRuleWithCount", {
1071
+ count: totalCount
1072
+ })
1073
+ })
1074
+ }), /*#__PURE__*/jsxRuntime.jsx(TableWrapper__default["default"], {
1075
+ hasPagination: totalCount > constants.DEFAULT_PAGE_SIZE,
1076
+ children: /*#__PURE__*/jsxRuntime.jsx(Table__default["default"], {
1077
+ columnData: columnData,
1078
+ totalCount: totalCount,
1079
+ fixedHeight: true,
1080
+ allowClick: false,
1081
+ currentPageNumber: page,
1082
+ defaultPageSize: constants.DEFAULT_PAGE_SIZE,
1083
+ handlePageChange: setPage,
1084
+ loading: isUpdating || isLoading || isCloning || isDeleting,
1085
+ rowData: rules.map(function (item) {
1086
+ return _objectSpread$o({
1087
+ key: item.id
1088
+ }, item);
1089
+ }),
1090
+ rowSelection: false,
1091
+ scroll: {
1092
+ x: 0
1093
+ },
1094
+ tableLayout: "fixed"
1095
+ })
1096
+ }), /*#__PURE__*/jsxRuntime.jsx(Alert__default["default"], {
1097
+ isOpen: !!selectedRule,
1098
+ isSubmitting: isDeleting,
1099
+ submitButtonLabel: t("neetoRules.button.delete"),
1100
+ title: t("neetoRules.deleteAlert.title"),
1101
+ message: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
1102
+ i18nKey: "neetoRules.deleteAlert.message",
1103
+ values: {
1104
+ name: selectedRule === null || selectedRule === void 0 ? void 0 : selectedRule.name
1105
+ }
1106
+ }),
1107
+ onClose: function onClose() {
1108
+ return setSelectedRule(null);
1109
+ },
1110
+ onSubmit: function onSubmit() {
1111
+ return deleteRule({
1112
+ id: selectedRule === null || selectedRule === void 0 ? void 0 : selectedRule.id,
1113
+ url: url
1114
+ }, {
1115
+ onSuccess: function onSuccess() {
1116
+ return setSelectedRule(null);
1117
+ }
1118
+ });
1119
+ }
1120
+ })]
1121
+ });
550
1122
  };
551
1123
 
552
1124
  function _typeof$2(o) {
@@ -1147,7 +1719,7 @@ function _extends$2() {
1147
1719
  }, _extends$2.apply(null, arguments);
1148
1720
  }
1149
1721
 
1150
- function _objectWithoutPropertiesLoose$2(r, e) {
1722
+ function _objectWithoutPropertiesLoose$1(r, e) {
1151
1723
  if (null == r) return {};
1152
1724
  var t = {};
1153
1725
  for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
@@ -1381,7 +1953,7 @@ function finalPropsSelectorFactory(dispatch, _ref) {
1381
1953
  initMapDispatchToProps,
1382
1954
  initMergeProps
1383
1955
  } = _ref,
1384
- options = _objectWithoutPropertiesLoose$2(_ref, _excluded$i);
1956
+ options = _objectWithoutPropertiesLoose$1(_ref, _excluded$i);
1385
1957
 
1386
1958
  const mapStateToProps = initMapStateToProps(dispatch, options);
1387
1959
  const mapDispatchToProps = initMapDispatchToProps(dispatch, options);
@@ -1896,7 +2468,7 @@ function connect(mapStateToProps, mapDispatchToProps, mergeProps, {
1896
2468
  const {
1897
2469
  reactReduxForwardedRef
1898
2470
  } = props,
1899
- wrapperProps = _objectWithoutPropertiesLoose$2(props, _excluded$h);
2471
+ wrapperProps = _objectWithoutPropertiesLoose$1(props, _excluded$h);
1900
2472
 
1901
2473
  return [props.context, reactReduxForwardedRef, wrapperProps];
1902
2474
  }, [props]);
@@ -9763,35 +10335,6 @@ function _objectDestructuringEmpty(obj) {
9763
10335
  if (obj == null) throw new TypeError("Cannot destructure " + obj);
9764
10336
  }
9765
10337
 
9766
- function _objectWithoutPropertiesLoose$1(source, excluded) {
9767
- if (source == null) return {};
9768
- var target = {};
9769
- var sourceKeys = Object.keys(source);
9770
- var key, i;
9771
- for (i = 0; i < sourceKeys.length; i++) {
9772
- key = sourceKeys[i];
9773
- if (excluded.indexOf(key) >= 0) continue;
9774
- target[key] = source[key];
9775
- }
9776
- return target;
9777
- }
9778
-
9779
- function _objectWithoutProperties$1(source, excluded) {
9780
- if (source == null) return {};
9781
- var target = _objectWithoutPropertiesLoose$1(source, excluded);
9782
- var key, i;
9783
- if (Object.getOwnPropertySymbols) {
9784
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
9785
- for (i = 0; i < sourceSymbolKeys.length; i++) {
9786
- key = sourceSymbolKeys[i];
9787
- if (excluded.indexOf(key) >= 0) continue;
9788
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
9789
- target[key] = source[key];
9790
- }
9791
- }
9792
- return target;
9793
- }
9794
-
9795
10338
  var propTypes = {exports: {}};
9796
10339
 
9797
10340
  /**
@@ -9883,22 +10426,6 @@ var factoryWithThrowingShims = function() {
9883
10426
  var propTypesExports = propTypes.exports;
9884
10427
  var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
9885
10428
 
9886
- function _arrayWithoutHoles$1(arr) {
9887
- if (Array.isArray(arr)) return _arrayLikeToArray$1(arr);
9888
- }
9889
-
9890
- function _iterableToArray$1(iter) {
9891
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
9892
- }
9893
-
9894
- function _nonIterableSpread$1() {
9895
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
9896
- }
9897
-
9898
- function _toConsumableArray$1(arr) {
9899
- return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1();
9900
- }
9901
-
9902
10429
  var ACTION_TYPES = {
9903
10430
  emailToIds: "emailToIds",
9904
10431
  email: "email",
@@ -9937,52 +10464,8 @@ var DEFAULT_RULE_ACTION = {
9937
10464
  };
9938
10465
  var EDITOR_ADDONS = ["code-block", "block-quote", "image-upload"];
9939
10466
  var EMAIL_REGEX = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
9940
- var MAXIMUM_OPTION_LENGTH$3 = 7;
9941
- var ACTION_INPUT_TYPES = ["text", "number", "decimal", "regex"];
9942
-
9943
- var OPERATORS$1 = {
9944
- or: "or_operator",
9945
- and: "and_operator"
9946
- };
9947
- var OPERATOR_LABELS = {
9948
- or_operator: i18next.t("neetoRules.operators.or"),
9949
- and_operator: i18next.t("neetoRules.operators.and")
9950
- };
9951
- var VERB_LABELS = {
9952
- is: i18next.t("neetoRules.conditionVerbs.is"),
9953
- is_not: i18next.t("neetoRules.conditionVerbs.isNot"),
9954
- contains: i18next.t("neetoRules.conditionVerbs.contains"),
9955
- does_not_contain: i18next.t("neetoRules.conditionVerbs.doesNotContain"),
9956
- contains_any_of: i18next.t("neetoRules.conditionVerbs.containsAnyOf"),
9957
- contains_all_of: i18next.t("neetoRules.conditionVerbs.containsAllOf"),
9958
- contains_none_of: i18next.t("neetoRules.conditionVerbs.containsNoneOf"),
9959
- starts_with: i18next.t("neetoRules.conditionVerbs.startsWith"),
9960
- ends_with: i18next.t("neetoRules.conditionVerbs.endsWith"),
9961
- less_than: i18next.t("neetoRules.conditionVerbs.lessThan"),
9962
- greater_than: i18next.t("neetoRules.conditionVerbs.greaterThan"),
9963
- any_time: i18next.t("neetoRules.conditionVerbs.anyTime"),
9964
- during: i18next.t("neetoRules.conditionVerbs.during"),
9965
- not_during: i18next.t("neetoRules.conditionVerbs.notDuring"),
9966
- any_of: i18next.t("neetoRules.conditionVerbs.anyOf"),
9967
- none_of: i18next.t("neetoRules.conditionVerbs.noneOf"),
9968
- is_before: i18next.t("neetoRules.conditionVerbs.isBefore"),
9969
- is_after: i18next.t("neetoRules.conditionVerbs.isAfter")
9970
- };
9971
- var CONDITION_VALUE_TYPES = {
9972
- text: "text",
9973
- number: "number",
9974
- decimal: "decimal",
9975
- url: "url",
9976
- email: "email",
9977
- dropdown: "dropdown",
9978
- multiSelect: "multi-select",
9979
- multiSelectCreate: "multi-select-create",
9980
- date: "date",
9981
- regex: "regex",
9982
- textarea: "textarea"
9983
- };
9984
- var INPUT_FIELD_TYPES = ["email", "text", "number", "decimal", "url", "regex"];
9985
10467
  var MAXIMUM_OPTION_LENGTH$2 = 7;
10468
+ var ACTION_INPUT_TYPES = ["text", "number", "decimal", "regex"];
9986
10469
 
9987
10470
  function ownKeys$l(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; }
9988
10471
  function _objectSpread$k(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$l(Object(t), !0).forEach(function (r) { _defineProperty$2(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$l(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -10095,7 +10578,7 @@ var getConditionsSchema = function getConditionsSchema(element) {
10095
10578
  } else if ([CONDITION_VALUE_TYPES.textarea].includes(type)) {
10096
10579
  return yup__namespace.object({
10097
10580
  value: yup__namespace.string().test("text", i18next.t("neetoRules.validations.required.text"), function (value) {
10098
- return !neetoEditor.isEditorEmpty(value);
10581
+ return !utils$1.isEditorEmpty(value);
10099
10582
  })
10100
10583
  });
10101
10584
  }
@@ -10124,7 +10607,7 @@ var getActionsSchema = function getActionsSchema(element, customData) {
10124
10607
  subject: !selectedAction.hideSubject ? yup__namespace.string().required(i18next.t("neetoRules.validations.required.subject")) : schema,
10125
10608
  emails: selectedAction.type === ACTION_TYPES.emailToIds ? yup__namespace.array().min(1, i18next.t("neetoRules.validations.required.emailId")).required(i18next.t("neetoRules.validations.required.emailId")).of(yup__namespace.string().email(i18next.t("neetoRules.validations.inValidEmail"))) : schema,
10126
10609
  body: yup__namespace.string().test("body", i18next.t("neetoRules.validations.required.body"), function (value) {
10127
- return !neetoEditor.isEditorEmpty(value);
10610
+ return !utils$1.isEditorEmpty(value);
10128
10611
  }),
10129
10612
  value: selectedAction.type === ACTION_TYPES.emailTo ? yup__namespace.string().required(i18next.t("neetoRules.validations.required.value")) : schema
10130
10613
  });
@@ -10136,7 +10619,7 @@ var getActionsSchema = function getActionsSchema(element, customData) {
10136
10619
  return PhoneNumber.isPhoneNumberValid(value);
10137
10620
  })) : schema,
10138
10621
  body: yup__namespace.string().test("body", i18next.t("neetoRules.validations.required.body"), function (value) {
10139
- return !neetoEditor.isEditorEmpty(value);
10622
+ return !utils$1.isEditorEmpty(value);
10140
10623
  }),
10141
10624
  value: selectedAction.type === ACTION_TYPES.smsTo ? yup__namespace.string().required(i18next.t("neetoRules.validations.required.value")) : schema
10142
10625
  });
@@ -10159,7 +10642,7 @@ var getActionsSchema = function getActionsSchema(element, customData) {
10159
10642
  } else if ((selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type) === ACTION_TYPES.note || (selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type) === ACTION_TYPES.textarea) {
10160
10643
  return yup__namespace.object({
10161
10644
  value: yup__namespace.string().test("body", i18next.t("neetoRules.validations.required.body"), function (value) {
10162
- return !neetoEditor.isEditorEmpty(value);
10645
+ return !utils$1.isEditorEmpty(value);
10163
10646
  })
10164
10647
  });
10165
10648
  } else if ((selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type) === ACTION_TYPES.dropdown || (selectedAction === null || selectedAction === void 0 ? void 0 : selectedAction.type) === ACTION_TYPES.date) {
@@ -10584,6 +11067,9 @@ var setEditorContent = function setEditorContent(ref, content) {
10584
11067
 
10585
11068
  // eslint-disable-next-line react-hooks/rules-of-hooks
10586
11069
  var dotPath = ramda.useWith(ramda.path, [ramda.split(".")]);
11070
+ var formatAdditionalData = function formatAdditionalData(additionalData) {
11071
+ return neetoCist.isPresent(additionalData) ? additionalData : [ADDITIONAL_DATA_INITIAL_VALUE];
11072
+ };
10587
11073
 
10588
11074
  var KeyValuePairsField = reactUtils.withT(function (_ref) {
10589
11075
  var t = _ref.t,
@@ -10697,7 +11183,7 @@ var ApiFields = function ApiFields(_ref) {
10697
11183
  var isTemplateSelectionEnabled = neetoCist.isPresent(templates);
10698
11184
  var handleTemplateChange = function handleTemplateChange(template) {
10699
11185
  setFieldValue("".concat(name, ".endpoint"), template.endpoint);
10700
- setFieldValue("".concat(name, ".additionalData"), template.additionalData);
11186
+ setFieldValue("".concat(name, ".additionalData"), formatAdditionalData(template.additionalData));
10701
11187
  };
10702
11188
  return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
10703
11189
  children: [/*#__PURE__*/jsxRuntime.jsx(Typography__default["default"], {
@@ -11066,7 +11552,7 @@ var DropdownField$1 = function DropdownField(_ref) {
11066
11552
  onClose: handleClose,
11067
11553
  children: /*#__PURE__*/jsxRuntime.jsxs(Menu$a, {
11068
11554
  className: "max-h-60 max-w-2xl p-3",
11069
- children: [dropdownOptions.length > MAXIMUM_OPTION_LENGTH$3 && /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
11555
+ children: [dropdownOptions.length > MAXIMUM_OPTION_LENGTH$2 && /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
11070
11556
  autoFocus: true,
11071
11557
  className: "mb-1",
11072
11558
  "data-cy": "search-text-field",
@@ -11080,7 +11566,7 @@ var DropdownField$1 = function DropdownField(_ref) {
11080
11566
  return e.stopPropagation();
11081
11567
  }
11082
11568
  }), /*#__PURE__*/jsxRuntime.jsx(OptionsWrapper, {
11083
- hasScroll: dropdownOptions.length > MAXIMUM_OPTION_LENGTH$3,
11569
+ hasScroll: dropdownOptions.length > MAXIMUM_OPTION_LENGTH$2,
11084
11570
  children: searchedOptions.map(function (option, idx) {
11085
11571
  return /*#__PURE__*/jsxRuntime.jsx(MenuItem$9.Button, {
11086
11572
  "data-cy": "".concat(utils.joinHyphenCase(option.label), "-menu-item"),
@@ -11132,7 +11618,7 @@ var EditorAction = function EditorAction(_ref) {
11132
11618
  React.useEffect(function () {
11133
11619
  setFieldValue(name, editorData);
11134
11620
  }, [debouncedValue]);
11135
- return /*#__PURE__*/jsxRuntime.jsx(neetoEditor.FormikEditor, _objectSpread$f({
11621
+ return /*#__PURE__*/jsxRuntime.jsx(FormikEditor__default["default"], _objectSpread$f({
11136
11622
  addons: addons,
11137
11623
  autoFocus: autoFocus,
11138
11624
  defaults: defaults,
@@ -11714,7 +12200,7 @@ var MultiSelect$1 = function MultiSelect(_ref) {
11714
12200
  onClose: handleClose,
11715
12201
  children: /*#__PURE__*/jsxRuntime.jsxs(Menu$9, {
11716
12202
  className: "max-h-60 max-w-2xl p-3",
11717
- children: [dropDownOptions.length > MAXIMUM_OPTION_LENGTH$3 && /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
12203
+ children: [dropDownOptions.length > MAXIMUM_OPTION_LENGTH$2 && /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
11718
12204
  autoFocus: true,
11719
12205
  className: "mb-1",
11720
12206
  "data-cy": "search-text-field",
@@ -11725,7 +12211,7 @@ var MultiSelect$1 = function MultiSelect(_ref) {
11725
12211
  return setSearchTerm(e.target.value);
11726
12212
  }
11727
12213
  }), /*#__PURE__*/jsxRuntime.jsx(OptionsWrapper, {
11728
- hasScroll: dropDownOptions.length > MAXIMUM_OPTION_LENGTH$3,
12214
+ hasScroll: dropDownOptions.length > MAXIMUM_OPTION_LENGTH$2,
11729
12215
  children: searchedOptions.map(function (option, idx) {
11730
12216
  return /*#__PURE__*/jsxRuntime.jsx(MenuItem$8.Button, {
11731
12217
  "data-cy": "".concat(utils.joinHyphenCase(option.label), "-menu-item"),
@@ -20409,7 +20895,7 @@ var DropdownField = function DropdownField(_ref) {
20409
20895
  onClose: handleClose,
20410
20896
  children: /*#__PURE__*/jsxRuntime.jsxs(Menu$6, {
20411
20897
  className: "max-h-60 max-w-2xl p-3",
20412
- children: [options.length > MAXIMUM_OPTION_LENGTH$2 && /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
20898
+ children: [options.length > MAXIMUM_OPTION_LENGTH$3 && /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
20413
20899
  autoFocus: true,
20414
20900
  className: "mb-1",
20415
20901
  "data-cy": "search-text-field",
@@ -20423,7 +20909,7 @@ var DropdownField = function DropdownField(_ref) {
20423
20909
  return e.stopPropagation();
20424
20910
  }
20425
20911
  }), /*#__PURE__*/jsxRuntime.jsx(OptionsWrapper, {
20426
- hasScroll: options.length > MAXIMUM_OPTION_LENGTH$2,
20912
+ hasScroll: options.length > MAXIMUM_OPTION_LENGTH$3,
20427
20913
  children: searchedOptions.map(function (option, idx) {
20428
20914
  return /*#__PURE__*/jsxRuntime.jsx(MenuItem$6.Button, {
20429
20915
  "data-cy": "".concat(utils.joinHyphenCase(option.label), "-menu-item"),
@@ -20531,7 +21017,7 @@ var Dropdown = function Dropdown(_ref) {
20531
21017
  onClose: handleClose,
20532
21018
  children: /*#__PURE__*/jsxRuntime.jsxs(Menu$5, {
20533
21019
  className: "max-h-60 max-w-2xl p-3",
20534
- children: [options.length > MAXIMUM_OPTION_LENGTH$2 && /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
21020
+ children: [options.length > MAXIMUM_OPTION_LENGTH$3 && /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
20535
21021
  autoFocus: true,
20536
21022
  className: "mb-1",
20537
21023
  "data-cy": "search-text-field",
@@ -20545,7 +21031,7 @@ var Dropdown = function Dropdown(_ref) {
20545
21031
  return e.stopPropagation();
20546
21032
  }
20547
21033
  }), /*#__PURE__*/jsxRuntime.jsx(OptionsWrapper, {
20548
- hasScroll: options.length > MAXIMUM_OPTION_LENGTH$2,
21034
+ hasScroll: options.length > MAXIMUM_OPTION_LENGTH$3,
20549
21035
  children: searchedOptions.map(function (option, idx) {
20550
21036
  return /*#__PURE__*/jsxRuntime.jsx(MenuItem$5.Button, {
20551
21037
  "data-cy": "".concat(utils.joinHyphenCase(option.label), "-menu-item"),
@@ -20705,7 +21191,7 @@ var MultiSelect = function MultiSelect(_ref) {
20705
21191
  onClose: handleClose,
20706
21192
  children: /*#__PURE__*/jsxRuntime.jsxs(Menu$4, {
20707
21193
  className: "max-h-60 max-w-2xl p-3",
20708
- children: [dropDownOptions.length > MAXIMUM_OPTION_LENGTH$2 && /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
21194
+ children: [dropDownOptions.length > MAXIMUM_OPTION_LENGTH$3 && /*#__PURE__*/jsxRuntime.jsx(Input__default["default"], {
20709
21195
  autoFocus: true,
20710
21196
  className: "mb-1",
20711
21197
  "data-cy": "search-text-field",
@@ -20716,7 +21202,7 @@ var MultiSelect = function MultiSelect(_ref) {
20716
21202
  return setSearchTerm(e.target.value);
20717
21203
  }
20718
21204
  }), /*#__PURE__*/jsxRuntime.jsx(OptionsWrapper, {
20719
- hasScroll: dropDownOptions.length > MAXIMUM_OPTION_LENGTH$2,
21205
+ hasScroll: dropDownOptions.length > MAXIMUM_OPTION_LENGTH$3,
20720
21206
  children: searchedOptions.map(function (option, idx) {
20721
21207
  return /*#__PURE__*/jsxRuntime.jsx(MenuItem$4.Button, {
20722
21208
  "data-cy": "".concat(utils.joinHyphenCase(option.label), "-menu-item"),
@@ -22583,5 +23069,6 @@ NeetoRules.EventConditions = EventConditions;
22583
23069
  exports.NeetoRulesForm = NeetoRules;
22584
23070
  exports.RulePreview = RulePreview;
22585
23071
  exports.RulesReorder = RulesReorder;
23072
+ exports.RulesTable = RulesTable;
22586
23073
  exports.useCustomDataStore = useCustomDataStore;
22587
23074
  //# sourceMappingURL=index.cjs.js.map