@capillarytech/creatives-library 9.2.2-alpha.sprint-cap-214249.44 → 9.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants/unified.js +1 -3
- package/package.json +1 -1
- package/translations/en.json +0 -1
- package/translations/ja-JP.json +0 -1
- package/translations/zh.json +0 -1
- package/utils/common.js +6 -0
- package/utils/createMobilePushPayload.js +56 -50
- package/utils/tagValidations.js +4 -35
- package/utils/tests/createMobilePushPayload.test.js +168 -177
- package/utils/tests/tagValidations.test.js +0 -48
- package/v2Components/CapMpushCTA/index.js +57 -47
- package/v2Components/CapMpushCTA/index.scss +5 -43
- package/v2Components/CapTagList/index.js +7 -46
- package/v2Components/CapTagList/messages.js +0 -44
- package/v2Components/CapTagList/style.scss +1 -113
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +8 -11
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
- package/v2Components/CommonTestAndPreview/constants.js +0 -2
- package/v2Components/CommonTestAndPreview/index.js +12 -51
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -83
- package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -100
- package/v2Components/FormBuilder/Classic.js +14 -24
- package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +0 -1
- package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
- package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +0 -57
- package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
- package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +0 -3
- package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +0 -5
- package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +0 -6
- package/v2Components/FormBuilder/Functional/channels/sms/validate.js +1 -3
- package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +0 -3
- package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +0 -22
- package/v2Components/MobilePushPreviewV2/index.js +9 -22
- package/v2Components/TemplatePreview/_templatePreview.scss +2 -18
- package/v2Components/TemplatePreview/index.js +18 -20
- package/v2Components/TemplatePreview/tests/index.test.js +0 -69
- package/v2Containers/Cap/messages.js +0 -4
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +0 -1
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js +2 -12
- package/v2Containers/CreativesContainer/SlideBoxContent.js +6 -4
- package/v2Containers/CreativesContainer/index.js +1 -2
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -43
- package/v2Containers/InApp/index.js +1 -4
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +0 -3
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +0 -2
- package/v2Containers/Line/Container/Text/index.js +1 -3
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +0 -16
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +0 -18
- package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +345 -105
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +105 -127
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +1484 -307
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +59 -165
- package/v2Containers/MobilePushNew/constants.js +0 -12
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -78
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -40
- package/v2Containers/MobilePushNew/hooks/useUpload.js +46 -42
- package/v2Containers/MobilePushNew/index.js +290 -502
- package/v2Containers/MobilePushNew/index.scss +4 -151
- package/v2Containers/MobilePushNew/messages.js +6 -106
- package/v2Containers/MobilePushNew/tests/index.test.js +1 -483
- package/v2Containers/MobilePushNew/tests/utils.test.js +0 -110
- package/v2Containers/MobilePushNew/utils.js +0 -83
- package/v2Containers/Rcs/index.js +1 -8
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +0 -59
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +0 -4
- package/v2Containers/SmsTrai/Edit/index.js +5 -13
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +0 -15
- package/v2Containers/Templates/_templates.scss +2 -10
- package/v2Containers/Templates/index.js +81 -86
- package/v2Containers/Templates/tests/index.test.js +0 -81
- package/v2Containers/Viber/index.js +1 -3
- package/v2Containers/WebPush/Create/utils/validation.js +0 -6
- package/v2Containers/WebPush/Create/utils/validation.test.js +0 -50
- package/v2Containers/Whatsapp/index.js +5 -9
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Zalo/index.js +1 -4
- package/v2Components/CapMpushCTA/tests/index.test.js +0 -150
- package/v2Components/CapTagList/TagFallbackPanel.js +0 -124
- package/v2Components/CapTagList/constants.js +0 -5
- package/v2Components/CapTagList/tests/TagFallback.test.js +0 -222
- package/v2Components/CapTagList/utils.js +0 -17
- package/v2Components/MobilePushPreviewV2/_mobilePushPreviewV2.scss +0 -7
- package/v2Components/MobilePushPreviewV2/tests/index.test.js +0 -55
- package/v2Components/TemplatePreview/_mobilePushPhone.scss +0 -72
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/extractContentForPreview.test.js +0 -45
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +0 -76
|
@@ -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,21 +88,36 @@ 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, getCarouselCardIssue,
|
|
95
|
-
extractDeepLinkParams, appendDeepLinkParams, hasAllDeepLinkParams,
|
|
96
|
-
} from "./utils";
|
|
91
|
+
import { validateExternalLink, validateDeepLink, isPlatformFieldsMissing } from "./utils";
|
|
97
92
|
import messages from "./messages";
|
|
98
93
|
import { EXTERNAL_URL, MOBILE_PUSH } from "../CreativesContainer/constants";
|
|
99
|
-
import createMobilePushPayloadWithIntl
|
|
94
|
+
import createMobilePushPayloadWithIntl from "../../utils/createMobilePushPayload";
|
|
100
95
|
import { MOBILEPUSH } from "../../v2Components/CapVideoUpload/constants";
|
|
101
96
|
import { StyledCapTab } from "./style";
|
|
102
97
|
import TestAndPreviewSlidebox from "../../v2Components/TestAndPreviewSlidebox";
|
|
103
98
|
|
|
104
99
|
import creativesMessages from "../CreativesContainer/messages";
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
100
|
+
import { error } from "jquery";
|
|
101
|
+
|
|
102
|
+
// Helper function to extract deep link keys from URL where value equals key
|
|
103
|
+
const extractDeepLinkKeys = (deepLinkValue) => {
|
|
104
|
+
try {
|
|
105
|
+
if (deepLinkValue?.includes('?')) {
|
|
106
|
+
const queryString = deepLinkValue.split('?')[1];
|
|
107
|
+
const searchParams = new URLSearchParams(queryString);
|
|
108
|
+
const extractedKeys = [];
|
|
109
|
+
searchParams.forEach((value, key) => {
|
|
110
|
+
if (value === key) { // Only extract keys where value equals key
|
|
111
|
+
extractedKeys.push(key);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return extractedKeys;
|
|
115
|
+
}
|
|
116
|
+
return [];
|
|
117
|
+
} catch (error) {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
};
|
|
108
121
|
|
|
109
122
|
// Helper function to process media type from various sources
|
|
110
123
|
/**
|
|
@@ -263,44 +276,8 @@ const processCtaButtons = (ctas, deepLink) => {
|
|
|
263
276
|
};
|
|
264
277
|
};
|
|
265
278
|
|
|
266
|
-
const getOtherPlatform = (platform) => (platform === ANDROID ? IOS : ANDROID);
|
|
267
|
-
|
|
268
|
-
// Title, message or media entered for a platform
|
|
269
|
-
const hasPlatformContent = (content) => !!(
|
|
270
|
-
content?.title?.trim()
|
|
271
|
-
|| content?.message?.trim()
|
|
272
|
-
|| (content?.mediaType && content.mediaType !== NONE)
|
|
273
|
-
);
|
|
274
|
-
|
|
275
|
-
// Platforms dropdown value for a saved template: whichever of ANDROID / IOS it has
|
|
276
|
-
const getSavedPlatformSelection = (base = {}) => {
|
|
277
|
-
const hasAndroid = !isEmpty(base?.ANDROID);
|
|
278
|
-
const hasIos = !isEmpty(base?.IOS);
|
|
279
|
-
if (hasAndroid && !hasIos) return ANDROID;
|
|
280
|
-
if (hasIos && !hasAndroid) return IOS;
|
|
281
|
-
return BOTH_PLATFORMS;
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
// Saved buttons in backend shape { actionText, type, actionLink }; used by Save and Test & Preview
|
|
285
|
-
const toSavedCtas = (ctaData = []) => (ctaData || [])
|
|
286
|
-
.filter((cta) => cta?.isSaved)
|
|
287
|
-
.map((cta) => {
|
|
288
|
-
let actionLink = cta?.url;
|
|
289
|
-
|
|
290
|
-
// Append deep link params ("key=value") to the URL
|
|
291
|
-
if (cta?.urlType === DEEP_LINK && cta?.deepLinkKeys?.length > 0) {
|
|
292
|
-
actionLink = appendDeepLinkParams(actionLink, cta?.deepLinkKeys);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return {
|
|
296
|
-
actionText: cta?.text,
|
|
297
|
-
type: cta?.urlType || DEEP_LINK,
|
|
298
|
-
actionLink,
|
|
299
|
-
};
|
|
300
|
-
});
|
|
301
|
-
|
|
302
279
|
// Helper function to create content data object
|
|
303
|
-
const createContentData =(contentType, mediaInfo, buttons, deepLink, processCarouselDataForDeepLinks) => {
|
|
280
|
+
const createContentData = (contentType, mediaInfo, buttons, deepLink, processCarouselDataForDeepLinks) => {
|
|
304
281
|
const {
|
|
305
282
|
mediaType,
|
|
306
283
|
imageSrc,
|
|
@@ -526,9 +503,6 @@ export const MobilePushNew = ({
|
|
|
526
503
|
supportedTags = [],
|
|
527
504
|
globalActions: globalActionsProps,
|
|
528
505
|
handleClose,
|
|
529
|
-
// Edit mode: footer Test & Preview button lives in CreativesContainer
|
|
530
|
-
showTestAndPreviewSlidebox: propsShowTestAndPreviewSlidebox,
|
|
531
|
-
handleCloseTestAndPreview: propsHandleCloseTestAndPreview,
|
|
532
506
|
fetchingLiquidValidation,
|
|
533
507
|
createTemplateError,
|
|
534
508
|
isGetFormData,
|
|
@@ -545,30 +519,11 @@ export const MobilePushNew = ({
|
|
|
545
519
|
const templateId = params?.id || templateData?._id || templateData?.id;
|
|
546
520
|
const isEditMode = !!templateId;
|
|
547
521
|
const computedCreativesMode = isEditMode || templateData?.type === MOBILEPUSH ? 'edit' : 'create';
|
|
548
|
-
|
|
549
|
-
const [sameContentChecked, setSameContent] = useState(false);
|
|
550
|
-
// Platforms dropdown: BOTH_PLATFORMS, ANDROID or IOS
|
|
551
|
-
const [platformSelection, setPlatformSelection] = useState(BOTH_PLATFORMS);
|
|
552
|
-
// Single platform waiting on the "Remove content" confirm
|
|
553
|
-
const [pendingPlatformSelection, setPendingPlatformSelection] = useState(null);
|
|
554
|
-
// Platform dropped by Both -> single; cleared after the switch, once sync is off
|
|
555
|
-
const [platformToClear, setPlatformToClear] = useState(null);
|
|
556
|
-
// Determine platform support from accountData
|
|
557
|
-
const isAndroidSupported = accountData?.configs?.android === '1';
|
|
558
|
-
const isIosSupported = accountData?.configs?.ios === '1';
|
|
559
|
-
// The Platforms dropdown only applies when the account supports both
|
|
560
|
-
const canChoosePlatforms = isAndroidSupported && isIosSupported;
|
|
561
|
-
// ANDROID or IOS when one platform is chosen, else null
|
|
562
|
-
const singlePlatform = canChoosePlatforms && platformSelection !== BOTH_PLATFORMS ? platformSelection : null;
|
|
563
|
-
const showAndroid = isAndroidSupported && singlePlatform !== IOS;
|
|
564
|
-
const showIos = isIosSupported && singlePlatform !== ANDROID;
|
|
565
|
-
const sameContent = sameContentChecked && !singlePlatform;
|
|
522
|
+
const [sameContent, setSameContent] = useState(false);
|
|
566
523
|
const [templateName, setTemplateName] = useState("");
|
|
567
524
|
const [spin, setSpin] = useState(false);
|
|
568
525
|
const [activeTab, setActiveTab] = useState(ANDROID);
|
|
569
526
|
const [templateNameError, setTemplateNameError] = useState(false);
|
|
570
|
-
// "Same content" tick waiting on the Replace confirm
|
|
571
|
-
const [isReplaceConfirmOpen, setIsReplaceConfirmOpen] = useState(false);
|
|
572
527
|
// Replace ctaData with platform-specific state
|
|
573
528
|
const [ctaDataAndroid, setCtaDataAndroid] = useState([]);
|
|
574
529
|
const [ctaDataIos, setCtaDataIos] = useState([]);
|
|
@@ -691,14 +646,58 @@ export const MobilePushNew = ({
|
|
|
691
646
|
const [iosDeepLinkError, setIosDeepLinkError] = useState("");
|
|
692
647
|
const [androidDeepLinkKeysError, setAndroidDeepLinkKeysError] = useState("");
|
|
693
648
|
const [iosDeepLinkKeysError, setIosDeepLinkKeysError] = useState("");
|
|
649
|
+
const [carouselLinkErrors, setCarouselLinkErrors] = useState({});
|
|
694
650
|
|
|
695
651
|
// Ref for create timeout fallback
|
|
696
652
|
const createTimeoutRef = useRef(null);
|
|
697
653
|
|
|
698
654
|
// Function to validate carousel data completeness
|
|
699
|
-
const validateCarouselData = useCallback((carouselData = []) =>
|
|
700
|
-
carouselData?.length
|
|
701
|
-
|
|
655
|
+
const validateCarouselData = useCallback((carouselData = []) => {
|
|
656
|
+
if (!carouselData || carouselData?.length === 0) {
|
|
657
|
+
return false;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
return carouselData.every((card) => {
|
|
661
|
+
// Check if image is uploaded (currently only image media type is supported)
|
|
662
|
+
if (card.mediaType === IMAGE.toLowerCase() && !card.imageUrl) {
|
|
663
|
+
return false;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// Check if buttons have proper link data when actionOnClick is true
|
|
667
|
+
if (card?.buttons?.length > 0) {
|
|
668
|
+
return card?.buttons?.every((button) => {
|
|
669
|
+
if (button.actionOnClick) {
|
|
670
|
+
// Check if link is provided based on link type
|
|
671
|
+
if (button.linkType === DEEP_LINK && !button.deepLinkValue) {
|
|
672
|
+
return false;
|
|
673
|
+
}
|
|
674
|
+
if (button.linkType === DEEP_LINK && button.deepLinkValue) {
|
|
675
|
+
// Check if the selected deep link has keys, and if so, require them
|
|
676
|
+
const selectedDeepLink = deepLink?.find((link) => link?.value === button.deepLinkValue);
|
|
677
|
+
const deepLinkKeysFromSelection = selectedDeepLink?.keys;
|
|
678
|
+
let deepLinkKeysFromSelectionArray = [];
|
|
679
|
+
if (Array.isArray(deepLinkKeysFromSelection)) {
|
|
680
|
+
deepLinkKeysFromSelectionArray = deepLinkKeysFromSelection;
|
|
681
|
+
} else if (deepLinkKeysFromSelection) {
|
|
682
|
+
deepLinkKeysFromSelectionArray = [deepLinkKeysFromSelection];
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// Only require deep link keys if the selected deep link has keys defined
|
|
686
|
+
if (deepLinkKeysFromSelectionArray?.length > 0 && (!Array.isArray(button?.deepLinkKeys) || button?.deepLinkKeys?.length === 0)) {
|
|
687
|
+
return false;
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
if (button.linkType === EXTERNAL_LINK && !button.externalLinkValue) {
|
|
691
|
+
return false;
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
return true;
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
return true;
|
|
699
|
+
});
|
|
700
|
+
}, [deepLink]);
|
|
702
701
|
|
|
703
702
|
// Function to check if carousel data is valid for both platforms
|
|
704
703
|
const isCarouselDataValid = useCallback(() => {
|
|
@@ -754,9 +753,6 @@ export const MobilePushNew = ({
|
|
|
754
753
|
setPrimaryButtonIos(false);
|
|
755
754
|
setSecondaryButtonIos(false);
|
|
756
755
|
setSameContent(false);
|
|
757
|
-
setPlatformSelection(BOTH_PLATFORMS);
|
|
758
|
-
setPendingPlatformSelection(null);
|
|
759
|
-
setPlatformToClear(null);
|
|
760
756
|
setTemplateNameError(false);
|
|
761
757
|
setAndroidTitleError("");
|
|
762
758
|
setAndroidMessageError("");
|
|
@@ -766,6 +762,7 @@ export const MobilePushNew = ({
|
|
|
766
762
|
setIosExternalLinkError("");
|
|
767
763
|
setAndroidDeepLinkError("");
|
|
768
764
|
setIosDeepLinkError("");
|
|
765
|
+
setCarouselLinkErrors({});
|
|
769
766
|
resetUploadStates();
|
|
770
767
|
}, [resetUploadStates]);
|
|
771
768
|
|
|
@@ -811,7 +808,7 @@ export const MobilePushNew = ({
|
|
|
811
808
|
(value) => {
|
|
812
809
|
let errorTemplateDescMessage = "";
|
|
813
810
|
|
|
814
|
-
const { isBraceError
|
|
811
|
+
const { isBraceError } = validateTags({
|
|
815
812
|
content: value,
|
|
816
813
|
tagsParam: tags,
|
|
817
814
|
location,
|
|
@@ -828,9 +825,6 @@ export const MobilePushNew = ({
|
|
|
828
825
|
globalMessages.unbalanacedCurlyBraces
|
|
829
826
|
);
|
|
830
827
|
}
|
|
831
|
-
if (isDefaultQuoteError) {
|
|
832
|
-
errorTemplateDescMessage = formatMessage(globalMessages.unquotedTagDefaultValue);
|
|
833
|
-
}
|
|
834
828
|
return errorTemplateDescMessage;
|
|
835
829
|
},
|
|
836
830
|
[tags, injectedTags, location, getDefaultTags, formatMessage]
|
|
@@ -972,8 +966,6 @@ export const MobilePushNew = ({
|
|
|
972
966
|
templateNameRef.current = name;
|
|
973
967
|
});
|
|
974
968
|
|
|
975
|
-
stateUpdates.push(() => setPlatformSelection(getSavedPlatformSelection(editContent)));
|
|
976
|
-
|
|
977
969
|
// Process Android content
|
|
978
970
|
const androidContentType = editContent?.ANDROID;
|
|
979
971
|
if (!isEmpty(androidContentType)) {
|
|
@@ -1109,8 +1101,6 @@ export const MobilePushNew = ({
|
|
|
1109
1101
|
templateNameRef.current = name;
|
|
1110
1102
|
});
|
|
1111
1103
|
|
|
1112
|
-
stateUpdates.push(() => setPlatformSelection(getSavedPlatformSelection(templateContent)));
|
|
1113
|
-
|
|
1114
1104
|
// Process Android content
|
|
1115
1105
|
const androidContentType = templateContent?.ANDROID;
|
|
1116
1106
|
if (!isEmpty(androidContentType)) {
|
|
@@ -1746,6 +1736,10 @@ export const MobilePushNew = ({
|
|
|
1746
1736
|
setSpin(false);
|
|
1747
1737
|
}, [templateData, isFullMode, deepLink, setUpdateMpushImageSrc, setUpdateMpushVideoSrc]);
|
|
1748
1738
|
|
|
1739
|
+
// Determine platform support from accountData
|
|
1740
|
+
const isAndroidSupported = accountData?.configs?.android === '1';
|
|
1741
|
+
const isIosSupported = accountData?.configs?.ios === '1';
|
|
1742
|
+
|
|
1749
1743
|
// Notify parent when personalization tokens are added/removed (for anonymous user flow)
|
|
1750
1744
|
useEffect(() => {
|
|
1751
1745
|
if (!restrictPersonalization || typeof onPersonalizationTokensChange !== 'function') return;
|
|
@@ -1754,8 +1748,8 @@ export const MobilePushNew = ({
|
|
|
1754
1748
|
|| (value.includes('[') && value.includes(']'))
|
|
1755
1749
|
);
|
|
1756
1750
|
const hasTokens = (
|
|
1757
|
-
(
|
|
1758
|
-
|| (
|
|
1751
|
+
(isAndroidSupported && (hasToken(androidContent?.title) || hasToken(androidContent?.message)))
|
|
1752
|
+
|| (isIosSupported && (hasToken(iosContent?.title) || hasToken(iosContent?.message)))
|
|
1759
1753
|
);
|
|
1760
1754
|
onPersonalizationTokensChange(hasTokens);
|
|
1761
1755
|
}, [
|
|
@@ -1764,21 +1758,18 @@ export const MobilePushNew = ({
|
|
|
1764
1758
|
androidContent?.message,
|
|
1765
1759
|
iosContent?.title,
|
|
1766
1760
|
iosContent?.message,
|
|
1767
|
-
|
|
1768
|
-
|
|
1761
|
+
isAndroidSupported,
|
|
1762
|
+
isIosSupported,
|
|
1769
1763
|
onPersonalizationTokensChange,
|
|
1770
1764
|
]);
|
|
1771
1765
|
|
|
1772
|
-
// Validation logic for template creation/update
|
|
1773
|
-
const isAndroidFieldsMissing = isPlatformFieldsMissing(
|
|
1774
|
-
const isIosFieldsMissing = isPlatformFieldsMissing(
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
(showAndroid || showIos)
|
|
1780
|
-
&& (!showAndroid || isAndroidFieldsMissing)
|
|
1781
|
-
&& (!showIos || isIosFieldsMissing)
|
|
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)
|
|
1782
1773
|
);
|
|
1783
1774
|
|
|
1784
1775
|
// Ref to dedupe reporting of content emptiness to the parent, so we only
|
|
@@ -1802,7 +1793,8 @@ export const MobilePushNew = ({
|
|
|
1802
1793
|
handleMessageChange,
|
|
1803
1794
|
handleTagSelect,
|
|
1804
1795
|
handleMediaTypeChange,
|
|
1805
|
-
|
|
1796
|
+
handleActionOnClickChange,
|
|
1797
|
+
handleLinkTypeChange,
|
|
1806
1798
|
} = usePlatformSync({
|
|
1807
1799
|
setAndroidContent,
|
|
1808
1800
|
setIosContent,
|
|
@@ -1874,21 +1866,9 @@ export const MobilePushNew = ({
|
|
|
1874
1866
|
}
|
|
1875
1867
|
}, [sameContent]);
|
|
1876
1868
|
|
|
1877
|
-
// Notification tap link Save / edit (both tabs when synced)
|
|
1878
|
-
const handleTapLinkSavedChange = useCallback((platform, tapLinkSaved) => {
|
|
1879
|
-
const update = (prev) => ({ ...prev, tapLinkSaved });
|
|
1880
|
-
if (platform === ANDROID || sameContent) setAndroidContent(update);
|
|
1881
|
-
if (platform === IOS || sameContent) setIosContent(update);
|
|
1882
|
-
}, [sameContent]);
|
|
1883
|
-
|
|
1884
|
-
// Notification tap URL: required once External link is chosen; same message as the button form
|
|
1885
|
-
const getTapUrlError = useCallback((url) => (
|
|
1886
|
-
!url?.trim() || validateExternalLink(url, formatMessage, messages) ? formatMessage(messages.urlNotValid) : ""
|
|
1887
|
-
), [formatMessage]);
|
|
1888
|
-
|
|
1889
1869
|
const handleExternalLinkChange = useCallback((platform, externalLinkValue) => {
|
|
1890
1870
|
// Validate URL
|
|
1891
|
-
const urlError =
|
|
1871
|
+
const urlError = validateExternalLink(externalLinkValue, formatMessage, messages);
|
|
1892
1872
|
|
|
1893
1873
|
const updateContent = {
|
|
1894
1874
|
externalLinkValue,
|
|
@@ -1915,9 +1895,16 @@ export const MobilePushNew = ({
|
|
|
1915
1895
|
setAndroidExternalLinkError(urlError || "");
|
|
1916
1896
|
}
|
|
1917
1897
|
}
|
|
1918
|
-
}, [
|
|
1898
|
+
}, [validateExternalLink, sameContent]);
|
|
1919
1899
|
|
|
1920
1900
|
// Carousel data handler for platform-specific carousel management
|
|
1901
|
+
const updateCarouselLinkError = useCallback((cardIndex, field, error) => {
|
|
1902
|
+
setCarouselLinkErrors((prev) => ({
|
|
1903
|
+
...prev,
|
|
1904
|
+
[`${cardIndex}-${field}`]: error,
|
|
1905
|
+
}));
|
|
1906
|
+
}, []);
|
|
1907
|
+
|
|
1921
1908
|
const handleCarouselDataChange = useCallback((platform, carouselData) => {
|
|
1922
1909
|
if (platform === ANDROID) {
|
|
1923
1910
|
setAndroidContent((prev) => {
|
|
@@ -2055,20 +2042,11 @@ export const MobilePushNew = ({
|
|
|
2055
2042
|
handleTitleChange,
|
|
2056
2043
|
handleMessageChange,
|
|
2057
2044
|
handleMediaTypeChange,
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
// The old link field is gone, so are its errors (on both tabs when synced)
|
|
2061
|
-
[platform, ...(sameContent ? [getOtherPlatform(platform)] : [])].forEach((target) => {
|
|
2062
|
-
const isAndroidTarget = target === ANDROID;
|
|
2063
|
-
(isAndroidTarget ? setAndroidExternalLinkError : setIosExternalLinkError)("");
|
|
2064
|
-
(isAndroidTarget ? setAndroidDeepLinkError : setIosDeepLinkError)("");
|
|
2065
|
-
(isAndroidTarget ? setAndroidDeepLinkKeysError : setIosDeepLinkKeysError)("");
|
|
2066
|
-
});
|
|
2067
|
-
},
|
|
2045
|
+
handleActionOnClickChange,
|
|
2046
|
+
handleLinkTypeChange,
|
|
2068
2047
|
handleDeepLinkChange: (value) => handleDeepLinkChange(platform, value),
|
|
2069
2048
|
handleDeepLinkKeysChange: (value) => handleDeepLinkKeysChange(platform, value),
|
|
2070
2049
|
handleExternalLinkChange: (value) => handleExternalLinkChange(platform, value),
|
|
2071
|
-
handleTapLinkSavedChange: (isSaved) => handleTapLinkSavedChange(platform, isSaved),
|
|
2072
2050
|
onTagSelect,
|
|
2073
2051
|
handleOnTagsContextChange,
|
|
2074
2052
|
};
|
|
@@ -2133,6 +2111,9 @@ export const MobilePushNew = ({
|
|
|
2133
2111
|
mobilePushActions,
|
|
2134
2112
|
carouselActiveTabIndex,
|
|
2135
2113
|
setCarouselActiveTabIndex,
|
|
2114
|
+
carouselLinkErrors,
|
|
2115
|
+
updateCarouselLinkError,
|
|
2116
|
+
linkProps: { deepLink },
|
|
2136
2117
|
videoPreviewKey: videoState?.videoPreviewKey,
|
|
2137
2118
|
};
|
|
2138
2119
|
|
|
@@ -2185,7 +2166,7 @@ export const MobilePushNew = ({
|
|
|
2185
2166
|
restrictPersonalization={restrictPersonalization}
|
|
2186
2167
|
/>
|
|
2187
2168
|
);
|
|
2188
|
-
}, [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, handleTitleChange, handleMessageChange, handleMediaTypeChange,
|
|
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]
|
|
2189
2170
|
);
|
|
2190
2171
|
|
|
2191
2172
|
// PANES: Only render enabled platforms
|
|
@@ -2195,8 +2176,8 @@ export const MobilePushNew = ({
|
|
|
2195
2176
|
panes.push({
|
|
2196
2177
|
key: ANDROID,
|
|
2197
2178
|
tab: (
|
|
2198
|
-
<CapRow
|
|
2199
|
-
<CapIcon type="android"
|
|
2179
|
+
<CapRow useLegacy>
|
|
2180
|
+
<CapIcon type="android" />
|
|
2200
2181
|
{formatMessage(messages.android)}
|
|
2201
2182
|
</CapRow>
|
|
2202
2183
|
),
|
|
@@ -2207,8 +2188,8 @@ export const MobilePushNew = ({
|
|
|
2207
2188
|
panes.push({
|
|
2208
2189
|
key: IOS,
|
|
2209
2190
|
tab: (
|
|
2210
|
-
<CapRow
|
|
2211
|
-
<CapIcon type="ios"
|
|
2191
|
+
<CapRow useLegacy>
|
|
2192
|
+
<CapIcon type="ios" />
|
|
2212
2193
|
{formatMessage(messages.ios)}
|
|
2213
2194
|
</CapRow>
|
|
2214
2195
|
),
|
|
@@ -2221,37 +2202,25 @@ export const MobilePushNew = ({
|
|
|
2221
2202
|
const errorInTitle = activeTab === ANDROID ? androidTitleError : iosTitleError;
|
|
2222
2203
|
const errorInMessage = activeTab === ANDROID ? androidMessageError : iosMessageError;
|
|
2223
2204
|
|
|
2224
|
-
//
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
templateNameError
|
|
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
|
|
2210
|
+
|| Object.values(carouselLinkErrors).some((error) => error !== null && error !== "")
|
|
2231
2211
|
|| !isCarouselDataValid()
|
|
2232
|
-
|| hasUnsavedTapLink
|
|
2233
2212
|
|| errorInTitle || errorInMessage
|
|
2234
2213
|
);
|
|
2235
|
-
// Save needs every shown platform filled
|
|
2236
|
-
const isSaveDisabled = isMobilePushContentMissing || hasFormErrors;
|
|
2237
|
-
const isTestAndPreviewDisabled = isAllContentMissing || hasFormErrors;
|
|
2238
2214
|
|
|
2239
|
-
// Validation in handleSave:
|
|
2215
|
+
// Validation in handleSave: only enforce content on enabled platforms, and
|
|
2216
|
+
// allow saving with just one supported platform filled in.
|
|
2240
2217
|
const handleSave = useCallback(() => {
|
|
2241
2218
|
if (isMobilePushContentMissing) {
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
missingPlatforms.forEach(([platform, , content]) => {
|
|
2247
|
-
const isAndroid = platform === ANDROID;
|
|
2248
|
-
(isAndroid ? setAndroidTitleError : setIosTitleError)(validateTitle(content?.title));
|
|
2249
|
-
(isAndroid ? setAndroidMessageError : setIosMessageError)(validateMessage(content?.message));
|
|
2219
|
+
CapNotification.error({
|
|
2220
|
+
message: formatMessage(
|
|
2221
|
+
isAndroidSupported ? messages.androidValidationError : messages.iosValidationError,
|
|
2222
|
+
),
|
|
2250
2223
|
});
|
|
2251
|
-
// Open a tab that has the errors, unless the open one already does
|
|
2252
|
-
if (!missingPlatforms.some(([platform]) => platform === activeTab)) {
|
|
2253
|
-
setActiveTab(missingPlatforms[0][0]);
|
|
2254
|
-
}
|
|
2255
2224
|
if (onValidationFail) onValidationFail();
|
|
2256
2225
|
return;
|
|
2257
2226
|
}
|
|
@@ -2275,38 +2244,32 @@ export const MobilePushNew = ({
|
|
|
2275
2244
|
// Use ref to get the latest template name value to avoid closure issues
|
|
2276
2245
|
let finalTemplateName = templateNameRef.current || templateName;
|
|
2277
2246
|
if (!isFullMode && (!finalTemplateName || !finalTemplateName.trim())) {
|
|
2278
|
-
if (
|
|
2247
|
+
if (androidContent?.title && androidContent.title.trim()) {
|
|
2279
2248
|
finalTemplateName = androidContent.title.trim();
|
|
2280
|
-
} else if (
|
|
2249
|
+
} else if (iosContent?.title && iosContent.title.trim()) {
|
|
2281
2250
|
finalTemplateName = iosContent.title.trim();
|
|
2282
2251
|
} else {
|
|
2283
2252
|
finalTemplateName = '';
|
|
2284
2253
|
}
|
|
2285
2254
|
}
|
|
2286
2255
|
|
|
2287
|
-
// Validate
|
|
2288
|
-
const
|
|
2289
|
-
const
|
|
2290
|
-
const iosUrlError = showIos && isTapExternalLink(iosContent) && getTapUrlError(iosContent.externalLinkValue);
|
|
2256
|
+
// Validate external links
|
|
2257
|
+
const androidUrlError = validateExternalLink(androidContent.externalLinkValue, formatMessage, messages);
|
|
2258
|
+
const iosUrlError = validateExternalLink(iosContent.externalLinkValue, formatMessage, messages);
|
|
2291
2259
|
|
|
2292
2260
|
setAndroidExternalLinkError(androidUrlError || "");
|
|
2293
2261
|
setIosExternalLinkError(iosUrlError || "");
|
|
2294
2262
|
|
|
2295
|
-
// Validate deep links
|
|
2296
|
-
const
|
|
2297
|
-
|
|
2298
|
-
? formatMessage(messages.deepLinkRequired)
|
|
2299
|
-
: validateDeepLink(content?.deepLinkValue, formatMessage, messages)
|
|
2300
|
-
);
|
|
2301
|
-
const androidDeepLinkUrlError = showAndroid && getTapDeepLinkError(androidContent);
|
|
2302
|
-
const iosDeepLinkUrlError = showIos && getTapDeepLinkError(iosContent);
|
|
2263
|
+
// Validate deep links
|
|
2264
|
+
const androidDeepLinkUrlError = validateDeepLink(androidContent.deepLinkValue, formatMessage, messages);
|
|
2265
|
+
const iosDeepLinkUrlError = validateDeepLink(iosContent.deepLinkValue, formatMessage, messages);
|
|
2303
2266
|
|
|
2304
2267
|
setAndroidDeepLinkError(androidDeepLinkUrlError || "");
|
|
2305
2268
|
setIosDeepLinkError(iosDeepLinkUrlError || "");
|
|
2306
2269
|
|
|
2307
2270
|
// Validate deep link keys - only require keys if the selected deep link has keys defined
|
|
2308
2271
|
const androidDeepLinkKeysErrorMsg = (() => {
|
|
2309
|
-
if (
|
|
2272
|
+
if (androidContent?.linkType === DEEP_LINK && androidContent?.deepLinkValue) {
|
|
2310
2273
|
// Use the same matching logic as deep link value extraction
|
|
2311
2274
|
let selectedDeepLink = null;
|
|
2312
2275
|
|
|
@@ -2321,8 +2284,8 @@ export const MobilePushNew = ({
|
|
|
2321
2284
|
|
|
2322
2285
|
const hasKeysDefined = selectedDeepLink?.keys?.length > 0;
|
|
2323
2286
|
|
|
2324
|
-
//
|
|
2325
|
-
if (hasKeysDefined && !
|
|
2287
|
+
// Only require keys if the selected deep link has keys defined
|
|
2288
|
+
if (hasKeysDefined && (!Array.isArray(androidContent?.deepLinkKeysValue) || androidContent?.deepLinkKeysValue?.length === 0)) {
|
|
2326
2289
|
return formatMessage(messages.deepLinkKeysRequired);
|
|
2327
2290
|
}
|
|
2328
2291
|
}
|
|
@@ -2330,7 +2293,7 @@ export const MobilePushNew = ({
|
|
|
2330
2293
|
})();
|
|
2331
2294
|
|
|
2332
2295
|
const iosDeepLinkKeysErrorMsg = (() => {
|
|
2333
|
-
if (
|
|
2296
|
+
if (iosContent?.linkType === DEEP_LINK && iosContent?.deepLinkValue) {
|
|
2334
2297
|
// Use the same matching logic as deep link value extraction
|
|
2335
2298
|
let selectedDeepLink = null;
|
|
2336
2299
|
|
|
@@ -2345,8 +2308,8 @@ export const MobilePushNew = ({
|
|
|
2345
2308
|
|
|
2346
2309
|
const hasKeysDefined = selectedDeepLink?.keys?.length > 0;
|
|
2347
2310
|
|
|
2348
|
-
//
|
|
2349
|
-
if (hasKeysDefined && !
|
|
2311
|
+
// Only require keys if the selected deep link has keys defined
|
|
2312
|
+
if (hasKeysDefined && (!Array.isArray(iosContent?.deepLinkKeysValue) || iosContent?.deepLinkKeysValue?.length === 0)) {
|
|
2350
2313
|
return formatMessage(messages.deepLinkKeysRequired);
|
|
2351
2314
|
}
|
|
2352
2315
|
}
|
|
@@ -2356,16 +2319,10 @@ export const MobilePushNew = ({
|
|
|
2356
2319
|
setAndroidDeepLinkKeysError(androidDeepLinkKeysErrorMsg || "");
|
|
2357
2320
|
setIosDeepLinkKeysError(iosDeepLinkKeysErrorMsg || "");
|
|
2358
2321
|
|
|
2359
|
-
//
|
|
2360
|
-
|
|
2361
|
-
CapNotification.error({ message: formatMessage(messages.saveTapLinkFirst) });
|
|
2362
|
-
if (onValidationFail) {
|
|
2363
|
-
onValidationFail();
|
|
2364
|
-
}
|
|
2365
|
-
return;
|
|
2366
|
-
}
|
|
2322
|
+
// Check for carousel link errors
|
|
2323
|
+
const hasCarouselErrors = Object.values(carouselLinkErrors).some((error) => error !== null && error !== "");
|
|
2367
2324
|
|
|
2368
|
-
if (androidUrlError || iosUrlError || androidDeepLinkUrlError || iosDeepLinkUrlError || androidDeepLinkKeysErrorMsg || iosDeepLinkKeysErrorMsg) {
|
|
2325
|
+
if (androidUrlError || iosUrlError || androidDeepLinkUrlError || iosDeepLinkUrlError || androidDeepLinkKeysErrorMsg || iosDeepLinkKeysErrorMsg || hasCarouselErrors) {
|
|
2369
2326
|
CapNotification.error({
|
|
2370
2327
|
message: formatMessage(messages.invalidUrl),
|
|
2371
2328
|
});
|
|
@@ -2381,34 +2338,74 @@ export const MobilePushNew = ({
|
|
|
2381
2338
|
const processedIosContent = { ...iosContent };
|
|
2382
2339
|
|
|
2383
2340
|
// Process button CTA data if it exists
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
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
|
+
}
|
|
2390
2368
|
}
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
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
|
+
}
|
|
2397
2396
|
}
|
|
2398
2397
|
|
|
2399
2398
|
// Create payload with enabled platform content and intl
|
|
2400
2399
|
const payload = createMobilePushPayloadWithIntl({
|
|
2401
2400
|
templateName: finalTemplateName,
|
|
2402
|
-
androidContent:
|
|
2403
|
-
iosContent:
|
|
2401
|
+
androidContent: isAndroidSupported ? processedAndroidContent : undefined,
|
|
2402
|
+
iosContent: isIosSupported ? processedIosContent : undefined,
|
|
2404
2403
|
imageSrc,
|
|
2405
2404
|
mpushVideoSrcAndPreview,
|
|
2406
2405
|
accountData,
|
|
2407
2406
|
sameContent,
|
|
2408
2407
|
options: {
|
|
2409
2408
|
mode: params?.mode,
|
|
2410
|
-
// One platform chosen: leave the other platform's key out of versions.base
|
|
2411
|
-
skipPlatform: singlePlatform ? getOtherPlatform(singlePlatform) : undefined,
|
|
2412
2409
|
},
|
|
2413
2410
|
intl,
|
|
2414
2411
|
});
|
|
@@ -2599,7 +2596,7 @@ export const MobilePushNew = ({
|
|
|
2599
2596
|
globalActionsProps,
|
|
2600
2597
|
onValidationFail,
|
|
2601
2598
|
resetFormData,
|
|
2602
|
-
|
|
2599
|
+
validateExternalLink,
|
|
2603
2600
|
ctaDataAndroid,
|
|
2604
2601
|
ctaDataIos,
|
|
2605
2602
|
intl,
|
|
@@ -2607,17 +2604,8 @@ export const MobilePushNew = ({
|
|
|
2607
2604
|
createTimeoutRef,
|
|
2608
2605
|
isAndroidSupported,
|
|
2609
2606
|
isIosSupported,
|
|
2610
|
-
showAndroid,
|
|
2611
|
-
showIos,
|
|
2612
|
-
singlePlatform,
|
|
2613
|
-
activeTab,
|
|
2614
|
-
validateTitle,
|
|
2615
|
-
validateMessage,
|
|
2616
2607
|
isMobilePushContentMissing,
|
|
2617
|
-
isAndroidFieldsMissing,
|
|
2618
|
-
isIosFieldsMissing,
|
|
2619
2608
|
isCarouselDataValid,
|
|
2620
|
-
hasUnsavedTapLink,
|
|
2621
2609
|
isFullMode,
|
|
2622
2610
|
templateId,
|
|
2623
2611
|
savedTemplateId,
|
|
@@ -2712,30 +2700,38 @@ export const MobilePushNew = ({
|
|
|
2712
2700
|
getLiquidTags: globalActionsProps.getLiquidTags,
|
|
2713
2701
|
formatMessage,
|
|
2714
2702
|
messages: formBuilderMessages,
|
|
2715
|
-
|
|
2716
|
-
singleTab: singlePlatform || getSingleTab(accountData),
|
|
2703
|
+
singleTab: getSingleTab(accountData),
|
|
2717
2704
|
});
|
|
2718
2705
|
}, [
|
|
2719
2706
|
androidContent,
|
|
2720
2707
|
iosContent,
|
|
2721
2708
|
activeTab,
|
|
2722
|
-
singlePlatform,
|
|
2723
2709
|
globalActionsProps,
|
|
2724
2710
|
formatMessage,
|
|
2725
2711
|
accountData,
|
|
2726
2712
|
isFullMode,
|
|
2727
2713
|
]);
|
|
2728
2714
|
|
|
2729
|
-
// Each platform's preview buttons follow its own ctaData, so iOS shows before its tab is opened
|
|
2730
|
-
const toPreviewButtons = (ctas) => (Array.isArray(ctas) ? ctas.map((data) => ({ label: data?.text || '' })) : []);
|
|
2731
|
-
|
|
2732
2715
|
useEffect(() => {
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
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]);
|
|
2739
2735
|
|
|
2740
2736
|
// Sync button data and state from active tab to other platform when sameContent is enabled
|
|
2741
2737
|
useEffect(() => {
|
|
@@ -2761,141 +2757,12 @@ export const MobilePushNew = ({
|
|
|
2761
2757
|
}
|
|
2762
2758
|
}, [sameContent, activeTab]);
|
|
2763
2759
|
|
|
2764
|
-
// What ticking "Same content" would copy over: text, media, links and buttons
|
|
2765
|
-
const getPlatformSnapshot = (platform) => {
|
|
2766
|
-
const isAndroid = platform === ANDROID;
|
|
2767
|
-
const content = isAndroid ? androidContent : iosContent;
|
|
2768
|
-
return JSON.stringify({
|
|
2769
|
-
title: content?.title || '',
|
|
2770
|
-
message: content?.message || '',
|
|
2771
|
-
mediaType: content?.mediaType || NONE,
|
|
2772
|
-
carouselData: content?.carouselData || [],
|
|
2773
|
-
actionOnClick: !!content?.actionOnClick,
|
|
2774
|
-
linkType: content?.linkType || '',
|
|
2775
|
-
deepLinkValue: content?.deepLinkValue || '',
|
|
2776
|
-
externalLinkValue: content?.externalLinkValue || '',
|
|
2777
|
-
image: (isAndroid ? imageSrc?.androidImageSrc : imageSrc?.iosImageSrc) || '',
|
|
2778
|
-
video: (isAndroid ? videoState?.androidVideoSrc : videoState?.iosVideoSrc) || '',
|
|
2779
|
-
buttons: toSavedCtas(isAndroid ? ctaDataAndroid : ctaDataIos),
|
|
2780
|
-
});
|
|
2781
|
-
};
|
|
2782
|
-
|
|
2783
2760
|
const handleSameContentChange = useCallback((e) => {
|
|
2784
2761
|
const isCurrentPlatformAndroid = activeTab === ANDROID;
|
|
2785
|
-
const otherContent = isCurrentPlatformAndroid ? iosContent : androidContent;
|
|
2786
|
-
// Ticking replaces the other tab: confirm when it has different content, not when it is empty
|
|
2787
|
-
if (e.target.checked && hasPlatformContent(otherContent) && getPlatformSnapshot(ANDROID) !== getPlatformSnapshot(IOS)) {
|
|
2788
|
-
setIsReplaceConfirmOpen(true);
|
|
2789
|
-
return;
|
|
2790
|
-
}
|
|
2791
2762
|
syncPlatformContent(isCurrentPlatformAndroid ? androidContent : iosContent, isCurrentPlatformAndroid ? ANDROID : IOS);
|
|
2792
2763
|
setSameContent(e.target.checked);
|
|
2793
|
-
}, [activeTab, androidContent, iosContent, imageSrc, videoState, ctaDataAndroid, ctaDataIos]);
|
|
2794
|
-
|
|
2795
|
-
const confirmSameContent = useCallback(() => {
|
|
2796
|
-
setIsReplaceConfirmOpen(false);
|
|
2797
|
-
syncPlatformContent(activeTab === ANDROID ? androidContent : iosContent, activeTab);
|
|
2798
|
-
setSameContent(true);
|
|
2799
2764
|
}, [activeTab, androidContent, iosContent]);
|
|
2800
2765
|
|
|
2801
|
-
// One platform chosen: its form is the only one shown, and the upload/button handlers follow activeTab
|
|
2802
|
-
useEffect(() => {
|
|
2803
|
-
if (singlePlatform && activeTab !== singlePlatform) {
|
|
2804
|
-
setActiveTab(singlePlatform);
|
|
2805
|
-
}
|
|
2806
|
-
}, [singlePlatform, activeTab]);
|
|
2807
|
-
|
|
2808
|
-
// Both -> single: empty the dropped platform. Runs after the switch so sync is off
|
|
2809
|
-
// and the kept platform's media stays.
|
|
2810
|
-
useEffect(() => {
|
|
2811
|
-
if (!platformToClear) return;
|
|
2812
|
-
const isAndroid = platformToClear === ANDROID;
|
|
2813
|
-
const platformIndex = isAndroid ? 0 : 1;
|
|
2814
|
-
clearImageDataByMediaType(IMAGE, platformToClear);
|
|
2815
|
-
clearImageDataByMediaType(VIDEO, platformToClear);
|
|
2816
|
-
// Uploaded-video list read by the upload box
|
|
2817
|
-
setUpdateMpushVideoSrc(platformIndex, {}, true);
|
|
2818
|
-
(isAndroid ? setAndroidContent : setIosContent)(INITIAL_CONTENT);
|
|
2819
|
-
(isAndroid ? setCtaDataAndroid : setCtaDataIos)([]);
|
|
2820
|
-
(isAndroid ? setPrimaryButtonAndroid : setPrimaryButtonIos)(false);
|
|
2821
|
-
(isAndroid ? setSecondaryButtonAndroid : setSecondaryButtonIos)(false);
|
|
2822
|
-
(isAndroid ? setAndroidTitleError : setIosTitleError)("");
|
|
2823
|
-
(isAndroid ? setAndroidMessageError : setIosMessageError)("");
|
|
2824
|
-
(isAndroid ? setAndroidExternalLinkError : setIosExternalLinkError)("");
|
|
2825
|
-
(isAndroid ? setAndroidDeepLinkError : setIosDeepLinkError)("");
|
|
2826
|
-
(isAndroid ? setAndroidDeepLinkKeysError : setIosDeepLinkKeysError)("");
|
|
2827
|
-
setPlatformToClear(null);
|
|
2828
|
-
}, [platformToClear, clearImageDataByMediaType, setUpdateMpushVideoSrc]);
|
|
2829
|
-
|
|
2830
|
-
// Android only <-> iOS only: give the empty target the current platform's content, buttons and media
|
|
2831
|
-
const copyPlatformContent = useCallback((source, target) => {
|
|
2832
|
-
const fromAndroid = source === ANDROID;
|
|
2833
|
-
const targetIndex = target === ANDROID ? 0 : 1;
|
|
2834
|
-
syncPlatformContent(fromAndroid ? androidContent : iosContent, source);
|
|
2835
|
-
(fromAndroid ? setCtaDataIos : setCtaDataAndroid)(cloneDeep(fromAndroid ? ctaDataAndroid : ctaDataIos));
|
|
2836
|
-
(fromAndroid ? setPrimaryButtonIos : setPrimaryButtonAndroid)(fromAndroid ? primaryButtonAndroid : primaryButtonIos);
|
|
2837
|
-
(fromAndroid ? setSecondaryButtonIos : setSecondaryButtonAndroid)(fromAndroid ? secondaryButtonAndroid : secondaryButtonIos);
|
|
2838
|
-
// Uploaded image/video live in the upload hook, per platform
|
|
2839
|
-
const sourceImage = fromAndroid ? imageSrc?.androidImageSrc : imageSrc?.iosImageSrc;
|
|
2840
|
-
if (sourceImage) {
|
|
2841
|
-
setUpdateMpushImageSrc(sourceImage, targetIndex, IMAGE);
|
|
2842
|
-
}
|
|
2843
|
-
const sourceVideo = fromAndroid ? videoState?.androidVideoSrc : videoState?.iosVideoSrc;
|
|
2844
|
-
if (sourceVideo) {
|
|
2845
|
-
setUpdateMpushVideoSrc(targetIndex, {
|
|
2846
|
-
...(fromAndroid ? androidAssetList : iosAssetList),
|
|
2847
|
-
videoSrc: sourceVideo,
|
|
2848
|
-
previewUrl: (fromAndroid ? videoState?.androidVideoPreview : videoState?.iosVideoPreview) || '',
|
|
2849
|
-
videoDuration: (fromAndroid ? videoState?.androidVideoDuration : videoState?.iosVideoDuration) || 0,
|
|
2850
|
-
}, true);
|
|
2851
|
-
}
|
|
2852
|
-
}, [androidContent, iosContent, ctaDataAndroid, ctaDataIos, primaryButtonAndroid, primaryButtonIos, secondaryButtonAndroid, secondaryButtonIos, imageSrc, videoState, androidAssetList, iosAssetList, setUpdateMpushImageSrc, setUpdateMpushVideoSrc]);
|
|
2853
|
-
|
|
2854
|
-
const handlePlatformChange = useCallback((value) => {
|
|
2855
|
-
if (value === platformSelection) return;
|
|
2856
|
-
const getPlatformContent = (platform) => (platform === ANDROID ? androidContent : iosContent);
|
|
2857
|
-
|
|
2858
|
-
if (platformSelection === BOTH_PLATFORMS) {
|
|
2859
|
-
// Both -> single: confirm before dropping a platform that has content
|
|
2860
|
-
if (hasPlatformContent(getPlatformContent(getOtherPlatform(value)))) {
|
|
2861
|
-
setPendingPlatformSelection(value);
|
|
2862
|
-
return;
|
|
2863
|
-
}
|
|
2864
|
-
setPlatformSelection(value);
|
|
2865
|
-
setPlatformToClear(getOtherPlatform(value));
|
|
2866
|
-
return;
|
|
2867
|
-
}
|
|
2868
|
-
|
|
2869
|
-
if (value === BOTH_PLATFORMS) {
|
|
2870
|
-
// Single -> Both: content stays in its tab; a ticked "Same content" syncs it to the other tab
|
|
2871
|
-
// (media and buttons follow through the existing on-tick effects)
|
|
2872
|
-
if (sameContentChecked) {
|
|
2873
|
-
syncPlatformContent(getPlatformContent(platformSelection), platformSelection);
|
|
2874
|
-
}
|
|
2875
|
-
setPlatformSelection(value);
|
|
2876
|
-
return;
|
|
2877
|
-
}
|
|
2878
|
-
|
|
2879
|
-
// Android only <-> iOS only: an empty target takes the current content
|
|
2880
|
-
if (!hasPlatformContent(getPlatformContent(value)) && hasPlatformContent(getPlatformContent(platformSelection))) {
|
|
2881
|
-
copyPlatformContent(platformSelection, value);
|
|
2882
|
-
}
|
|
2883
|
-
setPlatformSelection(value);
|
|
2884
|
-
}, [platformSelection, androidContent, iosContent, sameContentChecked, copyPlatformContent]);
|
|
2885
|
-
|
|
2886
|
-
const confirmPlatformRemoval = useCallback(() => {
|
|
2887
|
-
const value = pendingPlatformSelection;
|
|
2888
|
-
setPendingPlatformSelection(null);
|
|
2889
|
-
setPlatformSelection(value);
|
|
2890
|
-
setPlatformToClear(getOtherPlatform(value));
|
|
2891
|
-
}, [pendingPlatformSelection]);
|
|
2892
|
-
|
|
2893
|
-
const platformOptions = useMemo(() => [
|
|
2894
|
-
{ label: formatMessage(messages.androidAndIos), value: BOTH_PLATFORMS },
|
|
2895
|
-
{ label: formatMessage(messages.androidOnly), value: ANDROID },
|
|
2896
|
-
{ label: formatMessage(messages.iosOnly), value: IOS },
|
|
2897
|
-
], [formatMessage]);
|
|
2898
|
-
|
|
2899
2766
|
const getContentType = useCallback(
|
|
2900
2767
|
(content) => {
|
|
2901
2768
|
// Get image source from multiple possible locations
|
|
@@ -3018,34 +2885,23 @@ export const MobilePushNew = ({
|
|
|
3018
2885
|
const androidPreview = getContentType(androidContent);
|
|
3019
2886
|
const iosPreview = getContentType(iosContent);
|
|
3020
2887
|
|
|
3021
|
-
// Notification tap as Save sends it (same builder), in the keys Test & Preview reads; '' for Android, '2' for iOS
|
|
3022
|
-
const getTapFormFields = (content, keySuffix) => {
|
|
3023
|
-
const { cta } = buildPlatformContent(content, '', {}, ANDROID);
|
|
3024
|
-
if (!cta) return {};
|
|
3025
|
-
const isDeepLink = cta.type === DEEP_LINK;
|
|
3026
|
-
return {
|
|
3027
|
-
[`cta-deeplink${keySuffix}`]: isDeepLink ? 'Deeplink' : 'External Link',
|
|
3028
|
-
[`cta-deeplink${keySuffix}-select`]: isDeepLink ? cta.actionLink : '',
|
|
3029
|
-
[`cta-deeplink${keySuffix}-text`]: isDeepLink ? '' : cta.actionLink,
|
|
3030
|
-
};
|
|
3031
|
-
};
|
|
3032
|
-
|
|
3033
2888
|
// Convert Android content to formData format
|
|
3034
2889
|
const androidFormData = {
|
|
3035
2890
|
'message-title': androidPreview?.header || androidContent?.title || '',
|
|
3036
2891
|
'message-editor': androidPreview?.bodyText || androidContent?.message || '',
|
|
3037
2892
|
image: androidPreview?.bodyImage || androidContent?.expandableDetails?.image || '',
|
|
3038
|
-
//
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
2893
|
+
// Extract primary CTA
|
|
2894
|
+
...(androidContent?.cta && {
|
|
2895
|
+
'cta-deeplink': androidContent.cta.type === DEEP_LINK ? 'Deeplink' : 'External Link',
|
|
2896
|
+
'cta-deeplink-select': androidContent.cta.type === DEEP_LINK ? (androidContent.cta.actionLink || '') : '',
|
|
2897
|
+
'cta-deeplink-text': androidContent.cta.type !== DEEP_LINK ? (androidContent.cta.actionLink || '') : '',
|
|
2898
|
+
'cta-deeplink-label': androidContent.cta.actionText || '',
|
|
2899
|
+
}),
|
|
3043
2900
|
};
|
|
3044
2901
|
|
|
3045
|
-
//
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
androidCtas.forEach((cta, index) => {
|
|
2902
|
+
// Extract secondary CTAs from expandableDetails
|
|
2903
|
+
if (androidContent?.expandableDetails?.ctas && androidContent.expandableDetails.ctas.length > 0) {
|
|
2904
|
+
androidContent.expandableDetails.ctas.forEach((cta, index) => {
|
|
3049
2905
|
if (index === 0) {
|
|
3050
2906
|
androidFormData['secondary-cta-0-label'] = cta.actionText || '';
|
|
3051
2907
|
androidFormData['cta-deeplink-secondary-cta-0'] = cta.type === DEEP_LINK ? 'Deeplink' : 'External Link';
|
|
@@ -3066,14 +2922,18 @@ export const MobilePushNew = ({
|
|
|
3066
2922
|
'message-title2': iosPreview?.header || iosContent?.title || '',
|
|
3067
2923
|
'message-editor2': iosPreview?.bodyText || iosContent?.message || '',
|
|
3068
2924
|
image: iosPreview?.bodyImage || iosContent?.expandableDetails?.image || '',
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
2925
|
+
// Extract primary CTA
|
|
2926
|
+
...(iosContent?.cta && {
|
|
2927
|
+
'cta-deeplink2': iosContent.cta.type === DEEP_LINK ? 'Deeplink' : 'External Link',
|
|
2928
|
+
'cta-deeplink2-select': iosContent.cta.type === DEEP_LINK ? (iosContent.cta.actionLink || '') : '',
|
|
2929
|
+
'cta-deeplink2-text': iosContent.cta.type !== DEEP_LINK ? (iosContent.cta.actionLink || '') : '',
|
|
2930
|
+
'cta-deeplink2-label': iosContent.cta.actionText || '',
|
|
2931
|
+
}),
|
|
3072
2932
|
};
|
|
3073
2933
|
|
|
3074
|
-
|
|
3075
|
-
if (
|
|
3076
|
-
|
|
2934
|
+
// Extract secondary CTAs from expandableDetails
|
|
2935
|
+
if (iosContent?.expandableDetails?.ctas && iosContent.expandableDetails.ctas.length > 0) {
|
|
2936
|
+
iosContent.expandableDetails.ctas.forEach((cta, index) => {
|
|
3077
2937
|
if (index === 0) {
|
|
3078
2938
|
iosFormData['secondary-cta-1-label'] = cta.actionText || '';
|
|
3079
2939
|
iosFormData['cta-deeplink-secondary-cta-1'] = cta.type === DEEP_LINK ? 'Deeplink' : 'External Link';
|
|
@@ -3086,7 +2946,7 @@ export const MobilePushNew = ({
|
|
|
3086
2946
|
|
|
3087
2947
|
// Return in formData array format [androidData, iosData]
|
|
3088
2948
|
return [androidFormData, iosFormData];
|
|
3089
|
-
}, [androidContent, iosContent, getContentType
|
|
2949
|
+
}, [androidContent, iosContent, getContentType]);
|
|
3090
2950
|
|
|
3091
2951
|
// Handle Test and Preview button click
|
|
3092
2952
|
const handleTestAndPreview = useCallback(() => {
|
|
@@ -3096,8 +2956,7 @@ export const MobilePushNew = ({
|
|
|
3096
2956
|
// Handle close Test and Preview slidebox
|
|
3097
2957
|
const handleCloseTestAndPreview = useCallback(() => {
|
|
3098
2958
|
setShowTestAndPreviewSlidebox(false);
|
|
3099
|
-
|
|
3100
|
-
}, [propsHandleCloseTestAndPreview]);
|
|
2959
|
+
}, []);
|
|
3101
2960
|
|
|
3102
2961
|
// Add useEffect to handle isGetFormData prop changes (e.g. Done clicked in footer)
|
|
3103
2962
|
// In library mode: run liquid validation (extractTags) first; on success liquidMiddleWare calls handleSave
|
|
@@ -3223,45 +3082,24 @@ export const MobilePushNew = ({
|
|
|
3223
3082
|
<CapRow className="mobile-push-container">
|
|
3224
3083
|
<CapColumn className="content-section" span={14}>
|
|
3225
3084
|
{createModeContent()}
|
|
3226
|
-
{
|
|
3227
|
-
<
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
/>
|
|
3236
|
-
</CapRow>
|
|
3237
|
-
)}
|
|
3238
|
-
{singlePlatform ? (
|
|
3239
|
-
// One platform: its form only, no tabs or "Same content" checkbox
|
|
3240
|
-
<CapRow className="platform-header">
|
|
3241
|
-
{renderContentFields(singlePlatform)}
|
|
3242
|
-
</CapRow>
|
|
3243
|
-
) : (
|
|
3244
|
-
<>
|
|
3245
|
-
{isAndroidSupported && isIosSupported && (
|
|
3246
|
-
<CapCheckbox
|
|
3247
|
-
className="same-content-checkbox"
|
|
3248
|
-
checked={sameContent}
|
|
3249
|
-
onChange={handleSameContentChange}
|
|
3250
|
-
key={`same-content-${sameContent}`}
|
|
3251
|
-
>
|
|
3252
|
-
{formatMessage(messages.sameContentForBothChannels)}
|
|
3253
|
-
</CapCheckbox>
|
|
3254
|
-
)}
|
|
3255
|
-
<CapRow className="platform-header">
|
|
3256
|
-
<StyledCapTab
|
|
3257
|
-
className="platform-tabs"
|
|
3258
|
-
activeKey={activeTab}
|
|
3259
|
-
onChange={setActiveTab}
|
|
3260
|
-
panes={PANES}
|
|
3261
|
-
/>
|
|
3262
|
-
</CapRow>
|
|
3263
|
-
</>
|
|
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>
|
|
3264
3094
|
)}
|
|
3095
|
+
<CapRow className="platform-header">
|
|
3096
|
+
<StyledCapTab
|
|
3097
|
+
className="platform-tabs"
|
|
3098
|
+
activeKey={activeTab}
|
|
3099
|
+
onChange={setActiveTab}
|
|
3100
|
+
panes={PANES}
|
|
3101
|
+
/>
|
|
3102
|
+
</CapRow>
|
|
3265
3103
|
<CapRow>
|
|
3266
3104
|
<CapColumn span={24}>
|
|
3267
3105
|
<ErrorInfoNote
|
|
@@ -3271,6 +3109,39 @@ export const MobilePushNew = ({
|
|
|
3271
3109
|
STANDARD_ERROR_MSG: errorMessage?.STANDARD_ERROR_MSG,
|
|
3272
3110
|
}}
|
|
3273
3111
|
/>
|
|
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
|
+
|
|
3274
3145
|
</CapColumn>
|
|
3275
3146
|
</CapRow>
|
|
3276
3147
|
</CapColumn>
|
|
@@ -3283,87 +3154,8 @@ export const MobilePushNew = ({
|
|
|
3283
3154
|
/>
|
|
3284
3155
|
</CapColumn>
|
|
3285
3156
|
</CapRow>
|
|
3286
|
-
{/* In library mode, only show save button in create mode (edit mode has Done button from FormBuilder). In full mode, keep old logic. */}
|
|
3287
|
-
{/* Kept outside the content row so the sticky footer can stick across the whole scroll area */}
|
|
3288
|
-
{((!isFullMode && computedCreativesMode !== 'edit') || (isFullMode && !isEditMode && computedCreativesMode === 'create')) && (
|
|
3289
|
-
<CapRow className="save-section mpush-save-section">
|
|
3290
|
-
<CapColumn span={24}>
|
|
3291
|
-
<CapButton
|
|
3292
|
-
type="primary"
|
|
3293
|
-
onClick={() => {
|
|
3294
|
-
// Liquid validation (extractTags) only in library mode
|
|
3295
|
-
if (!isFullMode) {
|
|
3296
|
-
liquidMiddleWare();
|
|
3297
|
-
} else {
|
|
3298
|
-
handleSave();
|
|
3299
|
-
}
|
|
3300
|
-
}}
|
|
3301
|
-
className="save-button"
|
|
3302
|
-
disabled={isSaveDisabled}
|
|
3303
|
-
>
|
|
3304
|
-
{formatMessage(messages.saveTemplate)}
|
|
3305
|
-
</CapButton>
|
|
3306
|
-
<CapButton
|
|
3307
|
-
onClick={handleTestAndPreview}
|
|
3308
|
-
className="mobilepush-test-preview-btn"
|
|
3309
|
-
type="secondary"
|
|
3310
|
-
style={{ marginLeft: '8px' }}
|
|
3311
|
-
disabled={isTestAndPreviewDisabled}
|
|
3312
|
-
>
|
|
3313
|
-
<FormattedMessage {...creativesMessages.testAndPreview} />
|
|
3314
|
-
</CapButton>
|
|
3315
|
-
</CapColumn>
|
|
3316
|
-
</CapRow>
|
|
3317
|
-
)}
|
|
3318
|
-
<CapModal
|
|
3319
|
-
open={isReplaceConfirmOpen}
|
|
3320
|
-
centered
|
|
3321
|
-
width={520}
|
|
3322
|
-
title={formatMessage(messages.replacePlatformContent, { platform: formatMessage(activeTab === ANDROID ? messages.ios : messages.android) })}
|
|
3323
|
-
onCancel={() => setIsReplaceConfirmOpen(false)}
|
|
3324
|
-
footer={[
|
|
3325
|
-
<CapButton key="cancel" type="secondary" onClick={() => setIsReplaceConfirmOpen(false)}>
|
|
3326
|
-
{formatMessage(globalMessages.cancel)}
|
|
3327
|
-
</CapButton>,
|
|
3328
|
-
<CapButton
|
|
3329
|
-
key="replace"
|
|
3330
|
-
type="primary"
|
|
3331
|
-
className="mpush-replace-platform-content"
|
|
3332
|
-
onClick={confirmSameContent}
|
|
3333
|
-
>
|
|
3334
|
-
{formatMessage(messages.replace)}
|
|
3335
|
-
</CapButton>,
|
|
3336
|
-
]}
|
|
3337
|
-
>
|
|
3338
|
-
{formatMessage(messages.replacePlatformContentBody, {
|
|
3339
|
-
platform: formatMessage(activeTab === ANDROID ? messages.ios : messages.android),
|
|
3340
|
-
source: formatMessage(activeTab === ANDROID ? messages.android : messages.ios),
|
|
3341
|
-
})}
|
|
3342
|
-
</CapModal>
|
|
3343
|
-
<CapModal
|
|
3344
|
-
open={!!pendingPlatformSelection}
|
|
3345
|
-
centered
|
|
3346
|
-
width={520}
|
|
3347
|
-
title={formatMessage(messages.removePlatformContent, {
|
|
3348
|
-
platform: formatMessage(pendingPlatformSelection === ANDROID ? messages.ios : messages.android),
|
|
3349
|
-
})}
|
|
3350
|
-
onCancel={() => setPendingPlatformSelection(null)}
|
|
3351
|
-
footer={[
|
|
3352
|
-
<CapButton key="cancel" type="secondary" onClick={() => setPendingPlatformSelection(null)}>
|
|
3353
|
-
{formatMessage(globalMessages.cancel)}
|
|
3354
|
-
</CapButton>,
|
|
3355
|
-
<CapButton
|
|
3356
|
-
key="remove"
|
|
3357
|
-
type="primary"
|
|
3358
|
-
className="mpush-remove-platform-content"
|
|
3359
|
-
onClick={confirmPlatformRemoval}
|
|
3360
|
-
>
|
|
3361
|
-
{formatMessage(messages.removeContent)}
|
|
3362
|
-
</CapButton>,
|
|
3363
|
-
]}
|
|
3364
|
-
/>
|
|
3365
3157
|
<TestAndPreviewSlidebox
|
|
3366
|
-
show={
|
|
3158
|
+
show={showTestAndPreviewSlidebox}
|
|
3367
3159
|
onClose={handleCloseTestAndPreview}
|
|
3368
3160
|
formData={getFormDataForPayload()} // Pass formData structure for payload building
|
|
3369
3161
|
content={getTemplateContent()} // Also pass content for preview
|
|
@@ -3399,8 +3191,6 @@ MobilePushNew.propTypes = {
|
|
|
3399
3191
|
globalActions: PropTypes.object,
|
|
3400
3192
|
fetchingLiquidValidation: PropTypes.bool,
|
|
3401
3193
|
handleClose: PropTypes.func,
|
|
3402
|
-
showTestAndPreviewSlidebox: PropTypes.bool,
|
|
3403
|
-
handleCloseTestAndPreview: PropTypes.func,
|
|
3404
3194
|
createTemplateError: PropTypes.any,
|
|
3405
3195
|
isGetFormData: PropTypes.bool,
|
|
3406
3196
|
getTemplateDetailsInProgress: PropTypes.bool,
|
|
@@ -3433,8 +3223,6 @@ MobilePushNew.defaultProps = {
|
|
|
3433
3223
|
globalActions: {},
|
|
3434
3224
|
fetchingLiquidValidation: false,
|
|
3435
3225
|
handleClose: () => {},
|
|
3436
|
-
showTestAndPreviewSlidebox: false,
|
|
3437
|
-
handleCloseTestAndPreview: undefined,
|
|
3438
3226
|
createTemplateError: null,
|
|
3439
3227
|
isGetFormData: false,
|
|
3440
3228
|
getTemplateDetailsInProgress: false,
|