@capillarytech/creatives-library 9.1.8-alpha.sprint-cap-214249.39 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/constants/unified.js +4 -0
  2. package/package.json +1 -1
  3. package/translations/en.json +1 -0
  4. package/translations/ja-JP.json +1 -0
  5. package/translations/zh.json +1 -0
  6. package/utils/common.js +6 -0
  7. package/utils/createMobilePushPayload.js +33 -50
  8. package/utils/tagValidations.js +35 -4
  9. package/utils/templateVarUtils.js +49 -0
  10. package/utils/tests/createMobilePushPayload.test.js +8 -113
  11. package/utils/tests/tagValidations.test.js +48 -0
  12. package/utils/tests/templateVarUtils.test.js +89 -0
  13. package/v2Components/CapMpushCTA/index.js +9 -10
  14. package/v2Components/CapMpushCTA/index.scss +3 -29
  15. package/v2Components/CapTagList/TagFallbackPanel.js +124 -0
  16. package/v2Components/CapTagList/constants.js +5 -0
  17. package/v2Components/CapTagList/index.js +46 -7
  18. package/v2Components/CapTagList/messages.js +44 -0
  19. package/v2Components/CapTagList/style.scss +113 -1
  20. package/v2Components/CapTagList/tests/TagFallback.test.js +222 -0
  21. package/v2Components/CapTagList/utils.js +17 -0
  22. package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +12 -20
  23. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
  24. package/v2Components/CommonTestAndPreview/constants.js +3 -2
  25. package/v2Components/CommonTestAndPreview/index.js +61 -61
  26. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -81
  27. package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
  28. package/v2Components/CommonTestAndPreview/tests/utils.test.js +102 -0
  29. package/v2Components/CommonTestAndPreview/utils.js +42 -3
  30. package/v2Components/FormBuilder/Classic.js +24 -14
  31. package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +1 -0
  32. package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
  33. package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +57 -0
  34. package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
  35. package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +3 -0
  36. package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +5 -0
  37. package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +6 -0
  38. package/v2Components/FormBuilder/Functional/channels/sms/validate.js +3 -1
  39. package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +3 -0
  40. package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +22 -0
  41. package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
  42. package/v2Components/TemplatePreview/index.js +16 -24
  43. package/v2Components/TemplatePreview/tests/index.test.js +0 -68
  44. package/v2Containers/Cap/messages.js +4 -0
  45. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
  46. package/v2Containers/CreativesContainer/SlideBoxContent.js +6 -4
  47. package/v2Containers/CreativesContainer/index.js +1 -2
  48. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -43
  49. package/v2Containers/InApp/index.js +4 -1
  50. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
  51. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
  52. package/v2Containers/Line/Container/Text/index.js +3 -1
  53. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +16 -0
  54. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
  55. package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
  56. package/v2Containers/MobilePushNew/components/MediaUploaders.js +216 -297
  57. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +125 -158
  58. package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
  59. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +108 -464
  60. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +35 -106
  61. package/v2Containers/MobilePushNew/constants.js +0 -5
  62. package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
  63. package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -52
  64. package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -40
  65. package/v2Containers/MobilePushNew/hooks/useUpload.js +39 -29
  66. package/v2Containers/MobilePushNew/index.js +239 -488
  67. package/v2Containers/MobilePushNew/index.scss +4 -205
  68. package/v2Containers/MobilePushNew/messages.js +6 -106
  69. package/v2Containers/MobilePushNew/tests/index.test.js +1 -469
  70. package/v2Containers/MobilePushNew/tests/utils.test.js +0 -70
  71. package/v2Containers/MobilePushNew/utils.js +0 -56
  72. package/v2Containers/Rcs/index.js +8 -1
  73. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +59 -0
  74. package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
  75. package/v2Containers/SmsTrai/Edit/index.js +17 -7
  76. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +42 -0
  77. package/v2Containers/Templates/_templates.scss +2 -10
  78. package/v2Containers/Templates/index.js +81 -83
  79. package/v2Containers/Templates/tests/index.test.js +0 -68
  80. package/v2Containers/Viber/index.js +3 -1
  81. package/v2Containers/WebPush/Create/utils/validation.js +6 -0
  82. package/v2Containers/WebPush/Create/utils/validation.test.js +50 -0
  83. package/v2Containers/Whatsapp/index.js +9 -5
  84. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
  85. package/v2Containers/Zalo/index.js +4 -1
  86. package/v2Components/CapMpushCTA/tests/index.test.js +0 -89
  87. package/v2Containers/MobilePushNew/components/TapLinkActions.js +0 -76
@@ -15,11 +15,11 @@ import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
15
15
  import CapRadioGroup from "@capillarytech/cap-ui-library/CapRadioGroup";
16
16
  import CapRow from "@capillarytech/cap-ui-library/CapRow";
17
17
  import CapTab from "@capillarytech/cap-ui-library/CapTab";
18
+ import CapCheckbox from "@capillarytech/cap-ui-library/CapCheckbox";
18
19
  import CapLabel from "@capillarytech/cap-ui-library/CapLabel";
19
20
  import CapSelect from "@capillarytech/cap-ui-library/CapSelect";
20
21
  import CapInput from "@capillarytech/cap-ui-library/CapInput";
21
22
  import CapError from "@capillarytech/cap-ui-library/CapError";
22
- import CapTooltip from "@capillarytech/cap-ui-library/CapTooltip";
23
23
  import CapImageUpload from "../../../v2Components/CapImageUpload";
24
24
  import CapVideoUpload from "../../../v2Components/CapVideoUpload";
25
25
  import {
@@ -36,21 +36,14 @@ import {
36
36
  GIF,
37
37
  IMAGE,
38
38
  VIDEO,
39
+ LINK_TYPE_OPTIONS,
39
40
  DEEP_LINK,
40
41
  EXTERNAL_LINK,
41
42
  CAROUSEL,
42
- TAP_ACTION_APP,
43
43
  } from "../constants";
44
44
  import messages from "../messages";
45
- import {
46
- validateExternalLink,
47
- validateDeepLink,
48
- findSelectedDeepLink,
49
- getCarouselCardIssue,
50
- CAROUSEL_CARD_ISSUE,
51
- } from "../utils";
45
+ import { validateExternalLink, validateDeepLink } from "../utils";
52
46
  import TagList from "../../TagList";
53
- import { SavedTapLink, TapLinkSaveDelete } from "./TapLinkActions";
54
47
 
55
48
  // Initial carousel data structure
56
49
  const CAROUSEL_INITIAL_DATA = {
@@ -69,6 +62,22 @@ const CAROUSEL_INITIAL_DATA = {
69
62
  // Maximum number of carousel cards allowed
70
63
  const MAX_CAROUSEL_ALLOWED = 10;
71
64
 
65
+ // Helper function to find selected deep link with fallback to base URL
66
+ const findSelectedDeepLink = (links, value) => {
67
+ if (!links || !value) return undefined;
68
+
69
+ // Try to find exact match first
70
+ let selectedDeepLink = links.find((link) => link?.value === value);
71
+
72
+ // If no exact match and value contains query parameters, try base URL match
73
+ if (!selectedDeepLink && value?.includes('?')) {
74
+ const baseDeepLinkValue = value.split('?')[0];
75
+ selectedDeepLink = links.find((link) => link?.value === baseDeepLinkValue);
76
+ }
77
+
78
+ return selectedDeepLink;
79
+ };
80
+
72
81
  const MediaUploaders = ({
73
82
  mediaType,
74
83
  activeTab,
@@ -112,8 +121,6 @@ const MediaUploaders = ({
112
121
  // Track upload ID to prevent processing stale Redux data
113
122
  const [currentUploadId, setCurrentUploadId] = useState(null);
114
123
  const uploadIdRef = useRef(0); // Counter for generating unique upload IDs
115
- // Card whose video Re upload was clicked (its file input may belong to another card)
116
- const reuploadCardRef = useRef(null);
117
124
 
118
125
  // Track previous upload data to detect when a new upload completes
119
126
  const previousUploadDataRef = useRef(null);
@@ -158,12 +165,8 @@ const MediaUploaders = ({
158
165
  };
159
166
  }, [getCurrentCarouselData, updateCarouselCard]);
160
167
 
161
- // Clear previous media data when this pane's media type changes.
162
- // Skip re-runs from a tab switch: both panes stay mounted, and the
163
- // hidden one must not wipe the visible tab's media.
168
+ // Clear previous media data when switching media types
164
169
  useEffect(() => {
165
- if (previousMediaTypeRef.current === mediaType) return;
166
-
167
170
  // Clear carousel data when switching to non-carousel media types
168
171
  if (mediaType !== CAROUSEL) {
169
172
  setCurrentCarouselData([]);
@@ -175,15 +178,15 @@ const MediaUploaders = ({
175
178
  previousUploadDataRef.current = null;
176
179
  }
177
180
 
178
- // Clear image data when switching away from IMAGE media type (this pane's platform only)
181
+ // Clear image data when switching away from IMAGE media type
179
182
  if (mediaType !== IMAGE) {
180
- clearImageDataByMediaType(IMAGE, activeTab);
183
+ clearImageDataByMediaType(IMAGE);
181
184
  }
182
185
 
183
186
  // Clear image data when switching FROM CAROUSEL TO IMAGE
184
187
  // This prevents carousel images from appearing in IMAGE media type
185
188
  if (previousMediaTypeRef.current === CAROUSEL && mediaType === IMAGE) {
186
- clearImageDataByMediaType(IMAGE, activeTab);
189
+ clearImageDataByMediaType(IMAGE);
187
190
  }
188
191
 
189
192
  // Reset re-upload mode when switching media types
@@ -191,7 +194,7 @@ const MediaUploaders = ({
191
194
 
192
195
  // Update the previous media type ref
193
196
  previousMediaTypeRef.current = mediaType;
194
- }, [mediaType, activeTab, clearImageDataByMediaType, setCurrentCarouselData]);
197
+ }, [mediaType, clearImageDataByMediaType, setCurrentCarouselData]);
195
198
 
196
199
  // Handle platform tab changes for carousel data
197
200
  useEffect(() => {
@@ -366,7 +369,6 @@ const MediaUploaders = ({
366
369
  mediaType: value,
367
370
  imageUrl: value === IMAGE.toLowerCase() ? card.imageUrl : '',
368
371
  videoSrc: value === VIDEO.toLowerCase() ? card.videoSrc : '',
369
- videoPreviewImg: value === VIDEO.toLowerCase() ? card.videoPreviewImg : '',
370
372
  buttons: card.buttons || [{
371
373
  actionOnClick: false,
372
374
  linkType: DEEP_LINK,
@@ -380,18 +382,13 @@ const MediaUploaders = ({
380
382
  setCarouselActiveTabIndex(Number(key));
381
383
  };
382
384
 
383
- // A card is done once its media is uploaded and its tap link (if any) is filled
384
- const hasIncompleteCard = getCurrentCarouselData()?.some((card) => getCarouselCardIssue(card, deepLink));
385
-
386
385
  const addCarouselCard = () => {
387
386
  const currentData = getCurrentCarouselData();
388
- if (currentData?.length < MAX_CAROUSEL_ALLOWED && !hasIncompleteCard) {
387
+ if (currentData?.length < MAX_CAROUSEL_ALLOWED) {
389
388
  setCurrentCarouselData([
390
389
  ...currentData,
391
390
  { ...CAROUSEL_INITIAL_DATA, mediaType: carouselMediaType },
392
391
  ]);
393
- // Open the new card so its upload box is in view
394
- setCarouselActiveTabIndex(currentData.length);
395
392
  }
396
393
  };
397
394
 
@@ -441,44 +438,33 @@ const MediaUploaders = ({
441
438
  }, 100);
442
439
  };
443
440
 
444
- const tapActionOptions = [
445
- { label: formatMessage(messages.tapActionApp), value: TAP_ACTION_APP },
446
- { label: formatMessage(messages.tapActionDeepLink), value: DEEP_LINK },
447
- { label: formatMessage(messages.tapActionExternalLink), value: EXTERNAL_LINK },
448
- ];
441
+ // Action link handlers for carousel cards
442
+ const handleCarouselActionOnClickChange = (cardIndex, checked) => {
443
+ const currentData = getCurrentCarouselData();
444
+ const card = currentData[cardIndex];
445
+ const updatedButtons = [...card?.buttons];
446
+ updatedButtons[0] = { ...updatedButtons[0], actionOnClick: checked };
447
+ updateCarouselCard(cardIndex, { buttons: updatedButtons });
448
+ };
449
449
 
450
- // "When tapped, open" for a card: App turns the card action off, a link type turns it on
451
- const handleCarouselTapActionChange = (cardIndex, value) => {
450
+ const handleCarouselLinkTypeChange = (cardIndex, value) => {
452
451
  const currentData = getCurrentCarouselData();
453
452
  const card = currentData[cardIndex];
454
- const button = card?.buttons?.[0];
455
- const currentValue = button?.actionOnClick ? (button?.linkType || DEEP_LINK) : TAP_ACTION_APP;
456
- if (value === currentValue) return;
457
- const isApp = value === TAP_ACTION_APP;
458
453
  const updatedButtons = [...card?.buttons];
459
- updatedButtons[0] = {
460
- ...button,
461
- actionOnClick: !isApp,
462
- linkType: isApp ? DEEP_LINK : value,
454
+ updatedButtons[0] = {
455
+ ...updatedButtons[0],
456
+ linkType: value,
463
457
  deepLinkValue: '',
464
458
  externalLinkValue: '',
465
- deepLinkKeys: [],
466
- // A new link stays open until its Save is clicked
467
- isSaved: isApp ? undefined : false,
459
+ deepLinkKeys: []
468
460
  };
469
461
  updateCarouselCard(cardIndex, { buttons: updatedButtons });
462
+ // Clear errors when link type changes
470
463
  updateCarouselLinkError(cardIndex, 'deepLink', null);
471
464
  updateCarouselLinkError(cardIndex, 'externalLink', null);
472
465
  updateCarouselLinkError(cardIndex, 'deepLinkKeys', null);
473
466
  };
474
467
 
475
- const setCarouselTapLinkSaved = (cardIndex, isSaved) => {
476
- const card = getCurrentCarouselData()[cardIndex];
477
- const updatedButtons = [...card?.buttons];
478
- updatedButtons[0] = { ...updatedButtons[0], isSaved };
479
- updateCarouselCard(cardIndex, { buttons: updatedButtons });
480
- };
481
-
482
468
  const handleCarouselDeepLinkChange = (cardIndex, value) => {
483
469
  const currentData = getCurrentCarouselData();
484
470
  const card = currentData[cardIndex];
@@ -568,50 +554,25 @@ const MediaUploaders = ({
568
554
  );
569
555
  };
570
556
 
571
- // Called by the box as (index, data): Re upload passes an empty videoSrc
572
- const handleCarouselVideoChange = (cardIndex, data = {}) => {
573
- const { videoSrc = '', previewUrl = '' } = data;
574
- if (!videoSrc) {
575
- // Re upload clicks the page's first "videoFileName" input, which may be another card's
576
- reuploadCardRef.current = cardIndex;
577
- }
578
- updateCarouselCard(cardIndex, { videoSrc, videoPreviewImg: videoSrc ? previewUrl : '' });
579
- };
580
-
581
- const renderCarouselVideoComponent = (cardIndex) => {
582
- const card = getCurrentCarouselData()?.[cardIndex];
583
-
584
- // Track the uploading card; the completion effect below writes the result into it
585
- const handleCarouselVideoUpload = (file, assetType, fileParams, index) => {
586
- const targetCard = reuploadCardRef.current ?? cardIndex;
587
- reuploadCardRef.current = null;
588
- uploadIdRef.current += 1;
589
- setUploadingCardIndex(targetCard);
590
- setCurrentUploadId(uploadIdRef.current);
591
- return uploadMpushAsset(file, assetType, fileParams, index);
592
- };
593
-
594
- return (
595
- <CapVideoUpload
596
- key={`carousel-video-${activeTab}-${cardIndex}`}
597
- index={activeTab === ANDROID ? 0 : 1}
598
- allowedExtensionsRegex={ALLOWED_EXTENSIONS_VIDEO_REGEX}
599
- videoSize={MPUSH_VIDEO_SIZE}
600
- isFullMode={isFullMode}
601
- uploadAsset={handleCarouselVideoUpload}
602
- uploadedAssetList={card?.videoSrc ? { videoSrc: card.videoSrc, previewUrl: card.videoPreviewImg || '' } : {}}
603
- onVideoUploadUpdateAssestList={(_index, data) => handleCarouselVideoChange(cardIndex, data)}
604
- videoData={{}}
605
- className="cap-custom-video-upload"
606
- formClassName="mpush-video-upload"
607
- channel={MOBILE_PUSH_CHANNEL}
608
- errorMessage={formatMessage(messages.videoErrorMessage)}
609
- showVideoNameAndDuration={false}
610
- showReUploadButton
611
- mediaType="video"
612
- />
613
- );
614
- };
557
+ const renderCarouselVideoComponent = (cardIndex) => (
558
+ <CapVideoUpload
559
+ index={activeTab === ANDROID ? 0 : 1}
560
+ allowedExtensionsRegex={ALLOWED_EXTENSIONS_VIDEO_REGEX}
561
+ videoSize={MPUSH_VIDEO_SIZE}
562
+ isFullMode={isFullMode}
563
+ uploadAsset={uploadMpushAsset}
564
+ uploadedAssetList={videoAssetList}
565
+ onVideoUploadUpdateAssestList={(src) => updateCarouselCard(cardIndex, { videoSrc: src })}
566
+ videoData={videoDataForVideo}
567
+ className="cap-custom-video-upload"
568
+ formClassName="mpush-video-upload"
569
+ channel={MOBILE_PUSH_CHANNEL}
570
+ errorMessage={formatMessage(messages.videoErrorMessage)}
571
+ showVideoNameAndDuration={false}
572
+ showReUploadButton
573
+ mediaType="video"
574
+ />
575
+ );
615
576
 
616
577
  const renderCarouselActionLinks = (cardIndex) => {
617
578
  const currentData = getCurrentCarouselData();
@@ -623,191 +584,178 @@ const MediaUploaders = ({
623
584
  }
624
585
 
625
586
  const button = card?.buttons[0]; // We're handling only one button for now
626
- const tapAction = button?.actionOnClick ? (button?.linkType || DEEP_LINK) : TAP_ACTION_APP;
627
587
 
628
588
  // Use the callback creator instead of useCallback inside render function
629
589
  const onButtonTagSelect = createCarouselButtonTagSelectCallback(cardIndex);
630
590
 
631
- const toArray = (value) => {
632
- if (Array.isArray(value)) return value;
633
- return value ? [value] : [];
634
- };
635
- const keysFromSelection = toArray(findSelectedDeepLink(deepLink, button?.deepLinkValue)?.keys);
636
- const savedKeys = toArray(button?.deepLinkKeys);
637
- const showDeepLinkKeys = tapAction === DEEP_LINK && button?.deepLinkValue && keysFromSelection.length > 0;
638
-
639
- // Only errors from typed values show inline (as in Notification tap); an empty link just keeps Save off
640
- const deepLinkError = carouselLinkErrors[`${cardIndex}-deepLink`];
641
- const externalLinkError = carouselLinkErrors[`${cardIndex}-externalLink`];
642
- const deepLinkKeysError = carouselLinkErrors[`${cardIndex}-deepLinkKeys`];
643
- const cardIssue = getCarouselCardIssue(card, deepLink);
644
- const isLinkIncomplete = [
645
- CAROUSEL_CARD_ISSUE.DEEP_LINK,
646
- CAROUSEL_CARD_ISSUE.DEEP_LINK_KEYS,
647
- CAROUSEL_CARD_ISSUE.EXTERNAL_LINK,
648
- ].includes(cardIssue);
649
-
650
- // Link chosen and saved: collapsed row, as for a saved button
651
- const isLinkSaved = tapAction !== TAP_ACTION_APP && button?.isSaved !== false;
652
- const isLinkSaveDisabled = isLinkIncomplete || !!(deepLinkError || externalLinkError || deepLinkKeysError);
653
- const savedLinkText = tapAction === DEEP_LINK
654
- ? (findSelectedDeepLink(deepLink, button?.deepLinkValue)?.label || button?.deepLinkValue)
655
- : button?.externalLinkValue;
656
- const removeCardTapLink = () => handleCarouselTapActionChange(cardIndex, TAP_ACTION_APP);
657
-
658
- if (isLinkSaved) {
659
- return (
660
- <>
661
- <CapDivider />
662
- <CapRow useLegacy className="creatives-mpush-actions">
663
- <CapRow type="flex" align="middle" noWrap className="mpush-section-heading">
664
- <CapHeading type="h4" className="mpush-actions">
665
- <FormattedMessage {...messages.cardTap} />
666
- </CapHeading>
667
- <CapLabel className="optional-text">
668
- <FormattedMessage {...messages.optionalText} />
669
- </CapLabel>
670
- </CapRow>
671
- <CapLabel className="mpush-tap-description">
672
- <FormattedMessage {...messages.cardTapDescription} />
673
- </CapLabel>
674
- <SavedTapLink
675
- linkType={tapAction}
676
- linkText={savedLinkText}
677
- onEdit={() => setCarouselTapLinkSaved(cardIndex, false)}
678
- onDelete={removeCardTapLink}
679
- formatMessage={formatMessage}
680
- />
681
- </CapRow>
682
- </>
683
- );
684
- }
685
-
686
591
  return (
687
592
  <>
688
593
  <CapDivider />
689
594
  <CapRow useLegacy className="creatives-mpush-actions">
690
- <CapRow type="flex" align="middle" noWrap className="mpush-section-heading">
595
+ <CapRow useLegacy className="mpush-actions-main">
691
596
  <CapHeading type="h4" className="mpush-actions">
692
- <FormattedMessage {...messages.cardTap} />
597
+ <FormattedMessage {...messages.buttonsAndLinks} />
693
598
  </CapHeading>
694
599
  <CapLabel className="optional-text">
695
600
  <FormattedMessage {...messages.optionalText} />
696
601
  </CapLabel>
697
602
  </CapRow>
698
- <CapLabel className="mpush-tap-description">
699
- <FormattedMessage {...messages.cardTapDescription} />
700
- </CapLabel>
701
- <CapRow type="flex" noWrap gap={16} className="mpush-tap-row">
702
- <CapColumn flex="0 0 30%" className="mpush-tap-action">
703
- <CapHeading type="h4" className="mpush-tap-label">
704
- <FormattedMessage {...messages.whenTappedOpen} />
705
- </CapHeading>
706
- <CapSelect.CapCustomSelect
707
- id={`mobile-push-carousel-tap-action-${activeTab}-${cardIndex}`}
708
- width="100%"
709
- options={tapActionOptions}
710
- value={tapAction}
711
- onChange={(value) => handleCarouselTapActionChange(cardIndex, value)}
712
- />
713
- </CapColumn>
714
- {tapAction === DEEP_LINK && (
715
- <CapColumn flex="1 1 0" className="mpush-tap-link">
716
- <CapHeading type="h4" className="mpush-tap-label">
717
- <FormattedMessage {...messages.tapActionDeepLink} />
603
+ <CapCheckbox
604
+ checked={button.actionOnClick}
605
+ onChange={(e) => handleCarouselActionOnClickChange(cardIndex, e.target.checked)}
606
+ className="action-on-click-checkbox"
607
+ >
608
+ <FormattedMessage {...messages.actionOnClickBody} />
609
+ </CapCheckbox>
610
+ <CapRow useLegacy>
611
+ <CapLabel className="action-description">
612
+ <FormattedMessage {...messages.actionDescription} />
613
+ </CapLabel>
614
+ </CapRow>
615
+ {button?.actionOnClick && (
616
+ <CapRow style={{ display: "flex", justifyContent: "space-around" }}>
617
+ <CapColumn span={6}>
618
+ <CapHeading type="h4" className="buttons-heading">
619
+ <FormattedMessage {...messages.linkType} />
718
620
  </CapHeading>
719
621
  <CapSelect.CapCustomSelect
720
- width="100%"
721
- options={(() => {
722
- const options = [...(deepLink || [])];
723
- // If the current value is not in the options, add it
724
- if (button?.deepLinkValue && !options.find((opt) => opt.value === button?.deepLinkValue)) {
725
- options.push({
726
- value: button?.deepLinkValue,
727
- label: button?.deepLinkValue,
728
- });
729
- }
730
- return options;
731
- })()}
732
- value={button?.deepLinkValue}
733
- onChange={(value) => handleCarouselDeepLinkChange(cardIndex, value)}
734
- key={`mobile-push-deep-link-type-${activeTab}-${cardIndex}`}
622
+ options={LINK_TYPE_OPTIONS}
623
+ value={button.linkType}
624
+ onChange={(value) => handleCarouselLinkTypeChange(cardIndex, value)}
625
+ key={`mobile-push-link-type-${activeTab}-${cardIndex}`}
735
626
  selectPlaceholder={formatMessage(messages.selectDeepLink)}
736
627
  />
737
- {deepLinkError && (
738
- <CapError className="mobile-push-carousel-deep-link-error">
739
- {deepLinkError}
740
- </CapError>
741
- )}
742
- {showDeepLinkKeys && (
743
- <CapRow className="mpush-tap-deep-link-keys">
744
- <CapHeading type="h4" className="deep-link-keys-heading">
745
- {formatMessage(messages.deepLinkKeys)}
628
+ </CapColumn>
629
+ {button?.linkType === DEEP_LINK && (
630
+ <CapColumn span={14}>
631
+ <CapHeading type="h4" className="buttons-heading">
632
+ {formatMessage(messages.deepLink)}
633
+ </CapHeading>
634
+ <CapSelect.CapCustomSelect
635
+ options={(() => {
636
+ const options = [...(deepLink || [])];
637
+ // If the current value is not in the options, add it
638
+ if (button?.deepLinkValue && !options.find(opt => opt.value === button?.deepLinkValue)) {
639
+ options.push({
640
+ value: button?.deepLinkValue,
641
+ label: button?.deepLinkValue,
642
+ });
643
+ }
644
+ return options;
645
+ })()}
646
+ value={button?.deepLinkValue}
647
+ onChange={(value) => handleCarouselDeepLinkChange(cardIndex, value)}
648
+ key={`mobile-push-deep-link-type-${activeTab}-${cardIndex}`}
649
+ placeholder={formatMessage(messages.selectDeepLink)}
650
+ style={{ marginTop: "10px" }}
651
+ />
652
+ {carouselLinkErrors[`${cardIndex}-deepLink`] && (
653
+ <CapError className="mobile-push-carousel-deep-link-error">
654
+ {carouselLinkErrors[`${cardIndex}-deepLink`]}
655
+ </CapError>
656
+ )}
657
+ </CapColumn>
658
+ )}
659
+ {button?.linkType === EXTERNAL_LINK && (
660
+ <CapColumn span={14}>
661
+ <CapRow className="buttons-heading-container">
662
+ <CapHeading type="h4" className="buttons-heading">
663
+ {formatMessage(messages.externalLink)}
746
664
  </CapHeading>
747
- <CapLabel type="label2" className="deep-link-keys-value">
748
- {(keysFromSelection.length > 0 ? keysFromSelection : savedKeys).join(', ')}
749
- </CapLabel>
750
- <CapInput
751
- id={`mobile-push-carousel-deep-link-keys-input-${activeTab}-${cardIndex}`}
752
- onChange={(e) => handleCarouselDeepLinkKeysChange(cardIndex, e.target.value)}
753
- placeholder={formatMessage(messages.deepLinkKeysPlaceholder, {
754
- key: keysFromSelection.join(', ') || 'deep link keys',
755
- })}
756
- value={savedKeys.join(', ')}
757
- size="default"
758
- style={{ marginTop: "10px" }}
759
- error={deepLinkKeysError}
665
+ <TagList
666
+ moduleFilterEnabled={
667
+ location?.query?.type !== "embedded"
668
+ }
669
+ label={formatMessage(messages.addLabels)}
670
+ onTagSelect={onButtonTagSelect}
671
+ onContextChange={handleOnTagsContextChange}
672
+ location={location}
673
+ tags={tags}
674
+ injectedTags={injectedTags}
675
+ selectedOfferDetails={selectedOfferDetails}
760
676
  />
761
677
  </CapRow>
762
- )}
763
- </CapColumn>
764
- )}
765
- {tapAction === EXTERNAL_LINK && (
766
- <CapColumn flex="1 1 0" className="mpush-tap-link">
767
- <CapRow type="flex" align="middle" justify="space-between" noWrap className="mpush-tap-link-header">
768
- <CapHeading type="h4" className="mpush-tap-label">
769
- <FormattedMessage {...messages.url} />
770
- </CapHeading>
771
- <TagList
772
- moduleFilterEnabled={
773
- location?.query?.type !== "embedded"
774
- }
775
- label={formatMessage(messages.addLabels)}
776
- onTagSelect={onButtonTagSelect}
777
- onContextChange={handleOnTagsContextChange}
778
- location={location}
779
- tags={tags}
780
- injectedTags={injectedTags}
781
- selectedOfferDetails={selectedOfferDetails}
678
+ <CapInput
679
+ id={`mobile-push-external-link-input-${activeTab}-${cardIndex}`}
680
+ onChange={(e) => handleCarouselExternalLinkChange(cardIndex, e.target.value)}
681
+ placeholder={formatMessage(messages.enterExternalLink)}
682
+ value={button?.externalLinkValue}
683
+ size="default"
684
+ isRequired
782
685
  />
783
- </CapRow>
686
+ {carouselLinkErrors[`${cardIndex}-externalLink`] && (
687
+ <CapError className="mobile-push-carousel-external-link-error">
688
+ {carouselLinkErrors[`${cardIndex}-externalLink`]}
689
+ </CapError>
690
+ )}
691
+ </CapColumn>
692
+ )}
693
+ </CapRow>
694
+ )}
695
+ {button?.linkType === DEEP_LINK && button?.deepLinkValue && button?.actionOnClick && (() => {
696
+ const selectedDeepLink = findSelectedDeepLink(deepLink, button?.deepLinkValue);
697
+ const deepLinkKeysFromSelection = selectedDeepLink?.keys;
698
+ let deepLinkKeysFromSelectionArray = [];
699
+ if (Array.isArray(deepLinkKeysFromSelection)) {
700
+ deepLinkKeysFromSelectionArray = deepLinkKeysFromSelection;
701
+ } else if (deepLinkKeysFromSelection) {
702
+ deepLinkKeysFromSelectionArray = [deepLinkKeysFromSelection];
703
+ }
704
+ return deepLinkKeysFromSelectionArray?.length > 0;
705
+ })() && (
706
+ <CapRow style={{ marginTop: "10px", left: "6%", width: '115%'}}>
707
+ <CapColumn span={14}>
708
+ <CapHeading type="h4" className="deep-link-keys-heading">
709
+ {formatMessage(messages.deepLinkKeys)}
710
+ </CapHeading>
711
+ <CapLabel type="label2" className="deep-link-keys-value">
712
+ {(() => {
713
+ const selectedDeepLink = findSelectedDeepLink(deepLink, button?.deepLinkValue);
714
+ const deepLinkKeysFromSelection = selectedDeepLink?.keys;
715
+ let deepLinkKeysArray = [];
716
+ if (Array.isArray(button?.deepLinkKeys)) {
717
+ deepLinkKeysArray = button?.deepLinkKeys;
718
+ } else if (button?.deepLinkKeys) {
719
+ deepLinkKeysArray = [button?.deepLinkKeys];
720
+ }
721
+ let deepLinkKeysFromSelectionArray = [];
722
+ if (Array.isArray(deepLinkKeysFromSelection)) {
723
+ deepLinkKeysFromSelectionArray = deepLinkKeysFromSelection;
724
+ } else if (deepLinkKeysFromSelection) {
725
+ deepLinkKeysFromSelectionArray = [deepLinkKeysFromSelection];
726
+ }
727
+
728
+ if (deepLinkKeysFromSelectionArray?.length > 0) {
729
+ return deepLinkKeysFromSelectionArray.join(', ');
730
+ }
731
+ if (deepLinkKeysArray?.length > 0) {
732
+ return deepLinkKeysArray.join(', ');
733
+ }
734
+ })()}
735
+ </CapLabel>
784
736
  <CapInput
785
- id={`mobile-push-external-link-input-${activeTab}-${cardIndex}`}
786
- onChange={(e) => handleCarouselExternalLinkChange(cardIndex, e.target.value)}
787
- placeholder={formatMessage(messages.enterUrl)}
788
- value={button?.externalLinkValue}
737
+ id={`mobile-push-carousel-deep-link-keys-input-${activeTab}-${cardIndex}`}
738
+ onChange={(e) => handleCarouselDeepLinkKeysChange(cardIndex, e.target.value)}
739
+ placeholder={formatMessage(messages.deepLinkKeysPlaceholder, {
740
+ key: (() => {
741
+ const selectedDeepLink = findSelectedDeepLink(deepLink, button?.deepLinkValue);
742
+ const deepLinkKeysFromSelection = selectedDeepLink?.keys;
743
+ let deepLinkKeysFromSelectionArray = [];
744
+ if (Array.isArray(deepLinkKeysFromSelection)) {
745
+ deepLinkKeysFromSelectionArray = deepLinkKeysFromSelection;
746
+ } else if (deepLinkKeysFromSelection) {
747
+ deepLinkKeysFromSelectionArray = [deepLinkKeysFromSelection];
748
+ }
749
+ return deepLinkKeysFromSelectionArray.join(', ') || 'deep link keys';
750
+ })(),
751
+ })}
752
+ value={Array.isArray(button?.deepLinkKeys) ? button?.deepLinkKeys?.join(', ') : (button?.deepLinkKeys || "")}
789
753
  size="default"
790
- isRequired
754
+ style={{ marginTop: "10px" }}
755
+ error={carouselLinkErrors[`${cardIndex}-deepLinkKeys`]}
791
756
  />
792
- {externalLinkError && (
793
- <CapError className="mobile-push-carousel-external-link-error">
794
- {externalLinkError}
795
- </CapError>
796
- )}
797
757
  </CapColumn>
798
- )}
799
- </CapRow>
800
- {tapAction === TAP_ACTION_APP ? (
801
- <CapLabel className="mpush-tap-description mpush-tap-help">
802
- <FormattedMessage {...messages.cardTapAppHelp} />
803
- </CapLabel>
804
- ) : (
805
- <TapLinkSaveDelete
806
- isSaveDisabled={isLinkSaveDisabled}
807
- onSave={() => setCarouselTapLinkSaved(cardIndex, true)}
808
- onDelete={removeCardTapLink}
809
- formatMessage={formatMessage}
810
- />
758
+ </CapRow>
811
759
  )}
812
760
  </CapRow>
813
761
  </>
@@ -856,30 +804,17 @@ const MediaUploaders = ({
856
804
  }));
857
805
  };
858
806
 
859
- const isMaxCarouselCardsReached = getCurrentCarouselData()?.length >= MAX_CAROUSEL_ALLOWED;
860
- let addCardTooltipTitle = "";
861
- if (isMaxCarouselCardsReached) {
862
- addCardTooltipTitle = formatMessage(messages.carouselMaxCardTooltip, { max: MAX_CAROUSEL_ALLOWED });
863
- } else if (hasIncompleteCard) {
864
- addCardTooltipTitle = formatMessage(messages.completeCardToAdd);
865
- }
866
-
867
807
  const operations = (
868
808
  <>
869
809
  <CapDivider type="vertical" />
870
- <CapTooltip title={addCardTooltipTitle}>
871
- {/* Disabled buttons fire no hover events; the wrapper lets the tooltip show */}
872
- <span className="button-disabled-tooltip-wrapper">
873
- <CapButton
874
- onClick={addCarouselCard}
875
- type="link"
876
- className="add-carousel-content-button"
877
- disabled={isMaxCarouselCardsReached || hasIncompleteCard}
878
- >
879
- <CapIcon type="plus" />
880
- </CapButton>
881
- </span>
882
- </CapTooltip>
810
+ <CapButton
811
+ onClick={addCarouselCard}
812
+ type="link"
813
+ className="add-carousel-content-button"
814
+ disabled={getCurrentCarouselData()?.length >= MAX_CAROUSEL_ALLOWED}
815
+ >
816
+ <CapIcon type="plus" />
817
+ </CapButton>
883
818
  </>
884
819
  );
885
820
 
@@ -904,6 +839,7 @@ const MediaUploaders = ({
904
839
  {
905
840
  value: VIDEO.toLowerCase(),
906
841
  label: formatMessage(messages.mediaVideo),
842
+ disabled: true,
907
843
  },
908
844
  ]}
909
845
  value={carouselMediaType}
@@ -957,16 +893,8 @@ const MediaUploaders = ({
957
893
  const previousDataKey = previousUploadDataRef.current;
958
894
 
959
895
  if (currentDataKey !== previousDataKey) {
960
- const {
961
- secure_file_path: filePath,
962
- video_file_path_preview: videoPreview = '',
963
- preview_image_url: previewImage = '',
964
- } = uploadedData.metaInfo;
965
- const isVideoCard = getCurrentCarouselData()?.[uploadingCardIndex]?.mediaType === VIDEO.toLowerCase();
966
- // Update the specific card that was uploading (videoPreviewImg is what the phone preview shows)
967
- updateCarouselCard(uploadingCardIndex, isVideoCard
968
- ? { videoSrc: filePath, videoPreviewImg: videoPreview || previewImage }
969
- : { imageUrl: filePath });
896
+ // Update the specific card that was uploading
897
+ updateCarouselCard(uploadingCardIndex, { imageUrl: uploadedData?.metaInfo?.secure_file_path });
970
898
 
971
899
  // Store this upload data as "processed" to avoid reprocessing
972
900
  previousUploadDataRef.current = currentDataKey;
@@ -977,16 +905,7 @@ const MediaUploaders = ({
977
905
  }
978
906
  }
979
907
  }
980
- }, [mediaType, imageData, uploadingCardIndex, currentUploadId, activeTab, updateCarouselCard, getCurrentCarouselData]);
981
-
982
- // Editing a saved video carousel: show video boxes, not the default image ones
983
- useEffect(() => {
984
- const savedCardType = carouselData?.[0]?.mediaType;
985
- if (mediaType === CAROUSEL && savedCardType && savedCardType !== carouselMediaType) {
986
- setCarouselMediaType(savedCardType);
987
- }
988
- // eslint-disable-next-line react-hooks/exhaustive-deps
989
- }, [mediaType, carouselData]);
908
+ }, [mediaType, imageData, uploadingCardIndex, currentUploadId, activeTab, updateCarouselCard]);
990
909
 
991
910
  if (mediaType === IMAGE) return renderImageComponent();
992
911
  if (mediaType === VIDEO) return renderVideoComponent();