@capillarytech/creatives-library 9.2.1 → 9.2.2-alpha.sprint-cap-214249.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants/unified.js +0 -1
- package/package.json +1 -1
- package/utils/common.js +0 -6
- package/utils/createMobilePushPayload.js +50 -56
- package/utils/tests/createMobilePushPayload.test.js +177 -168
- package/v2Components/CapMpushCTA/index.js +47 -57
- package/v2Components/CapMpushCTA/index.scss +43 -5
- package/v2Components/CapMpushCTA/tests/index.test.js +150 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +11 -8
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/index.js +51 -12
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +83 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +100 -0
- package/v2Components/MobilePushPreviewV2/_mobilePushPreviewV2.scss +7 -0
- package/v2Components/MobilePushPreviewV2/index.js +22 -9
- package/v2Components/MobilePushPreviewV2/tests/index.test.js +55 -0
- package/v2Components/TemplatePreview/_mobilePushPhone.scss +72 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +18 -2
- package/v2Components/TemplatePreview/index.js +20 -18
- package/v2Components/TemplatePreview/tests/index.test.js +69 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/extractContentForPreview.test.js +45 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js +12 -2
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -6
- package/v2Containers/CreativesContainer/index.js +2 -1
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +43 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +105 -345
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +127 -105
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +76 -0
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +305 -1482
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +165 -59
- package/v2Containers/MobilePushNew/constants.js +12 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +78 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +40 -1
- package/v2Containers/MobilePushNew/hooks/useUpload.js +42 -46
- package/v2Containers/MobilePushNew/index.js +498 -289
- package/v2Containers/MobilePushNew/index.scss +151 -4
- package/v2Containers/MobilePushNew/messages.js +106 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +483 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +110 -0
- package/v2Containers/MobilePushNew/utils.js +83 -0
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +86 -81
- package/v2Containers/Templates/tests/index.test.js +81 -0
|
@@ -73,6 +73,75 @@ describe('Test Templates container', () => {
|
|
|
73
73
|
expect(renderedComponent).toMatchSnapshot();
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
+
describe('Mobile push action buttons', () => {
|
|
77
|
+
const renderMobilePush = (device, actions) => {
|
|
78
|
+
renderedComponent = shallowWithIntl(
|
|
79
|
+
<TemplatePreview
|
|
80
|
+
channel="MOBILEPUSH"
|
|
81
|
+
device={device}
|
|
82
|
+
content={{ header: 'Title', bodyText: 'Body', actions, carouselData: [] }}
|
|
83
|
+
/>,
|
|
84
|
+
);
|
|
85
|
+
return renderedComponent.find('.actions');
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
it.each(['android', 'ios'])('renders labels as typed on one flex row with index keys (%s)', (device) => {
|
|
89
|
+
const row = renderMobilePush(device, [
|
|
90
|
+
{ label: 'Shop', url: 'https://a.com' },
|
|
91
|
+
{ label: 'Shop' },
|
|
92
|
+
{ label: '' },
|
|
93
|
+
]);
|
|
94
|
+
const buttons = row.find('.action');
|
|
95
|
+
|
|
96
|
+
expect(row.props()).toEqual(expect.objectContaining({ type: 'flex', noWrap: true }));
|
|
97
|
+
expect(buttons).toHaveLength(2);
|
|
98
|
+
expect(buttons.map((button) => button.key())).toEqual(['action-0', 'action-1']);
|
|
99
|
+
expect(buttons.map((button) => button.text())).toEqual(['Shop', 'Shop']);
|
|
100
|
+
expect(buttons.at(0).prop('title')).toBe('https://a.com');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const renderCarousel = (device, carouselData) => {
|
|
104
|
+
renderedComponent = shallowWithIntl(
|
|
105
|
+
<TemplatePreview
|
|
106
|
+
channel="MOBILEPUSH"
|
|
107
|
+
device={device}
|
|
108
|
+
content={{ header: 'Title', carouselData }}
|
|
109
|
+
/>,
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
it.each(['android', 'ios'])('shows every card, with or without media, in one horizontal row (%s)', (device) => {
|
|
114
|
+
renderCarousel(device, [
|
|
115
|
+
{ mediaType: 'IMAGE', imageUrl: 'https://a.url' },
|
|
116
|
+
{ mediaType: 'IMAGE' },
|
|
117
|
+
{ mediaType: 'VIDEO', videoPreviewImg: 'https://b.url' },
|
|
118
|
+
]);
|
|
119
|
+
const scrollRow = renderedComponent.find('.scroll-container');
|
|
120
|
+
|
|
121
|
+
expect(scrollRow.props()).toEqual(expect.objectContaining({ type: 'flex', noWrap: true }));
|
|
122
|
+
expect(renderedComponent.find('.mobile-push-carousel-card')).toHaveLength(3);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it.each(['android', 'ios'])('shows a video card with no thumbnail as the video placeholder (%s)', (device) => {
|
|
126
|
+
renderCarousel(device, [{ mediaType: 'video', videoSrc: 'https://v.mp4' }]);
|
|
127
|
+
expect(renderedComponent.find('.mobile-push-carousel-card')).toHaveLength(1);
|
|
128
|
+
expect(renderedComponent.find('video')).toHaveLength(0);
|
|
129
|
+
expect(renderedComponent.find('.carousel-video-preview').prop('src')).toBe('test-file-stub');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it.each(['android', 'ios'])('shows an empty card while no media is uploaded (%s)', (device) => {
|
|
133
|
+
renderCarousel(device, [{ mediaType: 'IMAGE' }]);
|
|
134
|
+
expect(renderedComponent.find('.mobile-push-carousel-container')).toHaveLength(1);
|
|
135
|
+
expect(renderedComponent.find('.mobile-push-carousel-card')).toHaveLength(1);
|
|
136
|
+
expect(renderedComponent.find('.carousel-image')).toHaveLength(0);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it.each(['android', 'ios'])('shows no carousel when there are no cards (%s)', (device) => {
|
|
140
|
+
renderCarousel(device, []);
|
|
141
|
+
expect(renderedComponent.find('.mobile-push-carousel-container')).toHaveLength(0);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
76
145
|
describe('RCS carousel preview branches', () => {
|
|
77
146
|
const buildRcsContent = (cards) => ({
|
|
78
147
|
rcsPreviewContent: {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import extractContentForPreview from '../extractContentForPreview';
|
|
2
|
+
|
|
3
|
+
const extractMpush = (androidContent, iosContent = {}) => extractContentForPreview({
|
|
4
|
+
channel: 'MOBILEPUSH',
|
|
5
|
+
templateData: { androidContent, iosContent },
|
|
6
|
+
}).content;
|
|
7
|
+
|
|
8
|
+
describe('extractContentForPreview - Mobile Push', () => {
|
|
9
|
+
it('passes each saved notification tap (cta) for the test send', () => {
|
|
10
|
+
const androidCta = { type: 'DEEP_LINK', actionLink: 'app://home' };
|
|
11
|
+
const iosCta = { type: 'EXTERNAL_URL', actionLink: 'https://x.com' };
|
|
12
|
+
|
|
13
|
+
const content = extractMpush({ title: 'A', cta: androidCta }, { title: 'I', cta: iosCta });
|
|
14
|
+
|
|
15
|
+
expect(content.androidContent.cta).toEqual(androidCta);
|
|
16
|
+
expect(content.iosContent.cta).toEqual(iosCta);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('maps a saved video to the { videoSrc, videoPreview } shape the test send reads', () => {
|
|
20
|
+
const content = extractMpush(
|
|
21
|
+
{ expandableDetails: { style: 'VIDEO', media: [{ url: 'https://a.mp4', type: 'VIDEO', videoPreviewUrl: 'https://a.jpg' }] } },
|
|
22
|
+
{ expandableDetails: { style: 'VIDEO', media: [{ url: 'https://i.mp4', type: 'VIDEO' }] } },
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
expect(content.androidContent.bodyVideo).toEqual({ videoSrc: 'https://a.mp4', videoPreview: 'https://a.jpg' });
|
|
26
|
+
expect(content.iosContent.bodyVideo).toEqual({ videoSrc: 'https://i.mp4', videoPreview: '' });
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('gives no body video for a carousel whose first card is a video', () => {
|
|
30
|
+
const cards = [{ mediaType: 'video', videoSrc: 'https://c.mp4' }];
|
|
31
|
+
const content = extractMpush({
|
|
32
|
+
expandableDetails: { style: 'MANUAL_CAROUSEL', media: [{ url: 'https://c.mp4', type: 'VIDEO' }], carouselData: cards },
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
expect(content.androidContent.bodyVideo).toEqual({});
|
|
36
|
+
expect(content.androidContent.carouselData).toEqual(cards);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('gives no video or cta for a text template', () => {
|
|
40
|
+
const content = extractMpush({ title: 'A', expandableDetails: { style: 'BIG_TEXT' } });
|
|
41
|
+
|
|
42
|
+
expect(content.androidContent.bodyVideo).toEqual({});
|
|
43
|
+
expect(content.androidContent.cta).toBeUndefined();
|
|
44
|
+
});
|
|
45
|
+
});
|
package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
TEXT, IMAGE, VIDEO, DOCUMENT, CTA, QUICK_REPLY,
|
|
4
4
|
} from '../../../CreativesContainer/constants';
|
|
5
5
|
import { getWhatsappDocPreview } from '../../../Whatsapp/utils';
|
|
6
|
+
import { MANUAL_CAROUSEL } from '../../../MobilePushNew/constants';
|
|
6
7
|
|
|
7
8
|
const extractSmsContent = (templateData) => {
|
|
8
9
|
const smsBody = templateData.messageBody || templateData.smsBody || '';
|
|
@@ -20,19 +21,28 @@ const extractEmailContent = (templateData) => {
|
|
|
20
21
|
return { content: emailContent, formData };
|
|
21
22
|
};
|
|
22
23
|
|
|
24
|
+
// Saved media[0] is { url, type }; the test send reads { videoSrc, videoPreview }. A carousel's media are its cards
|
|
25
|
+
const toPreviewVideo = (style, media) => {
|
|
26
|
+
const { type, url, videoPreviewUrl } = media[0] || {};
|
|
27
|
+
return style !== MANUAL_CAROUSEL && type === VIDEO && url ? { videoSrc: url, videoPreview: videoPreviewUrl || '' } : {};
|
|
28
|
+
};
|
|
29
|
+
|
|
23
30
|
const extractMobilePushDevice = ({
|
|
24
31
|
title = '',
|
|
25
32
|
message = '',
|
|
33
|
+
cta,
|
|
26
34
|
expandableDetails: {
|
|
27
|
-
image = '', media = [], ctas = [], carouselData = [],
|
|
35
|
+
style, image = '', media = [], ctas = [], carouselData = [],
|
|
28
36
|
} = {},
|
|
29
37
|
} = {}) => ({
|
|
30
38
|
header: title,
|
|
31
39
|
bodyText: message,
|
|
32
40
|
bodyImage: image,
|
|
33
|
-
bodyVideo: media
|
|
41
|
+
bodyVideo: toPreviewVideo(style, media),
|
|
34
42
|
bodyGif: '',
|
|
35
43
|
actions: ctas,
|
|
44
|
+
// Notification tap, read by the test send
|
|
45
|
+
cta,
|
|
36
46
|
carouselData,
|
|
37
47
|
});
|
|
38
48
|
|
|
@@ -848,9 +848,7 @@ export function SlideBoxContent(props) {
|
|
|
848
848
|
})()
|
|
849
849
|
)}
|
|
850
850
|
{isEditMPush && (
|
|
851
|
-
|
|
852
|
-
(!isFullMode && isLoyaltyModule) ||
|
|
853
|
-
(!isFullMode && !isLoyaltyModule && !commonUtil.hasNewMobilePushFeatureEnabled()) ? (
|
|
851
|
+
!isFullMode && isLoyaltyModule ? (
|
|
854
852
|
<MobliPushEdit
|
|
855
853
|
getFormLibraryData={getFormData}
|
|
856
854
|
setIsLoadingContent={setIsLoadingContent}
|
|
@@ -912,6 +910,8 @@ export function SlideBoxContent(props) {
|
|
|
912
910
|
waitEventContextTags={waitEventContextTags}
|
|
913
911
|
showLiquidErrorInFooter={showLiquidErrorInFooter}
|
|
914
912
|
handleClose={handleClose}
|
|
913
|
+
showTestAndPreviewSlidebox={showTestAndPreviewSlidebox}
|
|
914
|
+
handleCloseTestAndPreview={handleCloseTestAndPreview}
|
|
915
915
|
restrictPersonalization={restrictPersonalization}
|
|
916
916
|
isAnonymousType={isAnonymousType}
|
|
917
917
|
onPersonalizationTokensChange={onPersonalizationTokensChange}
|
|
@@ -920,9 +920,7 @@ export function SlideBoxContent(props) {
|
|
|
920
920
|
)
|
|
921
921
|
)}
|
|
922
922
|
{isCreateMPush && (
|
|
923
|
-
|
|
924
|
-
(!isFullMode && isLoyaltyModule) ||
|
|
925
|
-
(!isFullMode && !isLoyaltyModule && !commonUtil.hasNewMobilePushFeatureEnabled()) ? (
|
|
923
|
+
!isFullMode && isLoyaltyModule ? (
|
|
926
924
|
<MobilepushWrapper
|
|
927
925
|
key="creatives-mobilepush-wrapper"
|
|
928
926
|
date={new Date().getMilliseconds()}
|
|
@@ -1042,7 +1042,8 @@ export class Creatives extends React.Component {
|
|
|
1042
1042
|
newExpandableDetails.message = expandableDetails.message || '';
|
|
1043
1043
|
newExpandableDetails.ctas = expandableDetails.ctas || [];
|
|
1044
1044
|
newExpandableDetails.media = expandableDetails.carouselData.map((carousel) => ({
|
|
1045
|
-
url
|
|
1045
|
+
// Video cards keep their url in videoSrc
|
|
1046
|
+
url: carousel?.mediaType?.toUpperCase() === VIDEO ? carousel.videoSrc : carousel.imageUrl,
|
|
1046
1047
|
type: carousel?.mediaType?.toUpperCase(),
|
|
1047
1048
|
text: '',
|
|
1048
1049
|
}));
|
|
@@ -4,6 +4,9 @@ import { SlideBoxContent } from '../SlideBoxContent';
|
|
|
4
4
|
import mockdata from '../../mockdata';
|
|
5
5
|
import { templateDetailsImage, templateDetailsVideo, templateDetailsText, templateDetails_ } from '../../Viber/tests/mockData';
|
|
6
6
|
import { CREATE, RICH_MEDIA } from '../../WeChat/Wrapper/constants';
|
|
7
|
+
import MobilePushNew from '../../MobilePushNew';
|
|
8
|
+
import MobilepushWrapper from '../../MobilepushWrapper';
|
|
9
|
+
import MobliPushEdit from '../../MobilePush/Edit';
|
|
7
10
|
|
|
8
11
|
const {
|
|
9
12
|
whatsappEditTemplateData,
|
|
@@ -1015,4 +1018,44 @@ describe('Test SlideBoxContent container', () => {
|
|
|
1015
1018
|
});
|
|
1016
1019
|
|
|
1017
1020
|
});
|
|
1021
|
+
|
|
1022
|
+
describe('Mobile push editor choice', () => {
|
|
1023
|
+
const editTemplateData = { _id: 'mp-1', type: 'MOBILEPUSH' };
|
|
1024
|
+
|
|
1025
|
+
it.each([
|
|
1026
|
+
['full mode', { isFullMode: true }],
|
|
1027
|
+
['embedded outside Loyalty', { isFullMode: false, isLoyaltyModule: false }],
|
|
1028
|
+
])('opens the new editor for create and edit in %s', (_, modeProps) => {
|
|
1029
|
+
renderFunction('MOBILEPUSH', 'createTemplate', { mode: 'create' }, modeProps);
|
|
1030
|
+
expect(renderedComponent.find(MobilePushNew).exists()).toBe(true);
|
|
1031
|
+
expect(renderedComponent.find(MobilepushWrapper).exists()).toBe(false);
|
|
1032
|
+
|
|
1033
|
+
renderFunction('MOBILEPUSH', 'editTemplate', editTemplateData, modeProps);
|
|
1034
|
+
expect(renderedComponent.find(MobilePushNew).exists()).toBe(true);
|
|
1035
|
+
expect(renderedComponent.find(MobliPushEdit).exists()).toBe(false);
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1038
|
+
it('passes the footer Test & Preview state to the new editor in edit', () => {
|
|
1039
|
+
const handleCloseTestAndPreview = jest.fn();
|
|
1040
|
+
renderFunction('MOBILEPUSH', 'editTemplate', editTemplateData, {
|
|
1041
|
+
isFullMode: true,
|
|
1042
|
+
showTestAndPreviewSlidebox: true,
|
|
1043
|
+
handleCloseTestAndPreview,
|
|
1044
|
+
});
|
|
1045
|
+
const editor = renderedComponent.find(MobilePushNew);
|
|
1046
|
+
expect(editor.prop('showTestAndPreviewSlidebox')).toBe(true);
|
|
1047
|
+
expect(editor.prop('handleCloseTestAndPreview')).toBe(handleCloseTestAndPreview);
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
it('keeps the old editor when embedded in Loyalty', () => {
|
|
1051
|
+
const loyaltyProps = { isFullMode: false, isLoyaltyModule: true };
|
|
1052
|
+
renderFunction('MOBILEPUSH', 'createTemplate', { mode: 'create' }, loyaltyProps);
|
|
1053
|
+
expect(renderedComponent.find(MobilepushWrapper).exists()).toBe(true);
|
|
1054
|
+
expect(renderedComponent.find(MobilePushNew).exists()).toBe(false);
|
|
1055
|
+
|
|
1056
|
+
renderFunction('MOBILEPUSH', 'editTemplate', editTemplateData, loyaltyProps);
|
|
1057
|
+
expect(renderedComponent.find(MobliPushEdit).exists()).toBe(true);
|
|
1058
|
+
expect(renderedComponent.find(MobilePushNew).exists()).toBe(false);
|
|
1059
|
+
});
|
|
1060
|
+
});
|
|
1018
1061
|
});
|
|
@@ -5,16 +5,20 @@ import CapRow from "@capillarytech/cap-ui-library/CapRow";
|
|
|
5
5
|
import CapButton from "@capillarytech/cap-ui-library/CapButton";
|
|
6
6
|
import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
|
|
7
7
|
import CapHeading from "@capillarytech/cap-ui-library/CapHeading";
|
|
8
|
-
import
|
|
8
|
+
import CapLabel from "@capillarytech/cap-ui-library/CapLabel";
|
|
9
|
+
// import CapTooltip from "@capillarytech/cap-ui-library/CapTooltip";
|
|
9
10
|
import CapMpushCTA from "../../../v2Components/CapMpushCTA";
|
|
10
|
-
import { PRIMARY,
|
|
11
|
+
import { PRIMARY, DEEP_LINK } from "../constants";
|
|
12
|
+
// import { SECONDARY } from "../constants";
|
|
11
13
|
import messages from "../messages";
|
|
12
14
|
|
|
15
|
+
// Secondary button is commented out below: it needs backend support, so it is being revamped.
|
|
16
|
+
// Restore the commented secondaryButton / setSecondaryButton props, state, handler and JSX together.
|
|
13
17
|
const CtaButtons = ({
|
|
14
18
|
primaryButton,
|
|
15
|
-
secondaryButton,
|
|
19
|
+
// secondaryButton,
|
|
16
20
|
setPrimaryButton,
|
|
17
|
-
setSecondaryButton,
|
|
21
|
+
// setSecondaryButton,
|
|
18
22
|
ctaData,
|
|
19
23
|
updateHandler,
|
|
20
24
|
deleteHandler,
|
|
@@ -27,7 +31,7 @@ const CtaButtons = ({
|
|
|
27
31
|
}) => {
|
|
28
32
|
// Local state to control CTA form visibility
|
|
29
33
|
const [showPrimaryCTA, setShowPrimaryCTA] = useState(false);
|
|
30
|
-
const [showSecondaryCTA, setShowSecondaryCTA] = useState(false);
|
|
34
|
+
// const [showSecondaryCTA, setShowSecondaryCTA] = useState(false);
|
|
31
35
|
|
|
32
36
|
const handleAddPrimary = () => {
|
|
33
37
|
// Prevent multiple clicks if primary button is already being added or form is already showing
|
|
@@ -53,68 +57,67 @@ const CtaButtons = ({
|
|
|
53
57
|
setShowPrimaryCTA(true);
|
|
54
58
|
};
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
isSaved: false,
|
|
77
|
-
};
|
|
78
|
-
updateHandler(newSecondaryButton, 1);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// setSecondaryButton(true);
|
|
82
|
-
// setShowSecondaryCTA(true);
|
|
83
|
-
};
|
|
60
|
+
// Secondary button: needs backend support, revamped
|
|
61
|
+
// const handleAddSecondary = () => {
|
|
62
|
+
// if (secondaryButton && showSecondaryCTA) {
|
|
63
|
+
// return;
|
|
64
|
+
// }
|
|
65
|
+
// if (ctaData?.length < 2 || !ctaData?.find((cta) => cta?.index === 1)) {
|
|
66
|
+
// const newSecondaryButton = {
|
|
67
|
+
// index: 1,
|
|
68
|
+
// ctaType: SECONDARY,
|
|
69
|
+
// text: "",
|
|
70
|
+
// urlType: DEEP_LINK,
|
|
71
|
+
// url: "",
|
|
72
|
+
// deepLinkKeys: "",
|
|
73
|
+
// isSaved: false,
|
|
74
|
+
// };
|
|
75
|
+
// updateHandler(newSecondaryButton, 1);
|
|
76
|
+
// }
|
|
77
|
+
// setSecondaryButton(true);
|
|
78
|
+
// setShowSecondaryCTA(true);
|
|
79
|
+
// };
|
|
84
80
|
|
|
85
81
|
// Check if primary button exists (saved or being edited)
|
|
86
82
|
const primaryButtonExists = ctaData?.length > 0 && ctaData[0]?.text;
|
|
87
83
|
const isPrimaryButtonSaved = primaryButtonExists && ctaData[0]?.isSaved;
|
|
88
84
|
|
|
89
|
-
//
|
|
90
|
-
const secondaryButtonExists = ctaData?.length > 1 && ctaData[1]?.text;
|
|
91
|
-
const isSecondaryButtonSaved = secondaryButtonExists && ctaData[1]?.isSaved;
|
|
85
|
+
// Secondary button: needs backend support, revamped
|
|
86
|
+
// const secondaryButtonExists = ctaData?.length > 1 && ctaData[1]?.text;
|
|
87
|
+
// const isSecondaryButtonSaved = secondaryButtonExists && ctaData[1]?.isSaved;
|
|
92
88
|
|
|
93
89
|
// Show primary CTA if button is active and (form is showing OR button exists)
|
|
94
90
|
const shouldShowPrimaryCTA = primaryButton && (showPrimaryCTA || primaryButtonExists);
|
|
95
91
|
|
|
96
|
-
//
|
|
97
|
-
const shouldShowSecondaryCTA = secondaryButton && (showSecondaryCTA || secondaryButtonExists);
|
|
92
|
+
// Secondary button: needs backend support, revamped
|
|
93
|
+
// const shouldShowSecondaryCTA = secondaryButton && (showSecondaryCTA || secondaryButtonExists);
|
|
98
94
|
|
|
99
95
|
// Enhanced delete handler to hide forms when buttons are deleted
|
|
100
96
|
const handleDelete = (index) => {
|
|
101
97
|
if (index === 0) {
|
|
102
98
|
setShowPrimaryCTA(false);
|
|
103
99
|
setPrimaryButton(false);
|
|
104
|
-
} else if (index === 1) {
|
|
105
|
-
//cooment until supported from BE & Hydra
|
|
106
|
-
// setShowSecondaryCTA(false);
|
|
107
|
-
// setSecondaryButton(false);
|
|
108
100
|
}
|
|
101
|
+
// Secondary button: needs backend support, revamped
|
|
102
|
+
// else if (index === 1) {
|
|
103
|
+
// setShowSecondaryCTA(false);
|
|
104
|
+
// setSecondaryButton(false);
|
|
105
|
+
// }
|
|
109
106
|
deleteHandler(index);
|
|
110
107
|
};
|
|
111
108
|
|
|
112
109
|
return (
|
|
113
110
|
<>
|
|
114
111
|
<CapRow className="mpush-cta-buttons">
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
{/* Heading with "(Optional)" on the same line */}
|
|
113
|
+
<CapRow type="flex" align="middle" noWrap className="mpush-section-heading">
|
|
114
|
+
<CapHeading type="h3">
|
|
115
|
+
<FormattedMessage {...messages.buttons} />
|
|
116
|
+
</CapHeading>
|
|
117
|
+
<CapLabel className="optional-text">
|
|
118
|
+
<FormattedMessage {...messages.optionalText} />
|
|
119
|
+
</CapLabel>
|
|
120
|
+
</CapRow>
|
|
118
121
|
{!isPrimaryButtonSaved && !shouldShowPrimaryCTA && (
|
|
119
122
|
<CapButton
|
|
120
123
|
type="link"
|
|
@@ -142,6 +145,7 @@ const CtaButtons = ({
|
|
|
142
145
|
handleOnTagsContextChange={handleOnTagsContextChange}
|
|
143
146
|
/>
|
|
144
147
|
)}
|
|
148
|
+
{/* Secondary button: needs backend support, so it is being revamped. Hidden until then.
|
|
145
149
|
{isPrimaryButtonSaved && !isSecondaryButtonSaved && !shouldShowSecondaryCTA && (
|
|
146
150
|
<CapTooltip
|
|
147
151
|
overlay={<FormattedMessage {...messages.secondaryButtonTooltip} />}
|
|
@@ -171,15 +175,16 @@ const CtaButtons = ({
|
|
|
171
175
|
buttonType={SECONDARY}
|
|
172
176
|
/>
|
|
173
177
|
)}
|
|
178
|
+
*/}
|
|
174
179
|
</>
|
|
175
180
|
);
|
|
176
181
|
};
|
|
177
182
|
|
|
178
183
|
CtaButtons.propTypes = {
|
|
179
184
|
primaryButton: PropTypes.bool.isRequired,
|
|
180
|
-
secondaryButton: PropTypes.bool.isRequired,
|
|
185
|
+
// secondaryButton: PropTypes.bool.isRequired,
|
|
181
186
|
setPrimaryButton: PropTypes.func.isRequired,
|
|
182
|
-
setSecondaryButton: PropTypes.func.isRequired,
|
|
187
|
+
// setSecondaryButton: PropTypes.func.isRequired,
|
|
183
188
|
ctaData: PropTypes.array.isRequired,
|
|
184
189
|
updateHandler: PropTypes.func.isRequired,
|
|
185
190
|
deleteHandler: PropTypes.func.isRequired,
|