@capillarytech/creatives-library 8.0.330-alpha.0 → 8.0.331-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/constants/unified.js +0 -18
  2. package/package.json +1 -1
  3. package/services/tests/api.test.js +0 -13
  4. package/utils/commonUtils.js +1 -19
  5. package/v2Components/CapTagList/index.js +0 -10
  6. package/v2Components/CommonTestAndPreview/CustomValuesEditor.js +49 -70
  7. package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +2 -8
  8. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +21 -207
  9. package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +0 -16
  10. package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +10 -85
  11. package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +0 -30
  12. package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +11 -79
  13. package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +1 -0
  14. package/v2Components/CommonTestAndPreview/SendTestMessage.js +5 -10
  15. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -20
  16. package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +4 -133
  17. package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +0 -11
  18. package/v2Components/CommonTestAndPreview/constants.js +2 -38
  19. package/v2Components/CommonTestAndPreview/index.js +176 -672
  20. package/v2Components/CommonTestAndPreview/messages.js +3 -41
  21. package/v2Components/CommonTestAndPreview/reducer.js +3 -1
  22. package/v2Components/CommonTestAndPreview/sagas.js +8 -16
  23. package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +284 -308
  24. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +65 -231
  25. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +5 -118
  26. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +0 -341
  27. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +13 -34
  28. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +1 -199
  29. package/v2Components/CommonTestAndPreview/tests/index.test.js +4 -132
  30. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +2 -2
  31. package/v2Components/FormBuilder/index.js +1 -7
  32. package/v2Components/TestAndPreviewSlidebox/index.js +1 -13
  33. package/v2Components/TestAndPreviewSlidebox/sagas.js +4 -11
  34. package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +1 -3
  35. package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -36
  36. package/v2Containers/CreativesContainer/SlideBoxFooter.js +1 -10
  37. package/v2Containers/CreativesContainer/SlideBoxHeader.js +4 -29
  38. package/v2Containers/CreativesContainer/constants.js +0 -9
  39. package/v2Containers/CreativesContainer/index.js +93 -292
  40. package/v2Containers/CreativesContainer/index.scss +1 -51
  41. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +34 -78
  42. package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +16 -79
  43. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +0 -8
  44. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +98 -357
  45. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +10 -20
  46. package/v2Containers/CreativesContainer/tests/index.test.js +9 -71
  47. package/v2Containers/Rcs/constants.js +3 -40
  48. package/v2Containers/Rcs/index.js +895 -1145
  49. package/v2Containers/Rcs/index.scss +6 -85
  50. package/v2Containers/Rcs/messages.js +2 -12
  51. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +1432 -40783
  52. package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +5 -0
  53. package/v2Containers/Rcs/tests/index.test.js +38 -41
  54. package/v2Containers/Rcs/tests/mockData.js +0 -38
  55. package/v2Containers/Rcs/tests/utils.test.js +1 -435
  56. package/v2Containers/Rcs/utils.js +10 -405
  57. package/v2Containers/Sms/Create/index.js +38 -100
  58. package/v2Containers/SmsTrai/Create/index.js +4 -9
  59. package/v2Containers/SmsTrai/Edit/constants.js +0 -2
  60. package/v2Containers/SmsTrai/Edit/index.js +128 -636
  61. package/v2Containers/SmsTrai/Edit/messages.js +4 -14
  62. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +2296 -4249
  63. package/v2Containers/SmsWrapper/index.js +8 -37
  64. package/v2Containers/TagList/index.js +11 -21
  65. package/v2Containers/Templates/_templates.scss +2 -63
  66. package/v2Containers/Templates/actions.js +0 -11
  67. package/v2Containers/Templates/constants.js +0 -2
  68. package/v2Containers/Templates/index.js +40 -90
  69. package/v2Containers/Templates/sagas.js +12 -57
  70. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1079 -1043
  71. package/v2Containers/Templates/tests/sagas.test.js +123 -193
  72. package/v2Containers/TemplatesV2/TemplatesV2.style.js +1 -72
  73. package/v2Containers/TemplatesV2/index.js +23 -86
  74. package/v2Containers/WebPush/Create/index.js +1 -1
  75. package/v2Containers/Whatsapp/index.js +20 -3
  76. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +34 -578
  77. package/utils/templateVarUtils.js +0 -201
  78. package/utils/tests/templateVarUtils.test.js +0 -204
  79. package/v2Components/CommonTestAndPreview/previewApiUtils.js +0 -59
  80. package/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +0 -67
  81. package/v2Components/SmsFallback/SmsFallbackLocalSelector.js +0 -87
  82. package/v2Components/SmsFallback/constants.js +0 -73
  83. package/v2Components/SmsFallback/index.js +0 -955
  84. package/v2Components/SmsFallback/index.scss +0 -265
  85. package/v2Components/SmsFallback/messages.js +0 -78
  86. package/v2Components/SmsFallback/smsFallbackUtils.js +0 -118
  87. package/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +0 -50
  88. package/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +0 -147
  89. package/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +0 -304
  90. package/v2Components/SmsFallback/tests/smsFallbackUi.test.js +0 -197
  91. package/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +0 -277
  92. package/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +0 -422
  93. package/v2Components/SmsFallback/useLocalTemplateList.js +0 -92
  94. package/v2Components/VarSegmentMessageEditor/constants.js +0 -2
  95. package/v2Components/VarSegmentMessageEditor/index.js +0 -125
  96. package/v2Components/VarSegmentMessageEditor/index.scss +0 -46
  97. package/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +0 -43
  98. package/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +0 -67
  99. package/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +0 -90
  100. package/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +0 -258
  101. package/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +0 -125
  102. package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +0 -225
  103. package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +0 -318
  104. package/v2Containers/Sms/smsFormDataHelpers.js +0 -67
  105. package/v2Containers/Sms/tests/smsFormDataHelpers.test.js +0 -253
  106. package/v2Containers/SmsTrai/Edit/index.scss +0 -121
  107. package/v2Containers/Templates/TemplatesActionBar.js +0 -101
  108. package/v2Containers/Templates/tests/TemplatesActionBar.test.js +0 -120
  109. package/v2Containers/Templates/tests/smsTemplatesListApi.test.js +0 -180
  110. package/v2Containers/Templates/utils/smsTemplatesListApi.js +0 -79
  111. package/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +0 -131
@@ -159,24 +159,6 @@ export const TAG_CONTENT_REGEX = /{{([^}]+)}}/g;
159
159
  export const ENTRY_TRIGGER_TAG_REGEX = /\bentryTrigger\.\w+(?:\.\w+)?(?:\(\w+\))?/g;
160
160
  export const SKIP_TAGS_REGEX_GROUPS = ["dynamic_expiry_date_after_\\d+_days.FORMAT_\\d", "unsubscribe\\(#[a-zA-Z\\d]{6}\\)", "Link_to_[a-zA-Z]", "SURVEY.*.TOKEN", "^[A-Za-z].*\\([a-zA-Z\\d]*\\)", "referral_unique_(code|url).*userid"];
161
161
 
162
- // --- Template variable tokens (`{{var}}`, DLT `{#var#}`) ---
163
- /** Global: all `{{…}}` placeholders in a string. */
164
- export const DEFAULT_MUSTACHE_VAR_REGEX = /\{\{[^}]+\}\}/g;
165
- /** Global: `{{…}}` or DLT `{#…#}` tokens (SMS combined mode). */
166
- export const COMBINED_SMS_TEMPLATE_VAR_REGEX = /\{\{[^}]+\}\}|\{\#[^#]*\#\}/g;
167
- /** Full-string check: one mustache token. */
168
- export const MUSTACHE_VAR_TOKEN_FULL_STRING_REGEX = /^\{\{[^}]+\}\}$/;
169
- /** Full-string check: one DLT hash token. */
170
- export const DLT_HASH_VAR_TOKEN_FULL_STRING_REGEX = /^\{\#[^#]*\#\}$/;
171
- /** Full-string with capture group: inner name for `{{ name }}`-style tokens (whitespace-tolerant). */
172
- export const MUSTACHE_TOKEN_INNER_NAME_REGEX = /^\{\{\s*([^}]+?)\s*\}\}$/;
173
- /** Full-string with capture group: inner name/body for `{# name #}` DLT tokens (whitespace-tolerant). */
174
- export const DLT_HASH_TOKEN_INNER_NAME_REGEX = /^\{#\s*(.*?)\s*#\}$/;
175
- /** Global with capture group: inner name inside `{{name}}`. */
176
- export const MUSTACHE_VAR_NAME_CAPTURE_REGEX = /\{\{([^}]+)\}\}/g;
177
- /** Global with capture group: inner body inside `{#body#}`. */
178
- export const DLT_VAR_BODY_CAPTURE_REGEX = /\{\#([^#]*)\#\}/g;
179
-
180
162
  export const GET_TRANSLATION_MAPPED = {
181
163
  'en': 'en-US',
182
164
  'zh-cn': 'zh',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.330-alpha.0",
4
+ "version": "8.0.331-alpha.0",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -1042,19 +1042,6 @@ describe('getMembersLookup', () => {
1042
1042
  getMembersLookup('email', 'user+test@example.com');
1043
1043
  expect(global.fetch).toHaveBeenCalled();
1044
1044
  const calls = global.fetch.mock.calls;
1045
- const withEncoding = calls.find(
1046
- (c) =>
1047
- c[0] &&
1048
- String(c[0]).includes('members') &&
1049
- String(c[0]).includes('identifierType=email') &&
1050
- String(c[0]).includes('user%2Btest%40example.com')
1051
- );
1052
- if (withEncoding) {
1053
- const [url, options] = withEncoding;
1054
- expect(url).toContain('identifierType=email');
1055
- expect(url).toContain('identifierValue=user%2Btest%40example.com');
1056
- expect(options?.method || 'GET').toBe('GET');
1057
- }
1058
1045
  const anyMembersCall = calls.find((c) => c[0] && String(c[0]).includes('members'));
1059
1046
  expect(anyMembersCall).toBeDefined();
1060
1047
  expect(anyMembersCall[0]).toContain('identifierType=');
@@ -539,22 +539,4 @@ export const isValidMobile = (mobile) => PHONE_REGEX.test(mobile);
539
539
  export const formatPhoneNumber = (phone) => {
540
540
  if (!phone) return '';
541
541
  return String(phone).replace(/[^\d]/g, '');
542
- };
543
-
544
- /**
545
- * TRAI sender IDs on persisted RCS SMS fallback: may live on the merged object, under
546
- * `templateConfigs`, or (legacy) `templateConfigs.header`. Same resolution order as
547
- * `createPayload` in `Rcs/index.js`.
548
- */
549
- export function extractRegisteredSenderIdsFromSmsFallbackRecord(record) {
550
- if (!record || typeof record !== 'object') return null;
551
- const tc = record.templateConfigs && typeof record.templateConfigs === 'object'
552
- ? record.templateConfigs
553
- : {};
554
- const candidates = [record.registeredSenderIds, tc.registeredSenderIds, tc.header];
555
- for (let i = 0; i < candidates.length; i += 1) {
556
- const a = candidates[i];
557
- if (Array.isArray(a) && a.length > 0) return a;
558
- }
559
- return null;
560
- }
542
+ };
@@ -382,9 +382,6 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
382
382
  render() {
383
383
  const {
384
384
  hidePopover = false, intl = {}, moduleFilterEnabled, label, modalProps, channel, fetchingSchemaError = false,
385
- overlayStyle,
386
- overlayClassName,
387
- getPopupContainer,
388
385
  } = this.props;
389
386
  const {formatMessage} = intl;
390
387
  const {
@@ -477,9 +474,6 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
477
474
  content={contentSection}
478
475
  trigger="click"
479
476
  placement={this.props.popoverPlacement || (channel === EMAIL.toUpperCase() ? "leftTop" : "rightTop")}
480
- overlayStyle={overlayStyle}
481
- overlayClassName={overlayClassName}
482
- getPopupContainer={getPopupContainer}
483
477
  >
484
478
  <CapTooltip
485
479
  title={
@@ -551,10 +545,6 @@ CapTagList.propTypes = {
551
545
  disableTooltipMsg: PropTypes.string,
552
546
  fetchingSchemaError: PropTypes.bool,
553
547
  popoverPlacement: PropTypes.string,
554
- overlayStyle: PropTypes.object,
555
- overlayClassName: PropTypes.string,
556
- /** e.g. () => document.body — avoids overflow/stacking issues inside slideboxes */
557
- getPopupContainer: PropTypes.func,
558
548
  };
559
549
 
560
550
  CapTagList.defaultValue = {
@@ -8,7 +8,6 @@ import CapButton from '@capillarytech/cap-ui-library/CapButton';
8
8
  import CapInput from '@capillarytech/cap-ui-library/CapInput';
9
9
  import CapLabel from '@capillarytech/cap-ui-library/CapLabel';
10
10
  import messages from './messages';
11
- import { CUSTOM_VALUES_EDITOR_SECTION_FALLBACK_KEY } from './constants';
12
11
 
13
12
  const CustomValuesEditor = ({
14
13
  isExtractingTags,
@@ -17,16 +16,15 @@ const CustomValuesEditor = ({
17
16
  setShowJSON,
18
17
  customValues,
19
18
  handleJSONTextChange,
20
- sections,
19
+ extractedTags,
20
+ requiredTags,
21
+ optionalTags,
21
22
  handleCustomValueChange,
22
23
  handleDiscardCustomValues,
23
24
  handleUpdatePreview,
24
25
  isUpdatingPreview,
25
26
  formatMessage,
26
27
  }) => {
27
- /** Same as SMS Test & Preview: show token path from extract-tags (fullPath or name). */
28
- const getPersonalizationTagColumnLabel = (tagNode) => tagNode?.fullPath ?? tagNode?.name ?? '';
29
-
30
28
  if (isExtractingTags) {
31
29
  return (
32
30
  <CapRow className="loading-container">
@@ -79,68 +77,52 @@ const CustomValuesEditor = ({
79
77
  </CapRow>
80
78
  ) : (
81
79
  <>
82
- {(sections || []).filter((tagsSection) =>
83
- (tagsSection?.requiredTags?.length || 0) + (tagsSection?.optionalTags?.length || 0) > 0).map((section) => (
84
- <React.Fragment key={section.key || section.title?.id || section.title || CUSTOM_VALUES_EDITOR_SECTION_FALLBACK_KEY}>
85
- {section.title ? (
86
- <CapLabel type="label2" className="tags-section-title">
87
- {typeof section.title === 'string' ? section.title : <FormattedMessage {...section.title} />}
80
+ {extractedTags?.length > 0 && (
81
+ <CapRow className="values-table">
82
+ <CapRow className="table-header">
83
+ <CapLabel type="label31" className="header-cell">
84
+ <FormattedMessage {...messages.personalizationTags} />
88
85
  </CapLabel>
89
- ) : null}
90
- <CapRow className="values-table">
91
- <CapRow className="table-header">
92
- <CapLabel type="label31" className="header-cell">
93
- <FormattedMessage {...messages.personalizationTags} />
94
- </CapLabel>
95
- <CapLabel type="label31" className="header-cell">
96
- <FormattedMessage {...messages.customValues} />
97
- </CapLabel>
98
- </CapRow>
99
- {(section?.requiredTags || []).map((tag, tagIndex) => {
100
- const personalizationTagColumnText = getPersonalizationTagColumnLabel(tag);
101
- return (
102
- <CapRow key={tag?.fullPath ?? `required-${tagIndex}`} className="value-row">
103
- <CapRow className="tag-name">
104
- {personalizationTagColumnText}
105
- <span className="required-tag-indicator">*</span>
106
- </CapRow>
107
- <CapRow className="tag-input">
108
- <CapInput
109
- type="text"
110
- isRequired
111
- className="tag-input-field"
112
- value={customValues?.[tag?.fullPath] ?? ''}
113
- onChange={(e) => handleCustomValueChange(tag?.fullPath, e.target.value)}
114
- placeholder={formatMessage(messages.enterValue)}
115
- size="small"
116
- />
117
- </CapRow>
86
+ <CapLabel type="label31" className="header-cell">
87
+ <FormattedMessage {...messages.customValues} />
88
+ </CapLabel>
89
+ </CapRow>
90
+ {requiredTags.map((tag) => (
91
+ <CapRow key={tag.fullPath} className="value-row">
92
+ <CapRow className="tag-name">
93
+ {tag.fullPath}
94
+ <span className="required-tag-indicator">*</span>
118
95
  </CapRow>
119
- );
120
- })}
121
- {(section?.optionalTags || []).map((tag, tagIndex) => {
122
- const personalizationTagColumnText = getPersonalizationTagColumnLabel(tag);
123
- return (
124
- <CapRow key={tag?.fullPath ?? `optional-${tagIndex}`} className="value-row">
125
- <CapRow className="tag-name">
126
- {personalizationTagColumnText}
127
- </CapRow>
128
- <CapRow className="tag-input">
129
- <CapInput
130
- type="text"
131
- className="tag-input-field"
132
- value={customValues?.[tag?.fullPath] ?? ''}
133
- onChange={(e) => handleCustomValueChange(tag?.fullPath, e.target.value)}
134
- placeholder={formatMessage(messages.enterValue)}
135
- size="small"
136
- />
137
- </CapRow>
96
+ <CapRow className="tag-input">
97
+ <CapInput
98
+ type="text"
99
+ isRequired
100
+ className="tag-input-field"
101
+ value={customValues[tag.fullPath] || ''}
102
+ onChange={(e) => handleCustomValueChange(tag.fullPath, e.target.value)}
103
+ placeholder={formatMessage(messages.enterValue)}
104
+ size="small"
105
+ />
138
106
  </CapRow>
139
- );
140
- })}
141
- </CapRow>
142
- </React.Fragment>
143
- ))}
107
+ </CapRow>
108
+ ))}
109
+ {optionalTags?.map((tag) => (
110
+ <CapRow key={tag.fullPath} className="value-row">
111
+ <CapRow className="tag-name">{tag.fullPath}</CapRow>
112
+ <CapRow className="tag-input">
113
+ <CapInput
114
+ type="text"
115
+ className="tag-input-field"
116
+ value={customValues[tag.fullPath] || ''}
117
+ onChange={(e) => handleCustomValueChange(tag.fullPath, e.target.value)}
118
+ placeholder={formatMessage(messages.enterValue)}
119
+ size="small"
120
+ />
121
+ </CapRow>
122
+ </CapRow>
123
+ ))}
124
+ </CapRow>
125
+ )}
144
126
  </>
145
127
  )}
146
128
  <CapRow className="editor-actions">
@@ -174,12 +156,9 @@ CustomValuesEditor.propTypes = {
174
156
  setShowJSON: PropTypes.func.isRequired,
175
157
  customValues: PropTypes.object.isRequired,
176
158
  handleJSONTextChange: PropTypes.func.isRequired,
177
- sections: PropTypes.arrayOf(PropTypes.shape({
178
- key: PropTypes.string,
179
- title: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
180
- requiredTags: PropTypes.array,
181
- optionalTags: PropTypes.array,
182
- })).isRequired,
159
+ extractedTags: PropTypes.array.isRequired,
160
+ requiredTags: PropTypes.array.isRequired,
161
+ optionalTags: PropTypes.array.isRequired,
183
162
  handleCustomValueChange: PropTypes.func.isRequired,
184
163
  handleDiscardCustomValues: PropTypes.func.isRequired,
185
164
  handleUpdatePreview: PropTypes.func.isRequired,
@@ -18,17 +18,11 @@
18
18
  }
19
19
 
20
20
  &__summary-entry {
21
- display: flex;
22
- align-items: baseline;
23
- gap: 0;
24
21
  margin-right: $CAP_SPACE_18;
25
22
  }
26
23
 
27
- &__summary-key,
28
- &__summary-value {
29
- line-height: 1.4;
30
- margin-top: 0;
31
- margin-bottom: 0;
24
+ &__summary-key {
25
+ line-height: $CAP_SPACE_16;
32
26
  }
33
27
 
34
28
  &__edit-icon {
@@ -32,37 +32,16 @@ import {
32
32
  DELIVERY_SETTING_KEY_SENDER_REPLY_TO,
33
33
  DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER,
34
34
  DELIVERY_SETTING_KEY_SENDER_MOB_NUM,
35
- DELIVERY_SETTING_KEY_SMS_FALLBACK_DOMAIN_ID,
36
35
  } from './constants';
37
36
  import './ModifyDeliverySettings.scss';
38
37
 
39
38
  const findDefault = (array) => find(array, { default: true }) || (array && array[0]) || {};
40
39
 
41
- /**
42
- * Drop empty GSM rows. Optionally drop rows whose value equals domain name — some APIs duplicate
43
- * domain label as a bogus sender row; RCS/DLT often legitimately use the same string (e.g. DetailsForGW1).
44
- */
45
- const filterUsableGsmSendersForDomain = (domain, gsmSenders, { skipDomainNameEchoFilter = false } = {}) => {
46
- const normalizedDomainName =
47
- domain?.domainName != null ? String(domain.domainName).trim().toLowerCase() : '';
48
- return (gsmSenders || []).filter((gsmSenderRow) => {
49
- const rawValue = gsmSenderRow?.value;
50
- if (rawValue == null) return false;
51
- const trimmedSenderValue = String(rawValue).trim();
52
- if (!trimmedSenderValue) return false;
53
- const senderMatchesDomainLabel =
54
- normalizedDomainName && trimmedSenderValue.toLowerCase() === normalizedDomainName;
55
- if (!skipDomainNameEchoFilter && senderMatchesDomainLabel) return false;
56
- return true;
57
- });
58
- };
59
-
60
40
  const ModifyDeliverySettings = (props) => {
61
41
  const {
62
42
  channel,
63
43
  deliverySettings: initialSettings = {},
64
44
  senderDetailsOptions = [],
65
- smsFallbackSenderDetailsOptions = [],
66
45
  wecrmAccounts = [],
67
46
  onSaveDeliverySettings,
68
47
  onClose,
@@ -123,21 +102,17 @@ const ModifyDeliverySettings = (props) => {
123
102
  if (!(channel === CHANNELS.SMS && smsTraiDltEnabled)) {
124
103
  return allDomainOptions;
125
104
  }
126
- // Without template registered sender IDs, strict DLT filter removes every domain — keep full list.
127
- if (!registeredSenderIds?.length) {
128
- return allDomainOptions;
129
- }
130
105
 
131
- return allDomainOptions.filter((domain) => (domain?.gsmSenders || []).some(
132
- (gsmSenderOption) => registeredSenderIds?.includes(gsmSenderOption?.value),
106
+ return allDomainOptions.filter((domain) => (domain.gsmSenders || []).some(
107
+ (gsmId) => registeredSenderIds.includes(gsmId.value),
133
108
  ));
134
109
  }, [allDomainOptions, channel, registeredSenderIds, smsTraiDltEnabled]);
135
110
 
136
111
  const selectedDomain = useMemo(
137
112
  () => (senderDetailsOptions || []).find(
138
- (senderDomain) => senderDomain.domainId === get(localSettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
113
+ (d) => d.domainId === get(localSettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
139
114
  ) || {},
140
- [senderDetailsOptions, get(localSettings, DELIVERY_SETTING_KEY_DOMAIN_ID)],
115
+ [senderDetailsOptions, localSettings.domainId],
141
116
  );
142
117
  const {
143
118
  gsmSenders: selectedDomainGsmSenders = [],
@@ -145,103 +120,25 @@ const ModifyDeliverySettings = (props) => {
145
120
  emailRepliers: selectedDomainEmailRepliers = [],
146
121
  } = selectedDomain;
147
122
 
148
- const rcsSenderOptions = useMemo(
149
- () => {
150
- if (channel !== CHANNELS.RCS) return [];
151
- const rcsDomainRows = senderDetailsOptions || [];
152
- const selectedRcsDomainId = get(localSettings, DELIVERY_SETTING_KEY_DOMAIN_ID);
153
- const rcsDomainsForDropdown =
154
- selectedRcsDomainId != null && selectedRcsDomainId !== ''
155
- ? rcsDomainRows.filter((senderDomain) => senderDomain?.domainId === selectedRcsDomainId)
156
- : rcsDomainRows;
157
- return rcsDomainsForDropdown.flatMap((senderDomain) =>
158
- filterUsableGsmSendersForDomain(senderDomain, senderDomain?.gsmSenders, {
159
- skipDomainNameEchoFilter: true,
160
- }).map((gsmSenderRow) => ({
161
- value: senderDomain?.domainId != null && gsmSenderRow?.value != null
162
- ? `${senderDomain.domainId}|${gsmSenderRow.value}`
163
- : gsmSenderRow?.value,
164
- label: String(gsmSenderRow?.value ?? ''),
165
- })));
166
- },
167
- [channel, senderDetailsOptions, localSettings],
168
- );
169
-
170
- const rcsGsmSenderIdForSelect = useMemo(() => {
171
- const raw = get(localSettings, DELIVERY_SETTING_KEY_GSM_SENDER_ID);
172
- if (raw == null || raw === '') return undefined;
173
- const allowed = new Set((rcsSenderOptions || []).map((senderOption) => senderOption.value));
174
- return allowed.has(raw) ? raw : undefined;
175
- }, [localSettings, rcsSenderOptions]);
176
-
177
- const smsFallbackDomainOptions = useMemo(
178
- () => {
179
- const raw = (smsFallbackSenderDetailsOptions || []).map((senderDetails) => ({
180
- label: senderDetails.domainName || senderDetails.domainId,
181
- value: senderDetails.domainId,
182
- ...senderDetails,
183
- }));
184
- if (!(channel === CHANNELS.RCS && smsTraiDltEnabled && registeredSenderIds?.length)) {
185
- return raw;
186
- }
187
- return raw.filter((domain) => (domain?.gsmSenders || []).some(
188
- (gsmSenderOption) => registeredSenderIds?.includes(gsmSenderOption?.value),
189
- ));
190
- },
191
- [channel, smsFallbackSenderDetailsOptions, smsTraiDltEnabled, registeredSenderIds],
192
- );
193
-
194
- const smsSenderOptions = useMemo(
195
- () => {
196
- if (channel !== CHANNELS.RCS) return [];
197
- const smsFallbackDomainRows = smsFallbackSenderDetailsOptions || [];
198
- const selectedSmsFallbackDomainId = get(localSettings, DELIVERY_SETTING_KEY_SMS_FALLBACK_DOMAIN_ID);
199
- const smsFallbackDomainsForDropdown =
200
- selectedSmsFallbackDomainId != null && selectedSmsFallbackDomainId !== ''
201
- ? smsFallbackDomainRows.filter((senderDomain) => senderDomain?.domainId === selectedSmsFallbackDomainId)
202
- : smsFallbackDomainRows;
203
- const shouldFilterSmsSendersByDltRegistration = smsTraiDltEnabled && registeredSenderIds?.length;
204
- return smsFallbackDomainsForDropdown.flatMap((senderDomain) =>
205
- filterUsableGsmSendersForDomain(senderDomain, senderDomain?.gsmSenders)
206
- .filter((smsGsmSenderRow) =>
207
- !shouldFilterSmsSendersByDltRegistration || registeredSenderIds?.includes(smsGsmSenderRow?.value))
208
- .map((gsmSenderRow) => ({
209
- value: senderDomain?.domainId != null && gsmSenderRow?.value != null
210
- ? `${senderDomain.domainId}|${gsmSenderRow.value}`
211
- : gsmSenderRow?.value,
212
- label: String(gsmSenderRow?.value ?? ''),
213
- })));
214
- },
215
- [channel, smsFallbackSenderDetailsOptions, localSettings, smsTraiDltEnabled, registeredSenderIds],
216
- );
217
-
218
- const smsFallbackGsmIdForSelect = useMemo(() => {
219
- const raw = get(localSettings, DELIVERY_SETTING_KEY_CDMA_SENDER_ID);
220
- if (raw == null || raw === '') return undefined;
221
- const allowed = new Set((smsSenderOptions || []).map((senderOption) => senderOption.value));
222
- return allowed.has(raw) ? raw : undefined;
223
- }, [localSettings, smsSenderOptions]);
224
-
225
123
  const gsmOptions = useMemo(
226
124
  () => {
227
- const smsGsmSendersForSelect = channel === CHANNELS.SMS && smsTraiDltEnabled && registeredSenderIds?.length
228
- ? selectedDomainGsmSenders.filter((gsmSenderOption) =>
229
- registeredSenderIds?.includes(gsmSenderOption?.value))
125
+ const smsGsmSenders = channel === CHANNELS.SMS && smsTraiDltEnabled
126
+ ? selectedDomainGsmSenders.filter((gsmId) => registeredSenderIds.includes(gsmId.value))
230
127
  : selectedDomainGsmSenders;
231
128
 
232
- return smsGsmSendersForSelect.map((gsmSenderRow) => ({
233
- label: gsmSenderRow?.value || gsmSenderRow?.label,
234
- value: gsmSenderRow?.value,
129
+ return smsGsmSenders.map((o) => ({
130
+ label: o.value || o.label,
131
+ value: o.value,
235
132
  }));
236
133
  },
237
134
  [channel, registeredSenderIds, selectedDomainGsmSenders, smsTraiDltEnabled],
238
135
  );
239
136
 
240
137
  const emailSenderOptions = useMemo(
241
- () => selectedDomainEmailSenders.map((emailSenderRow) => ({
242
- label: emailSenderRow.value || emailSenderRow.label,
243
- value: emailSenderRow.value,
244
- senderLabel: emailSenderRow.label,
138
+ () => selectedDomainEmailSenders.map((o) => ({
139
+ label: o.value || o.label,
140
+ value: o.value,
141
+ senderLabel: o.label,
245
142
  })),
246
143
  [selectedDomainEmailSenders],
247
144
  );
@@ -307,47 +204,13 @@ const ModifyDeliverySettings = (props) => {
307
204
  });
308
205
  }, []);
309
206
 
310
- const onSmsFallbackDomainChange = useCallback(
311
- (value) => {
312
- setLocalSettings((prev) => {
313
- const next = cloneDeep(prev);
314
- next[DELIVERY_SETTING_KEY_SMS_FALLBACK_DOMAIN_ID] = value;
315
- const selectedSmsFallbackDomain = (smsFallbackSenderDetailsOptions || []).find(
316
- (senderDomain) => senderDomain?.domainId === value,
317
- );
318
- const usableSmsFallbackGsmSenders = filterUsableGsmSendersForDomain(
319
- selectedSmsFallbackDomain,
320
- selectedSmsFallbackDomain?.gsmSenders,
321
- );
322
- const firstSmsFallbackGsmSender = usableSmsFallbackGsmSenders[0];
323
- const composite = selectedSmsFallbackDomain?.domainId != null && firstSmsFallbackGsmSender?.value != null
324
- ? `${selectedSmsFallbackDomain.domainId}|${firstSmsFallbackGsmSender.value}`
325
- : (firstSmsFallbackGsmSender?.value || '');
326
- next[DELIVERY_SETTING_KEY_CDMA_SENDER_ID] = composite;
327
- return next;
328
- });
329
- },
330
- [smsFallbackSenderDetailsOptions],
331
- );
332
-
333
207
  const onDomainChange = useCallback(
334
208
  (value) => {
335
- const domain = domainOptions.find((domainOption) => domainOption.value === value);
209
+ const domain = domainOptions.find((d) => d.value === value);
336
210
  updateSetting(DELIVERY_SETTING_KEY_DOMAIN_ID, value);
337
211
  if (domain?.dgmId != null) updateSetting(DELIVERY_SETTING_KEY_DOMAIN_GATEWAY_MAP_ID, domain.dgmId);
338
- if (channel === CHANNELS.RCS && domain) {
339
- const usableRcsGsmSenders = filterUsableGsmSendersForDomain(domain, domain?.gsmSenders, {
340
- skipDomainNameEchoFilter: true,
341
- });
342
- const firstRcsGsmSender = usableRcsGsmSenders[0];
343
- const composite = domain?.domainId != null && firstRcsGsmSender?.value != null
344
- ? `${domain.domainId}|${firstRcsGsmSender.value}`
345
- : (firstRcsGsmSender?.value || '');
346
- updateSetting(DELIVERY_SETTING_KEY_GSM_SENDER_ID, composite);
347
- return;
348
- }
349
212
  if (channel === CHANNELS.SMS && domain) {
350
- const smsGsmSenders = smsTraiDltEnabled && registeredSenderIds?.length
213
+ const smsGsmSenders = smsTraiDltEnabled
351
214
  ? (domain.gsmSenders || []).filter((gsmId) => registeredSenderIds.includes(gsmId.value))
352
215
  : domain.gsmSenders;
353
216
  const def = findDefault(smsGsmSenders);
@@ -367,20 +230,9 @@ const ModifyDeliverySettings = (props) => {
367
230
  );
368
231
 
369
232
  const handleDone = useCallback(() => {
370
- const next = cloneDeep(localSettings);
371
- if (channel === CHANNELS.RCS) {
372
- const rawRcs = get(next, DELIVERY_SETTING_KEY_GSM_SENDER_ID);
373
- if (rawRcs && !(rcsSenderOptions || []).some((senderOption) => senderOption.value === rawRcs)) {
374
- next[DELIVERY_SETTING_KEY_GSM_SENDER_ID] = '';
375
- }
376
- const rawSms = get(next, DELIVERY_SETTING_KEY_CDMA_SENDER_ID);
377
- if (rawSms && !(smsSenderOptions || []).some((senderOption) => senderOption.value === rawSms)) {
378
- next[DELIVERY_SETTING_KEY_CDMA_SENDER_ID] = '';
379
- }
380
- }
381
- onSaveDeliverySettings(next);
233
+ onSaveDeliverySettings(localSettings);
382
234
  if (onClose) onClose();
383
- }, [channel, localSettings, onSaveDeliverySettings, onClose, rcsSenderOptions, smsSenderOptions]);
235
+ }, [localSettings, onSaveDeliverySettings, onClose]);
384
236
 
385
237
  const renderSelectRow = useCallback(
386
238
  ({
@@ -434,7 +286,7 @@ const ModifyDeliverySettings = (props) => {
434
286
  value: get(localSettings, DELIVERY_SETTING_KEY_SENDER_EMAIL),
435
287
  onChange: (val) => {
436
288
  const sender = selectedDomainEmailSenders.find(
437
- (emailSenderRow) => emailSenderRow.value === val,
289
+ (s) => s.value === val,
438
290
  );
439
291
  updateSetting(DELIVERY_SETTING_KEY_SENDER_EMAIL, val);
440
292
  updateSetting(DELIVERY_SETTING_KEY_SENDER_LABEL, sender?.label || val);
@@ -446,7 +298,7 @@ const ModifyDeliverySettings = (props) => {
446
298
  value: get(localSettings, DELIVERY_SETTING_KEY_SENDER_LABEL) || '',
447
299
  onChange: (val) => {
448
300
  const sender = selectedDomainEmailSenders.find(
449
- (emailSenderRow) => (emailSenderRow.label || emailSenderRow.value) === val,
301
+ (s) => (s.label || s.value) === val,
450
302
  );
451
303
  if (sender) {
452
304
  updateSetting(DELIVERY_SETTING_KEY_SENDER_EMAIL, sender.value);
@@ -474,7 +326,7 @@ const ModifyDeliverySettings = (props) => {
474
326
  onChange: (val) => {
475
327
  updateSetting(DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER, val);
476
328
  const domain = (senderDetailsOptions || []).find(
477
- (whatsappAccountRow) => whatsappAccountRow.sourceAccountIdentifier === val,
329
+ (d) => d.sourceAccountIdentifier === val,
478
330
  );
479
331
  const first = domain?.gsmSenders?.[0];
480
332
  updateSetting(DELIVERY_SETTING_KEY_SENDER_MOB_NUM, first?.value || '');
@@ -488,39 +340,10 @@ const ModifyDeliverySettings = (props) => {
488
340
  onChange: (val) => updateSetting(DELIVERY_SETTING_KEY_SENDER_MOB_NUM, val),
489
341
  },
490
342
  ];
491
- const rcsFields = [
492
- {
493
- titleMessage: messages.rcsDomainLabel,
494
- options: domainOptions,
495
- value: get(localSettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
496
- onChange: (val) => onDomainChange(val),
497
- },
498
- {
499
- titleMessage: messages.rcsSenderIdLabel,
500
- options: rcsSenderOptions,
501
- value: rcsGsmSenderIdForSelect,
502
- onChange: (val) => updateSetting(DELIVERY_SETTING_KEY_GSM_SENDER_ID, val),
503
- },
504
- ...((smsFallbackSenderDetailsOptions || []).length > 0 ? [
505
- {
506
- titleMessage: messages.fallbackSmsDomainLabel,
507
- options: smsFallbackDomainOptions,
508
- value: get(localSettings, DELIVERY_SETTING_KEY_SMS_FALLBACK_DOMAIN_ID),
509
- onChange: onSmsFallbackDomainChange,
510
- },
511
- {
512
- titleMessage: messages.fallbackSmsSenderIdLabel,
513
- options: smsSenderOptions,
514
- value: smsFallbackGsmIdForSelect,
515
- onChange: (val) => updateSetting(DELIVERY_SETTING_KEY_CDMA_SENDER_ID, val),
516
- },
517
- ] : []),
518
- ];
519
343
  const byChannel = {
520
344
  [CHANNELS.SMS]: smsFields,
521
345
  [CHANNELS.EMAIL]: emailFields,
522
346
  [CHANNELS.WHATSAPP]: whatsappFields,
523
- [CHANNELS.RCS]: rcsFields,
524
347
  };
525
348
  return byChannel[channel] || [];
526
349
  }, [
@@ -533,13 +356,6 @@ const ModifyDeliverySettings = (props) => {
533
356
  wecrmAccountOptions,
534
357
  whatsappAccountOptionsForDisplay,
535
358
  whatsappSenderOptions,
536
- rcsSenderOptions,
537
- rcsGsmSenderIdForSelect,
538
- smsSenderOptions,
539
- smsFallbackGsmIdForSelect,
540
- smsFallbackDomainOptions,
541
- smsFallbackSenderDetailsOptions,
542
- onSmsFallbackDomainChange,
543
359
  localSettings,
544
360
  selectedDomainEmailSenders,
545
361
  senderDetailsOptions,
@@ -574,10 +390,9 @@ const ModifyDeliverySettings = (props) => {
574
390
  };
575
391
 
576
392
  ModifyDeliverySettings.propTypes = {
577
- channel: PropTypes.oneOf([CHANNELS.SMS, CHANNELS.EMAIL, CHANNELS.WHATSAPP, CHANNELS.RCS]).isRequired,
393
+ channel: PropTypes.oneOf([CHANNELS.SMS, CHANNELS.EMAIL, CHANNELS.WHATSAPP]).isRequired,
578
394
  deliverySettings: PropTypes.object,
579
395
  senderDetailsOptions: PropTypes.array,
580
- smsFallbackSenderDetailsOptions: PropTypes.array,
581
396
  wecrmAccounts: PropTypes.array,
582
397
  onSaveDeliverySettings: PropTypes.func.isRequired,
583
398
  onClose: PropTypes.func,
@@ -593,7 +408,6 @@ ModifyDeliverySettings.propTypes = {
593
408
  ModifyDeliverySettings.defaultProps = {
594
409
  deliverySettings: {},
595
410
  senderDetailsOptions: [],
596
- smsFallbackSenderDetailsOptions: [],
597
411
  wecrmAccounts: [],
598
412
  onClose: undefined,
599
413
  isLoading: false,