cap-creatives-ui 8.0.280 → 8.0.321

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 (247) hide show
  1. package/.github/workflows/pr-title-check.yml +88 -0
  2. package/app/constants/unified.js +21 -1
  3. package/app/containers/App/constants.js +0 -1
  4. package/app/containers/Login/test/index.test.js +123 -0
  5. package/app/containers/Login/test/selectors.test.js +165 -0
  6. package/app/initialState.js +0 -2
  7. package/app/services/api.js +6 -0
  8. package/app/services/tests/api.test.js +7 -0
  9. package/app/services/tests/getSchema.test.js +95 -0
  10. package/app/utils/common.js +23 -9
  11. package/app/utils/commonUtils.js +64 -93
  12. package/app/utils/tagValidations.js +83 -219
  13. package/app/utils/templateVarUtils.js +172 -0
  14. package/app/utils/tests/common.test.js +265 -323
  15. package/app/utils/tests/commonUtil.test.js +461 -118
  16. package/app/utils/tests/commonUtils.test.js +581 -0
  17. package/app/utils/tests/messageUtils.test.js +95 -0
  18. package/app/utils/tests/smsCharCount.test.js +304 -0
  19. package/app/utils/tests/smsCharCountV2.test.js +213 -10
  20. package/app/utils/tests/tagValidations.test.js +474 -357
  21. package/app/utils/tests/templateVarUtils.test.js +160 -0
  22. package/app/v2Components/CapDeviceContent/index.js +10 -7
  23. package/app/v2Components/CapTagList/index.js +32 -24
  24. package/app/v2Components/CapTagList/style.scss +48 -0
  25. package/app/v2Components/CapTagListWithInput/__tests__/CapTagListWithInput.test.js +63 -0
  26. package/app/v2Components/CapTagListWithInput/index.js +8 -0
  27. package/app/v2Components/CapWhatsappCTA/index.js +2 -0
  28. package/app/v2Components/CapWhatsappCarouselButton/index.js +32 -14
  29. package/app/v2Components/CapWhatsappCarouselButton/tests/index.test.js +120 -2
  30. package/app/v2Components/CommonTestAndPreview/CustomValuesEditor.js +70 -49
  31. package/app/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +39 -0
  32. package/app/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +606 -0
  33. package/app/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.scss +36 -0
  34. package/app/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +79 -0
  35. package/app/v2Components/CommonTestAndPreview/DeliverySettings/index.js +314 -0
  36. package/app/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +141 -0
  37. package/app/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +156 -0
  38. package/app/v2Components/CommonTestAndPreview/SendTestMessage.js +57 -1
  39. package/app/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +20 -1
  40. package/app/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +133 -4
  41. package/app/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +210 -4
  42. package/app/v2Components/CommonTestAndPreview/actions.js +20 -0
  43. package/app/v2Components/CommonTestAndPreview/constants.js +57 -1
  44. package/app/v2Components/CommonTestAndPreview/index.js +878 -156
  45. package/app/v2Components/CommonTestAndPreview/messages.js +41 -3
  46. package/app/v2Components/CommonTestAndPreview/previewApiUtils.js +59 -0
  47. package/app/v2Components/CommonTestAndPreview/reducer.js +47 -0
  48. package/app/v2Components/CommonTestAndPreview/sagas.js +75 -5
  49. package/app/v2Components/CommonTestAndPreview/selectors.js +51 -0
  50. package/app/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +352 -0
  51. package/app/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +1156 -0
  52. package/app/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +334 -0
  53. package/app/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +576 -0
  54. package/app/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +156 -0
  55. package/app/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +199 -1
  56. package/app/v2Components/CommonTestAndPreview/tests/actions.test.js +50 -0
  57. package/app/v2Components/CommonTestAndPreview/tests/constants.test.js +18 -7
  58. package/app/v2Components/CommonTestAndPreview/tests/index.test.js +914 -5
  59. package/app/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +67 -0
  60. package/app/v2Components/CommonTestAndPreview/tests/reducer.test.js +118 -0
  61. package/app/v2Components/CommonTestAndPreview/tests/sagas.test.js +146 -378
  62. package/app/v2Components/CommonTestAndPreview/tests/selectors.test.js +146 -0
  63. package/app/v2Components/ErrorInfoNote/index.js +24 -26
  64. package/app/v2Components/FormBuilder/index.js +182 -204
  65. package/app/v2Components/FormBuilder/messages.js +4 -8
  66. package/app/v2Components/HtmlEditor/HTMLEditor.js +7 -6
  67. package/app/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +1 -1
  68. package/app/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +928 -17
  69. package/app/v2Components/HtmlEditor/components/CodeEditorPane/index.js +4 -2
  70. package/app/v2Components/HtmlEditor/hooks/__tests__/useValidation.test.js +452 -3
  71. package/app/v2Components/HtmlEditor/hooks/useValidation.js +12 -9
  72. package/app/v2Components/HtmlEditor/utils/__tests__/htmlValidator.enhanced.test.js +132 -0
  73. package/app/v2Components/HtmlEditor/utils/htmlValidator.js +4 -2
  74. package/app/v2Components/SmsFallback/SmsFallbackLocalSelector.js +87 -0
  75. package/app/v2Components/SmsFallback/constants.js +73 -0
  76. package/app/v2Components/SmsFallback/index.js +956 -0
  77. package/app/v2Components/SmsFallback/index.scss +265 -0
  78. package/app/v2Components/SmsFallback/messages.js +78 -0
  79. package/app/v2Components/SmsFallback/smsFallbackUtils.js +107 -0
  80. package/app/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +50 -0
  81. package/app/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +147 -0
  82. package/app/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +304 -0
  83. package/app/v2Components/SmsFallback/tests/smsFallbackUi.test.js +197 -0
  84. package/app/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +261 -0
  85. package/app/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +422 -0
  86. package/app/v2Components/SmsFallback/useLocalTemplateList.js +92 -0
  87. package/app/v2Components/TestAndPreviewSlidebox/index.js +22 -1
  88. package/app/v2Components/TestAndPreviewSlidebox/sagas.js +11 -4
  89. package/app/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +3 -1
  90. package/app/v2Components/VarSegmentMessageEditor/constants.js +2 -0
  91. package/app/v2Components/VarSegmentMessageEditor/index.js +125 -0
  92. package/app/v2Components/VarSegmentMessageEditor/index.scss +46 -0
  93. package/app/v2Containers/BeeEditor/index.js +3 -0
  94. package/app/v2Containers/BeePopupEditor/index.js +9 -2
  95. package/app/v2Containers/Cap/mockData.js +0 -14
  96. package/app/v2Containers/Cap/reducer.js +3 -55
  97. package/app/v2Containers/Cap/tests/reducer.test.js +0 -102
  98. package/app/v2Containers/CommunicationFlow/CommunicationFlow.js +291 -0
  99. package/app/v2Containers/CommunicationFlow/CommunicationFlow.scss +25 -0
  100. package/app/v2Containers/CommunicationFlow/Tests/CommunicationFlow.test.js +255 -0
  101. package/app/v2Containers/CommunicationFlow/constants.js +200 -0
  102. package/app/v2Containers/CommunicationFlow/index.js +102 -0
  103. package/app/v2Containers/CommunicationFlow/messages.js +346 -0
  104. package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.js +522 -0
  105. package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.scss +170 -0
  106. package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/ChannelSelectionStep.test.js +796 -0
  107. package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/index.js +5 -0
  108. package/app/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/CommunicationStrategyStep.js +95 -0
  109. package/app/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/Tests/CommunicationStrategyStep.test.js +133 -0
  110. package/app/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/index.js +5 -0
  111. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js +289 -0
  112. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.scss +70 -0
  113. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.js +319 -0
  114. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.scss +69 -0
  115. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/DeliverySettingsSection.test.js +616 -0
  116. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/SenderDetails.test.js +577 -0
  117. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/deliverySettingsConfig.test.js +1111 -0
  118. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/deliverySettingsConfig.js +696 -0
  119. package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/index.js +7 -0
  120. package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/DynamicControlsStep.js +102 -0
  121. package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/DynamicControlsStep.scss +36 -0
  122. package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/Tests/DynamicControlsStep.test.js +91 -0
  123. package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/index.js +5 -0
  124. package/app/v2Containers/CommunicationFlow/steps/MessageTypeStep/MessageTypeStep.js +86 -0
  125. package/app/v2Containers/CommunicationFlow/steps/MessageTypeStep/Tests/MessageTypeStep.test.js +100 -0
  126. package/app/v2Containers/CommunicationFlow/steps/MessageTypeStep/index.js +5 -0
  127. package/app/v2Containers/CommunicationFlow/utils/getEnabledSteps.js +30 -0
  128. package/app/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +43 -0
  129. package/app/v2Containers/CreativesContainer/SlideBoxContent.js +127 -11
  130. package/app/v2Containers/CreativesContainer/SlideBoxFooter.js +62 -9
  131. package/app/v2Containers/CreativesContainer/SlideBoxHeader.js +29 -4
  132. package/app/v2Containers/CreativesContainer/constants.js +24 -0
  133. package/app/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +67 -0
  134. package/app/v2Containers/CreativesContainer/index.js +346 -71
  135. package/app/v2Containers/CreativesContainer/index.scss +51 -1
  136. package/app/v2Containers/CreativesContainer/messages.js +12 -0
  137. package/app/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +90 -0
  138. package/app/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +69 -1
  139. package/app/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +443 -0
  140. package/app/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +110 -0
  141. package/app/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +147 -4
  142. package/app/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +363 -0
  143. package/app/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +57 -10
  144. package/app/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +258 -0
  145. package/app/v2Containers/CreativesContainer/tests/index.test.js +71 -9
  146. package/app/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +125 -0
  147. package/app/v2Containers/Email/index.js +2 -5
  148. package/app/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +58 -77
  149. package/app/v2Containers/EmailWrapper/components/EmailWrapperView.js +3 -0
  150. package/app/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +158 -89
  151. package/app/v2Containers/EmailWrapper/components/__tests__/EmailWrapperView.test.js +16 -1
  152. package/app/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +17 -12
  153. package/app/v2Containers/EmailWrapper/index.js +4 -0
  154. package/app/v2Containers/EmailWrapper/tests/useEmailWrapper.edgeCases.test.js +1 -0
  155. package/app/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +133 -0
  156. package/app/v2Containers/FTP/index.js +2 -51
  157. package/app/v2Containers/FTP/messages.js +0 -4
  158. package/app/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +110 -155
  159. package/app/v2Containers/InApp/index.js +297 -118
  160. package/app/v2Containers/InApp/tests/index.test.js +17 -6
  161. package/app/v2Containers/InApp/tests/mockData.js +1 -1
  162. package/app/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +19 -0
  163. package/app/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +3 -0
  164. package/app/v2Containers/InAppWrapper/index.js +3 -0
  165. package/app/v2Containers/InappAdvance/index.js +5 -104
  166. package/app/v2Containers/InappAdvance/tests/index.test.js +2 -0
  167. package/app/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +24 -3
  168. package/app/v2Containers/Line/Container/Text/index.js +0 -1
  169. package/app/v2Containers/MobilePush/Create/index.js +105 -28
  170. package/app/v2Containers/MobilePush/Create/messages.js +4 -0
  171. package/app/v2Containers/MobilePush/Edit/index.js +250 -68
  172. package/app/v2Containers/MobilePush/Edit/messages.js +4 -0
  173. package/app/v2Containers/MobilePushNew/components/PlatformContentFields.js +36 -12
  174. package/app/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +68 -27
  175. package/app/v2Containers/MobilePushNew/index.js +78 -35
  176. package/app/v2Containers/MobilePushNew/messages.js +8 -0
  177. package/app/v2Containers/MobilepushWrapper/index.js +11 -1
  178. package/app/v2Containers/Rcs/constants.js +32 -1
  179. package/app/v2Containers/Rcs/index.js +963 -916
  180. package/app/v2Containers/Rcs/index.scss +85 -6
  181. package/app/v2Containers/Rcs/messages.js +10 -1
  182. package/app/v2Containers/Rcs/rcsLibraryHydrationUtils.js +205 -0
  183. package/app/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +41136 -1566
  184. package/app/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +0 -5
  185. package/app/v2Containers/Rcs/tests/index.test.js +41 -38
  186. package/app/v2Containers/Rcs/tests/mockData.js +38 -0
  187. package/app/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +251 -0
  188. package/app/v2Containers/Rcs/tests/utils.test.js +379 -1
  189. package/app/v2Containers/Rcs/utils.js +358 -10
  190. package/app/v2Containers/Sms/Create/index.js +122 -39
  191. package/app/v2Containers/Sms/Create/messages.js +4 -0
  192. package/app/v2Containers/Sms/Edit/index.js +37 -3
  193. package/app/v2Containers/Sms/commonMethods.js +3 -6
  194. package/app/v2Containers/Sms/smsFormDataHelpers.js +67 -0
  195. package/app/v2Containers/Sms/tests/commonMethods.test.js +122 -0
  196. package/app/v2Containers/Sms/tests/smsFormDataHelpers.test.js +253 -0
  197. package/app/v2Containers/SmsTrai/Create/index.js +9 -4
  198. package/app/v2Containers/SmsTrai/Create/index.scss +1 -1
  199. package/app/v2Containers/SmsTrai/Edit/constants.js +2 -0
  200. package/app/v2Containers/SmsTrai/Edit/index.js +667 -160
  201. package/app/v2Containers/SmsTrai/Edit/index.scss +121 -0
  202. package/app/v2Containers/SmsTrai/Edit/messages.js +9 -4
  203. package/app/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4590 -2436
  204. package/app/v2Containers/SmsWrapper/index.js +41 -8
  205. package/app/v2Containers/TagList/index.js +63 -2
  206. package/app/v2Containers/TagList/messages.js +8 -0
  207. package/app/v2Containers/TagList/tests/TagList.test.js +122 -20
  208. package/app/v2Containers/TagList/tests/mockdata.js +17 -0
  209. package/app/v2Containers/Templates/TemplatesActionBar.js +101 -0
  210. package/app/v2Containers/Templates/_templates.scss +61 -2
  211. package/app/v2Containers/Templates/actions.js +11 -0
  212. package/app/v2Containers/Templates/constants.js +2 -0
  213. package/app/v2Containers/Templates/index.js +90 -40
  214. package/app/v2Containers/Templates/reducer.js +3 -1
  215. package/app/v2Containers/Templates/sagas.js +57 -12
  216. package/app/v2Containers/Templates/tests/TemplatesActionBar.test.js +120 -0
  217. package/app/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1043 -1079
  218. package/app/v2Containers/Templates/tests/reducer.test.js +12 -0
  219. package/app/v2Containers/Templates/tests/sagas.test.js +193 -12
  220. package/app/v2Containers/Templates/tests/smsTemplatesListApi.test.js +180 -0
  221. package/app/v2Containers/Templates/utils/smsTemplatesListApi.js +79 -0
  222. package/app/v2Containers/TemplatesV2/TemplatesV2.style.js +72 -1
  223. package/app/v2Containers/TemplatesV2/index.js +147 -49
  224. package/app/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +131 -0
  225. package/app/v2Containers/Viber/index.js +9 -10
  226. package/app/v2Containers/Viber/index.scss +1 -1
  227. package/app/v2Containers/WebPush/Create/components/BrandIconSection.test.js +264 -0
  228. package/app/v2Containers/WebPush/Create/components/MessageSection.js +78 -19
  229. package/app/v2Containers/WebPush/Create/components/MessageSection.test.js +82 -0
  230. package/app/v2Containers/WebPush/Create/components/__snapshots__/BrandIconSection.test.js.snap +187 -0
  231. package/app/v2Containers/WebPush/Create/components/__snapshots__/MessageSection.test.js.snap +25 -17
  232. package/app/v2Containers/WebPush/Create/hooks/useAiraTriggerPosition.js +80 -0
  233. package/app/v2Containers/WebPush/Create/hooks/useAiraTriggerPosition.test.js +210 -0
  234. package/app/v2Containers/WebPush/Create/hooks/useTagManagement.js +1 -5
  235. package/app/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +0 -7
  236. package/app/v2Containers/WebPush/Create/index.js +36 -6
  237. package/app/v2Containers/WebPush/Create/index.scss +5 -0
  238. package/app/v2Containers/WebPush/Create/messages.js +8 -1
  239. package/app/v2Containers/WebPush/Create/preview/tests/NotificationContainer.test.js +269 -0
  240. package/app/v2Containers/WebPush/Create/utils/validation.js +31 -15
  241. package/app/v2Containers/WebPush/Create/utils/validation.test.js +72 -24
  242. package/app/v2Containers/Whatsapp/index.js +28 -53
  243. package/app/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +26939 -3982
  244. package/app/v2Containers/Whatsapp/tests/index.test.js +172 -0
  245. package/app/v2Containers/Zalo/index.js +5 -11
  246. package/package.json +2 -2
  247. package/version +9 -0
@@ -0,0 +1,606 @@
1
+ /**
2
+ * ModifyDeliverySettings — CapSlideBox content for Test and Preview delivery settings.
3
+ * Channel-specific dropdowns (SMS: domain + sender number; Email: domain + sender + reply-to; WhatsApp: account + sender number).
4
+ * Reference: cap-campaigns-v2 ModifyDeliverySettings + SenderDetails (field layout and options shape).
5
+ */
6
+
7
+ import React, {
8
+ useState, useCallback, useMemo, useEffect,
9
+ } from 'react';
10
+ import PropTypes from 'prop-types';
11
+ import CapRow from '@capillarytech/cap-ui-library/CapRow';
12
+ import CapHeader from '@capillarytech/cap-ui-library/CapHeader';
13
+ import CapSelect from '@capillarytech/cap-ui-library/CapSelect';
14
+ import CapButton from '@capillarytech/cap-ui-library/CapButton';
15
+ import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
16
+ import CapLabel from '@capillarytech/cap-ui-library/CapLabel';
17
+ import { FormattedMessage } from 'react-intl';
18
+ import get from 'lodash/get';
19
+ import find from 'lodash/find';
20
+ import cloneDeep from 'lodash/cloneDeep';
21
+ import messages from './messages';
22
+ import {
23
+ CHANNELS,
24
+ DEFAULT_DELIVERY_SETTINGS_BY_CHANNEL,
25
+ ROW_KEY_PREFIX,
26
+ DELIVERY_SETTING_KEY_DOMAIN_ID,
27
+ DELIVERY_SETTING_KEY_DOMAIN_GATEWAY_MAP_ID,
28
+ DELIVERY_SETTING_KEY_GSM_SENDER_ID,
29
+ DELIVERY_SETTING_KEY_CDMA_SENDER_ID,
30
+ DELIVERY_SETTING_KEY_SENDER_EMAIL,
31
+ DELIVERY_SETTING_KEY_SENDER_LABEL,
32
+ DELIVERY_SETTING_KEY_SENDER_REPLY_TO,
33
+ DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER,
34
+ DELIVERY_SETTING_KEY_SENDER_MOB_NUM,
35
+ DELIVERY_SETTING_KEY_SMS_FALLBACK_DOMAIN_ID,
36
+ } from './constants';
37
+ import './ModifyDeliverySettings.scss';
38
+
39
+ const findDefault = (array) => find(array, { default: true }) || (array && array[0]) || {};
40
+
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
+ const ModifyDeliverySettings = (props) => {
61
+ const {
62
+ channel,
63
+ deliverySettings: initialSettings = {},
64
+ senderDetailsOptions = [],
65
+ smsFallbackSenderDetailsOptions = [],
66
+ wecrmAccounts = [],
67
+ onSaveDeliverySettings,
68
+ onClose,
69
+ isLoading,
70
+ formatMessage,
71
+ smsTraiDltEnabled,
72
+ registeredSenderIds = [],
73
+ whatsappAccountFromForm,
74
+ } = props;
75
+
76
+ const defaultForChannel = DEFAULT_DELIVERY_SETTINGS_BY_CHANNEL[channel] || {};
77
+ const [localSettings, setLocalSettings] = useState(() => ({
78
+ ...defaultForChannel,
79
+ ...initialSettings,
80
+ }));
81
+
82
+ const isWhatsappAccountLocked = channel === CHANNELS.WHATSAPP && !!whatsappAccountFromForm?.accountName;
83
+
84
+ useEffect(() => {
85
+ if (!isWhatsappAccountLocked || !whatsappAccountFromForm?.accountName) return;
86
+ const accountByName = (wecrmAccounts || []).find(
87
+ (a) => (a.name || '') === whatsappAccountFromForm.accountName,
88
+ );
89
+ const sourceAccountId = accountByName?.sourceAccountIdentifier;
90
+ if (!sourceAccountId) return;
91
+ setLocalSettings((prev) => {
92
+ if (prev[DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER] === sourceAccountId) return prev;
93
+ const next = cloneDeep(prev);
94
+ next[DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER] = sourceAccountId;
95
+ const domain = (senderDetailsOptions || []).find(
96
+ (senderDetails) => senderDetails.sourceAccountIdentifier === sourceAccountId,
97
+ );
98
+ const first = domain?.gsmSenders?.[0];
99
+ if (first?.value != null) {
100
+ next[DELIVERY_SETTING_KEY_SENDER_MOB_NUM] = first.value;
101
+ }
102
+ return next;
103
+ });
104
+ }, [
105
+ isWhatsappAccountLocked,
106
+ whatsappAccountFromForm?.accountName,
107
+ wecrmAccounts,
108
+ senderDetailsOptions,
109
+ ]);
110
+
111
+ const noOptionsLabel = formatMessage(messages.noOptions);
112
+
113
+ const allDomainOptions = useMemo(
114
+ () => (senderDetailsOptions || []).map((senderDetails) => ({
115
+ label: senderDetails.domainName || senderDetails.domainId,
116
+ value: senderDetails.domainId,
117
+ ...senderDetails,
118
+ })),
119
+ [senderDetailsOptions],
120
+ );
121
+
122
+ const domainOptions = useMemo(() => {
123
+ if (!(channel === CHANNELS.SMS && smsTraiDltEnabled)) {
124
+ return allDomainOptions;
125
+ }
126
+ // Without template registered sender IDs, strict DLT filter removes every domain — keep full list.
127
+ if (!registeredSenderIds?.length) {
128
+ return allDomainOptions;
129
+ }
130
+
131
+ return allDomainOptions.filter((domain) => (domain?.gsmSenders || []).some(
132
+ (gsmSenderOption) => registeredSenderIds?.includes(gsmSenderOption?.value),
133
+ ));
134
+ }, [allDomainOptions, channel, registeredSenderIds, smsTraiDltEnabled]);
135
+
136
+ const selectedDomain = useMemo(
137
+ () => (senderDetailsOptions || []).find(
138
+ (senderDomain) => senderDomain.domainId === get(localSettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
139
+ ) || {},
140
+ [senderDetailsOptions, get(localSettings, DELIVERY_SETTING_KEY_DOMAIN_ID)],
141
+ );
142
+ const {
143
+ gsmSenders: selectedDomainGsmSenders = [],
144
+ emailSenders: selectedDomainEmailSenders = [],
145
+ emailRepliers: selectedDomainEmailRepliers = [],
146
+ } = selectedDomain;
147
+
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
+ const gsmOptions = useMemo(
226
+ () => {
227
+ const smsGsmSendersForSelect = channel === CHANNELS.SMS && smsTraiDltEnabled && registeredSenderIds?.length
228
+ ? selectedDomainGsmSenders.filter((gsmSenderOption) =>
229
+ registeredSenderIds?.includes(gsmSenderOption?.value))
230
+ : selectedDomainGsmSenders;
231
+
232
+ return smsGsmSendersForSelect.map((gsmSenderRow) => ({
233
+ label: gsmSenderRow?.value || gsmSenderRow?.label,
234
+ value: gsmSenderRow?.value,
235
+ }));
236
+ },
237
+ [channel, registeredSenderIds, selectedDomainGsmSenders, smsTraiDltEnabled],
238
+ );
239
+
240
+ const emailSenderOptions = useMemo(
241
+ () => selectedDomainEmailSenders.map((emailSenderRow) => ({
242
+ label: emailSenderRow.value || emailSenderRow.label,
243
+ value: emailSenderRow.value,
244
+ senderLabel: emailSenderRow.label,
245
+ })),
246
+ [selectedDomainEmailSenders],
247
+ );
248
+
249
+ const emailSenderIdOptions = useMemo(
250
+ () => selectedDomainEmailSenders.map((emailSender) => ({
251
+ label: emailSender.label || emailSender.value,
252
+ value: emailSender.label || emailSender.value,
253
+ senderEmail: emailSender.value,
254
+ })),
255
+ [selectedDomainEmailSenders],
256
+ );
257
+
258
+ const emailReplyToOptions = useMemo(
259
+ () => selectedDomainEmailRepliers.map((emailReplyTo) => ({
260
+ label: emailReplyTo.value || emailReplyTo.label,
261
+ value: emailReplyTo.value,
262
+ })),
263
+ [selectedDomainEmailRepliers],
264
+ );
265
+
266
+ const wecrmAccountOptions = useMemo(
267
+ () => (wecrmAccounts || []).map((wecrmAccount) => ({
268
+ label: wecrmAccount.name || wecrmAccount.sourceAccountIdentifier,
269
+ value: wecrmAccount.sourceAccountIdentifier,
270
+ ...wecrmAccount,
271
+ })),
272
+ [wecrmAccounts],
273
+ );
274
+
275
+ const whatsappAccountOptionsForDisplay = useMemo(() => {
276
+ if (!isWhatsappAccountLocked || !whatsappAccountFromForm?.accountName) return wecrmAccountOptions;
277
+ const name = whatsappAccountFromForm.accountName;
278
+ const match = wecrmAccountOptions.find(
279
+ (a) => (a.label === name || a.name === name),
280
+ );
281
+ if (match) return [match];
282
+ return [{ label: name, value: name }];
283
+ }, [isWhatsappAccountLocked, whatsappAccountFromForm?.accountName, wecrmAccountOptions]);
284
+
285
+ const whatsappSenderOptions = useMemo(() => {
286
+ const selectedAccId = get(localSettings, DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER);
287
+ if (!selectedAccId) {
288
+ return (senderDetailsOptions || []).flatMap((senderDetails) => (senderDetails.gsmSenders || []).map((gsmSender) => ({
289
+ label: gsmSender.value,
290
+ value: gsmSender.value,
291
+ })));
292
+ }
293
+ const domainForAccount = (senderDetailsOptions || []).find(
294
+ (senderDetails) => senderDetails?.sourceAccountIdentifier === selectedAccId,
295
+ );
296
+ return (domainForAccount?.gsmSenders || []).map((gsmSender) => ({
297
+ label: gsmSender.value,
298
+ value: gsmSender.value,
299
+ }));
300
+ }, [senderDetailsOptions, localSettings.sourceAccountIdentifier]);
301
+
302
+ const updateSetting = useCallback((key, value) => {
303
+ setLocalSettings((prev) => {
304
+ const next = cloneDeep(prev);
305
+ next[key] = value;
306
+ return next;
307
+ });
308
+ }, []);
309
+
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
+ const onDomainChange = useCallback(
334
+ (value) => {
335
+ const domain = domainOptions.find((domainOption) => domainOption.value === value);
336
+ updateSetting(DELIVERY_SETTING_KEY_DOMAIN_ID, value);
337
+ 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
+ if (channel === CHANNELS.SMS && domain) {
350
+ const smsGsmSenders = smsTraiDltEnabled && registeredSenderIds?.length
351
+ ? (domain.gsmSenders || []).filter((gsmId) => registeredSenderIds.includes(gsmId.value))
352
+ : domain.gsmSenders;
353
+ const def = findDefault(smsGsmSenders);
354
+ updateSetting(DELIVERY_SETTING_KEY_GSM_SENDER_ID, def?.value || '');
355
+ const defCdma = findDefault(domain.cdmaSenders);
356
+ updateSetting(DELIVERY_SETTING_KEY_CDMA_SENDER_ID, defCdma?.value || '');
357
+ }
358
+ if (channel === CHANNELS.EMAIL && domain) {
359
+ const defSender = findDefault(domain.emailSenders);
360
+ const defReply = findDefault(domain.emailRepliers);
361
+ updateSetting(DELIVERY_SETTING_KEY_SENDER_EMAIL, defSender?.value || '');
362
+ updateSetting(DELIVERY_SETTING_KEY_SENDER_LABEL, defSender?.label || '');
363
+ updateSetting(DELIVERY_SETTING_KEY_SENDER_REPLY_TO, defReply?.value || '');
364
+ }
365
+ },
366
+ [channel, domainOptions, registeredSenderIds, smsTraiDltEnabled, updateSetting],
367
+ );
368
+
369
+ 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);
382
+ if (onClose) onClose();
383
+ }, [channel, localSettings, onSaveDeliverySettings, onClose, rcsSenderOptions, smsSenderOptions]);
384
+
385
+ const renderSelectRow = useCallback(
386
+ ({
387
+ titleMessage, options, value, onChange, rowKey, disabled,
388
+ }) => (
389
+ <CapRow className="modify-delivery-settings__field-row" key={rowKey}>
390
+ <CapHeader
391
+ size="label"
392
+ title={<FormattedMessage {...titleMessage} />}
393
+ className="modify-delivery-settings__field-header"
394
+ />
395
+ <CapSelect
396
+ options={options}
397
+ value={value}
398
+ onChange={onChange}
399
+ placeholder={noOptionsLabel}
400
+ componentClassName={`modify-delivery-settings__select${disabled ? ' modify-delivery-settings__select--disabled' : ''}`}
401
+ disabled={disabled}
402
+ />
403
+ {disabled && <CapLabel type="label3">{formatMessage(messages.disabledMessage)}</CapLabel>}
404
+ </CapRow>
405
+ ),
406
+ [noOptionsLabel],
407
+ );
408
+
409
+ const getChannelFields = useCallback(() => {
410
+ const smsFields = [
411
+ {
412
+ titleMessage: messages.senderDomainLabel,
413
+ options: domainOptions,
414
+ value: get(localSettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
415
+ onChange: (val) => onDomainChange(val),
416
+ },
417
+ {
418
+ titleMessage: messages.senderIdLabel,
419
+ options: gsmOptions,
420
+ value: get(localSettings, DELIVERY_SETTING_KEY_GSM_SENDER_ID),
421
+ onChange: (val) => updateSetting(DELIVERY_SETTING_KEY_GSM_SENDER_ID, val),
422
+ },
423
+ ];
424
+ const emailFields = [
425
+ {
426
+ titleMessage: messages.emailDomainLabel,
427
+ options: domainOptions,
428
+ value: get(localSettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
429
+ onChange: (val) => onDomainChange(val),
430
+ },
431
+ {
432
+ titleMessage: messages.senderIdLabel,
433
+ options: emailSenderOptions,
434
+ value: get(localSettings, DELIVERY_SETTING_KEY_SENDER_EMAIL),
435
+ onChange: (val) => {
436
+ const sender = selectedDomainEmailSenders.find(
437
+ (emailSenderRow) => emailSenderRow.value === val,
438
+ );
439
+ updateSetting(DELIVERY_SETTING_KEY_SENDER_EMAIL, val);
440
+ updateSetting(DELIVERY_SETTING_KEY_SENDER_LABEL, sender?.label || val);
441
+ },
442
+ },
443
+ {
444
+ titleMessage: messages.senderNameLabelEmail,
445
+ options: emailSenderIdOptions,
446
+ value: get(localSettings, DELIVERY_SETTING_KEY_SENDER_LABEL) || '',
447
+ onChange: (val) => {
448
+ const sender = selectedDomainEmailSenders.find(
449
+ (emailSenderRow) => (emailSenderRow.label || emailSenderRow.value) === val,
450
+ );
451
+ if (sender) {
452
+ updateSetting(DELIVERY_SETTING_KEY_SENDER_EMAIL, sender.value);
453
+ updateSetting(DELIVERY_SETTING_KEY_SENDER_LABEL, sender.label || sender.value);
454
+ } else {
455
+ updateSetting(DELIVERY_SETTING_KEY_SENDER_LABEL, val);
456
+ }
457
+ },
458
+ },
459
+ {
460
+ titleMessage: messages.replyToIdLabel,
461
+ options: emailReplyToOptions,
462
+ value: get(localSettings, DELIVERY_SETTING_KEY_SENDER_REPLY_TO),
463
+ onChange: (val) => updateSetting(DELIVERY_SETTING_KEY_SENDER_REPLY_TO, val),
464
+ },
465
+ ];
466
+ const whatsappAccountValue = isWhatsappAccountLocked && whatsappAccountOptionsForDisplay.length > 0
467
+ ? whatsappAccountOptionsForDisplay[0]?.value
468
+ : get(localSettings, DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER);
469
+ const whatsappFields = [
470
+ {
471
+ titleMessage: messages.accountLabel,
472
+ options: whatsappAccountOptionsForDisplay,
473
+ value: whatsappAccountValue,
474
+ onChange: (val) => {
475
+ updateSetting(DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER, val);
476
+ const domain = (senderDetailsOptions || []).find(
477
+ (whatsappAccountRow) => whatsappAccountRow.sourceAccountIdentifier === val,
478
+ );
479
+ const first = domain?.gsmSenders?.[0];
480
+ updateSetting(DELIVERY_SETTING_KEY_SENDER_MOB_NUM, first?.value || '');
481
+ },
482
+ disabled: isWhatsappAccountLocked,
483
+ },
484
+ {
485
+ titleMessage: messages.senderNumberLabel,
486
+ options: whatsappSenderOptions,
487
+ value: get(localSettings, DELIVERY_SETTING_KEY_SENDER_MOB_NUM),
488
+ onChange: (val) => updateSetting(DELIVERY_SETTING_KEY_SENDER_MOB_NUM, val),
489
+ },
490
+ ];
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
+ const byChannel = {
520
+ [CHANNELS.SMS]: smsFields,
521
+ [CHANNELS.EMAIL]: emailFields,
522
+ [CHANNELS.WHATSAPP]: whatsappFields,
523
+ [CHANNELS.RCS]: rcsFields,
524
+ };
525
+ return byChannel[channel] || [];
526
+ }, [
527
+ channel,
528
+ domainOptions,
529
+ gsmOptions,
530
+ emailSenderOptions,
531
+ emailSenderIdOptions,
532
+ emailReplyToOptions,
533
+ wecrmAccountOptions,
534
+ whatsappAccountOptionsForDisplay,
535
+ whatsappSenderOptions,
536
+ rcsSenderOptions,
537
+ rcsGsmSenderIdForSelect,
538
+ smsSenderOptions,
539
+ smsFallbackGsmIdForSelect,
540
+ smsFallbackDomainOptions,
541
+ smsFallbackSenderDetailsOptions,
542
+ onSmsFallbackDomainChange,
543
+ localSettings,
544
+ selectedDomainEmailSenders,
545
+ senderDetailsOptions,
546
+ onDomainChange,
547
+ updateSetting,
548
+ isWhatsappAccountLocked,
549
+ whatsappAccountFromForm,
550
+ ]);
551
+
552
+ if (isLoading) {
553
+ return (
554
+ <CapRow className="modify-delivery-settings__loading-row">
555
+ <CapSpin spinning />
556
+ </CapRow>
557
+ );
558
+ }
559
+
560
+ return (
561
+ <CapRow className="modify-delivery-settings">
562
+ {getChannelFields().map((field, idx) => renderSelectRow({
563
+ ...field,
564
+ rowKey: field.titleMessage?.id || `${ROW_KEY_PREFIX}${idx}`,
565
+ disabled: field.disabled,
566
+ }))}
567
+ <CapRow className="modify-delivery-settings__actions">
568
+ <CapButton type="primary" onClick={handleDone}>
569
+ <FormattedMessage {...messages.done} />
570
+ </CapButton>
571
+ </CapRow>
572
+ </CapRow>
573
+ );
574
+ };
575
+
576
+ ModifyDeliverySettings.propTypes = {
577
+ channel: PropTypes.oneOf([CHANNELS.SMS, CHANNELS.EMAIL, CHANNELS.WHATSAPP, CHANNELS.RCS]).isRequired,
578
+ deliverySettings: PropTypes.object,
579
+ senderDetailsOptions: PropTypes.array,
580
+ smsFallbackSenderDetailsOptions: PropTypes.array,
581
+ wecrmAccounts: PropTypes.array,
582
+ onSaveDeliverySettings: PropTypes.func.isRequired,
583
+ onClose: PropTypes.func,
584
+ isLoading: PropTypes.bool,
585
+ formatMessage: PropTypes.func,
586
+ smsTraiDltEnabled: PropTypes.bool,
587
+ registeredSenderIds: PropTypes.array,
588
+ whatsappAccountFromForm: PropTypes.shape({
589
+ accountName: PropTypes.string,
590
+ }),
591
+ };
592
+
593
+ ModifyDeliverySettings.defaultProps = {
594
+ deliverySettings: {},
595
+ senderDetailsOptions: [],
596
+ smsFallbackSenderDetailsOptions: [],
597
+ wecrmAccounts: [],
598
+ onClose: undefined,
599
+ isLoading: false,
600
+ formatMessage: undefined,
601
+ smsTraiDltEnabled: false,
602
+ registeredSenderIds: [],
603
+ whatsappAccountFromForm: undefined,
604
+ };
605
+
606
+ export default ModifyDeliverySettings;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * ModifyDeliverySettings — styles for delivery settings form (SMS, Email, WhatsApp).
3
+ * Field rows, select width, and actions row.
4
+ */
5
+ @import '~@capillarytech/cap-ui-library/styles/_variables.scss';
6
+
7
+ .modify-delivery-settings {
8
+ height: 100%;
9
+ &__field-row {
10
+ margin-bottom: $CAP_SPACE_24;
11
+ }
12
+
13
+ &__field-header {
14
+ margin-bottom: $CAP_SPACE_08;
15
+ }
16
+
17
+ &__select {
18
+ width: 22.85rem;
19
+
20
+ &--disabled {
21
+ background-color: $CAP_G08;
22
+ pointer-events: none;
23
+ }
24
+ }
25
+
26
+ &__actions {
27
+ margin-top: $CAP_SPACE_24;
28
+ position: absolute;
29
+ bottom: 0;
30
+ margin-bottom: $CAP_SPACE_16;
31
+ }
32
+
33
+ &__loading-row {
34
+ display: block;
35
+ }
36
+ }