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.
- package/.github/workflows/pr-title-check.yml +88 -0
- package/app/constants/unified.js +21 -1
- package/app/containers/App/constants.js +0 -1
- package/app/containers/Login/test/index.test.js +123 -0
- package/app/containers/Login/test/selectors.test.js +165 -0
- package/app/initialState.js +0 -2
- package/app/services/api.js +6 -0
- package/app/services/tests/api.test.js +7 -0
- package/app/services/tests/getSchema.test.js +95 -0
- package/app/utils/common.js +23 -9
- package/app/utils/commonUtils.js +64 -93
- package/app/utils/tagValidations.js +83 -219
- package/app/utils/templateVarUtils.js +172 -0
- package/app/utils/tests/common.test.js +265 -323
- package/app/utils/tests/commonUtil.test.js +461 -118
- package/app/utils/tests/commonUtils.test.js +581 -0
- package/app/utils/tests/messageUtils.test.js +95 -0
- package/app/utils/tests/smsCharCount.test.js +304 -0
- package/app/utils/tests/smsCharCountV2.test.js +213 -10
- package/app/utils/tests/tagValidations.test.js +474 -357
- package/app/utils/tests/templateVarUtils.test.js +160 -0
- package/app/v2Components/CapDeviceContent/index.js +10 -7
- package/app/v2Components/CapTagList/index.js +32 -24
- package/app/v2Components/CapTagList/style.scss +48 -0
- package/app/v2Components/CapTagListWithInput/__tests__/CapTagListWithInput.test.js +63 -0
- package/app/v2Components/CapTagListWithInput/index.js +8 -0
- package/app/v2Components/CapWhatsappCTA/index.js +2 -0
- package/app/v2Components/CapWhatsappCarouselButton/index.js +32 -14
- package/app/v2Components/CapWhatsappCarouselButton/tests/index.test.js +120 -2
- package/app/v2Components/CommonTestAndPreview/CustomValuesEditor.js +70 -49
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +39 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +606 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.scss +36 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +79 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/index.js +314 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +141 -0
- package/app/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +156 -0
- package/app/v2Components/CommonTestAndPreview/SendTestMessage.js +57 -1
- package/app/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +20 -1
- package/app/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +133 -4
- package/app/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +210 -4
- package/app/v2Components/CommonTestAndPreview/actions.js +20 -0
- package/app/v2Components/CommonTestAndPreview/constants.js +57 -1
- package/app/v2Components/CommonTestAndPreview/index.js +878 -156
- package/app/v2Components/CommonTestAndPreview/messages.js +41 -3
- package/app/v2Components/CommonTestAndPreview/previewApiUtils.js +59 -0
- package/app/v2Components/CommonTestAndPreview/reducer.js +47 -0
- package/app/v2Components/CommonTestAndPreview/sagas.js +75 -5
- package/app/v2Components/CommonTestAndPreview/selectors.js +51 -0
- package/app/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +352 -0
- package/app/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +1156 -0
- package/app/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +334 -0
- package/app/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +576 -0
- package/app/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +156 -0
- package/app/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +199 -1
- package/app/v2Components/CommonTestAndPreview/tests/actions.test.js +50 -0
- package/app/v2Components/CommonTestAndPreview/tests/constants.test.js +18 -7
- package/app/v2Components/CommonTestAndPreview/tests/index.test.js +914 -5
- package/app/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +67 -0
- package/app/v2Components/CommonTestAndPreview/tests/reducer.test.js +118 -0
- package/app/v2Components/CommonTestAndPreview/tests/sagas.test.js +146 -378
- package/app/v2Components/CommonTestAndPreview/tests/selectors.test.js +146 -0
- package/app/v2Components/ErrorInfoNote/index.js +24 -26
- package/app/v2Components/FormBuilder/index.js +182 -204
- package/app/v2Components/FormBuilder/messages.js +4 -8
- package/app/v2Components/HtmlEditor/HTMLEditor.js +7 -6
- package/app/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +1 -1
- package/app/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +928 -17
- package/app/v2Components/HtmlEditor/components/CodeEditorPane/index.js +4 -2
- package/app/v2Components/HtmlEditor/hooks/__tests__/useValidation.test.js +452 -3
- package/app/v2Components/HtmlEditor/hooks/useValidation.js +12 -9
- package/app/v2Components/HtmlEditor/utils/__tests__/htmlValidator.enhanced.test.js +132 -0
- package/app/v2Components/HtmlEditor/utils/htmlValidator.js +4 -2
- package/app/v2Components/SmsFallback/SmsFallbackLocalSelector.js +87 -0
- package/app/v2Components/SmsFallback/constants.js +73 -0
- package/app/v2Components/SmsFallback/index.js +956 -0
- package/app/v2Components/SmsFallback/index.scss +265 -0
- package/app/v2Components/SmsFallback/messages.js +78 -0
- package/app/v2Components/SmsFallback/smsFallbackUtils.js +107 -0
- package/app/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +50 -0
- package/app/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +147 -0
- package/app/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +304 -0
- package/app/v2Components/SmsFallback/tests/smsFallbackUi.test.js +197 -0
- package/app/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +261 -0
- package/app/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +422 -0
- package/app/v2Components/SmsFallback/useLocalTemplateList.js +92 -0
- package/app/v2Components/TestAndPreviewSlidebox/index.js +22 -1
- package/app/v2Components/TestAndPreviewSlidebox/sagas.js +11 -4
- package/app/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +3 -1
- package/app/v2Components/VarSegmentMessageEditor/constants.js +2 -0
- package/app/v2Components/VarSegmentMessageEditor/index.js +125 -0
- package/app/v2Components/VarSegmentMessageEditor/index.scss +46 -0
- package/app/v2Containers/BeeEditor/index.js +3 -0
- package/app/v2Containers/BeePopupEditor/index.js +9 -2
- package/app/v2Containers/Cap/mockData.js +0 -14
- package/app/v2Containers/Cap/reducer.js +3 -55
- package/app/v2Containers/Cap/tests/reducer.test.js +0 -102
- package/app/v2Containers/CommunicationFlow/CommunicationFlow.js +291 -0
- package/app/v2Containers/CommunicationFlow/CommunicationFlow.scss +25 -0
- package/app/v2Containers/CommunicationFlow/Tests/CommunicationFlow.test.js +255 -0
- package/app/v2Containers/CommunicationFlow/constants.js +200 -0
- package/app/v2Containers/CommunicationFlow/index.js +102 -0
- package/app/v2Containers/CommunicationFlow/messages.js +346 -0
- package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.js +522 -0
- package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.scss +170 -0
- package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/ChannelSelectionStep.test.js +796 -0
- package/app/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/index.js +5 -0
- package/app/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/CommunicationStrategyStep.js +95 -0
- package/app/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/Tests/CommunicationStrategyStep.test.js +133 -0
- package/app/v2Containers/CommunicationFlow/steps/CommunicationStrategyStep/index.js +5 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js +289 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.scss +70 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.js +319 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.scss +69 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/DeliverySettingsSection.test.js +616 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/SenderDetails.test.js +577 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/deliverySettingsConfig.test.js +1111 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/deliverySettingsConfig.js +696 -0
- package/app/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/index.js +7 -0
- package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/DynamicControlsStep.js +102 -0
- package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/DynamicControlsStep.scss +36 -0
- package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/Tests/DynamicControlsStep.test.js +91 -0
- package/app/v2Containers/CommunicationFlow/steps/DynamicControlsStep/index.js +5 -0
- package/app/v2Containers/CommunicationFlow/steps/MessageTypeStep/MessageTypeStep.js +86 -0
- package/app/v2Containers/CommunicationFlow/steps/MessageTypeStep/Tests/MessageTypeStep.test.js +100 -0
- package/app/v2Containers/CommunicationFlow/steps/MessageTypeStep/index.js +5 -0
- package/app/v2Containers/CommunicationFlow/utils/getEnabledSteps.js +30 -0
- package/app/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +43 -0
- package/app/v2Containers/CreativesContainer/SlideBoxContent.js +127 -11
- package/app/v2Containers/CreativesContainer/SlideBoxFooter.js +62 -9
- package/app/v2Containers/CreativesContainer/SlideBoxHeader.js +29 -4
- package/app/v2Containers/CreativesContainer/constants.js +24 -0
- package/app/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +67 -0
- package/app/v2Containers/CreativesContainer/index.js +346 -71
- package/app/v2Containers/CreativesContainer/index.scss +51 -1
- package/app/v2Containers/CreativesContainer/messages.js +12 -0
- package/app/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +90 -0
- package/app/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +69 -1
- package/app/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +443 -0
- package/app/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +110 -0
- package/app/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +147 -4
- package/app/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +363 -0
- package/app/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +57 -10
- package/app/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +258 -0
- package/app/v2Containers/CreativesContainer/tests/index.test.js +71 -9
- package/app/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +125 -0
- package/app/v2Containers/Email/index.js +2 -5
- package/app/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +58 -77
- package/app/v2Containers/EmailWrapper/components/EmailWrapperView.js +3 -0
- package/app/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +158 -89
- package/app/v2Containers/EmailWrapper/components/__tests__/EmailWrapperView.test.js +16 -1
- package/app/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +17 -12
- package/app/v2Containers/EmailWrapper/index.js +4 -0
- package/app/v2Containers/EmailWrapper/tests/useEmailWrapper.edgeCases.test.js +1 -0
- package/app/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +133 -0
- package/app/v2Containers/FTP/index.js +2 -51
- package/app/v2Containers/FTP/messages.js +0 -4
- package/app/v2Containers/InApp/__tests__/InAppHTMLEditor.test.js +110 -155
- package/app/v2Containers/InApp/index.js +297 -118
- package/app/v2Containers/InApp/tests/index.test.js +17 -6
- package/app/v2Containers/InApp/tests/mockData.js +1 -1
- package/app/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +19 -0
- package/app/v2Containers/InAppWrapper/hooks/useInAppWrapper.js +3 -0
- package/app/v2Containers/InAppWrapper/index.js +3 -0
- package/app/v2Containers/InappAdvance/index.js +5 -104
- package/app/v2Containers/InappAdvance/tests/index.test.js +2 -0
- package/app/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +24 -3
- package/app/v2Containers/Line/Container/Text/index.js +0 -1
- package/app/v2Containers/MobilePush/Create/index.js +105 -28
- package/app/v2Containers/MobilePush/Create/messages.js +4 -0
- package/app/v2Containers/MobilePush/Edit/index.js +250 -68
- package/app/v2Containers/MobilePush/Edit/messages.js +4 -0
- package/app/v2Containers/MobilePushNew/components/PlatformContentFields.js +36 -12
- package/app/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +68 -27
- package/app/v2Containers/MobilePushNew/index.js +78 -35
- package/app/v2Containers/MobilePushNew/messages.js +8 -0
- package/app/v2Containers/MobilepushWrapper/index.js +11 -1
- package/app/v2Containers/Rcs/constants.js +32 -1
- package/app/v2Containers/Rcs/index.js +963 -916
- package/app/v2Containers/Rcs/index.scss +85 -6
- package/app/v2Containers/Rcs/messages.js +10 -1
- package/app/v2Containers/Rcs/rcsLibraryHydrationUtils.js +205 -0
- package/app/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +41136 -1566
- package/app/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +0 -5
- package/app/v2Containers/Rcs/tests/index.test.js +41 -38
- package/app/v2Containers/Rcs/tests/mockData.js +38 -0
- package/app/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +251 -0
- package/app/v2Containers/Rcs/tests/utils.test.js +379 -1
- package/app/v2Containers/Rcs/utils.js +358 -10
- package/app/v2Containers/Sms/Create/index.js +122 -39
- package/app/v2Containers/Sms/Create/messages.js +4 -0
- package/app/v2Containers/Sms/Edit/index.js +37 -3
- package/app/v2Containers/Sms/commonMethods.js +3 -6
- package/app/v2Containers/Sms/smsFormDataHelpers.js +67 -0
- package/app/v2Containers/Sms/tests/commonMethods.test.js +122 -0
- package/app/v2Containers/Sms/tests/smsFormDataHelpers.test.js +253 -0
- package/app/v2Containers/SmsTrai/Create/index.js +9 -4
- package/app/v2Containers/SmsTrai/Create/index.scss +1 -1
- package/app/v2Containers/SmsTrai/Edit/constants.js +2 -0
- package/app/v2Containers/SmsTrai/Edit/index.js +667 -160
- package/app/v2Containers/SmsTrai/Edit/index.scss +121 -0
- package/app/v2Containers/SmsTrai/Edit/messages.js +9 -4
- package/app/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4590 -2436
- package/app/v2Containers/SmsWrapper/index.js +41 -8
- package/app/v2Containers/TagList/index.js +63 -2
- package/app/v2Containers/TagList/messages.js +8 -0
- package/app/v2Containers/TagList/tests/TagList.test.js +122 -20
- package/app/v2Containers/TagList/tests/mockdata.js +17 -0
- package/app/v2Containers/Templates/TemplatesActionBar.js +101 -0
- package/app/v2Containers/Templates/_templates.scss +61 -2
- package/app/v2Containers/Templates/actions.js +11 -0
- package/app/v2Containers/Templates/constants.js +2 -0
- package/app/v2Containers/Templates/index.js +90 -40
- package/app/v2Containers/Templates/reducer.js +3 -1
- package/app/v2Containers/Templates/sagas.js +57 -12
- package/app/v2Containers/Templates/tests/TemplatesActionBar.test.js +120 -0
- package/app/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1043 -1079
- package/app/v2Containers/Templates/tests/reducer.test.js +12 -0
- package/app/v2Containers/Templates/tests/sagas.test.js +193 -12
- package/app/v2Containers/Templates/tests/smsTemplatesListApi.test.js +180 -0
- package/app/v2Containers/Templates/utils/smsTemplatesListApi.js +79 -0
- package/app/v2Containers/TemplatesV2/TemplatesV2.style.js +72 -1
- package/app/v2Containers/TemplatesV2/index.js +147 -49
- package/app/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +131 -0
- package/app/v2Containers/Viber/index.js +9 -10
- package/app/v2Containers/Viber/index.scss +1 -1
- package/app/v2Containers/WebPush/Create/components/BrandIconSection.test.js +264 -0
- package/app/v2Containers/WebPush/Create/components/MessageSection.js +78 -19
- package/app/v2Containers/WebPush/Create/components/MessageSection.test.js +82 -0
- package/app/v2Containers/WebPush/Create/components/__snapshots__/BrandIconSection.test.js.snap +187 -0
- package/app/v2Containers/WebPush/Create/components/__snapshots__/MessageSection.test.js.snap +25 -17
- package/app/v2Containers/WebPush/Create/hooks/useAiraTriggerPosition.js +80 -0
- package/app/v2Containers/WebPush/Create/hooks/useAiraTriggerPosition.test.js +210 -0
- package/app/v2Containers/WebPush/Create/hooks/useTagManagement.js +1 -5
- package/app/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +0 -7
- package/app/v2Containers/WebPush/Create/index.js +36 -6
- package/app/v2Containers/WebPush/Create/index.scss +5 -0
- package/app/v2Containers/WebPush/Create/messages.js +8 -1
- package/app/v2Containers/WebPush/Create/preview/tests/NotificationContainer.test.js +269 -0
- package/app/v2Containers/WebPush/Create/utils/validation.js +31 -15
- package/app/v2Containers/WebPush/Create/utils/validation.test.js +72 -24
- package/app/v2Containers/Whatsapp/index.js +28 -53
- package/app/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +26939 -3982
- package/app/v2Containers/Whatsapp/tests/index.test.js +172 -0
- package/app/v2Containers/Zalo/index.js +5 -11
- package/package.json +2 -2
- package/version +9 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeliverySettings constants for Test and Preview (SMS, Email, WhatsApp).
|
|
3
|
+
* Aligned with cap-campaigns-v2 DeliverySettingsV2/ModifyDeliverySettings field names.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { CHANNELS } from '../constants';
|
|
7
|
+
|
|
8
|
+
/** Placeholder shown in summary when a value is empty */
|
|
9
|
+
export const SUMMARY_EMPTY_PLACEHOLDER = '—';
|
|
10
|
+
|
|
11
|
+
/** Channel names — use CHANNELS.SMS, CHANNELS.EMAIL, CHANNELS.WHATSAPP from parent constants */
|
|
12
|
+
export { CHANNELS } from '../constants';
|
|
13
|
+
|
|
14
|
+
/** Delivery settings object keys (for get(deliverySettings, key) / updateSetting(key, value)) */
|
|
15
|
+
export const DELIVERY_SETTING_KEY_DOMAIN_ID = 'domainId';
|
|
16
|
+
export const DELIVERY_SETTING_KEY_DOMAIN_GATEWAY_MAP_ID = 'domainGatewayMapId';
|
|
17
|
+
export const DELIVERY_SETTING_KEY_GSM_SENDER_ID = 'gsmSenderId';
|
|
18
|
+
export const DELIVERY_SETTING_KEY_CDMA_SENDER_ID = 'cdmaSenderId';
|
|
19
|
+
export const DELIVERY_SETTING_KEY_SENDER_EMAIL = 'senderEmail';
|
|
20
|
+
export const DELIVERY_SETTING_KEY_SENDER_LABEL = 'senderLabel';
|
|
21
|
+
export const DELIVERY_SETTING_KEY_SENDER_REPLY_TO = 'senderReplyTo';
|
|
22
|
+
export const DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER = 'sourceAccountIdentifier';
|
|
23
|
+
export const DELIVERY_SETTING_KEY_SENDER_MOB_NUM = 'senderMobNum';
|
|
24
|
+
/** RCS: SMS fallback domain (separate from primary RCS domainId) */
|
|
25
|
+
export const DELIVERY_SETTING_KEY_SMS_FALLBACK_DOMAIN_ID = 'smsFallbackDomainId';
|
|
26
|
+
|
|
27
|
+
/** data-testid for delivery settings edit icon */
|
|
28
|
+
export const TEST_ID_DELIVERY_SETTINGS_EDIT = 'delivery-settings-edit';
|
|
29
|
+
|
|
30
|
+
/** Prefix for row keys in field list map */
|
|
31
|
+
export const ROW_KEY_PREFIX = 'row-';
|
|
32
|
+
|
|
33
|
+
export const CHANNELS_WITH_DELIVERY_SETTINGS = [
|
|
34
|
+
CHANNELS.SMS,
|
|
35
|
+
CHANNELS.EMAIL,
|
|
36
|
+
CHANNELS.WHATSAPP,
|
|
37
|
+
CHANNELS.RCS,
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
/** Default empty delivery setting per channel (campaigns-style shape) */
|
|
41
|
+
export const DEFAULT_DELIVERY_SETTING_SMS = {
|
|
42
|
+
domainId: null,
|
|
43
|
+
domainGatewayMapId: null,
|
|
44
|
+
gsmSenderId: '',
|
|
45
|
+
cdmaSenderId: '',
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const DEFAULT_DELIVERY_SETTING_EMAIL = {
|
|
49
|
+
domainId: null,
|
|
50
|
+
domainGatewayMapId: null,
|
|
51
|
+
senderEmail: '',
|
|
52
|
+
senderLabel: '',
|
|
53
|
+
senderReplyTo: '',
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const DEFAULT_DELIVERY_SETTING_WHATSAPP = {
|
|
57
|
+
domainId: null,
|
|
58
|
+
senderMobNum: '',
|
|
59
|
+
sourceAccountIdentifier: '',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/** RCS: gsmSenderId = RCS sender, cdmaSenderId = SMS fallback sender (reuse same keys) */
|
|
63
|
+
export const DEFAULT_DELIVERY_SETTING_RCS = {
|
|
64
|
+
domainId: null,
|
|
65
|
+
domainGatewayMapId: null,
|
|
66
|
+
gsmSenderId: '',
|
|
67
|
+
smsFallbackDomainId: null,
|
|
68
|
+
cdmaSenderId: '',
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export const DEFAULT_DELIVERY_SETTINGS_BY_CHANNEL = {
|
|
72
|
+
[CHANNELS.SMS]: DEFAULT_DELIVERY_SETTING_SMS,
|
|
73
|
+
[CHANNELS.EMAIL]: DEFAULT_DELIVERY_SETTING_EMAIL,
|
|
74
|
+
[CHANNELS.WHATSAPP]: DEFAULT_DELIVERY_SETTING_WHATSAPP,
|
|
75
|
+
[CHANNELS.RCS]: DEFAULT_DELIVERY_SETTING_RCS,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** API `contactInfo.type` keys that map to RCS-style GSM sender rows (env-specific naming). */
|
|
79
|
+
export const RCS_CONTACT_INFO_GSM_TYPE_KEYS = ['gsm_sender_id', 'rcs_sender_id', 'rcs_sender'];
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeliverySettings — summary row + CapSlideBox trigger for Test and Preview.
|
|
3
|
+
* Rendered for SMS, Email, WhatsApp, RCS (ModifyDeliverySettings). RCS uses gsmSenderId + cdmaSenderId (SMS fallback).
|
|
4
|
+
*
|
|
5
|
+
* Reference: cap-campaigns-v2 DeliverySettingsV2 (summary + modify panel).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import React, { useState, useCallback, useMemo } from "react";
|
|
9
|
+
import PropTypes from "prop-types";
|
|
10
|
+
import CapRow from "@capillarytech/cap-ui-library/CapRow";
|
|
11
|
+
import CapHeading from "@capillarytech/cap-ui-library/CapHeading";
|
|
12
|
+
import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
|
|
13
|
+
import CapLabel from "@capillarytech/cap-ui-library/CapLabel";
|
|
14
|
+
import CapSlideBox from "@capillarytech/cap-ui-library/CapSlideBox";
|
|
15
|
+
import { FormattedMessage } from "react-intl";
|
|
16
|
+
import get from "lodash/get";
|
|
17
|
+
import messages from "./messages";
|
|
18
|
+
import ModifyDeliverySettings from "./ModifyDeliverySettings";
|
|
19
|
+
import {
|
|
20
|
+
CHANNELS,
|
|
21
|
+
CHANNELS_WITH_DELIVERY_SETTINGS,
|
|
22
|
+
SUMMARY_EMPTY_PLACEHOLDER,
|
|
23
|
+
DELIVERY_SETTING_KEY_DOMAIN_ID,
|
|
24
|
+
DELIVERY_SETTING_KEY_GSM_SENDER_ID,
|
|
25
|
+
DELIVERY_SETTING_KEY_CDMA_SENDER_ID,
|
|
26
|
+
DELIVERY_SETTING_KEY_SENDER_EMAIL,
|
|
27
|
+
DELIVERY_SETTING_KEY_SENDER_LABEL,
|
|
28
|
+
DELIVERY_SETTING_KEY_SENDER_REPLY_TO,
|
|
29
|
+
DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER,
|
|
30
|
+
DELIVERY_SETTING_KEY_SENDER_MOB_NUM,
|
|
31
|
+
TEST_ID_DELIVERY_SETTINGS_EDIT,
|
|
32
|
+
} from "./constants";
|
|
33
|
+
import "./DeliverySettings.scss";
|
|
34
|
+
|
|
35
|
+
const DeliverySettings = (props) => {
|
|
36
|
+
const {
|
|
37
|
+
channel,
|
|
38
|
+
deliverySettings = {},
|
|
39
|
+
senderDetailsByChannel = {},
|
|
40
|
+
wecrmAccounts = [],
|
|
41
|
+
onSaveDeliverySettings,
|
|
42
|
+
isLoadingSenderDetails,
|
|
43
|
+
formatMessage,
|
|
44
|
+
smsTraiDltEnabled,
|
|
45
|
+
registeredSenderIds,
|
|
46
|
+
whatsappAccountFromForm,
|
|
47
|
+
isChannelSmsFallbackPreviewEnabled,
|
|
48
|
+
} = props;
|
|
49
|
+
|
|
50
|
+
const [isSlideBoxOpen, setSlideBoxOpen] = useState(false);
|
|
51
|
+
|
|
52
|
+
const openSlideBox = useCallback(() => setSlideBoxOpen(true), []);
|
|
53
|
+
const closeSlideBox = useCallback(() => setSlideBoxOpen(false), []);
|
|
54
|
+
|
|
55
|
+
const handleSave = useCallback(
|
|
56
|
+
(values) => {
|
|
57
|
+
onSaveDeliverySettings(values);
|
|
58
|
+
closeSlideBox();
|
|
59
|
+
},
|
|
60
|
+
[onSaveDeliverySettings, closeSlideBox]
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const senderDetailsOptions = useMemo(
|
|
64
|
+
() => (senderDetailsByChannel[channel] || []),
|
|
65
|
+
[senderDetailsByChannel, channel],
|
|
66
|
+
);
|
|
67
|
+
const smsDomainsForRcs = useMemo(
|
|
68
|
+
() => (channel === CHANNELS.RCS ? (senderDetailsByChannel[CHANNELS.SMS] || []) : []),
|
|
69
|
+
[channel, senderDetailsByChannel],
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
if (!CHANNELS_WITH_DELIVERY_SETTINGS.includes(channel)) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const notConfiguredLabel = formatMessage(messages.notConfigured);
|
|
77
|
+
|
|
78
|
+
const getDisplayFromDomains = (domains, compositeValue) => {
|
|
79
|
+
if (!compositeValue || !domains?.length) return compositeValue || SUMMARY_EMPTY_PLACEHOLDER;
|
|
80
|
+
for (const senderDomain of domains) {
|
|
81
|
+
for (const gsmSenderRow of senderDomain.gsmSenders || []) {
|
|
82
|
+
const value = senderDomain.domainId != null && gsmSenderRow.value != null
|
|
83
|
+
? `${senderDomain.domainId}|${gsmSenderRow.value}`
|
|
84
|
+
: gsmSenderRow.value;
|
|
85
|
+
if (value === compositeValue && (senderDomain.domainName || gsmSenderRow.value)) {
|
|
86
|
+
return [senderDomain.domainName, gsmSenderRow.value].filter(Boolean).join(' · ');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return compositeValue || SUMMARY_EMPTY_PLACEHOLDER;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/** RCS summary: show sender ID only (no "domain · sender"). */
|
|
94
|
+
const getSenderIdOnlyFromComposite = (domains, compositeValue) => {
|
|
95
|
+
if (!compositeValue || !domains?.length) return compositeValue || SUMMARY_EMPTY_PLACEHOLDER;
|
|
96
|
+
for (const senderDomain of domains) {
|
|
97
|
+
for (const gsmSenderRow of senderDomain.gsmSenders || []) {
|
|
98
|
+
const value = senderDomain.domainId != null && gsmSenderRow.value != null
|
|
99
|
+
? `${senderDomain.domainId}|${gsmSenderRow.value}`
|
|
100
|
+
: gsmSenderRow.value;
|
|
101
|
+
if (value === compositeValue && gsmSenderRow.value != null) {
|
|
102
|
+
return String(gsmSenderRow.value);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return compositeValue || SUMMARY_EMPTY_PLACEHOLDER;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const getSummaryText = () => {
|
|
110
|
+
const empty = SUMMARY_EMPTY_PLACEHOLDER;
|
|
111
|
+
if (channel === CHANNELS.RCS) {
|
|
112
|
+
const rcsVal = get(deliverySettings, DELIVERY_SETTING_KEY_GSM_SENDER_ID) || '';
|
|
113
|
+
const smsVal = get(deliverySettings, DELIVERY_SETTING_KEY_CDMA_SENDER_ID) || '';
|
|
114
|
+
const summaryRcs = {
|
|
115
|
+
rcsSenderId: getSenderIdOnlyFromComposite(senderDetailsOptions, rcsVal),
|
|
116
|
+
};
|
|
117
|
+
if (isChannelSmsFallbackPreviewEnabled) {
|
|
118
|
+
summaryRcs.smsFallbackSenderId = getSenderIdOnlyFromComposite(smsDomainsForRcs, smsVal);
|
|
119
|
+
}
|
|
120
|
+
return summaryRcs;
|
|
121
|
+
}
|
|
122
|
+
if (channel === CHANNELS.SMS) {
|
|
123
|
+
const domain = (senderDetailsOptions || []).find(
|
|
124
|
+
(senderDomain) => senderDomain.domainId === get(deliverySettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
|
|
125
|
+
);
|
|
126
|
+
const domainName = domain?.domainName || empty;
|
|
127
|
+
const senderId = get(deliverySettings, DELIVERY_SETTING_KEY_GSM_SENDER_ID) || empty;
|
|
128
|
+
return { senderDomain: domainName, senderId };
|
|
129
|
+
}
|
|
130
|
+
if (channel === CHANNELS.EMAIL) {
|
|
131
|
+
const domain = (senderDetailsOptions || []).find(
|
|
132
|
+
(senderDomain) => senderDomain.domainId === get(deliverySettings, DELIVERY_SETTING_KEY_DOMAIN_ID),
|
|
133
|
+
);
|
|
134
|
+
const emailDomain = domain?.domainName || empty;
|
|
135
|
+
const senderEmail = get(deliverySettings, DELIVERY_SETTING_KEY_SENDER_EMAIL) || empty;
|
|
136
|
+
const senderLabel = get(deliverySettings, DELIVERY_SETTING_KEY_SENDER_LABEL) || empty;
|
|
137
|
+
const replyToId = get(deliverySettings, DELIVERY_SETTING_KEY_SENDER_REPLY_TO) || empty;
|
|
138
|
+
return {
|
|
139
|
+
emailDomain,
|
|
140
|
+
senderEmail,
|
|
141
|
+
senderLabel,
|
|
142
|
+
replyToId,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
if (channel === CHANNELS.WHATSAPP) {
|
|
146
|
+
const account = (wecrmAccounts || []).find(
|
|
147
|
+
(a) => a.sourceAccountIdentifier
|
|
148
|
+
=== get(deliverySettings, DELIVERY_SETTING_KEY_SOURCE_ACCOUNT_IDENTIFIER),
|
|
149
|
+
);
|
|
150
|
+
const accountName = account?.name || empty;
|
|
151
|
+
const senderNumber = get(deliverySettings, DELIVERY_SETTING_KEY_SENDER_MOB_NUM) || empty;
|
|
152
|
+
return { account: accountName, senderNumber };
|
|
153
|
+
}
|
|
154
|
+
return { account: empty, sender: empty };
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const summary = getSummaryText();
|
|
158
|
+
let hasValues = false;
|
|
159
|
+
if (channel === CHANNELS.RCS) {
|
|
160
|
+
hasValues = (summary.rcsSenderId && summary.rcsSenderId !== SUMMARY_EMPTY_PLACEHOLDER)
|
|
161
|
+
|| (isChannelSmsFallbackPreviewEnabled
|
|
162
|
+
&& summary.smsFallbackSenderId
|
|
163
|
+
&& summary.smsFallbackSenderId !== SUMMARY_EMPTY_PLACEHOLDER);
|
|
164
|
+
} else if (channel === CHANNELS.SMS) {
|
|
165
|
+
hasValues = summary.senderDomain !== SUMMARY_EMPTY_PLACEHOLDER
|
|
166
|
+
|| summary.senderId !== SUMMARY_EMPTY_PLACEHOLDER;
|
|
167
|
+
} else if (channel === CHANNELS.EMAIL) {
|
|
168
|
+
hasValues = summary.emailDomain !== SUMMARY_EMPTY_PLACEHOLDER
|
|
169
|
+
|| summary.senderEmail !== SUMMARY_EMPTY_PLACEHOLDER
|
|
170
|
+
|| summary.senderLabel !== SUMMARY_EMPTY_PLACEHOLDER
|
|
171
|
+
|| summary.replyToId !== SUMMARY_EMPTY_PLACEHOLDER;
|
|
172
|
+
} else if (channel === CHANNELS.WHATSAPP) {
|
|
173
|
+
hasValues = summary.account !== SUMMARY_EMPTY_PLACEHOLDER
|
|
174
|
+
|| summary.senderNumber !== SUMMARY_EMPTY_PLACEHOLDER;
|
|
175
|
+
} else {
|
|
176
|
+
hasValues = summary.account !== SUMMARY_EMPTY_PLACEHOLDER
|
|
177
|
+
|| summary.sender !== SUMMARY_EMPTY_PLACEHOLDER;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const getSummaryObject = () => {
|
|
181
|
+
if (!hasValues) return null;
|
|
182
|
+
const label = (msg) => formatMessage(msg);
|
|
183
|
+
if (channel === CHANNELS.RCS) {
|
|
184
|
+
const rcsSummary = {
|
|
185
|
+
[label(messages.rcsSenderIdLabel)]: summary.rcsSenderId,
|
|
186
|
+
};
|
|
187
|
+
if (isChannelSmsFallbackPreviewEnabled) {
|
|
188
|
+
rcsSummary[label(messages.fallbackSmsSenderIdLabel)] = summary.smsFallbackSenderId;
|
|
189
|
+
}
|
|
190
|
+
return rcsSummary;
|
|
191
|
+
}
|
|
192
|
+
if (channel === CHANNELS.SMS) {
|
|
193
|
+
return {
|
|
194
|
+
[label(messages.senderDomainSummary)]: summary.senderDomain,
|
|
195
|
+
[label(messages.senderId)]: summary.senderId,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
if (channel === CHANNELS.EMAIL) {
|
|
199
|
+
return {
|
|
200
|
+
[label(messages.emailDomain)]: summary.emailDomain,
|
|
201
|
+
[label(messages.senderId)]: summary.senderEmail,
|
|
202
|
+
[label(messages.senderName)]: summary.senderLabel,
|
|
203
|
+
[label(messages.replyToId)]: summary.replyToId,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
if (channel === CHANNELS.WHATSAPP) {
|
|
207
|
+
return {
|
|
208
|
+
[label(messages.account)]: summary.account,
|
|
209
|
+
[label(messages.senderNumber)]: summary.senderNumber,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
[label(messages.account)]: summary.account,
|
|
214
|
+
[label(messages.senderNumber)]: summary.sender,
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
const summaryObject = getSummaryObject();
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<CapRow className="delivery-settings">
|
|
222
|
+
<CapRow className="delivery-settings__heading-row">
|
|
223
|
+
<CapHeading type="h10">
|
|
224
|
+
<FormattedMessage {...messages.deliverySettings} />
|
|
225
|
+
</CapHeading>
|
|
226
|
+
</CapRow>
|
|
227
|
+
<CapRow type="flex" className="delivery-settings__summary-row">
|
|
228
|
+
<CapRow type="flex" className="delivery-settings__summary-inner">
|
|
229
|
+
{summaryObject == null ? (
|
|
230
|
+
<CapLabel type="label2">{notConfiguredLabel}</CapLabel>
|
|
231
|
+
) : (
|
|
232
|
+
Object.entries(summaryObject).map(([key, value]) => (
|
|
233
|
+
<CapRow type="flex" key={key} className="delivery-settings__summary-entry">
|
|
234
|
+
<CapLabel type="label1" className="delivery-settings__summary-key">{key}</CapLabel>
|
|
235
|
+
<CapLabel type="label9" className="delivery-settings__summary-value">
|
|
236
|
+
:
|
|
237
|
+
{' '}
|
|
238
|
+
{value}
|
|
239
|
+
</CapLabel>
|
|
240
|
+
</CapRow>
|
|
241
|
+
))
|
|
242
|
+
)}
|
|
243
|
+
</CapRow>
|
|
244
|
+
<CapIcon
|
|
245
|
+
type="edit"
|
|
246
|
+
onClick={openSlideBox}
|
|
247
|
+
className="delivery-settings__edit-icon"
|
|
248
|
+
data-testid={TEST_ID_DELIVERY_SETTINGS_EDIT}
|
|
249
|
+
size="s"
|
|
250
|
+
/>
|
|
251
|
+
</CapRow>
|
|
252
|
+
|
|
253
|
+
{isSlideBoxOpen && (
|
|
254
|
+
<CapSlideBox
|
|
255
|
+
show
|
|
256
|
+
size="size-l"
|
|
257
|
+
header={<FormattedMessage {...messages.deliverySettings} />}
|
|
258
|
+
handleClose={closeSlideBox}
|
|
259
|
+
content={(
|
|
260
|
+
<ModifyDeliverySettings
|
|
261
|
+
channel={channel}
|
|
262
|
+
deliverySettings={deliverySettings}
|
|
263
|
+
senderDetailsOptions={senderDetailsOptions}
|
|
264
|
+
smsFallbackSenderDetailsOptions={
|
|
265
|
+
channel === CHANNELS.RCS && isChannelSmsFallbackPreviewEnabled
|
|
266
|
+
? smsDomainsForRcs
|
|
267
|
+
: undefined
|
|
268
|
+
}
|
|
269
|
+
wecrmAccounts={wecrmAccounts}
|
|
270
|
+
onSaveDeliverySettings={handleSave}
|
|
271
|
+
onClose={closeSlideBox}
|
|
272
|
+
isLoading={isLoadingSenderDetails}
|
|
273
|
+
formatMessage={formatMessage}
|
|
274
|
+
smsTraiDltEnabled={smsTraiDltEnabled}
|
|
275
|
+
registeredSenderIds={registeredSenderIds}
|
|
276
|
+
whatsappAccountFromForm={whatsappAccountFromForm}
|
|
277
|
+
/>
|
|
278
|
+
)}
|
|
279
|
+
/>
|
|
280
|
+
)}
|
|
281
|
+
</CapRow>
|
|
282
|
+
);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
DeliverySettings.propTypes = {
|
|
286
|
+
channel: PropTypes.string.isRequired,
|
|
287
|
+
deliverySettings: PropTypes.object,
|
|
288
|
+
senderDetailsByChannel: PropTypes.object,
|
|
289
|
+
wecrmAccounts: PropTypes.array,
|
|
290
|
+
onSaveDeliverySettings: PropTypes.func,
|
|
291
|
+
isLoadingSenderDetails: PropTypes.bool,
|
|
292
|
+
formatMessage: PropTypes.func,
|
|
293
|
+
smsTraiDltEnabled: PropTypes.bool,
|
|
294
|
+
registeredSenderIds: PropTypes.array,
|
|
295
|
+
whatsappAccountFromForm: PropTypes.shape({
|
|
296
|
+
accountName: PropTypes.string,
|
|
297
|
+
}),
|
|
298
|
+
isChannelSmsFallbackPreviewEnabled: PropTypes.bool,
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
DeliverySettings.defaultProps = {
|
|
302
|
+
deliverySettings: {},
|
|
303
|
+
senderDetailsByChannel: {},
|
|
304
|
+
wecrmAccounts: [],
|
|
305
|
+
onSaveDeliverySettings: () => {},
|
|
306
|
+
isLoadingSenderDetails: false,
|
|
307
|
+
formatMessage: undefined,
|
|
308
|
+
smsTraiDltEnabled: false,
|
|
309
|
+
registeredSenderIds: [],
|
|
310
|
+
whatsappAccountFromForm: undefined,
|
|
311
|
+
isChannelSmsFallbackPreviewEnabled: false,
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
export default DeliverySettings;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DeliverySettings messages for Test and Preview.
|
|
3
|
+
* Aligned with cap-campaigns-v2 DeliverySettingsV2 and ModifyDeliverySettings messages.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { defineMessages } from 'react-intl';
|
|
7
|
+
|
|
8
|
+
const prefix = 'creatives.CommonTestAndPreview.DeliverySettings';
|
|
9
|
+
|
|
10
|
+
export default defineMessages({
|
|
11
|
+
deliverySettings: {
|
|
12
|
+
id: `${prefix}.deliverySettings`,
|
|
13
|
+
defaultMessage: 'Delivery settings',
|
|
14
|
+
},
|
|
15
|
+
notConfigured: {
|
|
16
|
+
id: `${prefix}.notConfigured`,
|
|
17
|
+
defaultMessage: 'Not configured',
|
|
18
|
+
},
|
|
19
|
+
account: {
|
|
20
|
+
id: `${prefix}.account`,
|
|
21
|
+
defaultMessage: 'Account',
|
|
22
|
+
},
|
|
23
|
+
senderNumber: {
|
|
24
|
+
id: `${prefix}.senderNumber`,
|
|
25
|
+
defaultMessage: 'Sender number',
|
|
26
|
+
},
|
|
27
|
+
senderDomain: {
|
|
28
|
+
id: `${prefix}.senderDomain`,
|
|
29
|
+
defaultMessage: 'Sender domain',
|
|
30
|
+
},
|
|
31
|
+
senderId: {
|
|
32
|
+
id: `${prefix}.senderId`,
|
|
33
|
+
defaultMessage: 'Sender ID',
|
|
34
|
+
},
|
|
35
|
+
senderName: {
|
|
36
|
+
id: `${prefix}.senderName`,
|
|
37
|
+
defaultMessage: 'Sender name',
|
|
38
|
+
},
|
|
39
|
+
replyToId: {
|
|
40
|
+
id: `${prefix}.replyToId`,
|
|
41
|
+
defaultMessage: 'Reply-to ID',
|
|
42
|
+
},
|
|
43
|
+
done: {
|
|
44
|
+
id: `${prefix}.done`,
|
|
45
|
+
defaultMessage: 'Done',
|
|
46
|
+
},
|
|
47
|
+
smsDomain: {
|
|
48
|
+
id: `${prefix}.smsDomain`,
|
|
49
|
+
defaultMessage: 'SMS Domain',
|
|
50
|
+
},
|
|
51
|
+
/** SMS summary & form: "Sender Domain" (capital D) for summary line */
|
|
52
|
+
senderDomainSummary: {
|
|
53
|
+
id: `${prefix}.senderDomainSummary`,
|
|
54
|
+
defaultMessage: 'Sender Domain',
|
|
55
|
+
},
|
|
56
|
+
/** SMS form label with colon: "Sender domain:" */
|
|
57
|
+
senderDomainLabel: {
|
|
58
|
+
id: `${prefix}.senderDomainLabel`,
|
|
59
|
+
defaultMessage: 'Sender domain:',
|
|
60
|
+
},
|
|
61
|
+
/** SMS form label with colon: "Sender ID:" */
|
|
62
|
+
senderIdLabel: {
|
|
63
|
+
id: `${prefix}.senderIdLabel`,
|
|
64
|
+
defaultMessage: 'Sender ID:',
|
|
65
|
+
},
|
|
66
|
+
emailDomain: {
|
|
67
|
+
id: `${prefix}.emailDomain`,
|
|
68
|
+
defaultMessage: 'Email Domain',
|
|
69
|
+
},
|
|
70
|
+
/** Email form/summary: "Email domain:" (with colon) */
|
|
71
|
+
emailDomainLabel: {
|
|
72
|
+
id: `${prefix}.emailDomainLabel`,
|
|
73
|
+
defaultMessage: 'Email domain:',
|
|
74
|
+
},
|
|
75
|
+
/** Email form: "Sender ID:" (with colon) */
|
|
76
|
+
senderNameLabelEmail: {
|
|
77
|
+
id: `${prefix}.senderIdLabelEmail`,
|
|
78
|
+
defaultMessage: 'Sender Name:',
|
|
79
|
+
},
|
|
80
|
+
/** Email form/summary: "Reply-to ID:" (with colon) */
|
|
81
|
+
replyToIdLabel: {
|
|
82
|
+
id: `${prefix}.replyToIdLabel`,
|
|
83
|
+
defaultMessage: 'Reply-to ID:',
|
|
84
|
+
},
|
|
85
|
+
whatsappBusinessAcc: {
|
|
86
|
+
id: `${prefix}.whatsappBusinessAcc`,
|
|
87
|
+
defaultMessage: 'WhatsApp business account',
|
|
88
|
+
},
|
|
89
|
+
whatsappSenderNum: {
|
|
90
|
+
id: `${prefix}.whatsappSenderNum`,
|
|
91
|
+
defaultMessage: 'WhatsApp sender number',
|
|
92
|
+
},
|
|
93
|
+
/** WhatsApp form/summary: "Account:" (with colon) */
|
|
94
|
+
accountLabel: {
|
|
95
|
+
id: `${prefix}.accountLabel`,
|
|
96
|
+
defaultMessage: 'Account:',
|
|
97
|
+
},
|
|
98
|
+
/** WhatsApp form/summary: "Sender number:" (with colon) */
|
|
99
|
+
senderNumberLabel: {
|
|
100
|
+
id: `${prefix}.senderNumberLabel`,
|
|
101
|
+
defaultMessage: 'Sender number:',
|
|
102
|
+
},
|
|
103
|
+
noOptions: {
|
|
104
|
+
id: `${prefix}.noOptions`,
|
|
105
|
+
defaultMessage: 'No options',
|
|
106
|
+
},
|
|
107
|
+
disabledMessage: {
|
|
108
|
+
id: `${prefix}.disabledMessage`,
|
|
109
|
+
defaultMessage: 'Message template selected belongs to this account',
|
|
110
|
+
},
|
|
111
|
+
/** RCS: primary domain (slidebox) */
|
|
112
|
+
rcsDomainLabel: {
|
|
113
|
+
id: `${prefix}.rcsDomainLabel`,
|
|
114
|
+
defaultMessage: 'RCS domain:',
|
|
115
|
+
},
|
|
116
|
+
/** RCS: SMS fallback domain (slidebox) */
|
|
117
|
+
fallbackSmsDomainLabel: {
|
|
118
|
+
id: `${prefix}.fallbackSmsDomainLabel`,
|
|
119
|
+
defaultMessage: 'Fallback SMS domain:',
|
|
120
|
+
},
|
|
121
|
+
/** RCS: "RCS sender ID" */
|
|
122
|
+
rcsSenderIdLabel: {
|
|
123
|
+
id: `${prefix}.rcsSenderIdLabel`,
|
|
124
|
+
defaultMessage: 'RCS sender ID',
|
|
125
|
+
},
|
|
126
|
+
/** RCS: "Fallback SMS sender ID" */
|
|
127
|
+
fallbackSmsSenderIdLabel: {
|
|
128
|
+
id: `${prefix}.fallbackSmsSenderIdLabel`,
|
|
129
|
+
defaultMessage: 'Fallback SMS sender ID',
|
|
130
|
+
},
|
|
131
|
+
/** RCS: "Domain" (for domain · sender ID display) */
|
|
132
|
+
domainLabel: {
|
|
133
|
+
id: `${prefix}.domainLabel`,
|
|
134
|
+
defaultMessage: 'Domain',
|
|
135
|
+
},
|
|
136
|
+
/** RCS: placeholder for sender ID dropdown */
|
|
137
|
+
selectSenderId: {
|
|
138
|
+
id: `${prefix}.selectSenderId`,
|
|
139
|
+
defaultMessage: 'Select sender ID',
|
|
140
|
+
},
|
|
141
|
+
});
|
package/app/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalize getSenderDetails(channel, orgUnitId) API response for a single channel.
|
|
3
|
+
* Output shape matches cap-campaigns-v2 parseSenderDetails so UI can consume
|
|
4
|
+
* domains with domainId, domainName, gsmSenders, emailSenders, emailRepliers, etc.
|
|
5
|
+
*
|
|
6
|
+
* Reference: cap-campaigns-v2 app/utils/parseSenderDetails.js
|
|
7
|
+
* No cross-repo imports; logic aligned with campaigns domain structure.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import get from 'lodash/get';
|
|
11
|
+
import { CHANNELS } from '../../constants';
|
|
12
|
+
import { RCS_CONTACT_INFO_GSM_TYPE_KEYS } from '../constants';
|
|
13
|
+
|
|
14
|
+
/** Match API contactInfo.type (some envs use different casing). */
|
|
15
|
+
const typeMatches = (itemType, expectedKey) => {
|
|
16
|
+
if (!itemType || !expectedKey) return false;
|
|
17
|
+
const a = String(itemType).toLowerCase().replace(/-/g, '_');
|
|
18
|
+
const b = String(expectedKey).toLowerCase().replace(/-/g, '_');
|
|
19
|
+
return a === b;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Include row unless explicitly invalid — many APIs omit `valid`, which would
|
|
24
|
+
* otherwise filter out every sender (RCS/SMS lists empty in UI).
|
|
25
|
+
*/
|
|
26
|
+
const getSenderOptions = (contactInfo, key) =>
|
|
27
|
+
(contactInfo || [])
|
|
28
|
+
.filter((contactInfoItem) => typeMatches(contactInfoItem.type, key) && contactInfoItem.valid !== false)
|
|
29
|
+
.sort((contact) => (contact.default ? -1 : 0));
|
|
30
|
+
|
|
31
|
+
/** RCS APIs may label senders under several `contactInfo.type` keys — see `RCS_CONTACT_INFO_GSM_TYPE_KEYS`. */
|
|
32
|
+
const getRcsLikeGsmSenders = (contactInfo) => {
|
|
33
|
+
const seen = new Set();
|
|
34
|
+
const merged = [];
|
|
35
|
+
RCS_CONTACT_INFO_GSM_TYPE_KEYS.forEach((key) => {
|
|
36
|
+
getSenderOptions(contactInfo, key).forEach((row) => {
|
|
37
|
+
const v = row?.value;
|
|
38
|
+
// Skip empty/whitespace — they still pass `v != null` for "" and pollute RCS sender dropdowns.
|
|
39
|
+
if (v == null || String(v).trim() === '' || seen.has(v)) return;
|
|
40
|
+
seen.add(v);
|
|
41
|
+
merged.push(row);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
return merged.sort((a, b) => (a.default ? -1 : 0) - (b.default ? -1 : 0));
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Campaigns domainProperties may return { entity } or { result: { entity } } / { data: { entity } }.
|
|
49
|
+
*/
|
|
50
|
+
function unwrapEntity(response) {
|
|
51
|
+
if (!response || typeof response !== 'object') return null;
|
|
52
|
+
if (response.entity != null) return response.entity;
|
|
53
|
+
const nested = get(response, 'result.entity') ?? get(response, 'data.entity');
|
|
54
|
+
if (nested != null) return nested;
|
|
55
|
+
if (response.entity === null) return null;
|
|
56
|
+
return response;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Parse raw API response for one channel into { domains: [...] }
|
|
61
|
+
* @param {string} channel - SMS | EMAIL | WHATSAPP | RCS
|
|
62
|
+
* @param {Object} response - API response (e.g. { entity: { SMS: [...] } } or { entity: [...] })
|
|
63
|
+
* @returns {{ domains: Array }} - domains array compatible with campaigns DeliverySettingsV2
|
|
64
|
+
*/
|
|
65
|
+
export function parseSenderDetailsResponse(channel, response) {
|
|
66
|
+
const entity = unwrapEntity(response);
|
|
67
|
+
if (entity == null || entity === '') {
|
|
68
|
+
return { domains: [] };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Normalize once: entity keys may be any casing (SMS/sms/rcs) but downstream branches use CHANNELS.* (uppercase).
|
|
72
|
+
const normalizedChannel =
|
|
73
|
+
channel == null || String(channel).trim() === ''
|
|
74
|
+
? ''
|
|
75
|
+
: String(channel).trim().toUpperCase();
|
|
76
|
+
|
|
77
|
+
// Single-channel API: entity may be { [channel]: [...] } or direct array.
|
|
78
|
+
// Some responses use different casing (e.g. rcs vs RCS) or a single domain object instead of an array.
|
|
79
|
+
let channelSenderDetails =
|
|
80
|
+
get(entity, channel, null)
|
|
81
|
+
?? (normalizedChannel ? get(entity, normalizedChannel, null) : null)
|
|
82
|
+
?? (normalizedChannel ? get(entity, normalizedChannel.toLowerCase(), null) : null);
|
|
83
|
+
|
|
84
|
+
if (channelSenderDetails == null && Array.isArray(entity)) {
|
|
85
|
+
channelSenderDetails = entity;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (channelSenderDetails != null && !Array.isArray(channelSenderDetails)) {
|
|
89
|
+
const single = channelSenderDetails;
|
|
90
|
+
if (single && typeof single === 'object' && single.domainProperties) {
|
|
91
|
+
channelSenderDetails = [single];
|
|
92
|
+
} else {
|
|
93
|
+
return { domains: [] };
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!Array.isArray(channelSenderDetails)) {
|
|
98
|
+
return { domains: [] };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const domains = [];
|
|
102
|
+
|
|
103
|
+
channelSenderDetails.forEach((element) => {
|
|
104
|
+
const { id: dgmId, priority, domainProperties = {} } = element;
|
|
105
|
+
const {
|
|
106
|
+
domainName,
|
|
107
|
+
hostName,
|
|
108
|
+
id = -1,
|
|
109
|
+
contactInfo,
|
|
110
|
+
connectionProperties: {
|
|
111
|
+
sourceAccountIdentifier = '',
|
|
112
|
+
wabaId = '',
|
|
113
|
+
userid = '',
|
|
114
|
+
} = {},
|
|
115
|
+
} = domainProperties;
|
|
116
|
+
|
|
117
|
+
const resolvedDomainName = domainName || hostName;
|
|
118
|
+
|
|
119
|
+
const domain = {
|
|
120
|
+
dgmId,
|
|
121
|
+
domainName: resolvedDomainName,
|
|
122
|
+
domainId: id,
|
|
123
|
+
priority: priority != null ? priority : 0,
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
if ([CHANNELS.SMS, CHANNELS.WHATSAPP, CHANNELS.RCS].includes(normalizedChannel)) {
|
|
127
|
+
domain.cdmaSenders = getSenderOptions(contactInfo, 'cdma_sender_id');
|
|
128
|
+
domain.gsmSenders = normalizedChannel === CHANNELS.RCS
|
|
129
|
+
? getRcsLikeGsmSenders(contactInfo)
|
|
130
|
+
: getSenderOptions(contactInfo, 'gsm_sender_id');
|
|
131
|
+
domain.sourceAccountIdentifier =
|
|
132
|
+
sourceAccountIdentifier || wabaId || userid || '';
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (normalizedChannel === CHANNELS.EMAIL) {
|
|
136
|
+
domain.emailSenders = getSenderOptions(contactInfo, 'sender_id');
|
|
137
|
+
domain.emailRepliers = getSenderOptions(contactInfo, 'reply_to_id');
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
domains.push(domain);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Sort by priority and dedupe by domainName (match campaigns behaviour)
|
|
144
|
+
domains.sort((a, b) => (a.priority || 0) - (b.priority || 0));
|
|
145
|
+
const deduped = domains.reduce((acc, domain) => {
|
|
146
|
+
const key = domain.domainName ?? domain.domainId;
|
|
147
|
+
if (!acc.find((existing) => (existing.domainName ?? existing.domainId) === key)) {
|
|
148
|
+
acc.push(domain);
|
|
149
|
+
}
|
|
150
|
+
return acc;
|
|
151
|
+
}, []);
|
|
152
|
+
|
|
153
|
+
return { domains: deduped };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export default parseSenderDetailsResponse;
|