@capillarytech/creatives-library 8.0.158 → 8.0.159-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/app.js +1 -1
- package/package.json +1 -1
- package/v2Components/CustomerSearchSection/index.js +83 -79
- package/v2Components/EmailPreview/_emailPreview.scss +1 -0
- package/v2Components/EmailPreviewV2/_emailPreviewV2.scss +1 -0
- package/v2Components/FormBuilder/index.js +78 -53
- package/v2Components/TestAndPreviewSlidebox/PreviewSection.js +1 -1
- package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +2 -1
- package/v2Components/TestAndPreviewSlidebox/index.js +187 -14
- package/v2Components/TestAndPreviewSlidebox/tests/PreviewSection.test.js +1 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +11 -3
- package/v2Containers/CreativesContainer/index.js +30 -15
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +5 -0
- package/v2Containers/Email/index.js +150 -28
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +3 -0
- package/v2Containers/EmailWrapper/index.js +6 -0
- package/assets/loading_img.gif +0 -0
- package/utils/whatsappMediaUtils.js +0 -44
- package/v2Containers/Email/tests/index.test.js +0 -35
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import React, { useState, useEffect, useMemo } from 'react';
|
|
8
|
+
import React, { useState, useEffect, useMemo, useRef } from 'react';
|
|
9
9
|
import { convert } from "html-to-text";
|
|
10
10
|
import { createStructuredSelector } from 'reselect';
|
|
11
11
|
import { connect } from 'react-redux';
|
|
@@ -75,6 +75,7 @@ const TestAndPreviewSlidebox = (props) => {
|
|
|
75
75
|
prefilledValues,
|
|
76
76
|
isSendingTestMessage,
|
|
77
77
|
beeInstance,
|
|
78
|
+
currentTab = 1, // Add currentTab prop with default value
|
|
78
79
|
} = props;
|
|
79
80
|
|
|
80
81
|
// State management
|
|
@@ -87,28 +88,169 @@ const TestAndPreviewSlidebox = (props) => {
|
|
|
87
88
|
const [previewDevice, setPreviewDevice] = useState('desktop');
|
|
88
89
|
const [previewDataHtml, setPreviewDataHtml] = useState(previewData || '');
|
|
89
90
|
const [selectedTestEntities, setSelectedTestEntities] = useState([]);
|
|
91
|
+
const [beeContent, setBeeContent] = useState(''); // Track BEE editor content separately
|
|
92
|
+
const previousBeeContentRef = useRef(''); // Track previous BEE content to prevent unnecessary updates
|
|
90
93
|
|
|
91
94
|
const isUpdatePreviewDisabled = useMemo(() => (
|
|
92
95
|
requiredTags.some((tag) => !customValues[tag.fullPath])
|
|
93
96
|
), [requiredTags, customValues]);
|
|
94
97
|
|
|
98
|
+
// Get the current content based on editor type
|
|
99
|
+
const getCurrentContent = useMemo(() => {
|
|
100
|
+
const currentTabData = formData[currentTab - 1];
|
|
101
|
+
const activeTab = currentTabData?.activeTab;
|
|
102
|
+
const isDragDrop = currentTabData?.[activeTab]?.is_drag_drop;
|
|
103
|
+
|
|
104
|
+
console.log('🔍 getCurrentContent computed:', {
|
|
105
|
+
beeInstance: !!beeInstance,
|
|
106
|
+
isDragDrop,
|
|
107
|
+
beeContent: beeContent || 'EMPTY',
|
|
108
|
+
content: content || 'EMPTY',
|
|
109
|
+
templateContent: currentTabData?.[activeTab]?.[`template-content`] || 'EMPTY',
|
|
110
|
+
result: isDragDrop && beeContent ? beeContent : content
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
if (isDragDrop && beeContent) {
|
|
114
|
+
return beeContent; // Use BEE content if available
|
|
115
|
+
}
|
|
116
|
+
return content; // Fall back to content prop
|
|
117
|
+
}, [formData, currentTab, beeContent, content, beeInstance]);
|
|
118
|
+
|
|
95
119
|
useEffect(() => {
|
|
96
|
-
if
|
|
97
|
-
|
|
120
|
+
// Only save BEE content if we're actually using BEE editor
|
|
121
|
+
const currentTabData = formData[currentTab - 1];
|
|
122
|
+
const activeTab = currentTabData?.activeTab;
|
|
123
|
+
const isDragDrop = currentTabData?.[activeTab]?.is_drag_drop;
|
|
124
|
+
|
|
125
|
+
if (show && beeInstance && isDragDrop) {
|
|
126
|
+
// Check if we already have content in formData
|
|
127
|
+
const existingContent = currentTabData?.[activeTab]?.[`template-content`];
|
|
128
|
+
if (existingContent && existingContent.trim() !== '') {
|
|
129
|
+
// We already have content, update local state only if it's different
|
|
130
|
+
if (existingContent !== previousBeeContentRef.current) {
|
|
131
|
+
previousBeeContentRef.current = existingContent;
|
|
132
|
+
setBeeContent(existingContent);
|
|
133
|
+
setPreviewDataHtml({
|
|
134
|
+
resolvedBody: existingContent,
|
|
135
|
+
resolvedTitle: formData['template-subject'] || ''
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
// No content yet, trigger save
|
|
140
|
+
beeInstance.save();
|
|
141
|
+
}
|
|
98
142
|
}
|
|
99
|
-
}, [show, beeInstance]);
|
|
143
|
+
}, [show, beeInstance, currentTab]);
|
|
100
144
|
|
|
101
145
|
useEffect(() => {
|
|
102
146
|
if (show) {
|
|
147
|
+
// For BEE editor, ensure content is saved and synced first
|
|
148
|
+
const currentTabData = formData[currentTab - 1];
|
|
149
|
+
const activeTab = currentTabData?.activeTab;
|
|
150
|
+
const isDragDrop = currentTabData?.[activeTab]?.is_drag_drop;
|
|
151
|
+
|
|
152
|
+
console.log('🔍 Tag extraction debug:', {
|
|
153
|
+
show,
|
|
154
|
+
beeInstance: !!beeInstance,
|
|
155
|
+
isDragDrop,
|
|
156
|
+
currentTab,
|
|
157
|
+
activeTab,
|
|
158
|
+
currentTabData: !!currentTabData,
|
|
159
|
+
templateContent: currentTabData?.[activeTab]?.[`template-content`] || 'EMPTY',
|
|
160
|
+
contentProp: content || 'EMPTY',
|
|
161
|
+
getCurrentContent: getCurrentContent || 'EMPTY',
|
|
162
|
+
beeContentState: beeContent || 'EMPTY'
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
if (beeInstance && isDragDrop) {
|
|
166
|
+
console.log('🔍 Using BEE editor path for tag extraction');
|
|
167
|
+
|
|
168
|
+
// For BEE editor, trigger save first to ensure latest content is captured
|
|
169
|
+
console.log('🔍 Triggering BEE save to capture latest content...');
|
|
170
|
+
beeInstance.save();
|
|
171
|
+
|
|
172
|
+
// Get content from formData (which should have the latest BEE content)
|
|
173
|
+
const currentTabData = formData[currentTab - 1];
|
|
174
|
+
const activeTab = currentTabData?.activeTab;
|
|
175
|
+
const templateContent = currentTabData?.[activeTab]?.[`template-content`];
|
|
176
|
+
|
|
177
|
+
console.log('🔍 BEE content sources:', {
|
|
178
|
+
templateContent: templateContent || 'EMPTY',
|
|
179
|
+
beeContent: beeContent || 'EMPTY',
|
|
180
|
+
content: content || 'EMPTY'
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
// Use template content from formData if available, otherwise fall back to other sources
|
|
184
|
+
const beeContentToUse = templateContent || beeContent || content;
|
|
185
|
+
|
|
186
|
+
if (beeContentToUse && beeContentToUse.trim() !== '') {
|
|
187
|
+
console.log('🔍 Using BEE content for tag extraction:', beeContentToUse.substring(0, 100) + '...');
|
|
188
|
+
const payloadContent = convert(beeContentToUse, GLOBAL_CONVERT_OPTIONS);
|
|
189
|
+
console.log('🔍 Converted BEE content for tag extraction:', payloadContent || 'EMPTY');
|
|
190
|
+
actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
|
|
191
|
+
} else {
|
|
192
|
+
console.log('🔍 No BEE content available in any source');
|
|
193
|
+
// If no content available, wait a bit for the save to complete and try again
|
|
194
|
+
setTimeout(() => {
|
|
195
|
+
const updatedTemplateContent = formData[currentTab - 1]?.[activeTab]?.[`template-content`];
|
|
196
|
+
if (updatedTemplateContent && updatedTemplateContent.trim() !== '') {
|
|
197
|
+
console.log('🔍 BEE content now available after save:', updatedTemplateContent.substring(0, 100) + '...');
|
|
198
|
+
const payloadContent = convert(updatedTemplateContent, GLOBAL_CONVERT_OPTIONS);
|
|
199
|
+
actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
|
|
200
|
+
} else {
|
|
201
|
+
console.log('🔍 Still no BEE content, using empty content for tag extraction');
|
|
202
|
+
actions.extractTagsRequested(formData['template-subject'] || '', '');
|
|
203
|
+
}
|
|
204
|
+
}, 1000); // Wait 1 second for save to complete
|
|
205
|
+
}
|
|
206
|
+
} else {
|
|
207
|
+
console.log('🔍 Using non-BEE editor path for tag extraction');
|
|
208
|
+
console.log('🔍 Non-BEE content sources:', {
|
|
209
|
+
getCurrentContent: getCurrentContent || 'EMPTY',
|
|
210
|
+
contentProp: content || 'EMPTY'
|
|
211
|
+
});
|
|
212
|
+
// For non-BEE editor, use content prop directly
|
|
213
|
+
const payloadContent = convert(
|
|
214
|
+
getCurrentContent,
|
|
215
|
+
GLOBAL_CONVERT_OPTIONS
|
|
216
|
+
);
|
|
217
|
+
console.log('🔍 Converted content for tag extraction:', payloadContent || 'EMPTY');
|
|
218
|
+
actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
|
|
219
|
+
}
|
|
220
|
+
|
|
103
221
|
actions.fetchTestCustomersRequested();
|
|
104
222
|
actions.fetchTestGroupsRequested();
|
|
105
|
-
const payloadContent = convert(
|
|
106
|
-
content,
|
|
107
|
-
GLOBAL_CONVERT_OPTIONS
|
|
108
|
-
);
|
|
109
|
-
actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
|
|
110
223
|
}
|
|
111
|
-
}, [show,
|
|
224
|
+
}, [show, beeInstance, currentTab]);
|
|
225
|
+
|
|
226
|
+
// Single useEffect to handle BEE content updates without causing loops
|
|
227
|
+
useEffect(() => {
|
|
228
|
+
const currentTabData = formData[currentTab - 1];
|
|
229
|
+
const activeTab = currentTabData?.activeTab;
|
|
230
|
+
const isDragDrop = currentTabData?.[activeTab]?.is_drag_drop;
|
|
231
|
+
|
|
232
|
+
if (isDragDrop && currentTabData?.[activeTab]?.[`template-content`]) {
|
|
233
|
+
const newBeeContent = currentTabData[activeTab][`template-content`];
|
|
234
|
+
if (newBeeContent && newBeeContent.trim() !== '' && newBeeContent !== previousBeeContentRef.current) {
|
|
235
|
+
// Only update if content actually changed to prevent loops
|
|
236
|
+
previousBeeContentRef.current = newBeeContent;
|
|
237
|
+
setBeeContent(newBeeContent);
|
|
238
|
+
setPreviewDataHtml({
|
|
239
|
+
resolvedBody: newBeeContent,
|
|
240
|
+
resolvedTitle: formData['template-subject'] || ''
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}, [formData, currentTab]);
|
|
245
|
+
|
|
246
|
+
// Cleanup effect to reset ref when slidebox closes
|
|
247
|
+
useEffect(() => {
|
|
248
|
+
if (!show) {
|
|
249
|
+
previousBeeContentRef.current = '';
|
|
250
|
+
setBeeContent('');
|
|
251
|
+
setPreviewDataHtml('');
|
|
252
|
+
}
|
|
253
|
+
}, [show]);
|
|
112
254
|
|
|
113
255
|
useEffect(() => {
|
|
114
256
|
if (previewData) {
|
|
@@ -281,14 +423,43 @@ const TestAndPreviewSlidebox = (props) => {
|
|
|
281
423
|
};
|
|
282
424
|
|
|
283
425
|
// Handle update preview
|
|
284
|
-
const handleUpdatePreview = () => {
|
|
426
|
+
const handleUpdatePreview = async () => {
|
|
427
|
+
// For BEE editor, ensure content is saved first
|
|
428
|
+
const currentTabData = formData[currentTab - 1];
|
|
429
|
+
const activeTab = currentTabData?.activeTab;
|
|
430
|
+
|
|
431
|
+
// Get latest content from BEE editor if needed
|
|
432
|
+
if (beeInstance && currentTabData?.[activeTab]?.is_drag_drop) {
|
|
433
|
+
// Trigger save to ensure latest content
|
|
434
|
+
beeInstance.save();
|
|
435
|
+
|
|
436
|
+
// Wait a bit for save to complete
|
|
437
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
438
|
+
|
|
439
|
+
// Get latest content from BEE editor
|
|
440
|
+
beeInstance.getContent((jsonFile, htmlFile) => {
|
|
441
|
+
const payload = {
|
|
442
|
+
channel: EMAIL,
|
|
443
|
+
messageTitle: formData['template-subject'],
|
|
444
|
+
messageBody: htmlFile || getCurrentContent,
|
|
445
|
+
resolvedTags: customValues,
|
|
446
|
+
userId: selectedCustomer?.customerId,
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
actions.updatePreviewRequested(payload);
|
|
450
|
+
});
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// Use current content for non-BEE editor
|
|
285
455
|
const payload = {
|
|
286
456
|
channel: EMAIL,
|
|
287
457
|
messageTitle: formData['template-subject'],
|
|
288
|
-
messageBody:
|
|
458
|
+
messageBody: getCurrentContent,
|
|
289
459
|
resolvedTags: customValues,
|
|
290
460
|
userId: selectedCustomer?.customerId,
|
|
291
461
|
};
|
|
462
|
+
|
|
292
463
|
actions.updatePreviewRequested(payload);
|
|
293
464
|
};
|
|
294
465
|
|
|
@@ -316,7 +487,7 @@ const TestAndPreviewSlidebox = (props) => {
|
|
|
316
487
|
...INITIAL_PAYLOAD,
|
|
317
488
|
emailMessageContent: {
|
|
318
489
|
channel: EMAIL,
|
|
319
|
-
messageBody: previewData?.resolvedBody ||
|
|
490
|
+
messageBody: previewData?.resolvedBody || getCurrentContent,
|
|
320
491
|
messageSubject: previewData?.resolvedTitle || formData['template-subject'],
|
|
321
492
|
},
|
|
322
493
|
}, messageMetaConfigId, (response) => {
|
|
@@ -408,7 +579,7 @@ const TestAndPreviewSlidebox = (props) => {
|
|
|
408
579
|
formData={formData}
|
|
409
580
|
isUpdatingPreview={isUpdatingPreview}
|
|
410
581
|
previewDataHtml={previewDataHtml}
|
|
411
|
-
content={
|
|
582
|
+
content={getCurrentContent}
|
|
412
583
|
formatMessage={formatMessage}
|
|
413
584
|
PreviewChrome={PreviewChrome}
|
|
414
585
|
/>
|
|
@@ -548,6 +719,7 @@ TestAndPreviewSlidebox.propTypes = {
|
|
|
548
719
|
prefilledValues: PropTypes.object,
|
|
549
720
|
isSendingTestMessage: PropTypes.bool.isRequired,
|
|
550
721
|
beeInstance: PropTypes.object.isRequired,
|
|
722
|
+
currentTab: PropTypes.number,
|
|
551
723
|
};
|
|
552
724
|
|
|
553
725
|
TestAndPreviewSlidebox.defaultProps = {
|
|
@@ -555,6 +727,7 @@ TestAndPreviewSlidebox.defaultProps = {
|
|
|
555
727
|
currentChannel: EMAIL,
|
|
556
728
|
messageMetaConfigId: null,
|
|
557
729
|
prefilledValues: {},
|
|
730
|
+
currentTab: 1,
|
|
558
731
|
};
|
|
559
732
|
|
|
560
733
|
// Redux connection
|
|
@@ -91,7 +91,7 @@ describe('PreviewSection', () => {
|
|
|
91
91
|
</TestWrapper>
|
|
92
92
|
);
|
|
93
93
|
|
|
94
|
-
expect(container.querySelector('.preview-section')).toBeTruthy();
|
|
94
|
+
expect(container.querySelector('.test-and-preview-section')).toBeTruthy();
|
|
95
95
|
expect(container.querySelector('.panel-section')).toBeTruthy();
|
|
96
96
|
});
|
|
97
97
|
});
|
|
@@ -163,7 +163,9 @@ export function SlideBoxContent(props) {
|
|
|
163
163
|
showTestAndPreviewSlidebox,
|
|
164
164
|
handleTestAndPreview,
|
|
165
165
|
handleCloseTestAndPreview,
|
|
166
|
+
isTestAndPreviewMode,
|
|
166
167
|
} = props;
|
|
168
|
+
console.log('📥 SlideBoxContent received isTestAndPreviewMode:', isTestAndPreviewMode);
|
|
167
169
|
const type = (messageDetails.type || '').toLowerCase(); // type is context in get tags values : outbound | dvs | referral | loyalty | coupons
|
|
168
170
|
const query = { type: !isFullMode && 'embedded', module: isFullMode ? 'default' : 'library', isEditFromCampaigns: (templateData || {}).isEditFromCampaigns};
|
|
169
171
|
const creativesLocationProps = {
|
|
@@ -594,7 +596,7 @@ export function SlideBoxContent(props) {
|
|
|
594
596
|
/>
|
|
595
597
|
)}
|
|
596
598
|
|
|
597
|
-
|
|
599
|
+
{isEmailCreate && (
|
|
598
600
|
<EmailWrapper
|
|
599
601
|
key="creatives-email-wrapper"
|
|
600
602
|
date={new Date().getMilliseconds()}
|
|
@@ -626,7 +628,8 @@ export function SlideBoxContent(props) {
|
|
|
626
628
|
isLoyaltyModule={isLoyaltyModule}
|
|
627
629
|
showTestAndPreviewSlidebox={showTestAndPreviewSlidebox}
|
|
628
630
|
handleTestAndPreview={handleTestAndPreview}
|
|
629
|
-
handleCloseTestAndPreview={handleCloseTestAndPreview}
|
|
631
|
+
handleCloseTestAndPreview={handleCloseTestAndPreview}
|
|
632
|
+
isTestAndPreviewMode={isTestAndPreviewMode}
|
|
630
633
|
/>
|
|
631
634
|
)}
|
|
632
635
|
{(isEditEmailWithId || isEmailEditWithContent) && (
|
|
@@ -660,6 +663,10 @@ export function SlideBoxContent(props) {
|
|
|
660
663
|
showTestAndPreviewSlidebox={showTestAndPreviewSlidebox}
|
|
661
664
|
handleTestAndPreview={handleTestAndPreview}
|
|
662
665
|
handleCloseTestAndPreview={handleCloseTestAndPreview}
|
|
666
|
+
isTestAndPreviewMode={(() => {
|
|
667
|
+
console.log('📤 SlideBoxContent passing isTestAndPreviewMode:', isTestAndPreviewMode);
|
|
668
|
+
return isTestAndPreviewMode;
|
|
669
|
+
})()}
|
|
663
670
|
/>
|
|
664
671
|
)}
|
|
665
672
|
{isEditMPush && (
|
|
@@ -1055,6 +1062,7 @@ SlideBoxContent.propTypes = {
|
|
|
1055
1062
|
hostName: PropTypes.string,
|
|
1056
1063
|
showTestAndPreviewSlidebox: PropTypes.bool,
|
|
1057
1064
|
handleTestAndPreview: PropTypes.func,
|
|
1058
|
-
handleCloseTestAndPreview: PropTypes.func
|
|
1065
|
+
handleCloseTestAndPreview: PropTypes.func,
|
|
1066
|
+
isTestAndPreviewMode: PropTypes.bool
|
|
1059
1067
|
};
|
|
1060
1068
|
export default SlideBoxContent;
|
|
@@ -103,6 +103,7 @@ export class Creatives extends React.Component {
|
|
|
103
103
|
activeFormBuilderTab: constants.ANDROID,
|
|
104
104
|
// NEW: Test and Preview feature state
|
|
105
105
|
showTestAndPreviewSlidebox: false,
|
|
106
|
+
isTestAndPreviewMode: false, // Add flag to track Test & Preview mode
|
|
106
107
|
};
|
|
107
108
|
this.liquidFlow = Boolean(commonUtil.hasLiquidSupportFeature());
|
|
108
109
|
this.creativesTemplateSteps = {
|
|
@@ -877,7 +878,7 @@ export class Creatives extends React.Component {
|
|
|
877
878
|
const { Templates, templateData: templateDataProps } = this.props;
|
|
878
879
|
const selectedWhatsappAccount = Templates?.selectedWhatsappAccount;
|
|
879
880
|
const { accountDetails: selectedAccountDetails, accountId: selectedAccountId } = templateDataProps || {};
|
|
880
|
-
const accountDetails = (selectedWhatsappAccount
|
|
881
|
+
const accountDetails = (selectedWhatsappAccount || selectedAccountDetails);
|
|
881
882
|
const accountId = selectedAccountId || (selectedWhatsappAccount?.id || '');
|
|
882
883
|
const { versions } = template.value;
|
|
883
884
|
const {
|
|
@@ -917,13 +918,12 @@ export class Creatives extends React.Component {
|
|
|
917
918
|
//to send {{unsubscribe}} to backend inside varMapped
|
|
918
919
|
const unsubscribeRegex = /Click {{unsubscribe}} to unsubscribe/g;
|
|
919
920
|
if (
|
|
920
|
-
languages[0].content?.match(unsubscribeRegex)?.length > 0
|
|
921
|
-
Object.keys(varMapped)?.every(
|
|
921
|
+
languages[0].content?.match(unsubscribeRegex)?.length > 0
|
|
922
|
+
&& Object.keys(varMapped)?.every(
|
|
922
923
|
(key) => !key?.includes("_unsubscribe")
|
|
923
924
|
)
|
|
924
925
|
) {
|
|
925
|
-
varMapped[`{{${Object.keys(varMapped).length + 1}}}_unsubscribe`] =
|
|
926
|
-
"{{unsubscribe}}";
|
|
926
|
+
varMapped[`{{${Object.keys(varMapped).length + 1}}}_unsubscribe`] = "{{unsubscribe}}";
|
|
927
927
|
}
|
|
928
928
|
const whatsappMedia = {
|
|
929
929
|
header,
|
|
@@ -1255,14 +1255,26 @@ export class Creatives extends React.Component {
|
|
|
1255
1255
|
this.setState({ isDiscardMessage: true });
|
|
1256
1256
|
}
|
|
1257
1257
|
|
|
1258
|
+
|
|
1259
|
+
|
|
1258
1260
|
// NEW: Handler for Test and Preview button
|
|
1259
1261
|
handleTestAndPreview = () => {
|
|
1260
|
-
|
|
1262
|
+
console.log('🔓 CreativesContainer handleTestAndPreview called');
|
|
1263
|
+
console.log('🔓 Setting isTestAndPreviewMode to true');
|
|
1264
|
+
this.setState({
|
|
1265
|
+
showTestAndPreviewSlidebox: true,
|
|
1266
|
+
isTestAndPreviewMode: true, // Set flag to prevent validation
|
|
1267
|
+
});
|
|
1261
1268
|
}
|
|
1262
1269
|
|
|
1263
1270
|
// NEW: Handler to close Test and Preview slidebox
|
|
1264
1271
|
handleCloseTestAndPreview = () => {
|
|
1265
|
-
|
|
1272
|
+
console.log('🔒 CreativesContainer handleCloseTestAndPreview called');
|
|
1273
|
+
console.log('🔒 Setting isTestAndPreviewMode to false');
|
|
1274
|
+
this.setState({
|
|
1275
|
+
showTestAndPreviewSlidebox: false,
|
|
1276
|
+
isTestAndPreviewMode: false, // Reset flag when closing
|
|
1277
|
+
});
|
|
1266
1278
|
}
|
|
1267
1279
|
|
|
1268
1280
|
shouldShowFooter = () => {
|
|
@@ -1300,8 +1312,8 @@ export class Creatives extends React.Component {
|
|
|
1300
1312
|
}
|
|
1301
1313
|
if (channel === constants.MOBILE_PUSH
|
|
1302
1314
|
&& ((slidBoxContent === 'createTemplate' && !isEmpty(mobilePushCreateMode))
|
|
1303
|
-
|| (slidBoxContent === 'editTemplate' && (currentStep === 'modeSelection' || isFullMode)))
|
|
1304
|
-
templateNameExists) {
|
|
1315
|
+
|| (slidBoxContent === 'editTemplate' && (currentStep === 'modeSelection' || isFullMode)))
|
|
1316
|
+
&& templateNameExists) {
|
|
1305
1317
|
showFooter = true;
|
|
1306
1318
|
}
|
|
1307
1319
|
|
|
@@ -1312,8 +1324,8 @@ export class Creatives extends React.Component {
|
|
|
1312
1324
|
}
|
|
1313
1325
|
|
|
1314
1326
|
if (showFooter) {
|
|
1315
|
-
if (slidBoxContent === "createTemplate" && ((channel === constants.EMAIL && currentStep === 'createTemplateContent')
|
|
1316
|
-
([constants.SMS, constants.WECHAT].includes(channel) && currentStep === 'modeSelection'))) {
|
|
1327
|
+
if (slidBoxContent === "createTemplate" && ((channel === constants.EMAIL && currentStep === 'createTemplateContent')
|
|
1328
|
+
|| ([constants.SMS, constants.WECHAT].includes(channel) && currentStep === 'modeSelection'))) {
|
|
1317
1329
|
showFooter = showFooter && !this.state.isLoadingContent;
|
|
1318
1330
|
} else if (slidBoxContent === "editTemplate"
|
|
1319
1331
|
&& ([constants.SMS, constants.WECHAT, constants.EMAIL].includes(channel)
|
|
@@ -1378,7 +1390,7 @@ export class Creatives extends React.Component {
|
|
|
1378
1390
|
onBlur={() => { this.setState({ isEditName: false }, () => { this.showTemplateName({ formData, onFormDataChange }); }); }}
|
|
1379
1391
|
onChange={(ev) => {
|
|
1380
1392
|
const { value } = ev.currentTarget;
|
|
1381
|
-
const isEmptyTemplateName = value.trim()
|
|
1393
|
+
const isEmptyTemplateName = !value.trim();
|
|
1382
1394
|
|
|
1383
1395
|
const newFormData = { ...formData, 'template-name': value, 'isTemplateNameEdited': true };
|
|
1384
1396
|
this.setState({ isTemplateNameEmpty: isEmptyTemplateName });
|
|
@@ -1405,7 +1417,6 @@ export class Creatives extends React.Component {
|
|
|
1405
1417
|
}
|
|
1406
1418
|
|
|
1407
1419
|
showLiquidErrorInFooter = (errorMessagesFromFormBuilder, currentFormBuilderTab) => {
|
|
1408
|
-
|
|
1409
1420
|
this.setState({
|
|
1410
1421
|
isLiquidValidationError: !isEmpty(get(errorMessagesFromFormBuilder, constants.LIQUID_ERROR_MSG, [])) || !isEmpty(get(errorMessagesFromFormBuilder, constants.STANDARD_ERROR_MSG, [])),
|
|
1411
1422
|
liquidErrorMessage: errorMessagesFromFormBuilder,
|
|
@@ -1476,6 +1487,7 @@ export class Creatives extends React.Component {
|
|
|
1476
1487
|
liquidErrorMessage,
|
|
1477
1488
|
activeFormBuilderTab,
|
|
1478
1489
|
showTestAndPreviewSlidebox,
|
|
1490
|
+
isTestAndPreviewMode,
|
|
1479
1491
|
} = this.state;
|
|
1480
1492
|
const {
|
|
1481
1493
|
isFullMode,
|
|
@@ -1498,8 +1510,7 @@ export class Creatives extends React.Component {
|
|
|
1498
1510
|
isLoyaltyModule,
|
|
1499
1511
|
loyaltyMetaData = {},
|
|
1500
1512
|
} = this.props;
|
|
1501
|
-
const mapTemplateCreate =
|
|
1502
|
-
slidBoxContent === "createTemplate"
|
|
1513
|
+
const mapTemplateCreate = slidBoxContent === "createTemplate"
|
|
1503
1514
|
&& weChatTemplateType === MAP_TEMPLATE
|
|
1504
1515
|
&& templateStep !== "modeSelection";
|
|
1505
1516
|
const slideBoxWrapperMargin = (get(liquidErrorMessage, 'STANDARD_ERROR_MSG.length', 0) > 0 && get(liquidErrorMessage, 'LIQUID_ERROR_MSG.length', 0) > 0)
|
|
@@ -1606,6 +1617,10 @@ export class Creatives extends React.Component {
|
|
|
1606
1617
|
showTestAndPreviewSlidebox={showTestAndPreviewSlidebox}
|
|
1607
1618
|
handleTestAndPreview={this.handleTestAndPreview}
|
|
1608
1619
|
handleCloseTestAndPreview={this.handleCloseTestAndPreview}
|
|
1620
|
+
isTestAndPreviewMode={(() => {
|
|
1621
|
+
console.log('📤 CreativesContainer passing isTestAndPreviewMode:', this.state.isTestAndPreviewMode);
|
|
1622
|
+
return this.state.isTestAndPreviewMode;
|
|
1623
|
+
})()}
|
|
1609
1624
|
/>
|
|
1610
1625
|
)}
|
|
1611
1626
|
footer={this.shouldShowFooter() ? (
|
|
@@ -17,6 +17,7 @@ exports[`Test SlideBoxContent container campaign message, add creative click rcs
|
|
|
17
17
|
handleCloseTestAndPreview={[Function]}
|
|
18
18
|
handleTestAndPreview={[Function]}
|
|
19
19
|
hostName=""
|
|
20
|
+
isTestAndPreviewMode={false}
|
|
20
21
|
loyaltyMetaData={
|
|
21
22
|
Object {
|
|
22
23
|
"actionName": "SEND_COMMUNICATION_ACTION",
|
|
@@ -102,6 +103,7 @@ exports[`Test SlideBoxContent container campaign message, add creative click wha
|
|
|
102
103
|
handleCloseTestAndPreview={[Function]}
|
|
103
104
|
handleTestAndPreview={[Function]}
|
|
104
105
|
hostName=""
|
|
106
|
+
isTestAndPreviewMode={false}
|
|
105
107
|
loyaltyMetaData={
|
|
106
108
|
Object {
|
|
107
109
|
"actionName": "SEND_COMMUNICATION_ACTION",
|
|
@@ -187,6 +189,7 @@ exports[`Test SlideBoxContent container campaign message, whatsapp edit all data
|
|
|
187
189
|
handleCloseTestAndPreview={[Function]}
|
|
188
190
|
handleTestAndPreview={[Function]}
|
|
189
191
|
hostName=""
|
|
192
|
+
isTestAndPreviewMode={false}
|
|
190
193
|
loyaltyMetaData={
|
|
191
194
|
Object {
|
|
192
195
|
"actionName": "SEND_COMMUNICATION_ACTION",
|
|
@@ -284,6 +287,7 @@ exports[`Test SlideBoxContent container campaign message, whatsapp edit min data
|
|
|
284
287
|
handleCloseTestAndPreview={[Function]}
|
|
285
288
|
handleTestAndPreview={[Function]}
|
|
286
289
|
hostName=""
|
|
290
|
+
isTestAndPreviewMode={false}
|
|
287
291
|
loyaltyMetaData={
|
|
288
292
|
Object {
|
|
289
293
|
"actionName": "SEND_COMMUNICATION_ACTION",
|
|
@@ -381,6 +385,7 @@ exports[`Test SlideBoxContent container it should clear the url, on channel chan
|
|
|
381
385
|
handleCloseTestAndPreview={[Function]}
|
|
382
386
|
handleTestAndPreview={[Function]}
|
|
383
387
|
hostName=""
|
|
388
|
+
isTestAndPreviewMode={false}
|
|
384
389
|
loyaltyMetaData={
|
|
385
390
|
Object {
|
|
386
391
|
"actionName": "SEND_COMMUNICATION_ACTION",
|