@capillarytech/creatives-library 9.1.7 → 9.1.8-alpha.sprint-cap-214249.38

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 (81) hide show
  1. package/constants/unified.js +0 -1
  2. package/index.js +0 -13
  3. package/package.json +1 -1
  4. package/services/getSchema.js +1 -4
  5. package/services/tests/getSchema.test.js +2 -2
  6. package/utils/common.js +0 -6
  7. package/utils/createMobilePushPayload.js +47 -33
  8. package/utils/tests/createMobilePushPayload.test.js +102 -8
  9. package/v2Components/CapMpushCTA/index.js +10 -9
  10. package/v2Components/CapMpushCTA/index.scss +29 -3
  11. package/v2Components/CapMpushCTA/tests/index.test.js +89 -0
  12. package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +26 -13
  13. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
  14. package/v2Components/CommonTestAndPreview/constants.js +2 -0
  15. package/v2Components/CommonTestAndPreview/index.js +49 -11
  16. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +79 -5
  17. package/v2Components/CommonTestAndPreview/tests/index.test.js +86 -0
  18. package/v2Components/FormBuilder/Functional/tests/mpush.crossFlowParity.test.js +1 -1
  19. package/v2Components/FormBuilder/Functional/tests/mpush.shellEvents.test.js +1 -1
  20. package/v2Components/FormBuilder/Functional/tests/mpush.singlePlatform.test.js +1 -1
  21. package/v2Components/FormBuilder/tests/mpush.characterization.test.js +2 -2
  22. package/v2Components/TemplatePreview/_templatePreview.scss +12 -2
  23. package/v2Components/TemplatePreview/index.js +30 -17
  24. package/v2Components/TemplatePreview/tests/index.test.js +61 -0
  25. package/v2Containers/Cap/index.js +0 -3
  26. package/v2Containers/CreativesContainer/SlideBoxContent.js +70 -151
  27. package/v2Containers/CreativesContainer/index.js +3 -6
  28. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +29 -0
  29. package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
  30. package/v2Containers/MobilePushNew/components/MediaUploaders.js +207 -192
  31. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +116 -121
  32. package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
  33. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +316 -72
  34. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +45 -16
  35. package/v2Containers/MobilePushNew/constants.js +5 -0
  36. package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
  37. package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +52 -0
  38. package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +38 -1
  39. package/v2Containers/MobilePushNew/hooks/useUpload.js +29 -39
  40. package/v2Containers/MobilePushNew/index.js +453 -188
  41. package/v2Containers/MobilePushNew/index.scss +188 -4
  42. package/v2Containers/MobilePushNew/messages.js +86 -6
  43. package/v2Containers/MobilePushNew/tests/index.test.js +450 -1
  44. package/v2Containers/MobilePushNew/tests/utils.test.js +25 -0
  45. package/v2Containers/MobilePushNew/utils.js +8 -0
  46. package/v2Containers/Templates/_templates.scss +10 -2
  47. package/v2Containers/Templates/index.js +84 -90
  48. package/v2Containers/Templates/tests/index.test.js +68 -0
  49. package/v2Components/FormBuilder/Functional/tests/manual.typingPerf.test.js +0 -135
  50. package/v2Components/FormBuilder/Functional/tests/mpush.ctaFlows.parity.test.js +0 -320
  51. package/v2Components/FormBuilder/Functional/tests/mpush.editContainer.parity.test.js +0 -148
  52. package/v2Components/FormBuilder/Functional/tests/mpush.libraryValidity.parity.test.js +0 -152
  53. package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +0 -70
  54. package/v2Containers/MobilePush/Create/actions.js +0 -52
  55. package/v2Containers/MobilePush/Create/constants.js +0 -26
  56. package/v2Containers/MobilePush/Create/index.js +0 -2149
  57. package/v2Containers/MobilePush/Create/messages.js +0 -349
  58. package/v2Containers/MobilePush/Create/reducer.js +0 -72
  59. package/v2Containers/MobilePush/Create/sagas.js +0 -79
  60. package/v2Containers/MobilePush/Create/selectors.js +0 -29
  61. package/v2Containers/MobilePush/Create/test/contentValidity.test.js +0 -154
  62. package/v2Containers/MobilePush/Create/test/saga.test.js +0 -19
  63. package/v2Containers/MobilePush/Create/test/stayOpenOnSave.test.js +0 -80
  64. package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +0 -65
  65. package/v2Containers/MobilePush/Edit/actions.js +0 -94
  66. package/v2Containers/MobilePush/Edit/constants.js +0 -37
  67. package/v2Containers/MobilePush/Edit/index.js +0 -2407
  68. package/v2Containers/MobilePush/Edit/messages.js +0 -341
  69. package/v2Containers/MobilePush/Edit/reducer.js +0 -113
  70. package/v2Containers/MobilePush/Edit/sagas.js +0 -113
  71. package/v2Containers/MobilePush/Edit/selectors.js +0 -33
  72. package/v2Containers/MobilePush/Edit/test/contentValidity.test.js +0 -149
  73. package/v2Containers/MobilePush/Edit/test/saga.test.js +0 -255
  74. package/v2Containers/MobilePush/Edit/test/stayOpenOnSave.test.js +0 -60
  75. package/v2Containers/MobilePush/commonMethods.js +0 -333
  76. package/v2Containers/MobilePush/eventsMap.js +0 -130
  77. package/v2Containers/MobilePush/tests/commonMethods.test.js +0 -401
  78. package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +0 -22
  79. package/v2Containers/MobilepushWrapper/index.js +0 -178
  80. package/v2Containers/MobilepushWrapper/messages.js +0 -29
  81. /package/{v2Containers/MobilePush/initialSchema.js → v2Components/FormBuilder/Functional/tests/fixtures/mpushInitialSchema.js} +0 -0
@@ -19,10 +19,12 @@ import CapSpin from "@capillarytech/cap-ui-library/CapSpin";
19
19
  import CapTab from "@capillarytech/cap-ui-library/CapTab";
20
20
  import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
21
21
  import CapColumn from "@capillarytech/cap-ui-library/CapColumn";
22
+ import CapSelect from "@capillarytech/cap-ui-library/CapSelect";
22
23
  import { intlShape, FormattedMessage } from "react-intl";
23
24
  import "./index.scss";
24
25
  import { GA } from "@capillarytech/cap-ui-utils";
25
26
  import CapNotification from "@capillarytech/cap-ui-library/CapNotification";
27
+ import CapModal from "@capillarytech/cap-ui-library/CapModal";
26
28
  import { DAEMON } from "@capillarytech/vulcan-react-sdk/utils/sagaInjectorTypes";
27
29
  import globalMessages from "../Cap/messages";
28
30
  import * as actions from "./actions";
@@ -30,6 +32,7 @@ import {
30
32
  MEDIA_TYPES_OPTIONS,
31
33
  ANDROID,
32
34
  IOS,
35
+ BOTH_PLATFORMS,
33
36
  MOBILE_PUSH_CHANNEL,
34
37
  INITIAL_CONTENT,
35
38
  BIG_PICTURE,
@@ -75,7 +78,6 @@ import {
75
78
  import withCreatives from "../../hoc/withCreatives";
76
79
  import { BIG_TEXT, DEEP_LINK, DEVICE_SUPPORTED } from "../InApp/constants";
77
80
  import { v2MobilePushSagas } from "./sagas";
78
- import { getContent } from "../MobilePush/commonMethods";
79
81
  import { getMessageObject } from "../../utils/messageUtils";
80
82
  import { gtmPush } from "../../utils/gtmTrackers";
81
83
  import mobilePushReducer from "./reducer";
@@ -88,16 +90,17 @@ import useUpload from "./hooks/useUpload";
88
90
  import { validateTags } from "../../utils/tagValidations";
89
91
  import { PlatformContentFields } from "./components";
90
92
  import { CREATE, EDIT, TRACK_CREATE_MPUSH } from "../App/constants";
91
- import { validateExternalLink, validateDeepLink, isPlatformFieldsMissing } from "./utils";
93
+ import {
94
+ validateExternalLink, validateDeepLink, isPlatformFieldsMissing, getContent,
95
+ } from "./utils";
92
96
  import messages from "./messages";
93
97
  import { EXTERNAL_URL, MOBILE_PUSH } from "../CreativesContainer/constants";
94
- import createMobilePushPayloadWithIntl from "../../utils/createMobilePushPayload";
98
+ import createMobilePushPayloadWithIntl, { buildCarouselCards } from "../../utils/createMobilePushPayload";
95
99
  import { MOBILEPUSH } from "../../v2Components/CapVideoUpload/constants";
96
100
  import { StyledCapTab } from "./style";
97
101
  import TestAndPreviewSlidebox from "../../v2Components/TestAndPreviewSlidebox";
98
102
 
99
103
  import creativesMessages from "../CreativesContainer/messages";
100
- import { error } from "jquery";
101
104
 
102
105
  // Helper function to extract deep link keys from URL where value equals key
103
106
  const extractDeepLinkKeys = (deepLinkValue) => {
@@ -276,8 +279,50 @@ const processCtaButtons = (ctas, deepLink) => {
276
279
  };
277
280
  };
278
281
 
282
+ const getOtherPlatform = (platform) => (platform === ANDROID ? IOS : ANDROID);
283
+
284
+ // Title, message or media entered for a platform
285
+ const hasPlatformContent = (content) => !!(
286
+ content?.title?.trim()
287
+ || content?.message?.trim()
288
+ || (content?.mediaType && content.mediaType !== NONE)
289
+ );
290
+
291
+ // Platforms dropdown value for a saved template: whichever of ANDROID / IOS it has
292
+ const getSavedPlatformSelection = (base = {}) => {
293
+ const hasAndroid = !isEmpty(base?.ANDROID);
294
+ const hasIos = !isEmpty(base?.IOS);
295
+ if (hasAndroid && !hasIos) return ANDROID;
296
+ if (hasIos && !hasAndroid) return IOS;
297
+ return BOTH_PLATFORMS;
298
+ };
299
+
300
+ // Saved buttons in backend shape { actionText, type, actionLink }; used by Save and Test & Preview
301
+ const toSavedCtas = (ctaData = []) => (ctaData || [])
302
+ .filter((cta) => cta?.isSaved)
303
+ .map((cta) => {
304
+ let actionLink = cta?.url;
305
+
306
+ // Append deep link keys to URL if they exist
307
+ if (cta?.urlType === DEEP_LINK && cta?.deepLinkKeys?.length > 0) {
308
+ const deepLinkKeysArray = Array.isArray(cta?.deepLinkKeys) ? cta?.deepLinkKeys : [cta?.deepLinkKeys];
309
+ const validKeys = deepLinkKeysArray.filter((key) => typeof key === 'string' && key?.length > 0);
310
+ if (validKeys?.length > 0) {
311
+ const separator = actionLink.includes('?') ? '&' : '?';
312
+ const keyParams = validKeys.map((key) => `${key}=${key}`).join('&');
313
+ actionLink = `${actionLink}${separator}${keyParams}`;
314
+ }
315
+ }
316
+
317
+ return {
318
+ actionText: cta?.text,
319
+ type: cta?.urlType || DEEP_LINK,
320
+ actionLink,
321
+ };
322
+ });
323
+
279
324
  // Helper function to create content data object
280
- const createContentData = (contentType, mediaInfo, buttons, deepLink, processCarouselDataForDeepLinks) => {
325
+ const createContentData =(contentType, mediaInfo, buttons, deepLink, processCarouselDataForDeepLinks) => {
281
326
  const {
282
327
  mediaType,
283
328
  imageSrc,
@@ -503,6 +548,9 @@ export const MobilePushNew = ({
503
548
  supportedTags = [],
504
549
  globalActions: globalActionsProps,
505
550
  handleClose,
551
+ // Edit mode: footer Test & Preview button lives in CreativesContainer
552
+ showTestAndPreviewSlidebox: propsShowTestAndPreviewSlidebox,
553
+ handleCloseTestAndPreview: propsHandleCloseTestAndPreview,
506
554
  fetchingLiquidValidation,
507
555
  createTemplateError,
508
556
  isGetFormData,
@@ -519,11 +567,30 @@ export const MobilePushNew = ({
519
567
  const templateId = params?.id || templateData?._id || templateData?.id;
520
568
  const isEditMode = !!templateId;
521
569
  const computedCreativesMode = isEditMode || templateData?.type === MOBILEPUSH ? 'edit' : 'create';
522
- const [sameContent, setSameContent] = useState(false);
570
+ // The checkbox tick; only syncs while both platforms are shown (see sameContent below)
571
+ const [sameContentChecked, setSameContent] = useState(false);
572
+ // Platforms dropdown: BOTH_PLATFORMS, ANDROID or IOS
573
+ const [platformSelection, setPlatformSelection] = useState(BOTH_PLATFORMS);
574
+ // Single platform waiting on the "Remove content" confirm
575
+ const [pendingPlatformSelection, setPendingPlatformSelection] = useState(null);
576
+ // Platform dropped by Both -> single; cleared after the switch, once sync is off
577
+ const [platformToClear, setPlatformToClear] = useState(null);
578
+ // Determine platform support from accountData
579
+ const isAndroidSupported = accountData?.configs?.android === '1';
580
+ const isIosSupported = accountData?.configs?.ios === '1';
581
+ // The Platforms dropdown only applies when the account supports both
582
+ const canChoosePlatforms = isAndroidSupported && isIosSupported;
583
+ // ANDROID or IOS when one platform is chosen, else null
584
+ const singlePlatform = canChoosePlatforms && platformSelection !== BOTH_PLATFORMS ? platformSelection : null;
585
+ const showAndroid = isAndroidSupported && singlePlatform !== IOS;
586
+ const showIos = isIosSupported && singlePlatform !== ANDROID;
587
+ const sameContent = sameContentChecked && !singlePlatform;
523
588
  const [templateName, setTemplateName] = useState("");
524
589
  const [spin, setSpin] = useState(false);
525
590
  const [activeTab, setActiveTab] = useState(ANDROID);
526
591
  const [templateNameError, setTemplateNameError] = useState(false);
592
+ // "Same content" tick waiting on the Replace confirm
593
+ const [isReplaceConfirmOpen, setIsReplaceConfirmOpen] = useState(false);
527
594
  // Replace ctaData with platform-specific state
528
595
  const [ctaDataAndroid, setCtaDataAndroid] = useState([]);
529
596
  const [ctaDataIos, setCtaDataIos] = useState([]);
@@ -662,6 +729,9 @@ export const MobilePushNew = ({
662
729
  if (card.mediaType === IMAGE.toLowerCase() && !card.imageUrl) {
663
730
  return false;
664
731
  }
732
+ if (card.mediaType === VIDEO.toLowerCase() && !card.videoSrc) {
733
+ return false;
734
+ }
665
735
 
666
736
  // Check if buttons have proper link data when actionOnClick is true
667
737
  if (card?.buttons?.length > 0) {
@@ -753,6 +823,9 @@ export const MobilePushNew = ({
753
823
  setPrimaryButtonIos(false);
754
824
  setSecondaryButtonIos(false);
755
825
  setSameContent(false);
826
+ setPlatformSelection(BOTH_PLATFORMS);
827
+ setPendingPlatformSelection(null);
828
+ setPlatformToClear(null);
756
829
  setTemplateNameError(false);
757
830
  setAndroidTitleError("");
758
831
  setAndroidMessageError("");
@@ -966,6 +1039,8 @@ export const MobilePushNew = ({
966
1039
  templateNameRef.current = name;
967
1040
  });
968
1041
 
1042
+ stateUpdates.push(() => setPlatformSelection(getSavedPlatformSelection(editContent)));
1043
+
969
1044
  // Process Android content
970
1045
  const androidContentType = editContent?.ANDROID;
971
1046
  if (!isEmpty(androidContentType)) {
@@ -1101,6 +1176,8 @@ export const MobilePushNew = ({
1101
1176
  templateNameRef.current = name;
1102
1177
  });
1103
1178
 
1179
+ stateUpdates.push(() => setPlatformSelection(getSavedPlatformSelection(templateContent)));
1180
+
1104
1181
  // Process Android content
1105
1182
  const androidContentType = templateContent?.ANDROID;
1106
1183
  if (!isEmpty(androidContentType)) {
@@ -1736,10 +1813,6 @@ export const MobilePushNew = ({
1736
1813
  setSpin(false);
1737
1814
  }, [templateData, isFullMode, deepLink, setUpdateMpushImageSrc, setUpdateMpushVideoSrc]);
1738
1815
 
1739
- // Determine platform support from accountData
1740
- const isAndroidSupported = accountData?.configs?.android === '1';
1741
- const isIosSupported = accountData?.configs?.ios === '1';
1742
-
1743
1816
  // Notify parent when personalization tokens are added/removed (for anonymous user flow)
1744
1817
  useEffect(() => {
1745
1818
  if (!restrictPersonalization || typeof onPersonalizationTokensChange !== 'function') return;
@@ -1748,8 +1821,8 @@ export const MobilePushNew = ({
1748
1821
  || (value.includes('[') && value.includes(']'))
1749
1822
  );
1750
1823
  const hasTokens = (
1751
- (isAndroidSupported && (hasToken(androidContent?.title) || hasToken(androidContent?.message)))
1752
- || (isIosSupported && (hasToken(iosContent?.title) || hasToken(iosContent?.message)))
1824
+ (showAndroid && (hasToken(androidContent?.title) || hasToken(androidContent?.message)))
1825
+ || (showIos && (hasToken(iosContent?.title) || hasToken(iosContent?.message)))
1753
1826
  );
1754
1827
  onPersonalizationTokensChange(hasTokens);
1755
1828
  }, [
@@ -1758,18 +1831,21 @@ export const MobilePushNew = ({
1758
1831
  androidContent?.message,
1759
1832
  iosContent?.title,
1760
1833
  iosContent?.message,
1761
- isAndroidSupported,
1762
- isIosSupported,
1834
+ showAndroid,
1835
+ showIos,
1763
1836
  onPersonalizationTokensChange,
1764
1837
  ]);
1765
1838
 
1766
- // Validation logic for template creation/update.
1767
- const isAndroidFieldsMissing = isPlatformFieldsMissing(isAndroidSupported, androidContent);
1768
- const isIosFieldsMissing = isPlatformFieldsMissing(isIosSupported, iosContent);
1769
- const isMobilePushContentMissing = (
1770
- (isAndroidSupported || isIosSupported)
1771
- && (!isAndroidSupported || isAndroidFieldsMissing)
1772
- && (!isIosSupported || isIosFieldsMissing)
1839
+ // Validation logic for template creation/update; a platform left out by the dropdown is never missing.
1840
+ const isAndroidFieldsMissing = isPlatformFieldsMissing(showAndroid, androidContent);
1841
+ const isIosFieldsMissing = isPlatformFieldsMissing(showIos, iosContent);
1842
+ // Every shown platform needs a title and message before Save
1843
+ const isMobilePushContentMissing = isAndroidFieldsMissing || isIosFieldsMissing;
1844
+ // Test & Preview only needs one platform filled
1845
+ const isAllContentMissing = (
1846
+ (showAndroid || showIos)
1847
+ && (!showAndroid || isAndroidFieldsMissing)
1848
+ && (!showIos || isIosFieldsMissing)
1773
1849
  );
1774
1850
 
1775
1851
  // Ref to dedupe reporting of content emptiness to the parent, so we only
@@ -1793,8 +1869,7 @@ export const MobilePushNew = ({
1793
1869
  handleMessageChange,
1794
1870
  handleTagSelect,
1795
1871
  handleMediaTypeChange,
1796
- handleActionOnClickChange,
1797
- handleLinkTypeChange,
1872
+ handleTapActionChange,
1798
1873
  } = usePlatformSync({
1799
1874
  setAndroidContent,
1800
1875
  setIosContent,
@@ -1866,9 +1941,14 @@ export const MobilePushNew = ({
1866
1941
  }
1867
1942
  }, [sameContent]);
1868
1943
 
1944
+ // Notification tap URL: required once External link is chosen; same message as the button form
1945
+ const getTapUrlError = useCallback((url) => (
1946
+ !url?.trim() || validateExternalLink(url, formatMessage, messages) ? formatMessage(messages.urlNotValid) : ""
1947
+ ), [formatMessage]);
1948
+
1869
1949
  const handleExternalLinkChange = useCallback((platform, externalLinkValue) => {
1870
1950
  // Validate URL
1871
- const urlError = validateExternalLink(externalLinkValue, formatMessage, messages);
1951
+ const urlError = getTapUrlError(externalLinkValue);
1872
1952
 
1873
1953
  const updateContent = {
1874
1954
  externalLinkValue,
@@ -1895,7 +1975,7 @@ export const MobilePushNew = ({
1895
1975
  setAndroidExternalLinkError(urlError || "");
1896
1976
  }
1897
1977
  }
1898
- }, [validateExternalLink, sameContent]);
1978
+ }, [getTapUrlError, sameContent]);
1899
1979
 
1900
1980
  // Carousel data handler for platform-specific carousel management
1901
1981
  const updateCarouselLinkError = useCallback((cardIndex, field, error) => {
@@ -2042,8 +2122,16 @@ export const MobilePushNew = ({
2042
2122
  handleTitleChange,
2043
2123
  handleMessageChange,
2044
2124
  handleMediaTypeChange,
2045
- handleActionOnClickChange,
2046
- handleLinkTypeChange,
2125
+ handleTapActionChange: (value) => {
2126
+ handleTapActionChange(platform, value);
2127
+ // The old link field is gone, so are its errors (on both tabs when synced)
2128
+ [platform, ...(sameContent ? [getOtherPlatform(platform)] : [])].forEach((target) => {
2129
+ const isAndroidTarget = target === ANDROID;
2130
+ (isAndroidTarget ? setAndroidExternalLinkError : setIosExternalLinkError)("");
2131
+ (isAndroidTarget ? setAndroidDeepLinkError : setIosDeepLinkError)("");
2132
+ (isAndroidTarget ? setAndroidDeepLinkKeysError : setIosDeepLinkKeysError)("");
2133
+ });
2134
+ },
2047
2135
  handleDeepLinkChange: (value) => handleDeepLinkChange(platform, value),
2048
2136
  handleDeepLinkKeysChange: (value) => handleDeepLinkKeysChange(platform, value),
2049
2137
  handleExternalLinkChange: (value) => handleExternalLinkChange(platform, value),
@@ -2166,7 +2254,7 @@ export const MobilePushNew = ({
2166
2254
  restrictPersonalization={restrictPersonalization}
2167
2255
  />
2168
2256
  );
2169
- }, [androidContent, iosContent, androidTitleError, iosTitleError, androidMessageError, iosMessageError, androidExternalLinkError, iosExternalLinkError, androidDeepLinkError, iosDeepLinkError, androidDeepLinkKeysError, iosDeepLinkKeysError, formatMessage, activeTab, imageSrc, isFullMode, imageData, androidAssetList, iosAssetList, videoState, videoData, location, tags, injectedTags, selectedOfferDetails, primaryButtonAndroid, secondaryButtonAndroid, primaryButtonIos, secondaryButtonIos, ctaData, deepLink, mobilePushActions, carouselActiveTabIndex, carouselLinkErrors, handleTitleChange, handleMessageChange, handleMediaTypeChange, handleActionOnClickChange, handleLinkTypeChange, handleDeepLinkChange, handleDeepLinkKeysChange, handleExternalLinkChange, onTagSelect, handleOnTagsContextChange, setUpdateMpushImageSrc, updateOnMpushImageReUpload, setUpdateMpushVideoSrc, updateOnMpushVideoReUpload, clearImageDataByMediaType, handleCarouselDataChange, updateCarouselLinkError, sameContent, updateHandler, deleteHandler]
2257
+ }, [androidContent, iosContent, androidTitleError, iosTitleError, androidMessageError, iosMessageError, androidExternalLinkError, iosExternalLinkError, androidDeepLinkError, iosDeepLinkError, androidDeepLinkKeysError, iosDeepLinkKeysError, formatMessage, activeTab, imageSrc, isFullMode, imageData, androidAssetList, iosAssetList, videoState, videoData, location, tags, injectedTags, selectedOfferDetails, primaryButtonAndroid, secondaryButtonAndroid, primaryButtonIos, secondaryButtonIos, ctaData, deepLink, mobilePushActions, carouselActiveTabIndex, carouselLinkErrors, handleTitleChange, handleMessageChange, handleMediaTypeChange, handleTapActionChange, handleDeepLinkChange, handleDeepLinkKeysChange, handleExternalLinkChange, onTagSelect, handleOnTagsContextChange, setUpdateMpushImageSrc, updateOnMpushImageReUpload, setUpdateMpushVideoSrc, updateOnMpushVideoReUpload, clearImageDataByMediaType, handleCarouselDataChange, updateCarouselLinkError, sameContent, updateHandler, deleteHandler]
2170
2258
  );
2171
2259
 
2172
2260
  // PANES: Only render enabled platforms
@@ -2176,8 +2264,8 @@ export const MobilePushNew = ({
2176
2264
  panes.push({
2177
2265
  key: ANDROID,
2178
2266
  tab: (
2179
- <CapRow useLegacy>
2180
- <CapIcon type="android" />
2267
+ <CapRow type="flex" align="middle" noWrap className="tab-label">
2268
+ <CapIcon type="android" size="s" />
2181
2269
  {formatMessage(messages.android)}
2182
2270
  </CapRow>
2183
2271
  ),
@@ -2188,8 +2276,8 @@ export const MobilePushNew = ({
2188
2276
  panes.push({
2189
2277
  key: IOS,
2190
2278
  tab: (
2191
- <CapRow useLegacy>
2192
- <CapIcon type="ios" />
2279
+ <CapRow type="flex" align="middle" noWrap className="tab-label">
2280
+ <CapIcon type="ios" size="s" />
2193
2281
  {formatMessage(messages.ios)}
2194
2282
  </CapRow>
2195
2283
  ),
@@ -2202,25 +2290,32 @@ export const MobilePushNew = ({
2202
2290
  const errorInTitle = activeTab === ANDROID ? androidTitleError : iosTitleError;
2203
2291
  const errorInMessage = activeTab === ANDROID ? androidMessageError : iosMessageError;
2204
2292
 
2205
- // Save button disabled logic: only check enabled platforms, and allow
2206
- // saving with just one supported platform filled in (see isMobilePushContentMissing).
2207
- const isSaveDisabled = (
2208
- isMobilePushContentMissing
2209
- || templateNameError
2293
+ const hasFormErrors = (
2294
+ templateNameError
2210
2295
  || Object.values(carouselLinkErrors).some((error) => error !== null && error !== "")
2211
2296
  || !isCarouselDataValid()
2212
2297
  || errorInTitle || errorInMessage
2213
2298
  );
2299
+ // Save needs every shown platform filled
2300
+ const isSaveDisabled = isMobilePushContentMissing || hasFormErrors;
2301
+ const isTestAndPreviewDisabled = isAllContentMissing || hasFormErrors;
2214
2302
 
2215
- // Validation in handleSave: only enforce content on enabled platforms, and
2216
- // allow saving with just one supported platform filled in.
2303
+ // Validation in handleSave: every shown platform needs a title and message (no save-without dialog)
2217
2304
  const handleSave = useCallback(() => {
2218
2305
  if (isMobilePushContentMissing) {
2219
- CapNotification.error({
2220
- message: formatMessage(
2221
- isAndroidSupported ? messages.androidValidationError : messages.iosValidationError,
2222
- ),
2306
+ const missingPlatforms = [
2307
+ [ANDROID, isAndroidFieldsMissing, androidContent],
2308
+ [IOS, isIosFieldsMissing, iosContent],
2309
+ ].filter(([, isMissing]) => isMissing);
2310
+ missingPlatforms.forEach(([platform, , content]) => {
2311
+ const isAndroid = platform === ANDROID;
2312
+ (isAndroid ? setAndroidTitleError : setIosTitleError)(validateTitle(content?.title));
2313
+ (isAndroid ? setAndroidMessageError : setIosMessageError)(validateMessage(content?.message));
2223
2314
  });
2315
+ // Open a tab that has the errors, unless the open one already does
2316
+ if (!missingPlatforms.some(([platform]) => platform === activeTab)) {
2317
+ setActiveTab(missingPlatforms[0][0]);
2318
+ }
2224
2319
  if (onValidationFail) onValidationFail();
2225
2320
  return;
2226
2321
  }
@@ -2244,32 +2339,33 @@ export const MobilePushNew = ({
2244
2339
  // Use ref to get the latest template name value to avoid closure issues
2245
2340
  let finalTemplateName = templateNameRef.current || templateName;
2246
2341
  if (!isFullMode && (!finalTemplateName || !finalTemplateName.trim())) {
2247
- if (androidContent?.title && androidContent.title.trim()) {
2342
+ if (showAndroid && androidContent?.title && androidContent.title.trim()) {
2248
2343
  finalTemplateName = androidContent.title.trim();
2249
- } else if (iosContent?.title && iosContent.title.trim()) {
2344
+ } else if (showIos && iosContent?.title && iosContent.title.trim()) {
2250
2345
  finalTemplateName = iosContent.title.trim();
2251
2346
  } else {
2252
2347
  finalTemplateName = '';
2253
2348
  }
2254
2349
  }
2255
2350
 
2256
- // Validate external links
2257
- const androidUrlError = validateExternalLink(androidContent.externalLinkValue, formatMessage, messages);
2258
- const iosUrlError = validateExternalLink(iosContent.externalLinkValue, formatMessage, messages);
2351
+ // Validate the notification tap URL (only platforms that are saved, only when External link is chosen)
2352
+ const isTapExternalLink = (content) => content?.actionOnClick && content?.linkType === EXTERNAL_LINK;
2353
+ const androidUrlError = showAndroid && isTapExternalLink(androidContent) && getTapUrlError(androidContent.externalLinkValue);
2354
+ const iosUrlError = showIos && isTapExternalLink(iosContent) && getTapUrlError(iosContent.externalLinkValue);
2259
2355
 
2260
2356
  setAndroidExternalLinkError(androidUrlError || "");
2261
2357
  setIosExternalLinkError(iosUrlError || "");
2262
2358
 
2263
2359
  // Validate deep links
2264
- const androidDeepLinkUrlError = validateDeepLink(androidContent.deepLinkValue, formatMessage, messages);
2265
- const iosDeepLinkUrlError = validateDeepLink(iosContent.deepLinkValue, formatMessage, messages);
2360
+ const androidDeepLinkUrlError = showAndroid && validateDeepLink(androidContent.deepLinkValue, formatMessage, messages);
2361
+ const iosDeepLinkUrlError = showIos && validateDeepLink(iosContent.deepLinkValue, formatMessage, messages);
2266
2362
 
2267
2363
  setAndroidDeepLinkError(androidDeepLinkUrlError || "");
2268
2364
  setIosDeepLinkError(iosDeepLinkUrlError || "");
2269
2365
 
2270
2366
  // Validate deep link keys - only require keys if the selected deep link has keys defined
2271
2367
  const androidDeepLinkKeysErrorMsg = (() => {
2272
- if (androidContent?.linkType === DEEP_LINK && androidContent?.deepLinkValue) {
2368
+ if (showAndroid && androidContent?.linkType === DEEP_LINK && androidContent?.deepLinkValue) {
2273
2369
  // Use the same matching logic as deep link value extraction
2274
2370
  let selectedDeepLink = null;
2275
2371
 
@@ -2293,7 +2389,7 @@ export const MobilePushNew = ({
2293
2389
  })();
2294
2390
 
2295
2391
  const iosDeepLinkKeysErrorMsg = (() => {
2296
- if (iosContent?.linkType === DEEP_LINK && iosContent?.deepLinkValue) {
2392
+ if (showIos && iosContent?.linkType === DEEP_LINK && iosContent?.deepLinkValue) {
2297
2393
  // Use the same matching logic as deep link value extraction
2298
2394
  let selectedDeepLink = null;
2299
2395
 
@@ -2338,74 +2434,34 @@ export const MobilePushNew = ({
2338
2434
  const processedIosContent = { ...iosContent };
2339
2435
 
2340
2436
  // Process button CTA data if it exists
2341
- if (ctaDataAndroid?.length > 0) {
2342
- const savedCtas = ctaDataAndroid.filter((cta) => cta.isSaved);
2343
- if (savedCtas?.length > 0) {
2344
- processedAndroidContent.expandableDetails = {
2345
- ...processedAndroidContent.expandableDetails,
2346
- ctas: savedCtas.map((cta) => {
2347
- let actionLink = cta?.url;
2348
-
2349
- // Append deep link keys to URL if they exist
2350
- if (cta?.urlType === DEEP_LINK && cta?.deepLinkKeys?.length > 0) {
2351
- const deepLinkKeysArray = Array.isArray(cta?.deepLinkKeys) ? cta?.deepLinkKeys : [cta?.deepLinkKeys];
2352
- const validKeys = deepLinkKeysArray.filter((key) => typeof key === 'string' && key?.length > 0);
2353
- if (validKeys?.length > 0) {
2354
- const separator = actionLink.includes('?') ? '&' : '?';
2355
- const keyParams = validKeys.map((key) => `${key}=${key}`).join('&');
2356
- actionLink = `${actionLink}${separator}${keyParams}`;
2357
- }
2358
- }
2359
-
2360
- return {
2361
- actionText: cta?.text,
2362
- type: cta?.urlType || DEEP_LINK,
2363
- actionLink,
2364
- };
2365
- }),
2366
- };
2367
- }
2437
+ const savedAndroidCtas = toSavedCtas(ctaDataAndroid);
2438
+ if (savedAndroidCtas.length > 0) {
2439
+ processedAndroidContent.expandableDetails = {
2440
+ ...processedAndroidContent.expandableDetails,
2441
+ ctas: savedAndroidCtas,
2442
+ };
2368
2443
  }
2369
- if (ctaDataIos?.length > 0) {
2370
- const savedCtas = ctaDataIos.filter((cta) => cta.isSaved);
2371
- if (savedCtas?.length > 0) {
2372
- processedIosContent.expandableDetails = {
2373
- ...processedIosContent.expandableDetails,
2374
- ctas: savedCtas.map((cta) => {
2375
- let actionLink = cta?.url;
2376
-
2377
- // Append deep link keys to URL if they exist
2378
- if (cta?.urlType === DEEP_LINK && cta?.deepLinkKeys?.length > 0) {
2379
- const deepLinkKeysArray = Array.isArray(cta?.deepLinkKeys) ? cta?.deepLinkKeys : [cta?.deepLinkKeys];
2380
- const validKeys = deepLinkKeysArray.filter((key) => typeof key === 'string' && key?.length > 0);
2381
- if (validKeys?.length > 0) {
2382
- const separator = actionLink.includes('?') ? '&' : '?';
2383
- const keyParams = validKeys.map((key) => `${key}=${key}`).join('&');
2384
- actionLink = `${actionLink}${separator}${keyParams}`;
2385
- }
2386
- }
2387
-
2388
- return {
2389
- actionText: cta?.text,
2390
- type: cta?.urlType || DEEP_LINK,
2391
- actionLink,
2392
- };
2393
- }),
2394
- };
2395
- }
2444
+ const savedIosCtas = toSavedCtas(ctaDataIos);
2445
+ if (savedIosCtas.length > 0) {
2446
+ processedIosContent.expandableDetails = {
2447
+ ...processedIosContent.expandableDetails,
2448
+ ctas: savedIosCtas,
2449
+ };
2396
2450
  }
2397
2451
 
2398
2452
  // Create payload with enabled platform content and intl
2399
2453
  const payload = createMobilePushPayloadWithIntl({
2400
2454
  templateName: finalTemplateName,
2401
- androidContent: isAndroidSupported ? processedAndroidContent : undefined,
2402
- iosContent: isIosSupported ? processedIosContent : undefined,
2455
+ androidContent: showAndroid ? processedAndroidContent : undefined,
2456
+ iosContent: showIos ? processedIosContent : undefined,
2403
2457
  imageSrc,
2404
2458
  mpushVideoSrcAndPreview,
2405
2459
  accountData,
2406
2460
  sameContent,
2407
2461
  options: {
2408
2462
  mode: params?.mode,
2463
+ // One platform chosen: leave the other platform's key out of versions.base
2464
+ skipPlatform: singlePlatform ? getOtherPlatform(singlePlatform) : undefined,
2409
2465
  },
2410
2466
  intl,
2411
2467
  });
@@ -2596,7 +2652,7 @@ export const MobilePushNew = ({
2596
2652
  globalActionsProps,
2597
2653
  onValidationFail,
2598
2654
  resetFormData,
2599
- validateExternalLink,
2655
+ getTapUrlError,
2600
2656
  ctaDataAndroid,
2601
2657
  ctaDataIos,
2602
2658
  intl,
@@ -2604,7 +2660,15 @@ export const MobilePushNew = ({
2604
2660
  createTimeoutRef,
2605
2661
  isAndroidSupported,
2606
2662
  isIosSupported,
2663
+ showAndroid,
2664
+ showIos,
2665
+ singlePlatform,
2666
+ activeTab,
2667
+ validateTitle,
2668
+ validateMessage,
2607
2669
  isMobilePushContentMissing,
2670
+ isAndroidFieldsMissing,
2671
+ isIosFieldsMissing,
2608
2672
  isCarouselDataValid,
2609
2673
  isFullMode,
2610
2674
  templateId,
@@ -2700,38 +2764,30 @@ export const MobilePushNew = ({
2700
2764
  getLiquidTags: globalActionsProps.getLiquidTags,
2701
2765
  formatMessage,
2702
2766
  messages: formBuilderMessages,
2703
- singleTab: getSingleTab(accountData),
2767
+ // One platform chosen: validate only that platform
2768
+ singleTab: singlePlatform || getSingleTab(accountData),
2704
2769
  });
2705
2770
  }, [
2706
2771
  androidContent,
2707
2772
  iosContent,
2708
2773
  activeTab,
2774
+ singlePlatform,
2709
2775
  globalActionsProps,
2710
2776
  formatMessage,
2711
2777
  accountData,
2712
2778
  isFullMode,
2713
2779
  ]);
2714
2780
 
2781
+ // Each platform's preview buttons follow its own ctaData, so iOS shows before its tab is opened
2782
+ const toPreviewButtons = (ctas) => (Array.isArray(ctas) ? ctas.map((data) => ({ label: data?.text || '' })) : []);
2783
+
2715
2784
  useEffect(() => {
2716
- // Always map to { label } for both platforms
2717
- const newButtons = Array.isArray(ctaData)
2718
- ? ctaData.map((data) => ({
2719
- label: data?.text || '',
2720
- }))
2721
- : [];
2722
-
2723
- if (activeTab === ANDROID) {
2724
- setAndroidContent((prevContent) => ({
2725
- ...prevContent,
2726
- buttons: newButtons,
2727
- }));
2728
- } else if (activeTab === IOS) {
2729
- setIosContent((prevContent) => ({
2730
- ...prevContent,
2731
- buttons: newButtons,
2732
- }));
2733
- }
2734
- }, [ctaData, activeTab]);
2785
+ setAndroidContent((prevContent) => ({ ...prevContent, buttons: toPreviewButtons(ctaDataAndroid) }));
2786
+ }, [ctaDataAndroid]);
2787
+
2788
+ useEffect(() => {
2789
+ setIosContent((prevContent) => ({ ...prevContent, buttons: toPreviewButtons(ctaDataIos) }));
2790
+ }, [ctaDataIos]);
2735
2791
 
2736
2792
  // Sync button data and state from active tab to other platform when sameContent is enabled
2737
2793
  useEffect(() => {
@@ -2757,12 +2813,141 @@ export const MobilePushNew = ({
2757
2813
  }
2758
2814
  }, [sameContent, activeTab]);
2759
2815
 
2816
+ // What ticking "Same content" would copy over: text, media, links and buttons
2817
+ const getPlatformSnapshot = (platform) => {
2818
+ const isAndroid = platform === ANDROID;
2819
+ const content = isAndroid ? androidContent : iosContent;
2820
+ return JSON.stringify({
2821
+ title: content?.title || '',
2822
+ message: content?.message || '',
2823
+ mediaType: content?.mediaType || NONE,
2824
+ carouselData: content?.carouselData || [],
2825
+ actionOnClick: !!content?.actionOnClick,
2826
+ linkType: content?.linkType || '',
2827
+ deepLinkValue: content?.deepLinkValue || '',
2828
+ externalLinkValue: content?.externalLinkValue || '',
2829
+ image: (isAndroid ? imageSrc?.androidImageSrc : imageSrc?.iosImageSrc) || '',
2830
+ video: (isAndroid ? videoState?.androidVideoSrc : videoState?.iosVideoSrc) || '',
2831
+ buttons: toSavedCtas(isAndroid ? ctaDataAndroid : ctaDataIos),
2832
+ });
2833
+ };
2834
+
2760
2835
  const handleSameContentChange = useCallback((e) => {
2761
2836
  const isCurrentPlatformAndroid = activeTab === ANDROID;
2837
+ const otherContent = isCurrentPlatformAndroid ? iosContent : androidContent;
2838
+ // Ticking replaces the other tab: confirm when it has different content, not when it is empty
2839
+ if (e.target.checked && hasPlatformContent(otherContent) && getPlatformSnapshot(ANDROID) !== getPlatformSnapshot(IOS)) {
2840
+ setIsReplaceConfirmOpen(true);
2841
+ return;
2842
+ }
2762
2843
  syncPlatformContent(isCurrentPlatformAndroid ? androidContent : iosContent, isCurrentPlatformAndroid ? ANDROID : IOS);
2763
2844
  setSameContent(e.target.checked);
2845
+ }, [activeTab, androidContent, iosContent, imageSrc, videoState, ctaDataAndroid, ctaDataIos]);
2846
+
2847
+ const confirmSameContent = useCallback(() => {
2848
+ setIsReplaceConfirmOpen(false);
2849
+ syncPlatformContent(activeTab === ANDROID ? androidContent : iosContent, activeTab);
2850
+ setSameContent(true);
2764
2851
  }, [activeTab, androidContent, iosContent]);
2765
2852
 
2853
+ // One platform chosen: its form is the only one shown, and the upload/button handlers follow activeTab
2854
+ useEffect(() => {
2855
+ if (singlePlatform && activeTab !== singlePlatform) {
2856
+ setActiveTab(singlePlatform);
2857
+ }
2858
+ }, [singlePlatform, activeTab]);
2859
+
2860
+ // Both -> single: empty the dropped platform. Runs after the switch so sync is off
2861
+ // and the kept platform's media stays.
2862
+ useEffect(() => {
2863
+ if (!platformToClear) return;
2864
+ const isAndroid = platformToClear === ANDROID;
2865
+ const platformIndex = isAndroid ? 0 : 1;
2866
+ clearImageDataByMediaType(IMAGE, platformToClear);
2867
+ clearImageDataByMediaType(VIDEO, platformToClear);
2868
+ // Uploaded-video list read by the upload box
2869
+ setUpdateMpushVideoSrc(platformIndex, {}, true);
2870
+ (isAndroid ? setAndroidContent : setIosContent)(INITIAL_CONTENT);
2871
+ (isAndroid ? setCtaDataAndroid : setCtaDataIos)([]);
2872
+ (isAndroid ? setPrimaryButtonAndroid : setPrimaryButtonIos)(false);
2873
+ (isAndroid ? setSecondaryButtonAndroid : setSecondaryButtonIos)(false);
2874
+ (isAndroid ? setAndroidTitleError : setIosTitleError)("");
2875
+ (isAndroid ? setAndroidMessageError : setIosMessageError)("");
2876
+ (isAndroid ? setAndroidExternalLinkError : setIosExternalLinkError)("");
2877
+ (isAndroid ? setAndroidDeepLinkError : setIosDeepLinkError)("");
2878
+ (isAndroid ? setAndroidDeepLinkKeysError : setIosDeepLinkKeysError)("");
2879
+ setPlatformToClear(null);
2880
+ }, [platformToClear, clearImageDataByMediaType, setUpdateMpushVideoSrc]);
2881
+
2882
+ // Android only <-> iOS only: give the empty target the current platform's content, buttons and media
2883
+ const copyPlatformContent = useCallback((source, target) => {
2884
+ const fromAndroid = source === ANDROID;
2885
+ const targetIndex = target === ANDROID ? 0 : 1;
2886
+ syncPlatformContent(fromAndroid ? androidContent : iosContent, source);
2887
+ (fromAndroid ? setCtaDataIos : setCtaDataAndroid)(cloneDeep(fromAndroid ? ctaDataAndroid : ctaDataIos));
2888
+ (fromAndroid ? setPrimaryButtonIos : setPrimaryButtonAndroid)(fromAndroid ? primaryButtonAndroid : primaryButtonIos);
2889
+ (fromAndroid ? setSecondaryButtonIos : setSecondaryButtonAndroid)(fromAndroid ? secondaryButtonAndroid : secondaryButtonIos);
2890
+ // Uploaded image/video live in the upload hook, per platform
2891
+ const sourceImage = fromAndroid ? imageSrc?.androidImageSrc : imageSrc?.iosImageSrc;
2892
+ if (sourceImage) {
2893
+ setUpdateMpushImageSrc(sourceImage, targetIndex, IMAGE);
2894
+ }
2895
+ const sourceVideo = fromAndroid ? videoState?.androidVideoSrc : videoState?.iosVideoSrc;
2896
+ if (sourceVideo) {
2897
+ setUpdateMpushVideoSrc(targetIndex, {
2898
+ ...(fromAndroid ? androidAssetList : iosAssetList),
2899
+ videoSrc: sourceVideo,
2900
+ previewUrl: (fromAndroid ? videoState?.androidVideoPreview : videoState?.iosVideoPreview) || '',
2901
+ videoDuration: (fromAndroid ? videoState?.androidVideoDuration : videoState?.iosVideoDuration) || 0,
2902
+ }, true);
2903
+ }
2904
+ }, [androidContent, iosContent, ctaDataAndroid, ctaDataIos, primaryButtonAndroid, primaryButtonIos, secondaryButtonAndroid, secondaryButtonIos, imageSrc, videoState, androidAssetList, iosAssetList, setUpdateMpushImageSrc, setUpdateMpushVideoSrc]);
2905
+
2906
+ const handlePlatformChange = useCallback((value) => {
2907
+ if (value === platformSelection) return;
2908
+ const getPlatformContent = (platform) => (platform === ANDROID ? androidContent : iosContent);
2909
+
2910
+ if (platformSelection === BOTH_PLATFORMS) {
2911
+ // Both -> single: confirm before dropping a platform that has content
2912
+ if (hasPlatformContent(getPlatformContent(getOtherPlatform(value)))) {
2913
+ setPendingPlatformSelection(value);
2914
+ return;
2915
+ }
2916
+ setPlatformSelection(value);
2917
+ setPlatformToClear(getOtherPlatform(value));
2918
+ return;
2919
+ }
2920
+
2921
+ if (value === BOTH_PLATFORMS) {
2922
+ // Single -> Both: content stays in its tab; a ticked "Same content" syncs it to the other tab
2923
+ // (media and buttons follow through the existing on-tick effects)
2924
+ if (sameContentChecked) {
2925
+ syncPlatformContent(getPlatformContent(platformSelection), platformSelection);
2926
+ }
2927
+ setPlatformSelection(value);
2928
+ return;
2929
+ }
2930
+
2931
+ // Android only <-> iOS only: an empty target takes the current content
2932
+ if (!hasPlatformContent(getPlatformContent(value)) && hasPlatformContent(getPlatformContent(platformSelection))) {
2933
+ copyPlatformContent(platformSelection, value);
2934
+ }
2935
+ setPlatformSelection(value);
2936
+ }, [platformSelection, androidContent, iosContent, sameContentChecked, copyPlatformContent]);
2937
+
2938
+ const confirmPlatformRemoval = useCallback(() => {
2939
+ const value = pendingPlatformSelection;
2940
+ setPendingPlatformSelection(null);
2941
+ setPlatformSelection(value);
2942
+ setPlatformToClear(getOtherPlatform(value));
2943
+ }, [pendingPlatformSelection]);
2944
+
2945
+ const platformOptions = useMemo(() => [
2946
+ { label: formatMessage(messages.androidAndIos), value: BOTH_PLATFORMS },
2947
+ { label: formatMessage(messages.androidOnly), value: ANDROID },
2948
+ { label: formatMessage(messages.iosOnly), value: IOS },
2949
+ ], [formatMessage]);
2950
+
2766
2951
  const getContentType = useCallback(
2767
2952
  (content) => {
2768
2953
  // Get image source from multiple possible locations
@@ -2890,6 +3075,10 @@ export const MobilePushNew = ({
2890
3075
  'message-title': androidPreview?.header || androidContent?.title || '',
2891
3076
  'message-editor': androidPreview?.bodyText || androidContent?.message || '',
2892
3077
  image: androidPreview?.bodyImage || androidContent?.expandableDetails?.image || '',
3078
+ // Video only for now. This tab's own videoSrc: the preview falls back to the visible tab's video
3079
+ video: androidContent?.mediaType === VIDEO ? (androidContent?.videoSrc || '') : '',
3080
+ // Same cards Save sends
3081
+ carouselData: androidContent?.mediaType === CAROUSEL ? buildCarouselCards(androidContent?.carouselData) : [],
2893
3082
  // Extract primary CTA
2894
3083
  ...(androidContent?.cta && {
2895
3084
  'cta-deeplink': androidContent.cta.type === DEEP_LINK ? 'Deeplink' : 'External Link',
@@ -2899,9 +3088,10 @@ export const MobilePushNew = ({
2899
3088
  }),
2900
3089
  };
2901
3090
 
2902
- // Extract secondary CTAs from expandableDetails
2903
- if (androidContent?.expandableDetails?.ctas && androidContent.expandableDetails.ctas.length > 0) {
2904
- androidContent.expandableDetails.ctas.forEach((cta, index) => {
3091
+ // Buttons live in ctaData state, not in androidContent
3092
+ const androidCtas = toSavedCtas(ctaDataAndroid);
3093
+ if (androidCtas.length > 0) {
3094
+ androidCtas.forEach((cta, index) => {
2905
3095
  if (index === 0) {
2906
3096
  androidFormData['secondary-cta-0-label'] = cta.actionText || '';
2907
3097
  androidFormData['cta-deeplink-secondary-cta-0'] = cta.type === DEEP_LINK ? 'Deeplink' : 'External Link';
@@ -2922,6 +3112,8 @@ export const MobilePushNew = ({
2922
3112
  'message-title2': iosPreview?.header || iosContent?.title || '',
2923
3113
  'message-editor2': iosPreview?.bodyText || iosContent?.message || '',
2924
3114
  image: iosPreview?.bodyImage || iosContent?.expandableDetails?.image || '',
3115
+ video: iosContent?.mediaType === VIDEO ? (iosContent?.videoSrc || '') : '',
3116
+ carouselData: iosContent?.mediaType === CAROUSEL ? buildCarouselCards(iosContent?.carouselData) : [],
2925
3117
  // Extract primary CTA
2926
3118
  ...(iosContent?.cta && {
2927
3119
  'cta-deeplink2': iosContent.cta.type === DEEP_LINK ? 'Deeplink' : 'External Link',
@@ -2931,9 +3123,9 @@ export const MobilePushNew = ({
2931
3123
  }),
2932
3124
  };
2933
3125
 
2934
- // Extract secondary CTAs from expandableDetails
2935
- if (iosContent?.expandableDetails?.ctas && iosContent.expandableDetails.ctas.length > 0) {
2936
- iosContent.expandableDetails.ctas.forEach((cta, index) => {
3126
+ const iosCtas = toSavedCtas(ctaDataIos);
3127
+ if (iosCtas.length > 0) {
3128
+ iosCtas.forEach((cta, index) => {
2937
3129
  if (index === 0) {
2938
3130
  iosFormData['secondary-cta-1-label'] = cta.actionText || '';
2939
3131
  iosFormData['cta-deeplink-secondary-cta-1'] = cta.type === DEEP_LINK ? 'Deeplink' : 'External Link';
@@ -2946,7 +3138,7 @@ export const MobilePushNew = ({
2946
3138
 
2947
3139
  // Return in formData array format [androidData, iosData]
2948
3140
  return [androidFormData, iosFormData];
2949
- }, [androidContent, iosContent, getContentType]);
3141
+ }, [androidContent, iosContent, getContentType, ctaDataAndroid, ctaDataIos]);
2950
3142
 
2951
3143
  // Handle Test and Preview button click
2952
3144
  const handleTestAndPreview = useCallback(() => {
@@ -2956,7 +3148,8 @@ export const MobilePushNew = ({
2956
3148
  // Handle close Test and Preview slidebox
2957
3149
  const handleCloseTestAndPreview = useCallback(() => {
2958
3150
  setShowTestAndPreviewSlidebox(false);
2959
- }, []);
3151
+ if (propsHandleCloseTestAndPreview) propsHandleCloseTestAndPreview();
3152
+ }, [propsHandleCloseTestAndPreview]);
2960
3153
 
2961
3154
  // Add useEffect to handle isGetFormData prop changes (e.g. Done clicked in footer)
2962
3155
  // In library mode: run liquid validation (extractTags) first; on success liquidMiddleWare calls handleSave
@@ -3082,24 +3275,46 @@ export const MobilePushNew = ({
3082
3275
  <CapRow className="mobile-push-container">
3083
3276
  <CapColumn className="content-section" span={14}>
3084
3277
  {createModeContent()}
3085
- {isAndroidSupported && isIosSupported && (
3086
- <CapCheckbox
3087
- className="same-content-checkbox"
3088
- checked={sameContent}
3089
- onChange={handleSameContentChange}
3090
- key={`same-content-${sameContent}`}
3091
- >
3092
- {formatMessage(messages.sameContentForBothChannels)}
3093
- </CapCheckbox>
3278
+ {canChoosePlatforms && (
3279
+ <CapRow type="flex" vertical noWrap className="input-group creative-name-container">
3280
+ <CapSelect.CapCustomSelect
3281
+ id="mobile-push-platform-select"
3282
+ className="mobile-push-platform-select"
3283
+ label={formatMessage(messages.platforms)}
3284
+ width="100%"
3285
+ options={platformOptions}
3286
+ value={platformSelection}
3287
+ onChange={handlePlatformChange}
3288
+ />
3289
+ </CapRow>
3290
+ )}
3291
+ {singlePlatform ? (
3292
+ // One platform: its form only, no tabs or "Same content" checkbox
3293
+ <CapRow className="platform-header">
3294
+ {renderContentFields(singlePlatform)}
3295
+ </CapRow>
3296
+ ) : (
3297
+ <>
3298
+ {isAndroidSupported && isIosSupported && (
3299
+ <CapCheckbox
3300
+ className="same-content-checkbox"
3301
+ checked={sameContent}
3302
+ onChange={handleSameContentChange}
3303
+ key={`same-content-${sameContent}`}
3304
+ >
3305
+ {formatMessage(messages.sameContentForBothChannels)}
3306
+ </CapCheckbox>
3307
+ )}
3308
+ <CapRow className="platform-header">
3309
+ <StyledCapTab
3310
+ className="platform-tabs"
3311
+ activeKey={activeTab}
3312
+ onChange={setActiveTab}
3313
+ panes={PANES}
3314
+ />
3315
+ </CapRow>
3316
+ </>
3094
3317
  )}
3095
- <CapRow className="platform-header">
3096
- <StyledCapTab
3097
- className="platform-tabs"
3098
- activeKey={activeTab}
3099
- onChange={setActiveTab}
3100
- panes={PANES}
3101
- />
3102
- </CapRow>
3103
3318
  <CapRow>
3104
3319
  <CapColumn span={24}>
3105
3320
  <ErrorInfoNote
@@ -3109,39 +3324,6 @@ export const MobilePushNew = ({
3109
3324
  STANDARD_ERROR_MSG: errorMessage?.STANDARD_ERROR_MSG,
3110
3325
  }}
3111
3326
  />
3112
-
3113
- {/* In library mode, only show save button in create mode (edit mode has Done button from FormBuilder). In full mode, keep old logic. */}
3114
- {((!isFullMode && computedCreativesMode !== 'edit') || (isFullMode && !isEditMode && computedCreativesMode === 'create')) && (
3115
- <CapRow className="save-section">
3116
- <CapColumn span={24}>
3117
- <CapButton
3118
- type="primary"
3119
- onClick={() => {
3120
- // Liquid validation (extractTags) only in library mode
3121
- if (!isFullMode) {
3122
- liquidMiddleWare();
3123
- } else {
3124
- handleSave();
3125
- }
3126
- }}
3127
- className="save-button"
3128
- disabled={isSaveDisabled}
3129
- >
3130
- {formatMessage(messages.saveTemplate)}
3131
- </CapButton>
3132
- <CapButton
3133
- onClick={handleTestAndPreview}
3134
- className="mobilepush-test-preview-btn"
3135
- type="secondary"
3136
- style={{ marginLeft: '8px' }}
3137
- disabled={isSaveDisabled}
3138
- >
3139
- <FormattedMessage {...creativesMessages.testAndPreview} />
3140
- </CapButton>
3141
- </CapColumn>
3142
- </CapRow>
3143
- )}
3144
-
3145
3327
  </CapColumn>
3146
3328
  </CapRow>
3147
3329
  </CapColumn>
@@ -3154,8 +3336,87 @@ export const MobilePushNew = ({
3154
3336
  />
3155
3337
  </CapColumn>
3156
3338
  </CapRow>
3339
+ {/* In library mode, only show save button in create mode (edit mode has Done button from FormBuilder). In full mode, keep old logic. */}
3340
+ {/* Kept outside the content row so the sticky footer can stick across the whole scroll area */}
3341
+ {((!isFullMode && computedCreativesMode !== 'edit') || (isFullMode && !isEditMode && computedCreativesMode === 'create')) && (
3342
+ <CapRow className="save-section mpush-save-section">
3343
+ <CapColumn span={24}>
3344
+ <CapButton
3345
+ type="primary"
3346
+ onClick={() => {
3347
+ // Liquid validation (extractTags) only in library mode
3348
+ if (!isFullMode) {
3349
+ liquidMiddleWare();
3350
+ } else {
3351
+ handleSave();
3352
+ }
3353
+ }}
3354
+ className="save-button"
3355
+ disabled={isSaveDisabled}
3356
+ >
3357
+ {formatMessage(messages.saveTemplate)}
3358
+ </CapButton>
3359
+ <CapButton
3360
+ onClick={handleTestAndPreview}
3361
+ className="mobilepush-test-preview-btn"
3362
+ type="secondary"
3363
+ style={{ marginLeft: '8px' }}
3364
+ disabled={isTestAndPreviewDisabled}
3365
+ >
3366
+ <FormattedMessage {...creativesMessages.testAndPreview} />
3367
+ </CapButton>
3368
+ </CapColumn>
3369
+ </CapRow>
3370
+ )}
3371
+ <CapModal
3372
+ open={isReplaceConfirmOpen}
3373
+ centered
3374
+ width={520}
3375
+ title={formatMessage(messages.replacePlatformContent, { platform: formatMessage(activeTab === ANDROID ? messages.ios : messages.android) })}
3376
+ onCancel={() => setIsReplaceConfirmOpen(false)}
3377
+ footer={[
3378
+ <CapButton key="cancel" type="secondary" onClick={() => setIsReplaceConfirmOpen(false)}>
3379
+ {formatMessage(globalMessages.cancel)}
3380
+ </CapButton>,
3381
+ <CapButton
3382
+ key="replace"
3383
+ type="primary"
3384
+ className="mpush-replace-platform-content"
3385
+ onClick={confirmSameContent}
3386
+ >
3387
+ {formatMessage(messages.replace)}
3388
+ </CapButton>,
3389
+ ]}
3390
+ >
3391
+ {formatMessage(messages.replacePlatformContentBody, {
3392
+ platform: formatMessage(activeTab === ANDROID ? messages.ios : messages.android),
3393
+ source: formatMessage(activeTab === ANDROID ? messages.android : messages.ios),
3394
+ })}
3395
+ </CapModal>
3396
+ <CapModal
3397
+ open={!!pendingPlatformSelection}
3398
+ centered
3399
+ width={520}
3400
+ title={formatMessage(messages.removePlatformContent, {
3401
+ platform: formatMessage(pendingPlatformSelection === ANDROID ? messages.ios : messages.android),
3402
+ })}
3403
+ onCancel={() => setPendingPlatformSelection(null)}
3404
+ footer={[
3405
+ <CapButton key="cancel" type="secondary" onClick={() => setPendingPlatformSelection(null)}>
3406
+ {formatMessage(globalMessages.cancel)}
3407
+ </CapButton>,
3408
+ <CapButton
3409
+ key="remove"
3410
+ type="primary"
3411
+ className="mpush-remove-platform-content"
3412
+ onClick={confirmPlatformRemoval}
3413
+ >
3414
+ {formatMessage(messages.removeContent)}
3415
+ </CapButton>,
3416
+ ]}
3417
+ />
3157
3418
  <TestAndPreviewSlidebox
3158
- show={showTestAndPreviewSlidebox}
3419
+ show={propsShowTestAndPreviewSlidebox || showTestAndPreviewSlidebox}
3159
3420
  onClose={handleCloseTestAndPreview}
3160
3421
  formData={getFormDataForPayload()} // Pass formData structure for payload building
3161
3422
  content={getTemplateContent()} // Also pass content for preview
@@ -3191,6 +3452,8 @@ MobilePushNew.propTypes = {
3191
3452
  globalActions: PropTypes.object,
3192
3453
  fetchingLiquidValidation: PropTypes.bool,
3193
3454
  handleClose: PropTypes.func,
3455
+ showTestAndPreviewSlidebox: PropTypes.bool,
3456
+ handleCloseTestAndPreview: PropTypes.func,
3194
3457
  createTemplateError: PropTypes.any,
3195
3458
  isGetFormData: PropTypes.bool,
3196
3459
  getTemplateDetailsInProgress: PropTypes.bool,
@@ -3223,6 +3486,8 @@ MobilePushNew.defaultProps = {
3223
3486
  globalActions: {},
3224
3487
  fetchingLiquidValidation: false,
3225
3488
  handleClose: () => {},
3489
+ showTestAndPreviewSlidebox: false,
3490
+ handleCloseTestAndPreview: undefined,
3226
3491
  createTemplateError: null,
3227
3492
  isGetFormData: false,
3228
3493
  getTemplateDetailsInProgress: false,