@capillarytech/creatives-library 9.2.1 → 9.2.2-alpha.sprint-cap-214249.44
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/constants/unified.js +0 -1
- package/package.json +1 -1
- package/utils/common.js +0 -6
- package/utils/createMobilePushPayload.js +50 -56
- package/utils/tests/createMobilePushPayload.test.js +177 -168
- package/v2Components/CapMpushCTA/index.js +47 -57
- package/v2Components/CapMpushCTA/index.scss +43 -5
- package/v2Components/CapMpushCTA/tests/index.test.js +150 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +11 -8
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/index.js +51 -12
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +83 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +100 -0
- package/v2Components/MobilePushPreviewV2/_mobilePushPreviewV2.scss +7 -0
- package/v2Components/MobilePushPreviewV2/index.js +22 -9
- package/v2Components/MobilePushPreviewV2/tests/index.test.js +55 -0
- package/v2Components/TemplatePreview/_mobilePushPhone.scss +72 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +18 -2
- package/v2Components/TemplatePreview/index.js +20 -18
- package/v2Components/TemplatePreview/tests/index.test.js +69 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/extractContentForPreview.test.js +45 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js +12 -2
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -6
- package/v2Containers/CreativesContainer/index.js +2 -1
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +43 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +105 -345
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +127 -105
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +76 -0
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +305 -1482
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +165 -59
- package/v2Containers/MobilePushNew/constants.js +12 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +78 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +40 -1
- package/v2Containers/MobilePushNew/hooks/useUpload.js +42 -46
- package/v2Containers/MobilePushNew/index.js +498 -289
- package/v2Containers/MobilePushNew/index.scss +151 -4
- package/v2Containers/MobilePushNew/messages.js +106 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +483 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +110 -0
- package/v2Containers/MobilePushNew/utils.js +83 -0
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +86 -81
- package/v2Containers/Templates/tests/index.test.js +81 -0
|
@@ -5,7 +5,6 @@ import React, {
|
|
|
5
5
|
useRef,
|
|
6
6
|
} from "react";
|
|
7
7
|
import PropTypes from "prop-types";
|
|
8
|
-
import { FormattedMessage } from "react-intl";
|
|
9
8
|
import CapButton from "@capillarytech/cap-ui-library/CapButton";
|
|
10
9
|
import CapCard from "@capillarytech/cap-ui-library/CapCard";
|
|
11
10
|
import CapColumn from "@capillarytech/cap-ui-library/CapColumn";
|
|
@@ -15,11 +14,7 @@ import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
|
|
|
15
14
|
import CapRadioGroup from "@capillarytech/cap-ui-library/CapRadioGroup";
|
|
16
15
|
import CapRow from "@capillarytech/cap-ui-library/CapRow";
|
|
17
16
|
import CapTab from "@capillarytech/cap-ui-library/CapTab";
|
|
18
|
-
import
|
|
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";
|
|
17
|
+
import CapTooltip from "@capillarytech/cap-ui-library/CapTooltip";
|
|
23
18
|
import CapImageUpload from "../../../v2Components/CapImageUpload";
|
|
24
19
|
import CapVideoUpload from "../../../v2Components/CapVideoUpload";
|
|
25
20
|
import {
|
|
@@ -36,14 +31,11 @@ import {
|
|
|
36
31
|
GIF,
|
|
37
32
|
IMAGE,
|
|
38
33
|
VIDEO,
|
|
39
|
-
LINK_TYPE_OPTIONS,
|
|
40
34
|
DEEP_LINK,
|
|
41
|
-
EXTERNAL_LINK,
|
|
42
35
|
CAROUSEL,
|
|
43
36
|
} from "../constants";
|
|
44
37
|
import messages from "../messages";
|
|
45
|
-
import {
|
|
46
|
-
import TagList from "../../TagList";
|
|
38
|
+
import { getCarouselCardIssue } from "../utils";
|
|
47
39
|
|
|
48
40
|
// Initial carousel data structure
|
|
49
41
|
const CAROUSEL_INITIAL_DATA = {
|
|
@@ -62,22 +54,6 @@ const CAROUSEL_INITIAL_DATA = {
|
|
|
62
54
|
// Maximum number of carousel cards allowed
|
|
63
55
|
const MAX_CAROUSEL_ALLOWED = 10;
|
|
64
56
|
|
|
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
|
-
|
|
81
57
|
const MediaUploaders = ({
|
|
82
58
|
mediaType,
|
|
83
59
|
activeTab,
|
|
@@ -94,20 +70,12 @@ const MediaUploaders = ({
|
|
|
94
70
|
videoDataForGif,
|
|
95
71
|
videoSrc, // Add videoSrc prop for content state fallback
|
|
96
72
|
formatMessage,
|
|
97
|
-
linkProps,
|
|
98
73
|
clearImageDataByMediaType,
|
|
99
74
|
carouselData = [], // Carousel data from content state
|
|
100
75
|
onCarouselDataChange, // Callback to update carousel data in parent
|
|
101
76
|
mobilePushActions, // Mobile push actions for clearing assets
|
|
102
77
|
carouselActiveTabIndex,
|
|
103
78
|
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,
|
|
111
79
|
}) => {
|
|
112
80
|
// Carousel state management - separate for Android and iOS
|
|
113
81
|
const [carouselMediaType, setCarouselMediaType] = useState(IMAGE.toLowerCase());
|
|
@@ -121,15 +89,16 @@ const MediaUploaders = ({
|
|
|
121
89
|
// Track upload ID to prevent processing stale Redux data
|
|
122
90
|
const [currentUploadId, setCurrentUploadId] = useState(null);
|
|
123
91
|
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);
|
|
124
94
|
|
|
125
95
|
// Track previous upload data to detect when a new upload completes
|
|
126
96
|
const previousUploadDataRef = useRef(null);
|
|
127
97
|
|
|
128
98
|
// Track previous media type to handle transitions
|
|
129
99
|
const previousMediaTypeRef = useRef(mediaType);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const { deepLink } = linkProps || {};
|
|
100
|
+
// First card's media type last seen, for the saved-carousel effect
|
|
101
|
+
const prevCardTypeRef = useRef(null);
|
|
133
102
|
|
|
134
103
|
// Get current carousel data based on active tab
|
|
135
104
|
const getCurrentCarouselData = useCallback(() => carouselData || [], [carouselData]);
|
|
@@ -149,24 +118,12 @@ const MediaUploaders = ({
|
|
|
149
118
|
)));
|
|
150
119
|
}, [getCurrentCarouselData, setCurrentCarouselData]);
|
|
151
120
|
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
|
|
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]);
|
|
167
|
-
|
|
168
|
-
// Clear previous media data when switching media types
|
|
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.
|
|
169
124
|
useEffect(() => {
|
|
125
|
+
if (previousMediaTypeRef.current === mediaType) return;
|
|
126
|
+
|
|
170
127
|
// Clear carousel data when switching to non-carousel media types
|
|
171
128
|
if (mediaType !== CAROUSEL) {
|
|
172
129
|
setCurrentCarouselData([]);
|
|
@@ -178,15 +135,15 @@ const MediaUploaders = ({
|
|
|
178
135
|
previousUploadDataRef.current = null;
|
|
179
136
|
}
|
|
180
137
|
|
|
181
|
-
// Clear image data when switching away from IMAGE media type
|
|
138
|
+
// Clear image data when switching away from IMAGE media type (this pane's platform only)
|
|
182
139
|
if (mediaType !== IMAGE) {
|
|
183
|
-
clearImageDataByMediaType(IMAGE);
|
|
140
|
+
clearImageDataByMediaType(IMAGE, activeTab);
|
|
184
141
|
}
|
|
185
142
|
|
|
186
143
|
// Clear image data when switching FROM CAROUSEL TO IMAGE
|
|
187
144
|
// This prevents carousel images from appearing in IMAGE media type
|
|
188
145
|
if (previousMediaTypeRef.current === CAROUSEL && mediaType === IMAGE) {
|
|
189
|
-
clearImageDataByMediaType(IMAGE);
|
|
146
|
+
clearImageDataByMediaType(IMAGE, activeTab);
|
|
190
147
|
}
|
|
191
148
|
|
|
192
149
|
// Reset re-upload mode when switching media types
|
|
@@ -194,7 +151,7 @@ const MediaUploaders = ({
|
|
|
194
151
|
|
|
195
152
|
// Update the previous media type ref
|
|
196
153
|
previousMediaTypeRef.current = mediaType;
|
|
197
|
-
}, [mediaType, clearImageDataByMediaType, setCurrentCarouselData]);
|
|
154
|
+
}, [mediaType, activeTab, clearImageDataByMediaType, setCurrentCarouselData]);
|
|
198
155
|
|
|
199
156
|
// Handle platform tab changes for carousel data
|
|
200
157
|
useEffect(() => {
|
|
@@ -369,6 +326,7 @@ const MediaUploaders = ({
|
|
|
369
326
|
mediaType: value,
|
|
370
327
|
imageUrl: value === IMAGE.toLowerCase() ? card.imageUrl : '',
|
|
371
328
|
videoSrc: value === VIDEO.toLowerCase() ? card.videoSrc : '',
|
|
329
|
+
videoPreviewImg: value === VIDEO.toLowerCase() ? card.videoPreviewImg : '',
|
|
372
330
|
buttons: card.buttons || [{
|
|
373
331
|
actionOnClick: false,
|
|
374
332
|
linkType: DEEP_LINK,
|
|
@@ -382,13 +340,18 @@ const MediaUploaders = ({
|
|
|
382
340
|
setCarouselActiveTabIndex(Number(key));
|
|
383
341
|
};
|
|
384
342
|
|
|
343
|
+
// A card is done once its media is uploaded
|
|
344
|
+
const hasIncompleteCard = getCurrentCarouselData()?.some((card) => getCarouselCardIssue(card));
|
|
345
|
+
|
|
385
346
|
const addCarouselCard = () => {
|
|
386
347
|
const currentData = getCurrentCarouselData();
|
|
387
|
-
if (currentData?.length < MAX_CAROUSEL_ALLOWED) {
|
|
348
|
+
if (currentData?.length < MAX_CAROUSEL_ALLOWED && !hasIncompleteCard) {
|
|
388
349
|
setCurrentCarouselData([
|
|
389
350
|
...currentData,
|
|
390
351
|
{ ...CAROUSEL_INITIAL_DATA, mediaType: carouselMediaType },
|
|
391
352
|
]);
|
|
353
|
+
// Open the new card so its upload box is in view
|
|
354
|
+
setCarouselActiveTabIndex(currentData.length);
|
|
392
355
|
}
|
|
393
356
|
};
|
|
394
357
|
|
|
@@ -438,73 +401,6 @@ const MediaUploaders = ({
|
|
|
438
401
|
}, 100);
|
|
439
402
|
};
|
|
440
403
|
|
|
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
|
-
|
|
508
404
|
const renderCarouselImageComponent = (cardIndex) => {
|
|
509
405
|
const currentData = getCurrentCarouselData();
|
|
510
406
|
const card = currentData[cardIndex];
|
|
@@ -554,211 +450,48 @@ const MediaUploaders = ({
|
|
|
554
450
|
);
|
|
555
451
|
};
|
|
556
452
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
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;
|
|
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;
|
|
584
459
|
}
|
|
460
|
+
updateCarouselCard(cardIndex, { videoSrc, videoPreviewImg: videoSrc ? previewUrl : '' });
|
|
461
|
+
};
|
|
585
462
|
|
|
586
|
-
|
|
463
|
+
const renderCarouselVideoComponent = (cardIndex) => {
|
|
464
|
+
const card = getCurrentCarouselData()?.[cardIndex];
|
|
587
465
|
|
|
588
|
-
//
|
|
589
|
-
const
|
|
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
|
+
};
|
|
590
475
|
|
|
591
476
|
return (
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
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
|
-
</>
|
|
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
|
+
/>
|
|
762
495
|
);
|
|
763
496
|
};
|
|
764
497
|
|
|
@@ -798,23 +531,35 @@ const MediaUploaders = ({
|
|
|
798
531
|
</CapRow>
|
|
799
532
|
)}
|
|
800
533
|
</CapRow>
|
|
801
|
-
{renderCarouselActionLinks(index)}
|
|
802
534
|
</CapCard>
|
|
803
535
|
),
|
|
804
536
|
}));
|
|
805
537
|
};
|
|
806
538
|
|
|
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
|
+
|
|
807
547
|
const operations = (
|
|
808
548
|
<>
|
|
809
549
|
<CapDivider type="vertical" />
|
|
810
|
-
<
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
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>
|
|
818
563
|
</>
|
|
819
564
|
);
|
|
820
565
|
|
|
@@ -839,7 +584,6 @@ const MediaUploaders = ({
|
|
|
839
584
|
{
|
|
840
585
|
value: VIDEO.toLowerCase(),
|
|
841
586
|
label: formatMessage(messages.mediaVideo),
|
|
842
|
-
disabled: true,
|
|
843
587
|
},
|
|
844
588
|
]}
|
|
845
589
|
value={carouselMediaType}
|
|
@@ -875,10 +619,7 @@ const MediaUploaders = ({
|
|
|
875
619
|
videoDataForVideo,
|
|
876
620
|
formatMessage,
|
|
877
621
|
mobilePushActions,
|
|
878
|
-
carouselLinkErrors,
|
|
879
|
-
updateCarouselLinkError,
|
|
880
622
|
setCarouselActiveTabIndex,
|
|
881
|
-
deepLink,
|
|
882
623
|
]);
|
|
883
624
|
|
|
884
625
|
// Manually handle upload completion for carousel cards (since automatic restoration is disabled)
|
|
@@ -893,8 +634,16 @@ const MediaUploaders = ({
|
|
|
893
634
|
const previousDataKey = previousUploadDataRef.current;
|
|
894
635
|
|
|
895
636
|
if (currentDataKey !== previousDataKey) {
|
|
896
|
-
|
|
897
|
-
|
|
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 });
|
|
898
647
|
|
|
899
648
|
// Store this upload data as "processed" to avoid reprocessing
|
|
900
649
|
previousUploadDataRef.current = currentDataKey;
|
|
@@ -905,7 +654,21 @@ const MediaUploaders = ({
|
|
|
905
654
|
}
|
|
906
655
|
}
|
|
907
656
|
}
|
|
908
|
-
}, [mediaType, imageData, uploadingCardIndex, currentUploadId, activeTab, updateCarouselCard]);
|
|
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]);
|
|
909
672
|
|
|
910
673
|
if (mediaType === IMAGE) return renderImageComponent();
|
|
911
674
|
if (mediaType === VIDEO) return renderVideoComponent();
|
|
@@ -930,15 +693,12 @@ MediaUploaders.propTypes = {
|
|
|
930
693
|
videoDataForGif: PropTypes.object.isRequired,
|
|
931
694
|
videoSrc: PropTypes.object, // Add videoSrc prop for content state fallback
|
|
932
695
|
formatMessage: PropTypes.func.isRequired,
|
|
933
|
-
linkProps: PropTypes.object,
|
|
934
696
|
clearImageDataByMediaType: PropTypes.func.isRequired,
|
|
935
697
|
carouselData: PropTypes.array,
|
|
936
698
|
onCarouselDataChange: PropTypes.func,
|
|
937
699
|
mobilePushActions: PropTypes.object.isRequired,
|
|
938
700
|
carouselActiveTabIndex: PropTypes.number.isRequired,
|
|
939
701
|
setCarouselActiveTabIndex: PropTypes.func.isRequired,
|
|
940
|
-
carouselLinkErrors: PropTypes.object,
|
|
941
|
-
updateCarouselLinkError: PropTypes.func,
|
|
942
702
|
};
|
|
943
703
|
|
|
944
704
|
export default MediaUploaders;
|