@capillarytech/creatives-library 9.2.2-alpha.sprint-cap-214249.44 → 9.2.2

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 (89) hide show
  1. package/constants/unified.js +1 -3
  2. package/package.json +1 -1
  3. package/translations/en.json +0 -1
  4. package/translations/ja-JP.json +0 -1
  5. package/translations/zh.json +0 -1
  6. package/utils/common.js +6 -0
  7. package/utils/createMobilePushPayload.js +56 -50
  8. package/utils/tagValidations.js +4 -35
  9. package/utils/tests/createMobilePushPayload.test.js +168 -177
  10. package/utils/tests/tagValidations.test.js +0 -48
  11. package/v2Components/CapMpushCTA/index.js +57 -47
  12. package/v2Components/CapMpushCTA/index.scss +5 -43
  13. package/v2Components/CapTagList/index.js +7 -46
  14. package/v2Components/CapTagList/messages.js +0 -44
  15. package/v2Components/CapTagList/style.scss +1 -113
  16. package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +8 -11
  17. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
  18. package/v2Components/CommonTestAndPreview/constants.js +0 -2
  19. package/v2Components/CommonTestAndPreview/index.js +12 -51
  20. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -83
  21. package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -100
  22. package/v2Components/FormBuilder/Classic.js +14 -24
  23. package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +0 -1
  24. package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
  25. package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +0 -57
  26. package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
  27. package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +0 -3
  28. package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +0 -5
  29. package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +0 -6
  30. package/v2Components/FormBuilder/Functional/channels/sms/validate.js +1 -3
  31. package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +0 -3
  32. package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +0 -22
  33. package/v2Components/MobilePushPreviewV2/index.js +9 -22
  34. package/v2Components/TemplatePreview/_templatePreview.scss +2 -18
  35. package/v2Components/TemplatePreview/index.js +18 -20
  36. package/v2Components/TemplatePreview/tests/index.test.js +0 -69
  37. package/v2Containers/Cap/messages.js +0 -4
  38. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +0 -1
  39. package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js +2 -12
  40. package/v2Containers/CreativesContainer/SlideBoxContent.js +6 -4
  41. package/v2Containers/CreativesContainer/index.js +1 -2
  42. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -43
  43. package/v2Containers/InApp/index.js +1 -4
  44. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +0 -3
  45. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +0 -2
  46. package/v2Containers/Line/Container/Text/index.js +1 -3
  47. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +0 -16
  48. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +0 -18
  49. package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
  50. package/v2Containers/MobilePushNew/components/MediaUploaders.js +345 -105
  51. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +105 -127
  52. package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
  53. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +1484 -307
  54. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +59 -165
  55. package/v2Containers/MobilePushNew/constants.js +0 -12
  56. package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
  57. package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -78
  58. package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -40
  59. package/v2Containers/MobilePushNew/hooks/useUpload.js +46 -42
  60. package/v2Containers/MobilePushNew/index.js +290 -502
  61. package/v2Containers/MobilePushNew/index.scss +4 -151
  62. package/v2Containers/MobilePushNew/messages.js +6 -106
  63. package/v2Containers/MobilePushNew/tests/index.test.js +1 -483
  64. package/v2Containers/MobilePushNew/tests/utils.test.js +0 -110
  65. package/v2Containers/MobilePushNew/utils.js +0 -83
  66. package/v2Containers/Rcs/index.js +1 -8
  67. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +0 -59
  68. package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +0 -4
  69. package/v2Containers/SmsTrai/Edit/index.js +5 -13
  70. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +0 -15
  71. package/v2Containers/Templates/_templates.scss +2 -10
  72. package/v2Containers/Templates/index.js +81 -86
  73. package/v2Containers/Templates/tests/index.test.js +0 -81
  74. package/v2Containers/Viber/index.js +1 -3
  75. package/v2Containers/WebPush/Create/utils/validation.js +0 -6
  76. package/v2Containers/WebPush/Create/utils/validation.test.js +0 -50
  77. package/v2Containers/Whatsapp/index.js +5 -9
  78. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
  79. package/v2Containers/Zalo/index.js +1 -4
  80. package/v2Components/CapMpushCTA/tests/index.test.js +0 -150
  81. package/v2Components/CapTagList/TagFallbackPanel.js +0 -124
  82. package/v2Components/CapTagList/constants.js +0 -5
  83. package/v2Components/CapTagList/tests/TagFallback.test.js +0 -222
  84. package/v2Components/CapTagList/utils.js +0 -17
  85. package/v2Components/MobilePushPreviewV2/_mobilePushPreviewV2.scss +0 -7
  86. package/v2Components/MobilePushPreviewV2/tests/index.test.js +0 -55
  87. package/v2Components/TemplatePreview/_mobilePushPhone.scss +0 -72
  88. package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/extractContentForPreview.test.js +0 -45
  89. package/v2Containers/MobilePushNew/components/TapLinkActions.js +0 -76
@@ -5,6 +5,7 @@ import React, {
5
5
  useRef,
6
6
  } from "react";
7
7
  import PropTypes from "prop-types";
8
+ import { FormattedMessage } from "react-intl";
8
9
  import CapButton from "@capillarytech/cap-ui-library/CapButton";
9
10
  import CapCard from "@capillarytech/cap-ui-library/CapCard";
10
11
  import CapColumn from "@capillarytech/cap-ui-library/CapColumn";
@@ -14,7 +15,11 @@ import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
14
15
  import CapRadioGroup from "@capillarytech/cap-ui-library/CapRadioGroup";
15
16
  import CapRow from "@capillarytech/cap-ui-library/CapRow";
16
17
  import CapTab from "@capillarytech/cap-ui-library/CapTab";
17
- import CapTooltip from "@capillarytech/cap-ui-library/CapTooltip";
18
+ import CapCheckbox from "@capillarytech/cap-ui-library/CapCheckbox";
19
+ import CapLabel from "@capillarytech/cap-ui-library/CapLabel";
20
+ import CapSelect from "@capillarytech/cap-ui-library/CapSelect";
21
+ import CapInput from "@capillarytech/cap-ui-library/CapInput";
22
+ import CapError from "@capillarytech/cap-ui-library/CapError";
18
23
  import CapImageUpload from "../../../v2Components/CapImageUpload";
19
24
  import CapVideoUpload from "../../../v2Components/CapVideoUpload";
20
25
  import {
@@ -31,11 +36,14 @@ import {
31
36
  GIF,
32
37
  IMAGE,
33
38
  VIDEO,
39
+ LINK_TYPE_OPTIONS,
34
40
  DEEP_LINK,
41
+ EXTERNAL_LINK,
35
42
  CAROUSEL,
36
43
  } from "../constants";
37
44
  import messages from "../messages";
38
- import { getCarouselCardIssue } from "../utils";
45
+ import { validateExternalLink, validateDeepLink } from "../utils";
46
+ import TagList from "../../TagList";
39
47
 
40
48
  // Initial carousel data structure
41
49
  const CAROUSEL_INITIAL_DATA = {
@@ -54,6 +62,22 @@ const CAROUSEL_INITIAL_DATA = {
54
62
  // Maximum number of carousel cards allowed
55
63
  const MAX_CAROUSEL_ALLOWED = 10;
56
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
+
57
81
  const MediaUploaders = ({
58
82
  mediaType,
59
83
  activeTab,
@@ -70,12 +94,20 @@ const MediaUploaders = ({
70
94
  videoDataForGif,
71
95
  videoSrc, // Add videoSrc prop for content state fallback
72
96
  formatMessage,
97
+ linkProps,
73
98
  clearImageDataByMediaType,
74
99
  carouselData = [], // Carousel data from content state
75
100
  onCarouselDataChange, // Callback to update carousel data in parent
76
101
  mobilePushActions, // Mobile push actions for clearing assets
77
102
  carouselActiveTabIndex,
78
103
  setCarouselActiveTabIndex,
104
+ carouselLinkErrors = {}, // Carousel link errors from parent
105
+ updateCarouselLinkError, // Function to update carousel link errors in parent
106
+ location,
107
+ tags,
108
+ injectedTags,
109
+ selectedOfferDetails,
110
+ handleOnTagsContextChange,
79
111
  }) => {
80
112
  // Carousel state management - separate for Android and iOS
81
113
  const [carouselMediaType, setCarouselMediaType] = useState(IMAGE.toLowerCase());
@@ -89,16 +121,15 @@ const MediaUploaders = ({
89
121
  // Track upload ID to prevent processing stale Redux data
90
122
  const [currentUploadId, setCurrentUploadId] = useState(null);
91
123
  const uploadIdRef = useRef(0); // Counter for generating unique upload IDs
92
- // Card whose video Re upload was clicked (its file input may belong to another card)
93
- const reuploadCardRef = useRef(null);
94
124
 
95
125
  // Track previous upload data to detect when a new upload completes
96
126
  const previousUploadDataRef = useRef(null);
97
127
 
98
128
  // Track previous media type to handle transitions
99
129
  const previousMediaTypeRef = useRef(mediaType);
100
- // First card's media type last seen, for the saved-carousel effect
101
- const prevCardTypeRef = useRef(null);
130
+
131
+ // Extract link props
132
+ const { deepLink } = linkProps || {};
102
133
 
103
134
  // Get current carousel data based on active tab
104
135
  const getCurrentCarouselData = useCallback(() => carouselData || [], [carouselData]);
@@ -118,12 +149,24 @@ const MediaUploaders = ({
118
149
  )));
119
150
  }, [getCurrentCarouselData, setCurrentCarouselData]);
120
151
 
121
- // Clear previous media data when this pane's media type changes.
122
- // Skip re-runs from a tab switch: both panes stay mounted, and the
123
- // hidden one must not wipe the visible tab's media.
124
- useEffect(() => {
125
- if (previousMediaTypeRef.current === mediaType) return;
152
+ // Create carousel button tag select callback at component level to avoid hooks violation
153
+ const createCarouselButtonTagSelectCallback = useCallback((cardIndex) => {
154
+ return (value) => {
155
+ const currentData = getCurrentCarouselData();
156
+ const card = currentData[cardIndex];
157
+ const button = card?.buttons?.[0];
158
+ if (button) {
159
+ const newUrl = `${button?.externalLinkValue}{{${value}}}`;
160
+ // Update carousel card directly using updateCarouselCard
161
+ const updatedButtons = [...card?.buttons];
162
+ updatedButtons[0] = { ...updatedButtons[0], externalLinkValue: newUrl };
163
+ updateCarouselCard(cardIndex, { buttons: updatedButtons });
164
+ }
165
+ };
166
+ }, [getCurrentCarouselData, updateCarouselCard]);
126
167
 
168
+ // Clear previous media data when switching media types
169
+ useEffect(() => {
127
170
  // Clear carousel data when switching to non-carousel media types
128
171
  if (mediaType !== CAROUSEL) {
129
172
  setCurrentCarouselData([]);
@@ -135,15 +178,15 @@ const MediaUploaders = ({
135
178
  previousUploadDataRef.current = null;
136
179
  }
137
180
 
138
- // 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
139
182
  if (mediaType !== IMAGE) {
140
- clearImageDataByMediaType(IMAGE, activeTab);
183
+ clearImageDataByMediaType(IMAGE);
141
184
  }
142
185
 
143
186
  // Clear image data when switching FROM CAROUSEL TO IMAGE
144
187
  // This prevents carousel images from appearing in IMAGE media type
145
188
  if (previousMediaTypeRef.current === CAROUSEL && mediaType === IMAGE) {
146
- clearImageDataByMediaType(IMAGE, activeTab);
189
+ clearImageDataByMediaType(IMAGE);
147
190
  }
148
191
 
149
192
  // Reset re-upload mode when switching media types
@@ -151,7 +194,7 @@ const MediaUploaders = ({
151
194
 
152
195
  // Update the previous media type ref
153
196
  previousMediaTypeRef.current = mediaType;
154
- }, [mediaType, activeTab, clearImageDataByMediaType, setCurrentCarouselData]);
197
+ }, [mediaType, clearImageDataByMediaType, setCurrentCarouselData]);
155
198
 
156
199
  // Handle platform tab changes for carousel data
157
200
  useEffect(() => {
@@ -326,7 +369,6 @@ const MediaUploaders = ({
326
369
  mediaType: value,
327
370
  imageUrl: value === IMAGE.toLowerCase() ? card.imageUrl : '',
328
371
  videoSrc: value === VIDEO.toLowerCase() ? card.videoSrc : '',
329
- videoPreviewImg: value === VIDEO.toLowerCase() ? card.videoPreviewImg : '',
330
372
  buttons: card.buttons || [{
331
373
  actionOnClick: false,
332
374
  linkType: DEEP_LINK,
@@ -340,18 +382,13 @@ const MediaUploaders = ({
340
382
  setCarouselActiveTabIndex(Number(key));
341
383
  };
342
384
 
343
- // A card is done once its media is uploaded
344
- const hasIncompleteCard = getCurrentCarouselData()?.some((card) => getCarouselCardIssue(card));
345
-
346
385
  const addCarouselCard = () => {
347
386
  const currentData = getCurrentCarouselData();
348
- if (currentData?.length < MAX_CAROUSEL_ALLOWED && !hasIncompleteCard) {
387
+ if (currentData?.length < MAX_CAROUSEL_ALLOWED) {
349
388
  setCurrentCarouselData([
350
389
  ...currentData,
351
390
  { ...CAROUSEL_INITIAL_DATA, mediaType: carouselMediaType },
352
391
  ]);
353
- // Open the new card so its upload box is in view
354
- setCarouselActiveTabIndex(currentData.length);
355
392
  }
356
393
  };
357
394
 
@@ -401,6 +438,73 @@ const MediaUploaders = ({
401
438
  }, 100);
402
439
  };
403
440
 
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
+
450
+ const handleCarouselLinkTypeChange = (cardIndex, value) => {
451
+ const currentData = getCurrentCarouselData();
452
+ const card = currentData[cardIndex];
453
+ const updatedButtons = [...card?.buttons];
454
+ updatedButtons[0] = {
455
+ ...updatedButtons[0],
456
+ linkType: value,
457
+ deepLinkValue: '',
458
+ externalLinkValue: '',
459
+ deepLinkKeys: []
460
+ };
461
+ updateCarouselCard(cardIndex, { buttons: updatedButtons });
462
+ // Clear errors when link type changes
463
+ updateCarouselLinkError(cardIndex, 'deepLink', null);
464
+ updateCarouselLinkError(cardIndex, 'externalLink', null);
465
+ updateCarouselLinkError(cardIndex, 'deepLinkKeys', null);
466
+ };
467
+
468
+ const handleCarouselDeepLinkChange = (cardIndex, value) => {
469
+ const currentData = getCurrentCarouselData();
470
+ const card = currentData[cardIndex];
471
+ const updatedButtons = [...card?.buttons];
472
+ updatedButtons[0] = {
473
+ ...updatedButtons[0],
474
+ deepLinkValue: value,
475
+ // Clear deep link keys when deep link changes
476
+ deepLinkKeys: []
477
+ };
478
+ updateCarouselCard(cardIndex, { buttons: updatedButtons });
479
+ // Validate deep link
480
+ const error = validateDeepLink(value, formatMessage, messages);
481
+ updateCarouselLinkError(cardIndex, 'deepLink', error);
482
+ };
483
+
484
+ const handleCarouselExternalLinkChange = (cardIndex, value) => {
485
+ const currentData = getCurrentCarouselData();
486
+ const card = currentData[cardIndex];
487
+ const updatedButtons = [...card?.buttons];
488
+ updatedButtons[0] = { ...updatedButtons[0], externalLinkValue: value };
489
+ updateCarouselCard(cardIndex, { buttons: updatedButtons });
490
+ // Validate external link
491
+ const error = validateExternalLink(value, formatMessage, messages);
492
+ updateCarouselLinkError(cardIndex, 'externalLink', error);
493
+ };
494
+
495
+ const handleCarouselDeepLinkKeysChange = (cardIndex, value) => {
496
+ const currentData = getCurrentCarouselData();
497
+ const card = currentData[cardIndex];
498
+ const updatedButtons = [...card?.buttons];
499
+ // Parse comma-separated values into array
500
+ const keysArray = value?.split(',')?.map((key) => key?.trim())?.filter((key) => key?.length > 0);
501
+ updatedButtons[0] = { ...updatedButtons[0], deepLinkKeys: keysArray };
502
+ updateCarouselCard(cardIndex, { buttons: updatedButtons });
503
+ // Validate deep link keys
504
+ const error = keysArray?.length === 0 ? formatMessage(messages.deepLinkKeysRequired) : null;
505
+ updateCarouselLinkError(cardIndex, 'deepLinkKeys', error);
506
+ };
507
+
404
508
  const renderCarouselImageComponent = (cardIndex) => {
405
509
  const currentData = getCurrentCarouselData();
406
510
  const card = currentData[cardIndex];
@@ -450,48 +554,211 @@ const MediaUploaders = ({
450
554
  );
451
555
  };
452
556
 
453
- // Called by the box as (index, data): Re upload passes an empty videoSrc
454
- const handleCarouselVideoChange = (cardIndex, data = {}) => {
455
- const { videoSrc = '', previewUrl = '' } = data;
456
- if (!videoSrc) {
457
- // Re upload clicks the page's first "videoFileName" input, which may be another card's
458
- reuploadCardRef.current = cardIndex;
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
+ );
576
+
577
+ const renderCarouselActionLinks = (cardIndex) => {
578
+ const currentData = getCurrentCarouselData();
579
+ const card = currentData[cardIndex];
580
+
581
+ // Ensure buttons array exists and has at least one element
582
+ if (!card?.buttons || !Array.isArray(card?.buttons) || card?.buttons?.length === 0) {
583
+ return null;
459
584
  }
460
- updateCarouselCard(cardIndex, { videoSrc, videoPreviewImg: videoSrc ? previewUrl : '' });
461
- };
462
585
 
463
- const renderCarouselVideoComponent = (cardIndex) => {
464
- const card = getCurrentCarouselData()?.[cardIndex];
586
+ const button = card?.buttons[0]; // We're handling only one button for now
465
587
 
466
- // Track the uploading card; the completion effect below writes the result into it
467
- const handleCarouselVideoUpload = (file, assetType, fileParams, index) => {
468
- const targetCard = reuploadCardRef.current ?? cardIndex;
469
- reuploadCardRef.current = null;
470
- uploadIdRef.current += 1;
471
- setUploadingCardIndex(targetCard);
472
- setCurrentUploadId(uploadIdRef.current);
473
- return uploadMpushAsset(file, assetType, fileParams, index);
474
- };
588
+ // Use the callback creator instead of useCallback inside render function
589
+ const onButtonTagSelect = createCarouselButtonTagSelectCallback(cardIndex);
475
590
 
476
591
  return (
477
- <CapVideoUpload
478
- key={`carousel-video-${activeTab}-${cardIndex}`}
479
- index={activeTab === ANDROID ? 0 : 1}
480
- allowedExtensionsRegex={ALLOWED_EXTENSIONS_VIDEO_REGEX}
481
- videoSize={MPUSH_VIDEO_SIZE}
482
- isFullMode={isFullMode}
483
- uploadAsset={handleCarouselVideoUpload}
484
- uploadedAssetList={card?.videoSrc ? { videoSrc: card.videoSrc, previewUrl: card.videoPreviewImg || '' } : {}}
485
- onVideoUploadUpdateAssestList={(_index, data) => handleCarouselVideoChange(cardIndex, data)}
486
- videoData={{}}
487
- className="cap-custom-video-upload"
488
- formClassName="mpush-video-upload"
489
- channel={MOBILE_PUSH_CHANNEL}
490
- errorMessage={formatMessage(messages.videoErrorMessage)}
491
- showVideoNameAndDuration={false}
492
- showReUploadButton
493
- mediaType="video"
494
- />
592
+ <>
593
+ <CapDivider />
594
+ <CapRow useLegacy className="creatives-mpush-actions">
595
+ <CapRow useLegacy className="mpush-actions-main">
596
+ <CapHeading type="h4" className="mpush-actions">
597
+ <FormattedMessage {...messages.buttonsAndLinks} />
598
+ </CapHeading>
599
+ <CapLabel className="optional-text">
600
+ <FormattedMessage {...messages.optionalText} />
601
+ </CapLabel>
602
+ </CapRow>
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} />
620
+ </CapHeading>
621
+ <CapSelect.CapCustomSelect
622
+ options={LINK_TYPE_OPTIONS}
623
+ value={button.linkType}
624
+ onChange={(value) => handleCarouselLinkTypeChange(cardIndex, value)}
625
+ key={`mobile-push-link-type-${activeTab}-${cardIndex}`}
626
+ selectPlaceholder={formatMessage(messages.selectDeepLink)}
627
+ />
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)}
664
+ </CapHeading>
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}
676
+ />
677
+ </CapRow>
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
685
+ />
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>
736
+ <CapInput
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 || "")}
753
+ size="default"
754
+ style={{ marginTop: "10px" }}
755
+ error={carouselLinkErrors[`${cardIndex}-deepLinkKeys`]}
756
+ />
757
+ </CapColumn>
758
+ </CapRow>
759
+ )}
760
+ </CapRow>
761
+ </>
495
762
  );
496
763
  };
497
764
 
@@ -531,35 +798,23 @@ const MediaUploaders = ({
531
798
  </CapRow>
532
799
  )}
533
800
  </CapRow>
801
+ {renderCarouselActionLinks(index)}
534
802
  </CapCard>
535
803
  ),
536
804
  }));
537
805
  };
538
806
 
539
- const isMaxCarouselCardsReached = getCurrentCarouselData()?.length >= MAX_CAROUSEL_ALLOWED;
540
- let addCardTooltipTitle = "";
541
- if (isMaxCarouselCardsReached) {
542
- addCardTooltipTitle = formatMessage(messages.carouselMaxCardTooltip, { max: MAX_CAROUSEL_ALLOWED });
543
- } else if (hasIncompleteCard) {
544
- addCardTooltipTitle = formatMessage(messages.completeCardToAdd);
545
- }
546
-
547
807
  const operations = (
548
808
  <>
549
809
  <CapDivider type="vertical" />
550
- <CapTooltip title={addCardTooltipTitle}>
551
- {/* Disabled buttons fire no hover events; the wrapper lets the tooltip show */}
552
- <CapRow className="button-disabled-tooltip-wrapper">
553
- <CapButton
554
- onClick={addCarouselCard}
555
- type="link"
556
- className="add-carousel-content-button"
557
- disabled={isMaxCarouselCardsReached || hasIncompleteCard}
558
- >
559
- <CapIcon type="plus" />
560
- </CapButton>
561
- </CapRow>
562
- </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>
563
818
  </>
564
819
  );
565
820
 
@@ -584,6 +839,7 @@ const MediaUploaders = ({
584
839
  {
585
840
  value: VIDEO.toLowerCase(),
586
841
  label: formatMessage(messages.mediaVideo),
842
+ disabled: true,
587
843
  },
588
844
  ]}
589
845
  value={carouselMediaType}
@@ -619,7 +875,10 @@ const MediaUploaders = ({
619
875
  videoDataForVideo,
620
876
  formatMessage,
621
877
  mobilePushActions,
878
+ carouselLinkErrors,
879
+ updateCarouselLinkError,
622
880
  setCarouselActiveTabIndex,
881
+ deepLink,
623
882
  ]);
624
883
 
625
884
  // Manually handle upload completion for carousel cards (since automatic restoration is disabled)
@@ -634,16 +893,8 @@ const MediaUploaders = ({
634
893
  const previousDataKey = previousUploadDataRef.current;
635
894
 
636
895
  if (currentDataKey !== previousDataKey) {
637
- const {
638
- secure_file_path: filePath,
639
- video_file_path_preview: videoPreview = '',
640
- preview_image_url: previewImage = '',
641
- } = uploadedData.metaInfo;
642
- const isVideoCard = getCurrentCarouselData()?.[uploadingCardIndex]?.mediaType === VIDEO.toLowerCase();
643
- // Update the specific card that was uploading (videoPreviewImg is what the phone preview shows)
644
- updateCarouselCard(uploadingCardIndex, isVideoCard
645
- ? { videoSrc: filePath, videoPreviewImg: videoPreview || previewImage }
646
- : { imageUrl: filePath });
896
+ // Update the specific card that was uploading
897
+ updateCarouselCard(uploadingCardIndex, { imageUrl: uploadedData?.metaInfo?.secure_file_path });
647
898
 
648
899
  // Store this upload data as "processed" to avoid reprocessing
649
900
  previousUploadDataRef.current = currentDataKey;
@@ -654,21 +905,7 @@ const MediaUploaders = ({
654
905
  }
655
906
  }
656
907
  }
657
- }, [mediaType, imageData, uploadingCardIndex, currentUploadId, activeTab, updateCarouselCard, getCurrentCarouselData]);
658
-
659
- // Editing a saved video carousel: show video boxes, not the default image ones.
660
- // Follows the cards' type only when it changes, so a radio click isn't undone.
661
- useEffect(() => {
662
- if (mediaType !== CAROUSEL) {
663
- prevCardTypeRef.current = null;
664
- return;
665
- }
666
- const savedCardType = carouselData?.[0]?.mediaType;
667
- if (savedCardType && savedCardType !== prevCardTypeRef.current) {
668
- setCarouselMediaType(savedCardType);
669
- }
670
- prevCardTypeRef.current = savedCardType;
671
- }, [mediaType, carouselData]);
908
+ }, [mediaType, imageData, uploadingCardIndex, currentUploadId, activeTab, updateCarouselCard]);
672
909
 
673
910
  if (mediaType === IMAGE) return renderImageComponent();
674
911
  if (mediaType === VIDEO) return renderVideoComponent();
@@ -693,12 +930,15 @@ MediaUploaders.propTypes = {
693
930
  videoDataForGif: PropTypes.object.isRequired,
694
931
  videoSrc: PropTypes.object, // Add videoSrc prop for content state fallback
695
932
  formatMessage: PropTypes.func.isRequired,
933
+ linkProps: PropTypes.object,
696
934
  clearImageDataByMediaType: PropTypes.func.isRequired,
697
935
  carouselData: PropTypes.array,
698
936
  onCarouselDataChange: PropTypes.func,
699
937
  mobilePushActions: PropTypes.object.isRequired,
700
938
  carouselActiveTabIndex: PropTypes.number.isRequired,
701
939
  setCarouselActiveTabIndex: PropTypes.func.isRequired,
940
+ carouselLinkErrors: PropTypes.object,
941
+ updateCarouselLinkError: PropTypes.func,
702
942
  };
703
943
 
704
944
  export default MediaUploaders;