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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/constants/unified.js +4 -0
  2. package/index.js +13 -0
  3. package/package.json +1 -1
  4. package/services/getSchema.js +4 -1
  5. package/services/tests/getSchema.test.js +2 -2
  6. package/translations/en.json +1 -0
  7. package/translations/ja-JP.json +1 -0
  8. package/translations/zh.json +1 -0
  9. package/utils/common.js +6 -0
  10. package/utils/createMobilePushPayload.js +33 -47
  11. package/utils/tagValidations.js +35 -4
  12. package/utils/templateVarUtils.js +49 -0
  13. package/utils/tests/createMobilePushPayload.test.js +8 -102
  14. package/utils/tests/tagValidations.test.js +48 -0
  15. package/utils/tests/templateVarUtils.test.js +89 -0
  16. package/v2Components/CapMpushCTA/index.js +9 -10
  17. package/v2Components/CapMpushCTA/index.scss +3 -29
  18. package/v2Components/CapTagList/TagFallbackPanel.js +124 -0
  19. package/v2Components/CapTagList/constants.js +5 -0
  20. package/v2Components/CapTagList/index.js +46 -7
  21. package/v2Components/CapTagList/messages.js +44 -0
  22. package/v2Components/CapTagList/style.scss +113 -1
  23. package/v2Components/CapTagList/tests/TagFallback.test.js +222 -0
  24. package/v2Components/CapTagList/utils.js +17 -0
  25. package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +13 -26
  26. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
  27. package/v2Components/CommonTestAndPreview/constants.js +3 -2
  28. package/v2Components/CommonTestAndPreview/index.js +62 -62
  29. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -79
  30. package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
  31. package/v2Components/CommonTestAndPreview/tests/utils.test.js +102 -0
  32. package/v2Components/CommonTestAndPreview/utils.js +42 -3
  33. package/v2Components/FormBuilder/Classic.js +24 -14
  34. package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +1 -0
  35. package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
  36. package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +57 -0
  37. package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
  38. package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +3 -0
  39. package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +5 -0
  40. package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +6 -0
  41. package/v2Components/FormBuilder/Functional/channels/sms/validate.js +3 -1
  42. package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +3 -0
  43. package/v2Components/FormBuilder/Functional/tests/manual.typingPerf.test.js +135 -0
  44. package/v2Components/FormBuilder/Functional/tests/mpush.crossFlowParity.test.js +1 -1
  45. package/v2Components/FormBuilder/Functional/tests/mpush.ctaFlows.parity.test.js +320 -0
  46. package/v2Components/FormBuilder/Functional/tests/mpush.editContainer.parity.test.js +148 -0
  47. package/v2Components/FormBuilder/Functional/tests/mpush.libraryValidity.parity.test.js +152 -0
  48. package/v2Components/FormBuilder/Functional/tests/mpush.shellEvents.test.js +1 -1
  49. package/v2Components/FormBuilder/Functional/tests/mpush.singlePlatform.test.js +1 -1
  50. package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +22 -0
  51. package/v2Components/FormBuilder/tests/mpush.characterization.test.js +2 -2
  52. package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
  53. package/v2Components/TemplatePreview/index.js +17 -30
  54. package/v2Components/TemplatePreview/tests/index.test.js +0 -61
  55. package/v2Containers/Cap/index.js +3 -0
  56. package/v2Containers/Cap/messages.js +4 -0
  57. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
  58. package/v2Containers/CreativesContainer/SlideBoxContent.js +151 -70
  59. package/v2Containers/CreativesContainer/index.js +6 -3
  60. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -29
  61. package/v2Containers/InApp/index.js +4 -1
  62. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
  63. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
  64. package/v2Containers/Line/Container/Text/index.js +3 -1
  65. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +16 -0
  66. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
  67. package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +70 -0
  68. package/v2Containers/MobilePush/Create/actions.js +52 -0
  69. package/v2Containers/MobilePush/Create/constants.js +26 -0
  70. package/v2Containers/MobilePush/Create/index.js +2149 -0
  71. package/v2Containers/MobilePush/Create/messages.js +349 -0
  72. package/v2Containers/MobilePush/Create/reducer.js +72 -0
  73. package/v2Containers/MobilePush/Create/sagas.js +79 -0
  74. package/v2Containers/MobilePush/Create/selectors.js +29 -0
  75. package/v2Containers/MobilePush/Create/test/contentValidity.test.js +154 -0
  76. package/v2Containers/MobilePush/Create/test/saga.test.js +19 -0
  77. package/v2Containers/MobilePush/Create/test/stayOpenOnSave.test.js +80 -0
  78. package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +65 -0
  79. package/v2Containers/MobilePush/Edit/actions.js +94 -0
  80. package/v2Containers/MobilePush/Edit/constants.js +37 -0
  81. package/v2Containers/MobilePush/Edit/index.js +2407 -0
  82. package/v2Containers/MobilePush/Edit/messages.js +341 -0
  83. package/v2Containers/MobilePush/Edit/reducer.js +113 -0
  84. package/v2Containers/MobilePush/Edit/sagas.js +113 -0
  85. package/v2Containers/MobilePush/Edit/selectors.js +33 -0
  86. package/v2Containers/MobilePush/Edit/test/contentValidity.test.js +149 -0
  87. package/v2Containers/MobilePush/Edit/test/saga.test.js +255 -0
  88. package/v2Containers/MobilePush/Edit/test/stayOpenOnSave.test.js +60 -0
  89. package/v2Containers/MobilePush/commonMethods.js +333 -0
  90. package/v2Containers/MobilePush/eventsMap.js +130 -0
  91. package/v2Containers/MobilePush/tests/commonMethods.test.js +401 -0
  92. package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
  93. package/v2Containers/MobilePushNew/components/MediaUploaders.js +192 -207
  94. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +121 -116
  95. package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
  96. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +72 -316
  97. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +16 -45
  98. package/v2Containers/MobilePushNew/constants.js +0 -5
  99. package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
  100. package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -52
  101. package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -38
  102. package/v2Containers/MobilePushNew/hooks/useUpload.js +39 -29
  103. package/v2Containers/MobilePushNew/index.js +192 -454
  104. package/v2Containers/MobilePushNew/index.scss +4 -188
  105. package/v2Containers/MobilePushNew/messages.js +6 -86
  106. package/v2Containers/MobilePushNew/tests/index.test.js +1 -450
  107. package/v2Containers/MobilePushNew/tests/utils.test.js +0 -25
  108. package/v2Containers/MobilePushNew/utils.js +0 -8
  109. package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +22 -0
  110. package/v2Containers/MobilepushWrapper/index.js +178 -0
  111. package/v2Containers/MobilepushWrapper/messages.js +29 -0
  112. package/v2Containers/Rcs/index.js +8 -1
  113. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +59 -0
  114. package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
  115. package/v2Containers/SmsTrai/Edit/index.js +17 -7
  116. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +42 -0
  117. package/v2Containers/Templates/_templates.scss +2 -10
  118. package/v2Containers/Templates/index.js +90 -84
  119. package/v2Containers/Templates/tests/index.test.js +0 -68
  120. package/v2Containers/Viber/index.js +3 -1
  121. package/v2Containers/WebPush/Create/utils/validation.js +6 -0
  122. package/v2Containers/WebPush/Create/utils/validation.test.js +50 -0
  123. package/v2Containers/Whatsapp/index.js +9 -5
  124. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
  125. package/v2Containers/Zalo/index.js +4 -1
  126. package/v2Components/CapMpushCTA/tests/index.test.js +0 -89
  127. /package/{v2Components/FormBuilder/Functional/tests/fixtures/mpushInitialSchema.js → v2Containers/MobilePush/initialSchema.js} +0 -0
@@ -19,12 +19,10 @@ 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";
23
22
  import { intlShape, FormattedMessage } from "react-intl";
24
23
  import "./index.scss";
25
24
  import { GA } from "@capillarytech/cap-ui-utils";
26
25
  import CapNotification from "@capillarytech/cap-ui-library/CapNotification";
27
- import CapModal from "@capillarytech/cap-ui-library/CapModal";
28
26
  import { DAEMON } from "@capillarytech/vulcan-react-sdk/utils/sagaInjectorTypes";
29
27
  import globalMessages from "../Cap/messages";
30
28
  import * as actions from "./actions";
@@ -32,7 +30,6 @@ import {
32
30
  MEDIA_TYPES_OPTIONS,
33
31
  ANDROID,
34
32
  IOS,
35
- BOTH_PLATFORMS,
36
33
  MOBILE_PUSH_CHANNEL,
37
34
  INITIAL_CONTENT,
38
35
  BIG_PICTURE,
@@ -78,6 +75,7 @@ import {
78
75
  import withCreatives from "../../hoc/withCreatives";
79
76
  import { BIG_TEXT, DEEP_LINK, DEVICE_SUPPORTED } from "../InApp/constants";
80
77
  import { v2MobilePushSagas } from "./sagas";
78
+ import { getContent } from "../MobilePush/commonMethods";
81
79
  import { getMessageObject } from "../../utils/messageUtils";
82
80
  import { gtmPush } from "../../utils/gtmTrackers";
83
81
  import mobilePushReducer from "./reducer";
@@ -90,17 +88,16 @@ import useUpload from "./hooks/useUpload";
90
88
  import { validateTags } from "../../utils/tagValidations";
91
89
  import { PlatformContentFields } from "./components";
92
90
  import { CREATE, EDIT, TRACK_CREATE_MPUSH } from "../App/constants";
93
- import {
94
- validateExternalLink, validateDeepLink, isPlatformFieldsMissing, getContent,
95
- } from "./utils";
91
+ import { validateExternalLink, validateDeepLink, isPlatformFieldsMissing } from "./utils";
96
92
  import messages from "./messages";
97
93
  import { EXTERNAL_URL, MOBILE_PUSH } from "../CreativesContainer/constants";
98
- import createMobilePushPayloadWithIntl, { buildCarouselCards } from "../../utils/createMobilePushPayload";
94
+ import createMobilePushPayloadWithIntl from "../../utils/createMobilePushPayload";
99
95
  import { MOBILEPUSH } from "../../v2Components/CapVideoUpload/constants";
100
96
  import { StyledCapTab } from "./style";
101
97
  import TestAndPreviewSlidebox from "../../v2Components/TestAndPreviewSlidebox";
102
98
 
103
99
  import creativesMessages from "../CreativesContainer/messages";
100
+ import { error } from "jquery";
104
101
 
105
102
  // Helper function to extract deep link keys from URL where value equals key
106
103
  const extractDeepLinkKeys = (deepLinkValue) => {
@@ -279,50 +276,8 @@ const processCtaButtons = (ctas, deepLink) => {
279
276
  };
280
277
  };
281
278
 
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
-
324
279
  // Helper function to create content data object
325
- const createContentData =(contentType, mediaInfo, buttons, deepLink, processCarouselDataForDeepLinks) => {
280
+ const createContentData = (contentType, mediaInfo, buttons, deepLink, processCarouselDataForDeepLinks) => {
326
281
  const {
327
282
  mediaType,
328
283
  imageSrc,
@@ -548,9 +503,6 @@ export const MobilePushNew = ({
548
503
  supportedTags = [],
549
504
  globalActions: globalActionsProps,
550
505
  handleClose,
551
- // Edit mode: footer Test & Preview button lives in CreativesContainer
552
- showTestAndPreviewSlidebox: propsShowTestAndPreviewSlidebox,
553
- handleCloseTestAndPreview: propsHandleCloseTestAndPreview,
554
506
  fetchingLiquidValidation,
555
507
  createTemplateError,
556
508
  isGetFormData,
@@ -567,30 +519,11 @@ export const MobilePushNew = ({
567
519
  const templateId = params?.id || templateData?._id || templateData?.id;
568
520
  const isEditMode = !!templateId;
569
521
  const computedCreativesMode = isEditMode || templateData?.type === MOBILEPUSH ? 'edit' : 'create';
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;
522
+ const [sameContent, setSameContent] = useState(false);
588
523
  const [templateName, setTemplateName] = useState("");
589
524
  const [spin, setSpin] = useState(false);
590
525
  const [activeTab, setActiveTab] = useState(ANDROID);
591
526
  const [templateNameError, setTemplateNameError] = useState(false);
592
- // "Same content" tick waiting on the Replace confirm
593
- const [isReplaceConfirmOpen, setIsReplaceConfirmOpen] = useState(false);
594
527
  // Replace ctaData with platform-specific state
595
528
  const [ctaDataAndroid, setCtaDataAndroid] = useState([]);
596
529
  const [ctaDataIos, setCtaDataIos] = useState([]);
@@ -729,9 +662,6 @@ export const MobilePushNew = ({
729
662
  if (card.mediaType === IMAGE.toLowerCase() && !card.imageUrl) {
730
663
  return false;
731
664
  }
732
- if (card.mediaType === VIDEO.toLowerCase() && !card.videoSrc) {
733
- return false;
734
- }
735
665
 
736
666
  // Check if buttons have proper link data when actionOnClick is true
737
667
  if (card?.buttons?.length > 0) {
@@ -823,9 +753,6 @@ export const MobilePushNew = ({
823
753
  setPrimaryButtonIos(false);
824
754
  setSecondaryButtonIos(false);
825
755
  setSameContent(false);
826
- setPlatformSelection(BOTH_PLATFORMS);
827
- setPendingPlatformSelection(null);
828
- setPlatformToClear(null);
829
756
  setTemplateNameError(false);
830
757
  setAndroidTitleError("");
831
758
  setAndroidMessageError("");
@@ -881,7 +808,7 @@ export const MobilePushNew = ({
881
808
  (value) => {
882
809
  let errorTemplateDescMessage = "";
883
810
 
884
- const { isBraceError } = validateTags({
811
+ const { isBraceError, isDefaultQuoteError } = validateTags({
885
812
  content: value,
886
813
  tagsParam: tags,
887
814
  location,
@@ -898,6 +825,9 @@ export const MobilePushNew = ({
898
825
  globalMessages.unbalanacedCurlyBraces
899
826
  );
900
827
  }
828
+ if (isDefaultQuoteError) {
829
+ errorTemplateDescMessage = formatMessage(globalMessages.unquotedTagDefaultValue);
830
+ }
901
831
  return errorTemplateDescMessage;
902
832
  },
903
833
  [tags, injectedTags, location, getDefaultTags, formatMessage]
@@ -1039,8 +969,6 @@ export const MobilePushNew = ({
1039
969
  templateNameRef.current = name;
1040
970
  });
1041
971
 
1042
- stateUpdates.push(() => setPlatformSelection(getSavedPlatformSelection(editContent)));
1043
-
1044
972
  // Process Android content
1045
973
  const androidContentType = editContent?.ANDROID;
1046
974
  if (!isEmpty(androidContentType)) {
@@ -1176,8 +1104,6 @@ export const MobilePushNew = ({
1176
1104
  templateNameRef.current = name;
1177
1105
  });
1178
1106
 
1179
- stateUpdates.push(() => setPlatformSelection(getSavedPlatformSelection(templateContent)));
1180
-
1181
1107
  // Process Android content
1182
1108
  const androidContentType = templateContent?.ANDROID;
1183
1109
  if (!isEmpty(androidContentType)) {
@@ -1813,6 +1739,10 @@ export const MobilePushNew = ({
1813
1739
  setSpin(false);
1814
1740
  }, [templateData, isFullMode, deepLink, setUpdateMpushImageSrc, setUpdateMpushVideoSrc]);
1815
1741
 
1742
+ // Determine platform support from accountData
1743
+ const isAndroidSupported = accountData?.configs?.android === '1';
1744
+ const isIosSupported = accountData?.configs?.ios === '1';
1745
+
1816
1746
  // Notify parent when personalization tokens are added/removed (for anonymous user flow)
1817
1747
  useEffect(() => {
1818
1748
  if (!restrictPersonalization || typeof onPersonalizationTokensChange !== 'function') return;
@@ -1821,8 +1751,8 @@ export const MobilePushNew = ({
1821
1751
  || (value.includes('[') && value.includes(']'))
1822
1752
  );
1823
1753
  const hasTokens = (
1824
- (showAndroid && (hasToken(androidContent?.title) || hasToken(androidContent?.message)))
1825
- || (showIos && (hasToken(iosContent?.title) || hasToken(iosContent?.message)))
1754
+ (isAndroidSupported && (hasToken(androidContent?.title) || hasToken(androidContent?.message)))
1755
+ || (isIosSupported && (hasToken(iosContent?.title) || hasToken(iosContent?.message)))
1826
1756
  );
1827
1757
  onPersonalizationTokensChange(hasTokens);
1828
1758
  }, [
@@ -1831,21 +1761,18 @@ export const MobilePushNew = ({
1831
1761
  androidContent?.message,
1832
1762
  iosContent?.title,
1833
1763
  iosContent?.message,
1834
- showAndroid,
1835
- showIos,
1764
+ isAndroidSupported,
1765
+ isIosSupported,
1836
1766
  onPersonalizationTokensChange,
1837
1767
  ]);
1838
1768
 
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)
1769
+ // Validation logic for template creation/update.
1770
+ const isAndroidFieldsMissing = isPlatformFieldsMissing(isAndroidSupported, androidContent);
1771
+ const isIosFieldsMissing = isPlatformFieldsMissing(isIosSupported, iosContent);
1772
+ const isMobilePushContentMissing = (
1773
+ (isAndroidSupported || isIosSupported)
1774
+ && (!isAndroidSupported || isAndroidFieldsMissing)
1775
+ && (!isIosSupported || isIosFieldsMissing)
1849
1776
  );
1850
1777
 
1851
1778
  // Ref to dedupe reporting of content emptiness to the parent, so we only
@@ -1869,7 +1796,8 @@ export const MobilePushNew = ({
1869
1796
  handleMessageChange,
1870
1797
  handleTagSelect,
1871
1798
  handleMediaTypeChange,
1872
- handleTapActionChange,
1799
+ handleActionOnClickChange,
1800
+ handleLinkTypeChange,
1873
1801
  } = usePlatformSync({
1874
1802
  setAndroidContent,
1875
1803
  setIosContent,
@@ -1941,14 +1869,9 @@ export const MobilePushNew = ({
1941
1869
  }
1942
1870
  }, [sameContent]);
1943
1871
 
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
-
1949
1872
  const handleExternalLinkChange = useCallback((platform, externalLinkValue) => {
1950
1873
  // Validate URL
1951
- const urlError = getTapUrlError(externalLinkValue);
1874
+ const urlError = validateExternalLink(externalLinkValue, formatMessage, messages);
1952
1875
 
1953
1876
  const updateContent = {
1954
1877
  externalLinkValue,
@@ -1975,7 +1898,7 @@ export const MobilePushNew = ({
1975
1898
  setAndroidExternalLinkError(urlError || "");
1976
1899
  }
1977
1900
  }
1978
- }, [getTapUrlError, sameContent]);
1901
+ }, [validateExternalLink, sameContent]);
1979
1902
 
1980
1903
  // Carousel data handler for platform-specific carousel management
1981
1904
  const updateCarouselLinkError = useCallback((cardIndex, field, error) => {
@@ -2122,16 +2045,8 @@ export const MobilePushNew = ({
2122
2045
  handleTitleChange,
2123
2046
  handleMessageChange,
2124
2047
  handleMediaTypeChange,
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
- },
2048
+ handleActionOnClickChange,
2049
+ handleLinkTypeChange,
2135
2050
  handleDeepLinkChange: (value) => handleDeepLinkChange(platform, value),
2136
2051
  handleDeepLinkKeysChange: (value) => handleDeepLinkKeysChange(platform, value),
2137
2052
  handleExternalLinkChange: (value) => handleExternalLinkChange(platform, value),
@@ -2254,7 +2169,7 @@ export const MobilePushNew = ({
2254
2169
  restrictPersonalization={restrictPersonalization}
2255
2170
  />
2256
2171
  );
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]
2172
+ }, [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]
2258
2173
  );
2259
2174
 
2260
2175
  // PANES: Only render enabled platforms
@@ -2264,8 +2179,8 @@ export const MobilePushNew = ({
2264
2179
  panes.push({
2265
2180
  key: ANDROID,
2266
2181
  tab: (
2267
- <CapRow type="flex" align="middle" noWrap className="tab-label">
2268
- <CapIcon type="android" size="s" />
2182
+ <CapRow useLegacy>
2183
+ <CapIcon type="android" />
2269
2184
  {formatMessage(messages.android)}
2270
2185
  </CapRow>
2271
2186
  ),
@@ -2276,8 +2191,8 @@ export const MobilePushNew = ({
2276
2191
  panes.push({
2277
2192
  key: IOS,
2278
2193
  tab: (
2279
- <CapRow type="flex" align="middle" noWrap className="tab-label">
2280
- <CapIcon type="ios" size="s" />
2194
+ <CapRow useLegacy>
2195
+ <CapIcon type="ios" />
2281
2196
  {formatMessage(messages.ios)}
2282
2197
  </CapRow>
2283
2198
  ),
@@ -2290,32 +2205,25 @@ export const MobilePushNew = ({
2290
2205
  const errorInTitle = activeTab === ANDROID ? androidTitleError : iosTitleError;
2291
2206
  const errorInMessage = activeTab === ANDROID ? androidMessageError : iosMessageError;
2292
2207
 
2293
- const hasFormErrors = (
2294
- templateNameError
2208
+ // Save button disabled logic: only check enabled platforms, and allow
2209
+ // saving with just one supported platform filled in (see isMobilePushContentMissing).
2210
+ const isSaveDisabled = (
2211
+ isMobilePushContentMissing
2212
+ || templateNameError
2295
2213
  || Object.values(carouselLinkErrors).some((error) => error !== null && error !== "")
2296
2214
  || !isCarouselDataValid()
2297
2215
  || errorInTitle || errorInMessage
2298
2216
  );
2299
- // Save needs every shown platform filled
2300
- const isSaveDisabled = isMobilePushContentMissing || hasFormErrors;
2301
- const isTestAndPreviewDisabled = isAllContentMissing || hasFormErrors;
2302
2217
 
2303
- // Validation in handleSave: every shown platform needs a title and message (no save-without dialog)
2218
+ // Validation in handleSave: only enforce content on enabled platforms, and
2219
+ // allow saving with just one supported platform filled in.
2304
2220
  const handleSave = useCallback(() => {
2305
2221
  if (isMobilePushContentMissing) {
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));
2222
+ CapNotification.error({
2223
+ message: formatMessage(
2224
+ isAndroidSupported ? messages.androidValidationError : messages.iosValidationError,
2225
+ ),
2314
2226
  });
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
- }
2319
2227
  if (onValidationFail) onValidationFail();
2320
2228
  return;
2321
2229
  }
@@ -2339,33 +2247,32 @@ export const MobilePushNew = ({
2339
2247
  // Use ref to get the latest template name value to avoid closure issues
2340
2248
  let finalTemplateName = templateNameRef.current || templateName;
2341
2249
  if (!isFullMode && (!finalTemplateName || !finalTemplateName.trim())) {
2342
- if (showAndroid && androidContent?.title && androidContent.title.trim()) {
2250
+ if (androidContent?.title && androidContent.title.trim()) {
2343
2251
  finalTemplateName = androidContent.title.trim();
2344
- } else if (showIos && iosContent?.title && iosContent.title.trim()) {
2252
+ } else if (iosContent?.title && iosContent.title.trim()) {
2345
2253
  finalTemplateName = iosContent.title.trim();
2346
2254
  } else {
2347
2255
  finalTemplateName = '';
2348
2256
  }
2349
2257
  }
2350
2258
 
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
+ // Validate external links
2260
+ const androidUrlError = validateExternalLink(androidContent.externalLinkValue, formatMessage, messages);
2261
+ const iosUrlError = validateExternalLink(iosContent.externalLinkValue, formatMessage, messages);
2355
2262
 
2356
2263
  setAndroidExternalLinkError(androidUrlError || "");
2357
2264
  setIosExternalLinkError(iosUrlError || "");
2358
2265
 
2359
2266
  // Validate deep links
2360
- const androidDeepLinkUrlError = showAndroid && validateDeepLink(androidContent.deepLinkValue, formatMessage, messages);
2361
- const iosDeepLinkUrlError = showIos && validateDeepLink(iosContent.deepLinkValue, formatMessage, messages);
2267
+ const androidDeepLinkUrlError = validateDeepLink(androidContent.deepLinkValue, formatMessage, messages);
2268
+ const iosDeepLinkUrlError = validateDeepLink(iosContent.deepLinkValue, formatMessage, messages);
2362
2269
 
2363
2270
  setAndroidDeepLinkError(androidDeepLinkUrlError || "");
2364
2271
  setIosDeepLinkError(iosDeepLinkUrlError || "");
2365
2272
 
2366
2273
  // Validate deep link keys - only require keys if the selected deep link has keys defined
2367
2274
  const androidDeepLinkKeysErrorMsg = (() => {
2368
- if (showAndroid && androidContent?.linkType === DEEP_LINK && androidContent?.deepLinkValue) {
2275
+ if (androidContent?.linkType === DEEP_LINK && androidContent?.deepLinkValue) {
2369
2276
  // Use the same matching logic as deep link value extraction
2370
2277
  let selectedDeepLink = null;
2371
2278
 
@@ -2389,7 +2296,7 @@ export const MobilePushNew = ({
2389
2296
  })();
2390
2297
 
2391
2298
  const iosDeepLinkKeysErrorMsg = (() => {
2392
- if (showIos && iosContent?.linkType === DEEP_LINK && iosContent?.deepLinkValue) {
2299
+ if (iosContent?.linkType === DEEP_LINK && iosContent?.deepLinkValue) {
2393
2300
  // Use the same matching logic as deep link value extraction
2394
2301
  let selectedDeepLink = null;
2395
2302
 
@@ -2434,34 +2341,74 @@ export const MobilePushNew = ({
2434
2341
  const processedIosContent = { ...iosContent };
2435
2342
 
2436
2343
  // Process button CTA data if it exists
2437
- const savedAndroidCtas = toSavedCtas(ctaDataAndroid);
2438
- if (savedAndroidCtas.length > 0) {
2439
- processedAndroidContent.expandableDetails = {
2440
- ...processedAndroidContent.expandableDetails,
2441
- ctas: savedAndroidCtas,
2442
- };
2344
+ if (ctaDataAndroid?.length > 0) {
2345
+ const savedCtas = ctaDataAndroid.filter((cta) => cta.isSaved);
2346
+ if (savedCtas?.length > 0) {
2347
+ processedAndroidContent.expandableDetails = {
2348
+ ...processedAndroidContent.expandableDetails,
2349
+ ctas: savedCtas.map((cta) => {
2350
+ let actionLink = cta?.url;
2351
+
2352
+ // Append deep link keys to URL if they exist
2353
+ if (cta?.urlType === DEEP_LINK && cta?.deepLinkKeys?.length > 0) {
2354
+ const deepLinkKeysArray = Array.isArray(cta?.deepLinkKeys) ? cta?.deepLinkKeys : [cta?.deepLinkKeys];
2355
+ const validKeys = deepLinkKeysArray.filter((key) => typeof key === 'string' && key?.length > 0);
2356
+ if (validKeys?.length > 0) {
2357
+ const separator = actionLink.includes('?') ? '&' : '?';
2358
+ const keyParams = validKeys.map((key) => `${key}=${key}`).join('&');
2359
+ actionLink = `${actionLink}${separator}${keyParams}`;
2360
+ }
2361
+ }
2362
+
2363
+ return {
2364
+ actionText: cta?.text,
2365
+ type: cta?.urlType || DEEP_LINK,
2366
+ actionLink,
2367
+ };
2368
+ }),
2369
+ };
2370
+ }
2443
2371
  }
2444
- const savedIosCtas = toSavedCtas(ctaDataIos);
2445
- if (savedIosCtas.length > 0) {
2446
- processedIosContent.expandableDetails = {
2447
- ...processedIosContent.expandableDetails,
2448
- ctas: savedIosCtas,
2449
- };
2372
+ if (ctaDataIos?.length > 0) {
2373
+ const savedCtas = ctaDataIos.filter((cta) => cta.isSaved);
2374
+ if (savedCtas?.length > 0) {
2375
+ processedIosContent.expandableDetails = {
2376
+ ...processedIosContent.expandableDetails,
2377
+ ctas: savedCtas.map((cta) => {
2378
+ let actionLink = cta?.url;
2379
+
2380
+ // Append deep link keys to URL if they exist
2381
+ if (cta?.urlType === DEEP_LINK && cta?.deepLinkKeys?.length > 0) {
2382
+ const deepLinkKeysArray = Array.isArray(cta?.deepLinkKeys) ? cta?.deepLinkKeys : [cta?.deepLinkKeys];
2383
+ const validKeys = deepLinkKeysArray.filter((key) => typeof key === 'string' && key?.length > 0);
2384
+ if (validKeys?.length > 0) {
2385
+ const separator = actionLink.includes('?') ? '&' : '?';
2386
+ const keyParams = validKeys.map((key) => `${key}=${key}`).join('&');
2387
+ actionLink = `${actionLink}${separator}${keyParams}`;
2388
+ }
2389
+ }
2390
+
2391
+ return {
2392
+ actionText: cta?.text,
2393
+ type: cta?.urlType || DEEP_LINK,
2394
+ actionLink,
2395
+ };
2396
+ }),
2397
+ };
2398
+ }
2450
2399
  }
2451
2400
 
2452
2401
  // Create payload with enabled platform content and intl
2453
2402
  const payload = createMobilePushPayloadWithIntl({
2454
2403
  templateName: finalTemplateName,
2455
- androidContent: showAndroid ? processedAndroidContent : undefined,
2456
- iosContent: showIos ? processedIosContent : undefined,
2404
+ androidContent: isAndroidSupported ? processedAndroidContent : undefined,
2405
+ iosContent: isIosSupported ? processedIosContent : undefined,
2457
2406
  imageSrc,
2458
2407
  mpushVideoSrcAndPreview,
2459
2408
  accountData,
2460
2409
  sameContent,
2461
2410
  options: {
2462
2411
  mode: params?.mode,
2463
- // One platform chosen: leave the other platform's key out of versions.base
2464
- skipPlatform: singlePlatform ? getOtherPlatform(singlePlatform) : undefined,
2465
2412
  },
2466
2413
  intl,
2467
2414
  });
@@ -2652,7 +2599,7 @@ export const MobilePushNew = ({
2652
2599
  globalActionsProps,
2653
2600
  onValidationFail,
2654
2601
  resetFormData,
2655
- getTapUrlError,
2602
+ validateExternalLink,
2656
2603
  ctaDataAndroid,
2657
2604
  ctaDataIos,
2658
2605
  intl,
@@ -2660,15 +2607,7 @@ export const MobilePushNew = ({
2660
2607
  createTimeoutRef,
2661
2608
  isAndroidSupported,
2662
2609
  isIosSupported,
2663
- showAndroid,
2664
- showIos,
2665
- singlePlatform,
2666
- activeTab,
2667
- validateTitle,
2668
- validateMessage,
2669
2610
  isMobilePushContentMissing,
2670
- isAndroidFieldsMissing,
2671
- isIosFieldsMissing,
2672
2611
  isCarouselDataValid,
2673
2612
  isFullMode,
2674
2613
  templateId,
@@ -2764,30 +2703,38 @@ export const MobilePushNew = ({
2764
2703
  getLiquidTags: globalActionsProps.getLiquidTags,
2765
2704
  formatMessage,
2766
2705
  messages: formBuilderMessages,
2767
- // One platform chosen: validate only that platform
2768
- singleTab: singlePlatform || getSingleTab(accountData),
2706
+ singleTab: getSingleTab(accountData),
2769
2707
  });
2770
2708
  }, [
2771
2709
  androidContent,
2772
2710
  iosContent,
2773
2711
  activeTab,
2774
- singlePlatform,
2775
2712
  globalActionsProps,
2776
2713
  formatMessage,
2777
2714
  accountData,
2778
2715
  isFullMode,
2779
2716
  ]);
2780
2717
 
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
-
2784
- useEffect(() => {
2785
- setAndroidContent((prevContent) => ({ ...prevContent, buttons: toPreviewButtons(ctaDataAndroid) }));
2786
- }, [ctaDataAndroid]);
2787
-
2788
2718
  useEffect(() => {
2789
- setIosContent((prevContent) => ({ ...prevContent, buttons: toPreviewButtons(ctaDataIos) }));
2790
- }, [ctaDataIos]);
2719
+ // Always map to { label } for both platforms
2720
+ const newButtons = Array.isArray(ctaData)
2721
+ ? ctaData.map((data) => ({
2722
+ label: data?.text || '',
2723
+ }))
2724
+ : [];
2725
+
2726
+ if (activeTab === ANDROID) {
2727
+ setAndroidContent((prevContent) => ({
2728
+ ...prevContent,
2729
+ buttons: newButtons,
2730
+ }));
2731
+ } else if (activeTab === IOS) {
2732
+ setIosContent((prevContent) => ({
2733
+ ...prevContent,
2734
+ buttons: newButtons,
2735
+ }));
2736
+ }
2737
+ }, [ctaData, activeTab]);
2791
2738
 
2792
2739
  // Sync button data and state from active tab to other platform when sameContent is enabled
2793
2740
  useEffect(() => {
@@ -2813,141 +2760,12 @@ export const MobilePushNew = ({
2813
2760
  }
2814
2761
  }, [sameContent, activeTab]);
2815
2762
 
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
-
2835
2763
  const handleSameContentChange = useCallback((e) => {
2836
2764
  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
- }
2843
2765
  syncPlatformContent(isCurrentPlatformAndroid ? androidContent : iosContent, isCurrentPlatformAndroid ? ANDROID : IOS);
2844
2766
  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);
2851
2767
  }, [activeTab, androidContent, iosContent]);
2852
2768
 
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
-
2951
2769
  const getContentType = useCallback(
2952
2770
  (content) => {
2953
2771
  // Get image source from multiple possible locations
@@ -3075,10 +2893,6 @@ export const MobilePushNew = ({
3075
2893
  'message-title': androidPreview?.header || androidContent?.title || '',
3076
2894
  'message-editor': androidPreview?.bodyText || androidContent?.message || '',
3077
2895
  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) : [],
3082
2896
  // Extract primary CTA
3083
2897
  ...(androidContent?.cta && {
3084
2898
  'cta-deeplink': androidContent.cta.type === DEEP_LINK ? 'Deeplink' : 'External Link',
@@ -3088,10 +2902,9 @@ export const MobilePushNew = ({
3088
2902
  }),
3089
2903
  };
3090
2904
 
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
+ // Extract secondary CTAs from expandableDetails
2906
+ if (androidContent?.expandableDetails?.ctas && androidContent.expandableDetails.ctas.length > 0) {
2907
+ androidContent.expandableDetails.ctas.forEach((cta, index) => {
3095
2908
  if (index === 0) {
3096
2909
  androidFormData['secondary-cta-0-label'] = cta.actionText || '';
3097
2910
  androidFormData['cta-deeplink-secondary-cta-0'] = cta.type === DEEP_LINK ? 'Deeplink' : 'External Link';
@@ -3112,8 +2925,6 @@ export const MobilePushNew = ({
3112
2925
  'message-title2': iosPreview?.header || iosContent?.title || '',
3113
2926
  'message-editor2': iosPreview?.bodyText || iosContent?.message || '',
3114
2927
  image: iosPreview?.bodyImage || iosContent?.expandableDetails?.image || '',
3115
- video: iosContent?.mediaType === VIDEO ? (iosContent?.videoSrc || '') : '',
3116
- carouselData: iosContent?.mediaType === CAROUSEL ? buildCarouselCards(iosContent?.carouselData) : [],
3117
2928
  // Extract primary CTA
3118
2929
  ...(iosContent?.cta && {
3119
2930
  'cta-deeplink2': iosContent.cta.type === DEEP_LINK ? 'Deeplink' : 'External Link',
@@ -3123,9 +2934,9 @@ export const MobilePushNew = ({
3123
2934
  }),
3124
2935
  };
3125
2936
 
3126
- const iosCtas = toSavedCtas(ctaDataIos);
3127
- if (iosCtas.length > 0) {
3128
- iosCtas.forEach((cta, index) => {
2937
+ // Extract secondary CTAs from expandableDetails
2938
+ if (iosContent?.expandableDetails?.ctas && iosContent.expandableDetails.ctas.length > 0) {
2939
+ iosContent.expandableDetails.ctas.forEach((cta, index) => {
3129
2940
  if (index === 0) {
3130
2941
  iosFormData['secondary-cta-1-label'] = cta.actionText || '';
3131
2942
  iosFormData['cta-deeplink-secondary-cta-1'] = cta.type === DEEP_LINK ? 'Deeplink' : 'External Link';
@@ -3138,7 +2949,7 @@ export const MobilePushNew = ({
3138
2949
 
3139
2950
  // Return in formData array format [androidData, iosData]
3140
2951
  return [androidFormData, iosFormData];
3141
- }, [androidContent, iosContent, getContentType, ctaDataAndroid, ctaDataIos]);
2952
+ }, [androidContent, iosContent, getContentType]);
3142
2953
 
3143
2954
  // Handle Test and Preview button click
3144
2955
  const handleTestAndPreview = useCallback(() => {
@@ -3148,8 +2959,7 @@ export const MobilePushNew = ({
3148
2959
  // Handle close Test and Preview slidebox
3149
2960
  const handleCloseTestAndPreview = useCallback(() => {
3150
2961
  setShowTestAndPreviewSlidebox(false);
3151
- if (propsHandleCloseTestAndPreview) propsHandleCloseTestAndPreview();
3152
- }, [propsHandleCloseTestAndPreview]);
2962
+ }, []);
3153
2963
 
3154
2964
  // Add useEffect to handle isGetFormData prop changes (e.g. Done clicked in footer)
3155
2965
  // In library mode: run liquid validation (extractTags) first; on success liquidMiddleWare calls handleSave
@@ -3275,46 +3085,24 @@ export const MobilePushNew = ({
3275
3085
  <CapRow className="mobile-push-container">
3276
3086
  <CapColumn className="content-section" span={14}>
3277
3087
  {createModeContent()}
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
- </>
3088
+ {isAndroidSupported && isIosSupported && (
3089
+ <CapCheckbox
3090
+ className="same-content-checkbox"
3091
+ checked={sameContent}
3092
+ onChange={handleSameContentChange}
3093
+ key={`same-content-${sameContent}`}
3094
+ >
3095
+ {formatMessage(messages.sameContentForBothChannels)}
3096
+ </CapCheckbox>
3317
3097
  )}
3098
+ <CapRow className="platform-header">
3099
+ <StyledCapTab
3100
+ className="platform-tabs"
3101
+ activeKey={activeTab}
3102
+ onChange={setActiveTab}
3103
+ panes={PANES}
3104
+ />
3105
+ </CapRow>
3318
3106
  <CapRow>
3319
3107
  <CapColumn span={24}>
3320
3108
  <ErrorInfoNote
@@ -3324,6 +3112,39 @@ export const MobilePushNew = ({
3324
3112
  STANDARD_ERROR_MSG: errorMessage?.STANDARD_ERROR_MSG,
3325
3113
  }}
3326
3114
  />
3115
+
3116
+ {/* In library mode, only show save button in create mode (edit mode has Done button from FormBuilder). In full mode, keep old logic. */}
3117
+ {((!isFullMode && computedCreativesMode !== 'edit') || (isFullMode && !isEditMode && computedCreativesMode === 'create')) && (
3118
+ <CapRow className="save-section">
3119
+ <CapColumn span={24}>
3120
+ <CapButton
3121
+ type="primary"
3122
+ onClick={() => {
3123
+ // Liquid validation (extractTags) only in library mode
3124
+ if (!isFullMode) {
3125
+ liquidMiddleWare();
3126
+ } else {
3127
+ handleSave();
3128
+ }
3129
+ }}
3130
+ className="save-button"
3131
+ disabled={isSaveDisabled}
3132
+ >
3133
+ {formatMessage(messages.saveTemplate)}
3134
+ </CapButton>
3135
+ <CapButton
3136
+ onClick={handleTestAndPreview}
3137
+ className="mobilepush-test-preview-btn"
3138
+ type="secondary"
3139
+ style={{ marginLeft: '8px' }}
3140
+ disabled={isSaveDisabled}
3141
+ >
3142
+ <FormattedMessage {...creativesMessages.testAndPreview} />
3143
+ </CapButton>
3144
+ </CapColumn>
3145
+ </CapRow>
3146
+ )}
3147
+
3327
3148
  </CapColumn>
3328
3149
  </CapRow>
3329
3150
  </CapColumn>
@@ -3336,87 +3157,8 @@ export const MobilePushNew = ({
3336
3157
  />
3337
3158
  </CapColumn>
3338
3159
  </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
- />
3418
3160
  <TestAndPreviewSlidebox
3419
- show={propsShowTestAndPreviewSlidebox || showTestAndPreviewSlidebox}
3161
+ show={showTestAndPreviewSlidebox}
3420
3162
  onClose={handleCloseTestAndPreview}
3421
3163
  formData={getFormDataForPayload()} // Pass formData structure for payload building
3422
3164
  content={getTemplateContent()} // Also pass content for preview
@@ -3452,8 +3194,6 @@ MobilePushNew.propTypes = {
3452
3194
  globalActions: PropTypes.object,
3453
3195
  fetchingLiquidValidation: PropTypes.bool,
3454
3196
  handleClose: PropTypes.func,
3455
- showTestAndPreviewSlidebox: PropTypes.bool,
3456
- handleCloseTestAndPreview: PropTypes.func,
3457
3197
  createTemplateError: PropTypes.any,
3458
3198
  isGetFormData: PropTypes.bool,
3459
3199
  getTemplateDetailsInProgress: PropTypes.bool,
@@ -3486,8 +3226,6 @@ MobilePushNew.defaultProps = {
3486
3226
  globalActions: {},
3487
3227
  fetchingLiquidValidation: false,
3488
3228
  handleClose: () => {},
3489
- showTestAndPreviewSlidebox: false,
3490
- handleCloseTestAndPreview: undefined,
3491
3229
  createTemplateError: null,
3492
3230
  isGetFormData: false,
3493
3231
  getTemplateDetailsInProgress: false,