@capillarytech/creatives-library 9.2.1-alpha.sprint-cap-214249.42 → 9.2.1
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/AppRoot.js +4 -7
- package/constants/unified.js +1 -0
- package/package.json +1 -1
- package/utils/beePluginLoader.js +106 -0
- package/utils/common.js +6 -0
- package/utils/createMobilePushPayload.js +51 -56
- package/utils/tests/beePluginLoader.test.js +199 -0
- package/utils/tests/createMobilePushPayload.test.js +10 -162
- package/v2Components/CapMpushCTA/index.js +57 -47
- package/v2Components/CapMpushCTA/index.scss +5 -43
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +8 -11
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
- package/v2Components/CommonTestAndPreview/constants.js +0 -2
- package/v2Components/CommonTestAndPreview/index.js +10 -48
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -83
- package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
- package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
- package/v2Components/TemplatePreview/index.js +12 -14
- package/v2Components/TemplatePreview/tests/index.test.js +0 -69
- package/v2Containers/BeeEditor/index.js +49 -22
- package/v2Containers/BeeEditor/index.scss +12 -0
- package/v2Containers/BeeEditor/messages.js +8 -0
- package/v2Containers/BeeEditor/test/index.test.js +78 -0
- package/v2Containers/BeePopupEditor/index.js +22 -11
- package/v2Containers/CreativesContainer/SlideBoxContent.js +9 -5
- package/v2Containers/CreativesContainer/index.js +1 -2
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -43
- package/v2Containers/Email/index.js +2 -2
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +25 -23
- package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +222 -314
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +130 -161
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +123 -484
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +46 -152
- package/v2Containers/MobilePushNew/constants.js +0 -12
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -78
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -40
- package/v2Containers/MobilePushNew/hooks/useUpload.js +46 -42
- package/v2Containers/MobilePushNew/index.js +273 -503
- package/v2Containers/MobilePushNew/index.scss +4 -215
- package/v2Containers/MobilePushNew/messages.js +6 -106
- package/v2Containers/MobilePushNew/tests/index.test.js +1 -482
- package/v2Containers/MobilePushNew/tests/utils.test.js +0 -122
- package/v2Containers/MobilePushNew/utils.js +0 -107
- package/v2Containers/Templates/_templates.scss +2 -10
- package/v2Containers/Templates/index.js +81 -83
- package/v2Containers/Templates/tests/index.test.js +0 -68
- package/v2Components/CapMpushCTA/tests/index.test.js +0 -150
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +0 -76
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useCallback, useEffect
|
|
1
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
2
2
|
import { getCdnUrl } from '../../../utils/cdnTransformation';
|
|
3
3
|
import {
|
|
4
4
|
MOBILE_PUSH_CHANNEL,
|
|
@@ -51,10 +51,6 @@ const useUpload = (mobilePushActions, editData = {}, _uploadedAssetData0 = {}, _
|
|
|
51
51
|
|
|
52
52
|
const [uploadErrors, setUploadErrors] = useState({});
|
|
53
53
|
|
|
54
|
-
// Latest tick/tab: the uploader's Re-upload button keeps its first-render handlers
|
|
55
|
-
const syncStateRef = useRef({ sameContent, activeTab });
|
|
56
|
-
syncStateRef.current = { sameContent, activeTab };
|
|
57
|
-
|
|
58
54
|
// Add assetList state for test assertions
|
|
59
55
|
const [assetList, setAssetList] = useState([]);
|
|
60
56
|
|
|
@@ -152,9 +148,8 @@ const useUpload = (mobilePushActions, editData = {}, _uploadedAssetData0 = {}, _
|
|
|
152
148
|
mobilePushActions.uploadAsset(file, assetType, fileParams, activeTab === ANDROID ? 0 : 1, mobilePushParams);
|
|
153
149
|
}, [mobilePushActions, validateImageFile, validateVideoFile, validateGifFile, activeTab]);
|
|
154
150
|
|
|
155
|
-
// Clear media data when switching media types
|
|
156
|
-
|
|
157
|
-
const clearImageDataByMediaType = useCallback((mediaType, platform = activeTab) => {
|
|
151
|
+
// Clear media data when switching media types
|
|
152
|
+
const clearImageDataByMediaType = useCallback((mediaType) => {
|
|
158
153
|
if (mediaType === IMAGE) {
|
|
159
154
|
if (sameContent) {
|
|
160
155
|
// When sync is enabled, clear both platforms
|
|
@@ -163,11 +158,11 @@ const useUpload = (mobilePushActions, editData = {}, _uploadedAssetData0 = {}, _
|
|
|
163
158
|
iosImageSrc: "",
|
|
164
159
|
});
|
|
165
160
|
} else {
|
|
166
|
-
// When sync is disabled, only clear
|
|
167
|
-
const
|
|
161
|
+
// When sync is disabled, only clear the current platform
|
|
162
|
+
const platform = activeTab === ANDROID ? 'androidImageSrc' : 'iosImageSrc';
|
|
168
163
|
setImageSrc((prevState) => ({
|
|
169
164
|
...prevState,
|
|
170
|
-
[
|
|
165
|
+
[platform]: "",
|
|
171
166
|
}));
|
|
172
167
|
}
|
|
173
168
|
} else if (mediaType === VIDEO || mediaType === GIF) {
|
|
@@ -201,9 +196,9 @@ const useUpload = (mobilePushActions, editData = {}, _uploadedAssetData0 = {}, _
|
|
|
201
196
|
mobilePushActions.clearAsset(0);
|
|
202
197
|
mobilePushActions.clearAsset(1);
|
|
203
198
|
} else {
|
|
204
|
-
// When sync is disabled, only clear
|
|
205
|
-
const platformIndex =
|
|
206
|
-
const isAndroid =
|
|
199
|
+
// When sync is disabled, only clear the current platform
|
|
200
|
+
const platformIndex = activeTab === ANDROID ? 0 : 1;
|
|
201
|
+
const isAndroid = activeTab === ANDROID;
|
|
207
202
|
const videoProps = getVideoProperties(isAndroid);
|
|
208
203
|
|
|
209
204
|
setVideoState((prevState) => ({
|
|
@@ -298,11 +293,17 @@ const useUpload = (mobilePushActions, editData = {}, _uploadedAssetData0 = {}, _
|
|
|
298
293
|
}
|
|
299
294
|
}, [videoState?.androidVideoSrc, videoState?.iosVideoSrc, videoState?.androidVideoPreview, videoState?.iosVideoPreview, videoState?.androidVideoDuration, videoState?.iosVideoDuration, sameContent]);
|
|
300
295
|
|
|
301
|
-
//
|
|
296
|
+
// Sync imageSrc state for both platforms when sameContent is toggled ON
|
|
302
297
|
useEffect(() => {
|
|
303
298
|
if (sameContent) {
|
|
304
|
-
|
|
305
|
-
|
|
299
|
+
// Determine which image to use (prefer activeTab, fallback to either)
|
|
300
|
+
let currentImageSrc = '';
|
|
301
|
+
if (activeTab === ANDROID) {
|
|
302
|
+
currentImageSrc = imageSrc?.androidImageSrc || imageSrc?.iosImageSrc;
|
|
303
|
+
} else {
|
|
304
|
+
currentImageSrc = imageSrc?.iosImageSrc || imageSrc?.androidImageSrc;
|
|
305
|
+
}
|
|
306
|
+
if (currentImageSrc && (imageSrc?.androidImageSrc !== currentImageSrc || imageSrc?.iosImageSrc !== currentImageSrc)) {
|
|
306
307
|
setImageSrc({
|
|
307
308
|
androidImageSrc: currentImageSrc,
|
|
308
309
|
iosImageSrc: currentImageSrc,
|
|
@@ -313,20 +314,31 @@ const useUpload = (mobilePushActions, editData = {}, _uploadedAssetData0 = {}, _
|
|
|
313
314
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
314
315
|
}, [sameContent, activeTab]);
|
|
315
316
|
|
|
316
|
-
//
|
|
317
|
+
// Sync videoState for both platforms when sameContent is toggled ON
|
|
317
318
|
useEffect(() => {
|
|
318
319
|
if (sameContent) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
320
|
+
// Determine which video to use (prefer activeTab, fallback to either)
|
|
321
|
+
let currentVideoSrc = '';
|
|
322
|
+
let currentVideoPreview = '';
|
|
323
|
+
let currentVideoDuration = 0;
|
|
324
|
+
if (activeTab === ANDROID) {
|
|
325
|
+
currentVideoSrc = videoState?.androidVideoSrc || videoState?.iosVideoSrc;
|
|
326
|
+
currentVideoPreview = videoState?.androidVideoPreview || videoState?.iosVideoPreview;
|
|
327
|
+
currentVideoDuration = videoState?.androidVideoDuration || videoState?.iosVideoDuration;
|
|
328
|
+
} else {
|
|
329
|
+
currentVideoSrc = videoState?.iosVideoSrc || videoState?.androidVideoSrc;
|
|
330
|
+
currentVideoPreview = videoState?.iosVideoPreview || videoState?.androidVideoPreview;
|
|
331
|
+
currentVideoDuration = videoState?.iosVideoDuration || videoState?.androidVideoDuration;
|
|
332
|
+
}
|
|
323
333
|
if (
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
334
|
+
currentVideoSrc && (
|
|
335
|
+
videoState?.androidVideoSrc !== currentVideoSrc
|
|
336
|
+
|| videoState?.iosVideoSrc !== currentVideoSrc
|
|
337
|
+
|| videoState?.androidVideoPreview !== currentVideoPreview
|
|
338
|
+
|| videoState?.iosVideoPreview !== currentVideoPreview
|
|
339
|
+
|| videoState?.androidVideoDuration !== currentVideoDuration
|
|
340
|
+
|| videoState?.iosVideoDuration !== currentVideoDuration
|
|
341
|
+
)
|
|
330
342
|
) {
|
|
331
343
|
setVideoState({
|
|
332
344
|
androidVideoSrc: currentVideoSrc,
|
|
@@ -337,12 +349,6 @@ const useUpload = (mobilePushActions, editData = {}, _uploadedAssetData0 = {}, _
|
|
|
337
349
|
iosVideoDuration: currentVideoDuration,
|
|
338
350
|
});
|
|
339
351
|
}
|
|
340
|
-
// The upload box also reads the uploaded-file list
|
|
341
|
-
const sourceAssetList = isAndroid ? androidAssetList : iosAssetList;
|
|
342
|
-
const targetAssetList = isAndroid ? iosAssetList : androidAssetList;
|
|
343
|
-
if (JSON.stringify(sourceAssetList) !== JSON.stringify(targetAssetList)) {
|
|
344
|
-
(isAndroid ? updateIosAssetList : updateAndroidAssetList)(sourceAssetList);
|
|
345
|
-
}
|
|
346
352
|
}
|
|
347
353
|
// Only run when sameContent or activeTab changes
|
|
348
354
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -350,29 +356,27 @@ const useUpload = (mobilePushActions, editData = {}, _uploadedAssetData0 = {}, _
|
|
|
350
356
|
|
|
351
357
|
// Image upload handlers
|
|
352
358
|
const updateOnMpushImageReUpload = useCallback(() => {
|
|
353
|
-
|
|
354
|
-
if (isSynced) {
|
|
359
|
+
if (sameContent) {
|
|
355
360
|
// When sync is enabled, set image for both platforms
|
|
356
361
|
setImageSrc({
|
|
357
362
|
androidImageSrc: "",
|
|
358
363
|
iosImageSrc: "",
|
|
359
364
|
});
|
|
360
365
|
} else {
|
|
361
|
-
const platform =
|
|
366
|
+
const platform = activeTab === ANDROID ? 'androidImageSrc' : 'iosImageSrc';
|
|
362
367
|
setImageSrc((prevState) => ({
|
|
363
368
|
...prevState,
|
|
364
369
|
[platform]: "",
|
|
365
370
|
}));
|
|
366
371
|
}
|
|
367
|
-
}, []);
|
|
372
|
+
}, [sameContent, activeTab]);
|
|
368
373
|
|
|
369
374
|
const setUpdateMpushImageSrc = useCallback((filePath, index, mediaType = IMAGE) => {
|
|
370
|
-
const { sameContent: isSynced } = syncStateRef.current;
|
|
371
375
|
// Handle both non-carousel and carousel media types
|
|
372
376
|
if (mediaType === CAROUSEL) {
|
|
373
377
|
// For carousel images, we need to set them in the Redux state for the uploader to recognize
|
|
374
378
|
// This is needed when initializing carousel images from template data
|
|
375
|
-
if (
|
|
379
|
+
if (sameContent) {
|
|
376
380
|
// When sync is enabled, set image for both platforms
|
|
377
381
|
setImageSrc({
|
|
378
382
|
androidImageSrc: filePath,
|
|
@@ -390,7 +394,7 @@ const useUpload = (mobilePushActions, editData = {}, _uploadedAssetData0 = {}, _
|
|
|
390
394
|
return;
|
|
391
395
|
}
|
|
392
396
|
|
|
393
|
-
if (
|
|
397
|
+
if (sameContent) {
|
|
394
398
|
// When sync is enabled, set image for both platforms
|
|
395
399
|
setImageSrc({
|
|
396
400
|
androidImageSrc: filePath,
|
|
@@ -406,7 +410,7 @@ const useUpload = (mobilePushActions, editData = {}, _uploadedAssetData0 = {}, _
|
|
|
406
410
|
}
|
|
407
411
|
|
|
408
412
|
mobilePushActions.clearAsset(index);
|
|
409
|
-
}, [mobilePushActions, setImageSrc]);
|
|
413
|
+
}, [mobilePushActions, sameContent, setImageSrc]);
|
|
410
414
|
|
|
411
415
|
// Video re-upload handler - clear video data based on platform and sync settings
|
|
412
416
|
const updateOnMpushVideoReUpload = useCallback(() => {
|