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,160 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractTemplateVariables,
|
|
3
|
+
splitTemplateVarString,
|
|
4
|
+
splitContentByOrderedVarTokens,
|
|
5
|
+
getFallbackResolvedContent,
|
|
6
|
+
getFallbackResolvedContentForCardDisplay,
|
|
7
|
+
isDltHashVarToken,
|
|
8
|
+
isAnyTemplateVarToken,
|
|
9
|
+
} from '../templateVarUtils';
|
|
10
|
+
|
|
11
|
+
describe('templateVarUtils', () => {
|
|
12
|
+
describe('splitContentByOrderedVarTokens', () => {
|
|
13
|
+
it('pushes remainder when next token is not found in string', () => {
|
|
14
|
+
expect(splitContentByOrderedVarTokens(['{{b}}'], 'hello')).toEqual(['hello']);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('handles empty token queue by pushing remainder', () => {
|
|
18
|
+
expect(splitContentByOrderedVarTokens([], 'rest')).toEqual(['rest']);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('handles null matchedVariableTokens as empty queue', () => {
|
|
22
|
+
expect(splitContentByOrderedVarTokens(null, 'abc')).toEqual(['abc']);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('stops and pushes remainder when next token in queue is empty string', () => {
|
|
26
|
+
expect(splitContentByOrderedVarTokens(['{{a}}', ''], 'x{{a}}y')).toEqual(['x', '{{a}}', 'y']);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('splits multiple ordered tokens across content', () => {
|
|
30
|
+
expect(splitContentByOrderedVarTokens(['{{a}}', '{{b}}'], 'p{{a}}q{{b}}r')).toEqual([
|
|
31
|
+
'p',
|
|
32
|
+
'{{a}}',
|
|
33
|
+
'q',
|
|
34
|
+
'{{b}}',
|
|
35
|
+
'r',
|
|
36
|
+
]);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('returns empty segment list when content is null and queue is empty', () => {
|
|
40
|
+
expect(splitContentByOrderedVarTokens([], null)).toEqual([]);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('splitTemplateVarString', () => {
|
|
45
|
+
it('returns empty array for falsy string', () => {
|
|
46
|
+
expect(splitTemplateVarString('')).toEqual([]);
|
|
47
|
+
expect(splitTemplateVarString(null)).toEqual([]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('splits mustache segments', () => {
|
|
51
|
+
const parts = splitTemplateVarString('Hi {{name}}!');
|
|
52
|
+
expect(parts.some((p) => p.includes('name'))).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('omits empty segments after filtering', () => {
|
|
56
|
+
expect(splitTemplateVarString('a{{x}}b')).toEqual(['a', '{{x}}', 'b']);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('getFallbackResolvedContent', () => {
|
|
61
|
+
it('replaces var segments from varMapData', () => {
|
|
62
|
+
const out = getFallbackResolvedContent('{{a}}', { '{{a}}_0': 'X' });
|
|
63
|
+
expect(out).toBe('X');
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('keeps DLT token string when slot empty', () => {
|
|
67
|
+
const out = getFallbackResolvedContent('{#v#}', {});
|
|
68
|
+
expect(out).toContain('#');
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('returns empty string for mustache slot when map has no value', () => {
|
|
72
|
+
const out = getFallbackResolvedContent('Hi {{missing}}', {});
|
|
73
|
+
expect(out).toBe('Hi ');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('treats null as empty; explicit empty string is kept (cleared input)', () => {
|
|
77
|
+
expect(getFallbackResolvedContent('{{a}}', { '{{a}}_0': null })).toBe('');
|
|
78
|
+
expect(getFallbackResolvedContent('{{a}}', { '{{a}}_0': '' })).toBe('');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('keeps DLT token in preview when slot map has empty string (no tag yet)', () => {
|
|
82
|
+
expect(getFallbackResolvedContent('{#v#}', { '{#v#}_0': '' })).toBe('{#v#}');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('keeps DLT token in preview when slot map has null', () => {
|
|
86
|
+
expect(getFallbackResolvedContent('{#v#}', { '{#v#}_0': null })).toBe('{#v#}');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('uses slot replacement when value is non-empty string', () => {
|
|
90
|
+
expect(getFallbackResolvedContent('A{{b}}C', { '{{b}}_1': 'ok' })).toBe('AokC');
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('getFallbackResolvedContentForCardDisplay', () => {
|
|
95
|
+
it('shows raw tokens when map is empty or slots unset', () => {
|
|
96
|
+
expect(getFallbackResolvedContentForCardDisplay('Hi {{name}}', {})).toBe('Hi {{name}}');
|
|
97
|
+
expect(getFallbackResolvedContentForCardDisplay('{#var#}', {})).toBe('{#var#}');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('shows raw token when slot key exists but value is empty (no labels)', () => {
|
|
101
|
+
expect(getFallbackResolvedContentForCardDisplay('{#var#}', { '{#var#}_0': '' })).toBe('{#var#}');
|
|
102
|
+
expect(getFallbackResolvedContentForCardDisplay('{{a}}', { '{{a}}_0': '' })).toBe('{{a}}');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('replaces when slot has non-empty value', () => {
|
|
106
|
+
expect(getFallbackResolvedContentForCardDisplay('Hi {{name}}', { '{{name}}_1': 'Pat' })).toBe('Hi Pat');
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe('isDltHashVarToken / isAnyTemplateVarToken', () => {
|
|
111
|
+
it('detects DLT hash token', () => {
|
|
112
|
+
expect(isDltHashVarToken('{#x#}')).toBe(true);
|
|
113
|
+
expect(isDltHashVarToken('plain')).toBe(false);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('isAnyTemplateVarToken combines mustache and DLT', () => {
|
|
117
|
+
expect(isAnyTemplateVarToken('{{a}}')).toBe(true);
|
|
118
|
+
expect(isAnyTemplateVarToken('{#x#}')).toBe(true);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe('extractTemplateVariables', () => {
|
|
123
|
+
it('returns empty array for empty or missing template', () => {
|
|
124
|
+
expect(extractTemplateVariables('')).toEqual([]);
|
|
125
|
+
expect(extractTemplateVariables()).toEqual([]);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('includes DLT {#var#} names when no custom capture regex', () => {
|
|
129
|
+
const vars = extractTemplateVariables('Hello {#promo#} and {{name}}');
|
|
130
|
+
expect(vars).toEqual(expect.arrayContaining(['promo', 'name']));
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('skips DLT scan when captureRegex is provided', () => {
|
|
134
|
+
const re = /\{\{([^}]+)\}\}/g;
|
|
135
|
+
expect(extractTemplateVariables('{#x#} {{y}}', re)).toEqual(['y']);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('dedupes duplicate variable names', () => {
|
|
139
|
+
expect(extractTemplateVariables('{{a}} {{a}}')).toEqual(['a']);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it('uses default name var when DLT body capture is empty', () => {
|
|
143
|
+
const vars = extractTemplateVariables('{##}');
|
|
144
|
+
expect(vars).toContain('var');
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
describe('extractTemplateVariables (regex global)', () => {
|
|
149
|
+
it('extracts all vars when caller passes a non-global capture regex (avoids infinite exec loop)', () => {
|
|
150
|
+
const nonGlobal = /\{\{([^}]+)\}\}/;
|
|
151
|
+
expect(nonGlobal.global).toBe(false);
|
|
152
|
+
expect(extractTemplateVariables('{{a}} and {{b}}', nonGlobal)).toEqual(['a', 'b']);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('still works when capture regex already has the global flag', () => {
|
|
156
|
+
const globalRe = /\{\{([^}]+)\}\}/g;
|
|
157
|
+
expect(extractTemplateVariables('{{x}} {{y}}', globalRe)).toEqual(['x', 'y']);
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|
|
@@ -63,6 +63,7 @@ const CapDeviceContent = (props) => {
|
|
|
63
63
|
deepLinkValue,
|
|
64
64
|
setDeepLinkValue,
|
|
65
65
|
onCopyTitleAndContent,
|
|
66
|
+
isOtherDeviceSupported,
|
|
66
67
|
tags,
|
|
67
68
|
onTagSelect,
|
|
68
69
|
handleOnTagsContextChange,
|
|
@@ -167,13 +168,15 @@ const CapDeviceContent = (props) => {
|
|
|
167
168
|
return (
|
|
168
169
|
<>
|
|
169
170
|
<CapRow className="creatives-device-content">
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
171
|
+
{isOtherDeviceSupported && (
|
|
172
|
+
<CapLink
|
|
173
|
+
title={isAndroid
|
|
174
|
+
? formatMessage(messages.copyContentFromIOS)
|
|
175
|
+
: formatMessage(messages.copyCotentFromAndroid)}
|
|
176
|
+
className="inapp-copy-content"
|
|
177
|
+
onClick={onCopyTitleAndContent}
|
|
178
|
+
/>
|
|
179
|
+
)}
|
|
177
180
|
<CapRow className="creatives-inapp-title">
|
|
178
181
|
<CapColumn
|
|
179
182
|
className="inapp-content-main"
|
|
@@ -211,6 +211,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
211
211
|
} else if (info && info.selectedNodes && info.selectedNodes.length > 0 && !info.selectedNodes[0].props.isLeaf) {
|
|
212
212
|
this.handleOnExpand(selectedKeys[0]);
|
|
213
213
|
}
|
|
214
|
+
this.setState({expandedKeys: []})
|
|
214
215
|
}
|
|
215
216
|
};
|
|
216
217
|
|
|
@@ -233,6 +234,13 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
233
234
|
}
|
|
234
235
|
};
|
|
235
236
|
|
|
237
|
+
/** Single-line ellipsis within popover width; full label on hover via CapTooltip. */
|
|
238
|
+
wrapTreeTitle = (displayNode, text) => (
|
|
239
|
+
<CapTooltip title={displayNode}>
|
|
240
|
+
<CapLabel.CapLabelInline type="label15" className="cap-tag-list-tree-title-wrap">{text || displayNode}</CapLabel.CapLabelInline>
|
|
241
|
+
</CapTooltip>
|
|
242
|
+
);
|
|
243
|
+
|
|
236
244
|
renderDynamicTagFlow = () => {
|
|
237
245
|
this.setState({showModal: true, visible: false});
|
|
238
246
|
};
|
|
@@ -280,7 +288,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
280
288
|
if (temp?.length) {
|
|
281
289
|
const tagValue = (
|
|
282
290
|
<CapTreeNode
|
|
283
|
-
title={disabled ?
|
|
291
|
+
title={disabled ? this.wrapTreeTitle(loyaltyAttrDisableText, val?.name) : this.wrapTreeTitle(val?.name)}
|
|
284
292
|
tag={val}
|
|
285
293
|
key={val?.incentiveSeriesId ? `${key}(${val?.incentiveSeriesId})` : `${key}`}
|
|
286
294
|
disabled={disabled}
|
|
@@ -303,17 +311,9 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
303
311
|
<CapTreeNode
|
|
304
312
|
title={
|
|
305
313
|
childDisabled ? (
|
|
306
|
-
|
|
307
|
-
title={
|
|
308
|
-
key === CUSTOMER_BARCODE_TAG
|
|
309
|
-
? customerBarcodeDisableText
|
|
310
|
-
: loyaltyAttrDisableText
|
|
311
|
-
}
|
|
312
|
-
>
|
|
313
|
-
{val?.desc || val?.name}
|
|
314
|
-
</CapTooltip>
|
|
314
|
+
this.wrapTreeTitle(key === CUSTOMER_BARCODE_TAG ? customerBarcodeDisableText : loyaltyAttrDisableText, val?.desc || val?.name)
|
|
315
315
|
) : (
|
|
316
|
-
val?.desc || val?.name
|
|
316
|
+
this.wrapTreeTitle(val?.desc || val?.name)
|
|
317
317
|
)
|
|
318
318
|
}
|
|
319
319
|
tag={val}
|
|
@@ -339,17 +339,9 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
339
339
|
<CapTreeNode
|
|
340
340
|
title={
|
|
341
341
|
childDisabled ? (
|
|
342
|
-
|
|
343
|
-
title={
|
|
344
|
-
key === CUSTOMER_BARCODE_TAG
|
|
345
|
-
? customerBarcodeDisableText
|
|
346
|
-
: loyaltyAttrDisableText
|
|
347
|
-
}
|
|
348
|
-
>
|
|
349
|
-
{val?.desc || val?.name}
|
|
350
|
-
</CapTooltip>
|
|
342
|
+
this.wrapTreeTitle(key === CUSTOMER_BARCODE_TAG ? customerBarcodeDisableText : loyaltyAttrDisableText, val?.desc || val?.name)
|
|
351
343
|
) : (
|
|
352
|
-
val?.desc || val?.name
|
|
344
|
+
this.wrapTreeTitle(val?.desc || val?.name)
|
|
353
345
|
)
|
|
354
346
|
}
|
|
355
347
|
tag={val}
|
|
@@ -382,6 +374,9 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
382
374
|
render() {
|
|
383
375
|
const {
|
|
384
376
|
hidePopover = false, intl = {}, moduleFilterEnabled, label, modalProps, channel, fetchingSchemaError = false,
|
|
377
|
+
overlayStyle,
|
|
378
|
+
overlayClassName,
|
|
379
|
+
getPopupContainer,
|
|
385
380
|
} = this.props;
|
|
386
381
|
const {formatMessage} = intl;
|
|
387
382
|
const {
|
|
@@ -404,7 +399,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
404
399
|
},
|
|
405
400
|
];
|
|
406
401
|
const contentSection = (
|
|
407
|
-
<CapRow>
|
|
402
|
+
<CapRow className="cap-tag-list-popover-inner">
|
|
408
403
|
<CapSpin tip={formatMessage(messages.gettingTags)} spinning={shouldShowLoading}>
|
|
409
404
|
<Search
|
|
410
405
|
style={{ marginBottom: 8, width: '250px'}}
|
|
@@ -456,6 +451,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
456
451
|
</CapSpin>
|
|
457
452
|
</CapRow>
|
|
458
453
|
);
|
|
454
|
+
const {disableTooltipMsg, disabled} = this.props || {};
|
|
459
455
|
return (
|
|
460
456
|
<>
|
|
461
457
|
{hidePopover ? (
|
|
@@ -471,12 +467,18 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
471
467
|
visible={fetchingSchemaError ? false : visible}
|
|
472
468
|
onVisibleChange={this.togglePopoverVisibility}
|
|
473
469
|
content={contentSection}
|
|
470
|
+
overlayClassName="cap-tag-list-popover-overlay"
|
|
474
471
|
trigger="click"
|
|
475
472
|
placement={this.props.popoverPlacement || (channel === EMAIL.toUpperCase() ? "leftTop" : "rightTop")}
|
|
473
|
+
overlayStyle={overlayStyle}
|
|
474
|
+
overlayClassName={overlayClassName}
|
|
475
|
+
getPopupContainer={getPopupContainer}
|
|
476
476
|
>
|
|
477
477
|
<CapTooltip
|
|
478
478
|
title={
|
|
479
|
-
|
|
479
|
+
disableTooltipMsg && disabled ? (
|
|
480
|
+
disableTooltipMsg
|
|
481
|
+
) : fetchingSchemaError ? (
|
|
480
482
|
<CapRow className="tooltip-text-container">
|
|
481
483
|
<CapLabel className="tooltip-text1">
|
|
482
484
|
{formatMessage(messages.somethingWentWrong)}
|
|
@@ -485,7 +487,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
485
487
|
{formatMessage(messages.labelFetchErrorMsg)}
|
|
486
488
|
</CapLabel>
|
|
487
489
|
</CapRow>
|
|
488
|
-
)
|
|
490
|
+
) : null
|
|
489
491
|
}
|
|
490
492
|
placement="right"
|
|
491
493
|
>
|
|
@@ -538,8 +540,14 @@ CapTagList.propTypes = {
|
|
|
538
540
|
currentOrgDetails: PropTypes.object,
|
|
539
541
|
channel: PropTypes.string,
|
|
540
542
|
disabled: PropTypes.bool,
|
|
543
|
+
// Optional custom tooltip message when disabled (used for personalization restriction)
|
|
544
|
+
disableTooltipMsg: PropTypes.string,
|
|
541
545
|
fetchingSchemaError: PropTypes.bool,
|
|
542
546
|
popoverPlacement: PropTypes.string,
|
|
547
|
+
overlayStyle: PropTypes.object,
|
|
548
|
+
overlayClassName: PropTypes.string,
|
|
549
|
+
/** e.g. () => document.body — avoids overflow/stacking issues inside slideboxes */
|
|
550
|
+
getPopupContainer: PropTypes.func,
|
|
543
551
|
};
|
|
544
552
|
|
|
545
553
|
CapTagList.defaultValue = {
|
|
@@ -1,5 +1,53 @@
|
|
|
1
1
|
@import "~@capillarytech/cap-ui-library/styles/_variables";
|
|
2
2
|
|
|
3
|
+
// Tag list popover: keep overlay width aligned with search (250px); tree rows ellipsis + tooltip for full text
|
|
4
|
+
.cap-tag-list-popover-overlay.ant-popover {
|
|
5
|
+
.ant-popover-inner-content {
|
|
6
|
+
max-width: 20rem;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.cap-tag-list-popover-inner {
|
|
13
|
+
max-width: 20rem;
|
|
14
|
+
min-width: 0;
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
|
|
17
|
+
.ant-tree.cap-tree-v2.ant-tree-icon-hide {
|
|
18
|
+
width: 100%;
|
|
19
|
+
max-width: 100%;
|
|
20
|
+
|
|
21
|
+
ul {
|
|
22
|
+
max-width: 100%;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
li {
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
max-width: 100%;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
li .ant-tree-node-content-wrapper {
|
|
31
|
+
width: calc(100% - 3.5rem); // leave room for switcher (~24px)
|
|
32
|
+
max-width: calc(100% - 3.5rem);
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
vertical-align: top;
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.cap-tag-list-tree-title-wrap {
|
|
39
|
+
display: inline-block;
|
|
40
|
+
width: 100%;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
text-overflow: ellipsis;
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
max-width: 100%;
|
|
45
|
+
vertical-align: top;
|
|
46
|
+
margin-top: 0.5rem;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
3
51
|
@media (max-height: 25rem) {
|
|
4
52
|
.ant-tree.cap-tree-v2.ant-tree-icon-hide {
|
|
5
53
|
height: 8.5714rem;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { IntlProvider } from 'react-intl';
|
|
5
|
+
import CapTagListWithInput from '../index';
|
|
6
|
+
|
|
7
|
+
const capturedTagListProps = { current: null };
|
|
8
|
+
|
|
9
|
+
jest.mock('../../../v2Containers/TagList', () => {
|
|
10
|
+
const React = require('react');
|
|
11
|
+
const Mock = (props) => {
|
|
12
|
+
capturedTagListProps.current = props;
|
|
13
|
+
return <div data-testid="mock-tag-list">TagList</div>;
|
|
14
|
+
};
|
|
15
|
+
return Mock;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
jest.mock('@capillarytech/cap-ui-library/CapRow', () => ({ children }) => <div>{children}</div>);
|
|
19
|
+
jest.mock('@capillarytech/cap-ui-library/CapColumn', () => ({ children }) => <div>{children}</div>);
|
|
20
|
+
jest.mock('@capillarytech/cap-ui-library/CapHeading', () => () => null);
|
|
21
|
+
jest.mock('@capillarytech/cap-ui-library/CapInput', () => () => <input data-testid="cap-input" />);
|
|
22
|
+
|
|
23
|
+
const waitMap = {
|
|
24
|
+
b1: { eventName: 'Order Placed', blockName: 'Wait', tags: [] },
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
describe('CapTagListWithInput', () => {
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
capturedTagListProps.current = null;
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('forwards waitEventContextTags to TagList', () => {
|
|
33
|
+
render(
|
|
34
|
+
<IntlProvider locale="en" messages={{}}>
|
|
35
|
+
<CapTagListWithInput
|
|
36
|
+
inputId="test-url"
|
|
37
|
+
inputOnChange={jest.fn()}
|
|
38
|
+
waitEventContextTags={waitMap}
|
|
39
|
+
onTagSelect={jest.fn()}
|
|
40
|
+
onContextChange={jest.fn()}
|
|
41
|
+
/>
|
|
42
|
+
</IntlProvider>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
expect(screen.getByTestId('mock-tag-list')).toBeInTheDocument();
|
|
46
|
+
expect(capturedTagListProps.current.waitEventContextTags).toEqual(waitMap);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('uses default empty object for waitEventContextTags when omitted', () => {
|
|
50
|
+
render(
|
|
51
|
+
<IntlProvider locale="en" messages={{}}>
|
|
52
|
+
<CapTagListWithInput
|
|
53
|
+
inputId="test-url"
|
|
54
|
+
inputOnChange={jest.fn()}
|
|
55
|
+
onTagSelect={jest.fn()}
|
|
56
|
+
onContextChange={jest.fn()}
|
|
57
|
+
/>
|
|
58
|
+
</IntlProvider>
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
expect(capturedTagListProps.current.waitEventContextTags).toEqual({});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -26,6 +26,8 @@ export const CapTagListWithInput = (props) => {
|
|
|
26
26
|
className = '',
|
|
27
27
|
userLocale = 'en',
|
|
28
28
|
eventContextTags = [],
|
|
29
|
+
restrictPersonalization = false,
|
|
30
|
+
waitEventContextTags = {},
|
|
29
31
|
// CapInput props
|
|
30
32
|
inputId,
|
|
31
33
|
inputValue = '',
|
|
@@ -76,8 +78,10 @@ export const CapTagListWithInput = (props) => {
|
|
|
76
78
|
userLocale={userLocale}
|
|
77
79
|
selectedOfferDetails={selectedOfferDetails}
|
|
78
80
|
eventContextTags={eventContextTags}
|
|
81
|
+
waitEventContextTags={waitEventContextTags}
|
|
79
82
|
style={tagListStyle}
|
|
80
83
|
popoverPlacement={popoverPlacement}
|
|
84
|
+
restrictPersonalization={restrictPersonalization}
|
|
81
85
|
/>
|
|
82
86
|
)}
|
|
83
87
|
</CapRow>
|
|
@@ -113,6 +117,8 @@ CapTagListWithInput.propTypes = {
|
|
|
113
117
|
className: PropTypes.string,
|
|
114
118
|
userLocale: PropTypes.string,
|
|
115
119
|
eventContextTags: PropTypes.array,
|
|
120
|
+
restrictPersonalization: PropTypes.bool,
|
|
121
|
+
waitEventContextTags: PropTypes.object,
|
|
116
122
|
|
|
117
123
|
// CapInput props
|
|
118
124
|
inputId: PropTypes.string.isRequired,
|
|
@@ -150,6 +156,8 @@ CapTagListWithInput.defaultProps = {
|
|
|
150
156
|
className: '',
|
|
151
157
|
userLocale: 'en',
|
|
152
158
|
eventContextTags: [],
|
|
159
|
+
restrictPersonalization: false,
|
|
160
|
+
waitEventContextTags: {},
|
|
153
161
|
inputValue: '',
|
|
154
162
|
inputSize: 'default',
|
|
155
163
|
inputRequired: false,
|
|
@@ -52,6 +52,7 @@ export const CapWhatsappCTA = (props) => {
|
|
|
52
52
|
injectedTags = {},
|
|
53
53
|
selectedOfferDetails = [],
|
|
54
54
|
eventContextTags = [],
|
|
55
|
+
waitEventContextTags = {},
|
|
55
56
|
} = props;
|
|
56
57
|
const { formatMessage } = intl;
|
|
57
58
|
const invalidVarRegex = /{{(.*?)}}/g;
|
|
@@ -283,6 +284,7 @@ export const CapWhatsappCTA = (props) => {
|
|
|
283
284
|
injectedTags={injectedTags}
|
|
284
285
|
selectedOfferDetails={selectedOfferDetails}
|
|
285
286
|
eventContextTags={eventContextTags}
|
|
287
|
+
waitEventContextTags={waitEventContextTags}
|
|
286
288
|
/>
|
|
287
289
|
</CapColumn>
|
|
288
290
|
)}
|
|
@@ -55,19 +55,26 @@ export const CapWhatsappCarouselButton = (props) => {
|
|
|
55
55
|
const invalidVarRegex = /{{(.*?)}}/g;
|
|
56
56
|
|
|
57
57
|
const handleButtonType = ({ target: { value } }, buttonIndex) => {
|
|
58
|
-
const cloneCarouselData = cloneDeep(carouselData);
|
|
59
58
|
const dataMap = {
|
|
60
59
|
[PHONE_NUMBER]: INITIAL_CAROUSEL_PHONE_NUMBER_DATA,
|
|
61
60
|
[URL]: INITIAL_CAROUSEL_URL_DATA,
|
|
62
61
|
[QUICK_REPLY]: INITIAL_CAROUSEL_QUICK_REPLY_DATA,
|
|
63
62
|
};
|
|
63
|
+
const initialData = dataMap[value];
|
|
64
|
+
const newButtonData = initialData ? cloneDeep(initialData) : {};
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
setCarouselData(
|
|
67
|
+
carouselData.map((item, index) =>
|
|
68
|
+
index === carouselIndex
|
|
69
|
+
? {
|
|
70
|
+
...item,
|
|
71
|
+
buttons: item.buttons.map((btn, i) =>
|
|
72
|
+
i === buttonIndex ? newButtonData : btn
|
|
73
|
+
),
|
|
74
|
+
}
|
|
75
|
+
: item
|
|
76
|
+
)
|
|
77
|
+
);
|
|
71
78
|
};
|
|
72
79
|
|
|
73
80
|
const onValueChange = (buttonIndex, fields = []) => {
|
|
@@ -148,17 +155,28 @@ export const CapWhatsappCarouselButton = (props) => {
|
|
|
148
155
|
};
|
|
149
156
|
|
|
150
157
|
const handleDeleteButton = (buttonIndex) => {
|
|
151
|
-
setCarouselData((prevData) =>
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
158
|
+
setCarouselData((prevData) =>
|
|
159
|
+
prevData.map((carousel, index) =>
|
|
160
|
+
index === carouselIndex
|
|
161
|
+
? {
|
|
162
|
+
...carousel,
|
|
163
|
+
buttons: carousel.buttons.filter((_, i) => i !== buttonIndex),
|
|
164
|
+
}
|
|
165
|
+
: carousel
|
|
166
|
+
)
|
|
167
|
+
);
|
|
155
168
|
};
|
|
156
169
|
|
|
157
170
|
const addCarouselButton = () => {
|
|
158
171
|
setCarouselData(
|
|
159
|
-
carouselData.map((item, index) =>
|
|
160
|
-
|
|
161
|
-
|
|
172
|
+
carouselData.map((item, index) =>
|
|
173
|
+
index === carouselIndex
|
|
174
|
+
? {
|
|
175
|
+
...item,
|
|
176
|
+
buttons: [...buttonData, cloneDeep(INITIAL_CAROUSEL_PHONE_NUMBER_DATA)],
|
|
177
|
+
}
|
|
178
|
+
: item
|
|
179
|
+
)
|
|
162
180
|
);
|
|
163
181
|
};
|
|
164
182
|
|