@capillarytech/creatives-library 8.0.236-beta.0 → 8.0.236
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/services/api.js +0 -5
- package/utils/common.js +1 -6
- package/v2Components/CapTagList/index.js +1 -2
- package/v2Components/CapTagListWithInput/index.js +1 -5
- package/v2Components/CapTagListWithInput/messages.js +1 -1
- package/v2Components/ErrorInfoNote/style.scss +1 -1
- package/v2Components/HtmlEditor/HTMLEditor.js +14 -86
- package/v2Components/HtmlEditor/_htmlEditor.scss +4 -0
- package/v2Components/HtmlEditor/_index.lazy.scss +1 -1
- package/v2Components/HtmlEditor/components/CodeEditorPane/_codeEditorPane.scss +98 -11
- package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +115 -174
- package/v2Components/HtmlEditor/components/SplitContainer/_splitContainer.scss +1 -1
- package/v2Components/HtmlEditor/hooks/useEditorContent.js +2 -5
- package/v2Components/TestAndPreviewSlidebox/index.js +25 -31
- package/v2Containers/CreativesContainer/SlideBoxContent.js +35 -83
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +3 -9
- package/v2Containers/CreativesContainer/index.js +11 -83
- package/v2Containers/CreativesContainer/messages.js +0 -4
- package/v2Containers/Email/actions.js +0 -7
- package/v2Containers/Email/constants.js +1 -5
- package/v2Containers/Email/index.js +0 -13
- package/v2Containers/Email/messages.js +0 -32
- package/v2Containers/Email/reducer.js +1 -12
- package/v2Containers/Email/sagas.js +0 -17
- package/v2Containers/EmailWrapper/components/EmailWrapperView.js +7 -193
- package/v2Containers/EmailWrapper/constants.js +0 -2
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +67 -436
- package/v2Containers/EmailWrapper/index.js +23 -99
- package/v2Containers/EmailWrapper/messages.js +1 -61
- package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +49 -49
- package/v2Containers/TagList/index.js +0 -2
- package/v2Containers/Templates/index.js +0 -5
- package/HOW_BEE_EDITOR_WORKS.md +0 -375
- package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +0 -1034
- package/v2Containers/EmailWrapper/tests/EmailHTMLEditor.test.js +0 -177
- package/v2Containers/EmailWrapper/tests/EmailHTMLEditorValidation.test.js +0 -90
|
@@ -9,7 +9,6 @@ import { connect } from 'react-redux';
|
|
|
9
9
|
import { injectIntl, intlShape } from 'react-intl';
|
|
10
10
|
import { createStructuredSelector } from 'reselect';
|
|
11
11
|
import { bindActionCreators } from 'redux';
|
|
12
|
-
import { compose } from 'redux';
|
|
13
12
|
import { UserIsAuthenticated } from '../../utils/authWrapper';
|
|
14
13
|
import {
|
|
15
14
|
selectEmailLayout,
|
|
@@ -19,17 +18,10 @@ import {
|
|
|
19
18
|
selectCmsTemplatesLoader,
|
|
20
19
|
} from '../Templates/selectors';
|
|
21
20
|
import * as templatesActionsCreators from '../Templates/actions';
|
|
22
|
-
import { selectCurrentOrgDetails
|
|
23
|
-
import { makeSelectEmail, selectLoadingStatus, makeSelectFetchingCmsData } from '../Email/selectors';
|
|
24
|
-
import * as emailActionsCreators from '../Email/actions';
|
|
25
|
-
import * as globalActions from '../Cap/actions';
|
|
21
|
+
import { selectCurrentOrgDetails } from "../../v2Containers/Cap/selectors";
|
|
26
22
|
import EmailWrapperView from './components/EmailWrapperView';
|
|
27
23
|
import useEmailWrapper from './hooks/useEmailWrapper';
|
|
28
24
|
import HTMLEditorTesting from './components/HTMLEditorTesting';
|
|
29
|
-
import injectReducer from '../../utils/injectReducer';
|
|
30
|
-
import injectSaga from '../../utils/injectSaga';
|
|
31
|
-
import v2EmailReducer from '../Email/reducer';
|
|
32
|
-
import { v2EmailSagas } from '../Email/sagas';
|
|
33
25
|
|
|
34
26
|
|
|
35
27
|
const EmailWrapper = (props) => {
|
|
@@ -72,18 +64,6 @@ const EmailWrapper = (props) => {
|
|
|
72
64
|
handleTestAndPreview,
|
|
73
65
|
handleCloseTestAndPreview,
|
|
74
66
|
isTestAndPreviewMode,
|
|
75
|
-
location,
|
|
76
|
-
emailActions,
|
|
77
|
-
Email,
|
|
78
|
-
metaEntities,
|
|
79
|
-
loadingTags,
|
|
80
|
-
injectedTags,
|
|
81
|
-
globalActions: globalActionsProp,
|
|
82
|
-
templateData,
|
|
83
|
-
params,
|
|
84
|
-
fetchingLiquidTags,
|
|
85
|
-
createTemplateInProgress,
|
|
86
|
-
fetchingCmsData,
|
|
87
67
|
} = props;
|
|
88
68
|
|
|
89
69
|
// Pass destructured props to the custom hook
|
|
@@ -137,68 +117,32 @@ const EmailWrapper = (props) => {
|
|
|
137
117
|
handleTestAndPreview,
|
|
138
118
|
handleCloseTestAndPreview,
|
|
139
119
|
isTestAndPreviewMode,
|
|
140
|
-
location,
|
|
141
|
-
emailActions,
|
|
142
|
-
Email,
|
|
143
|
-
templateData,
|
|
144
|
-
params,
|
|
145
120
|
});
|
|
146
121
|
|
|
147
122
|
// Render using the presentation component with data from the hook
|
|
148
123
|
return (
|
|
149
124
|
<div>
|
|
150
125
|
<EmailWrapperView
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
// These props are needed for EmailHTMLEditor component (tag loading, validation, etc.)
|
|
172
|
-
metaEntities={metaEntities}
|
|
173
|
-
loadingTags={loadingTags}
|
|
174
|
-
injectedTags={injectedTags}
|
|
175
|
-
globalActions={globalActionsProp}
|
|
176
|
-
supportedTags={props.supportedTags}
|
|
177
|
-
getDefaultTags={type}
|
|
178
|
-
location={location}
|
|
179
|
-
currentOrgDetails={currentOrgDetails}
|
|
180
|
-
onValidationFail={onValidationFail}
|
|
181
|
-
forwardedTags={forwardedTags}
|
|
182
|
-
selectedOfferDetails={selectedOfferDetails}
|
|
183
|
-
eventContextTags={eventContextTags}
|
|
184
|
-
getFormdata={getFormdata}
|
|
185
|
-
isGetFormData={isGetFormData}
|
|
186
|
-
getLiquidTags={globalActionsProp?.getLiquidTags}
|
|
187
|
-
showLiquidErrorInFooter={showLiquidErrorInFooter}
|
|
188
|
-
intl={intl}
|
|
189
|
-
emailActions={emailActions}
|
|
190
|
-
showTestAndPreviewSlidebox={showTestAndPreviewSlidebox}
|
|
191
|
-
handleTestAndPreview={handleTestAndPreview}
|
|
192
|
-
handleCloseTestAndPreview={handleCloseTestAndPreview}
|
|
193
|
-
Email={Email}
|
|
194
|
-
setIsLoadingContent={setIsLoadingContent}
|
|
195
|
-
templateData={templateData}
|
|
196
|
-
params={params}
|
|
197
|
-
showTemplateName={showTemplateName}
|
|
198
|
-
fetchingLiquidTags={fetchingLiquidTags}
|
|
199
|
-
createTemplateInProgress={createTemplateInProgress}
|
|
200
|
-
fetchingCmsData={fetchingCmsData}
|
|
201
|
-
/>
|
|
126
|
+
isUploading={isUploading}
|
|
127
|
+
emailCreateMode={emailCreateMode}
|
|
128
|
+
step={step}
|
|
129
|
+
isFullMode={isFullMode}
|
|
130
|
+
templateName={templateName}
|
|
131
|
+
onTemplateNameChange={onTemplateNameChange}
|
|
132
|
+
isTemplateNameEmpty={isTemplateNameEmpty}
|
|
133
|
+
modes={modes}
|
|
134
|
+
onChange={onChange}
|
|
135
|
+
EmailLayout={EmailLayout}
|
|
136
|
+
modeContent={modeContent}
|
|
137
|
+
useFileUpload={useFileUpload}
|
|
138
|
+
uploadButtonLabel={uploadButtonLabel}
|
|
139
|
+
isShowEmailCreate={isShowEmailCreate}
|
|
140
|
+
emailProps={emailProps}
|
|
141
|
+
cmsTemplatesProps={cmsTemplatesProps}
|
|
142
|
+
onPreviewContentClicked={onPreviewContentClicked}
|
|
143
|
+
onTestContentClicked={onTestContentClicked}
|
|
144
|
+
editor={editor}
|
|
145
|
+
/>
|
|
202
146
|
|
|
203
147
|
{/* HTMLEditor Testing Component - Console Controlled */}
|
|
204
148
|
<HTMLEditorTesting />
|
|
@@ -215,7 +159,7 @@ EmailWrapper.propTypes = {
|
|
|
215
159
|
templatesActions: PropTypes.object,
|
|
216
160
|
CmsTemplates: PropTypes.arrayOf(PropTypes.object),
|
|
217
161
|
SelectedEdmDefaultTemplate: PropTypes.object,
|
|
218
|
-
step: PropTypes.
|
|
162
|
+
step: PropTypes.string,
|
|
219
163
|
showNextStep: PropTypes.func,
|
|
220
164
|
getFormdata: PropTypes.func,
|
|
221
165
|
intl: intlShape,
|
|
@@ -243,7 +187,6 @@ EmailWrapper.propTypes = {
|
|
|
243
187
|
handleTestAndPreview: PropTypes.func,
|
|
244
188
|
handleCloseTestAndPreview: PropTypes.func,
|
|
245
189
|
isTestAndPreviewMode: PropTypes.bool,
|
|
246
|
-
location: PropTypes.object,
|
|
247
190
|
};
|
|
248
191
|
|
|
249
192
|
const mapStateToProps = createStructuredSelector({
|
|
@@ -253,31 +196,12 @@ const mapStateToProps = createStructuredSelector({
|
|
|
253
196
|
isUploading: uploadSelector(),
|
|
254
197
|
cmsTemplatesLoader: selectCmsTemplatesLoader(),
|
|
255
198
|
currentOrgDetails: selectCurrentOrgDetails(),
|
|
256
|
-
Email: makeSelectEmail(),
|
|
257
|
-
metaEntities: makeSelectMetaEntities(),
|
|
258
|
-
loadingTags: isLoadingMetaEntities(),
|
|
259
|
-
injectedTags: setInjectedTags(),
|
|
260
|
-
fetchingLiquidTags: selectLiquidStateDetails(),
|
|
261
|
-
createTemplateInProgress: selectLoadingStatus(),
|
|
262
|
-
fetchingCmsData: makeSelectFetchingCmsData(),
|
|
263
199
|
});
|
|
264
200
|
|
|
265
201
|
function mapDispatchToProps(dispatch) {
|
|
266
202
|
return {
|
|
267
203
|
templatesActions: bindActionCreators(templatesActionsCreators, dispatch),
|
|
268
|
-
emailActions: bindActionCreators(emailActionsCreators, dispatch),
|
|
269
|
-
globalActions: bindActionCreators(globalActions, dispatch),
|
|
270
204
|
};
|
|
271
205
|
}
|
|
272
206
|
|
|
273
|
-
|
|
274
|
-
const withReducer = injectReducer({ key: 'email', reducer: v2EmailReducer });
|
|
275
|
-
const withEmailSaga = injectSaga({ key: 'email', saga: v2EmailSagas });
|
|
276
|
-
|
|
277
|
-
const ConnectedEmailWrapper = connect(mapStateToProps, mapDispatchToProps)(injectIntl(EmailWrapper));
|
|
278
|
-
|
|
279
|
-
export default compose(
|
|
280
|
-
UserIsAuthenticated,
|
|
281
|
-
withReducer,
|
|
282
|
-
withEmailSaga,
|
|
283
|
-
)(ConnectedEmailWrapper);
|
|
207
|
+
export default UserIsAuthenticated(connect(mapStateToProps, mapDispatchToProps)(injectIntl(EmailWrapper)));
|
|
@@ -60,66 +60,6 @@ export default defineMessages({
|
|
|
60
60
|
},
|
|
61
61
|
emptyTemplateName: {
|
|
62
62
|
id: `creatives.containersV2.EmailWrapper.emptyTemplateName`,
|
|
63
|
-
defaultMessage: `Please enter template name
|
|
64
|
-
},
|
|
65
|
-
htmlEditorTitle: {
|
|
66
|
-
id: 'creatives.EmailWrapper.htmlEditorTitle',
|
|
67
|
-
defaultMessage: 'HTML editor',
|
|
68
|
-
},
|
|
69
|
-
htmlEditorDesc: {
|
|
70
|
-
id: 'creatives.EmailWrapper.htmlEditorDesc',
|
|
71
|
-
defaultMessage: 'Use a basic HTML editor to write and format your content. Suitable if you are familiar with HTML.',
|
|
72
|
-
},
|
|
73
|
-
dragDropEditorTitle: {
|
|
74
|
-
id: 'creatives.EmailWrapper.dragDropEditorTitle',
|
|
75
|
-
defaultMessage: 'Drag & drop editor',
|
|
76
|
-
},
|
|
77
|
-
dragDropEditorDesc: {
|
|
78
|
-
id: 'creatives.EmailWrapper.dragDropEditorDesc',
|
|
79
|
-
defaultMessage: 'Create your content visually by dragging blocks — no coding needed. Great for quick, easy designs.',
|
|
80
|
-
},
|
|
81
|
-
uploadZipTitle: {
|
|
82
|
-
id: 'creatives.EmailWrapper.uploadZipTitle',
|
|
83
|
-
defaultMessage: 'Upload zip file',
|
|
84
|
-
},
|
|
85
|
-
uploadZipDesc: {
|
|
86
|
-
id: 'creatives.EmailWrapper.uploadZipDesc',
|
|
87
|
-
defaultMessage: 'Upload a ZIP containing your custom HTML, images, and assets. Ideal if your content is already built.',
|
|
88
|
-
},
|
|
89
|
-
next: {
|
|
90
|
-
id: 'creatives.EmailWrapper.next',
|
|
91
|
-
defaultMessage: 'Next',
|
|
92
|
-
},
|
|
93
|
-
beeEditorDisabledTooltip: {
|
|
94
|
-
id: 'creatives.EmailWrapper.beeEditorDisabledTooltip',
|
|
95
|
-
defaultMessage: 'Please get the drag & drop editor enabled for your brand',
|
|
96
|
-
},
|
|
97
|
-
emailContent: {
|
|
98
|
-
id: 'creatives.containersV2.Email.emailContent',
|
|
99
|
-
defaultMessage: 'Email content',
|
|
100
|
-
},
|
|
101
|
-
create: {
|
|
102
|
-
id: 'creatives.containersV2.EmailWrapper.create',
|
|
103
|
-
defaultMessage: 'Create',
|
|
104
|
-
},
|
|
105
|
-
update: {
|
|
106
|
-
id: 'creatives.containersV2.EmailWrapper.update',
|
|
107
|
-
defaultMessage: 'Update',
|
|
108
|
-
},
|
|
109
|
-
previewAndTest: {
|
|
110
|
-
id: 'creatives.containersV2.EmailWrapper.previewAndTest',
|
|
111
|
-
defaultMessage: 'Preview and Test',
|
|
112
|
-
},
|
|
113
|
-
required: {
|
|
114
|
-
id: 'creatives.containersV2.EmailWrapper.required',
|
|
115
|
-
defaultMessage: 'Required',
|
|
116
|
-
},
|
|
117
|
-
subject: {
|
|
118
|
-
id: 'creatives.containersV2.EmailWrapper.subject',
|
|
119
|
-
defaultMessage: 'Subject',
|
|
120
|
-
},
|
|
121
|
-
enterEmailSubject: {
|
|
122
|
-
id: 'creatives.containersV2.EmailWrapper.enterEmailSubject',
|
|
123
|
-
defaultMessage: 'Enter Email Subject',
|
|
63
|
+
defaultMessage: `Please enter template name.`
|
|
124
64
|
},
|
|
125
65
|
});
|
|
@@ -55,11 +55,11 @@ describe('useEmailWrapper', () => {
|
|
|
55
55
|
mockStopTimer.mockClear();
|
|
56
56
|
|
|
57
57
|
isEmpty.mockImplementation(val => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
if (val === null || val === undefined) return true;
|
|
59
|
+
if (typeof val === 'object') return Object.keys(val).length === 0;
|
|
60
|
+
if (typeof val === 'string') return val.trim().length === 0;
|
|
61
|
+
return !val;
|
|
62
|
+
});
|
|
63
63
|
|
|
64
64
|
mockProps = {
|
|
65
65
|
...EmailWrapperMockData,
|
|
@@ -224,7 +224,7 @@ describe('useEmailWrapper', () => {
|
|
|
224
224
|
const mockReader = {
|
|
225
225
|
onload: null,
|
|
226
226
|
onerror: null,
|
|
227
|
-
readAsText: jest.fn(function
|
|
227
|
+
readAsText: jest.fn(function() {
|
|
228
228
|
this.result = mockHtmlContent;
|
|
229
229
|
if (this.onload) {
|
|
230
230
|
this.onload();
|
|
@@ -294,7 +294,7 @@ describe('useEmailWrapper', () => {
|
|
|
294
294
|
});
|
|
295
295
|
|
|
296
296
|
expect(mockCapNotificationError).toHaveBeenCalledWith(expect.objectContaining({
|
|
297
|
-
|
|
297
|
+
key: "email-upload-error",
|
|
298
298
|
}));
|
|
299
299
|
expect(mockProps.templatesActions.handleZipUpload).not.toHaveBeenCalled();
|
|
300
300
|
});
|
|
@@ -309,14 +309,14 @@ describe('useEmailWrapper', () => {
|
|
|
309
309
|
result.current.useFileUpload({ file: null });
|
|
310
310
|
});
|
|
311
311
|
expect(mockCapNotificationError).toHaveBeenCalledTimes(1);
|
|
312
|
-
expect(mockCapNotificationError).toHaveBeenCalledWith(expect.objectContaining({ key: "email-upload-error"
|
|
312
|
+
expect(mockCapNotificationError).toHaveBeenCalledWith(expect.objectContaining({ key: "email-upload-error"}));
|
|
313
313
|
|
|
314
314
|
mockCapNotificationError.mockClear();
|
|
315
315
|
reactAct(() => {
|
|
316
|
-
|
|
316
|
+
result.current.useFileUpload({ file: { name: 'test.zip', size: 100 } });
|
|
317
317
|
});
|
|
318
318
|
expect(mockCapNotificationError).toHaveBeenCalledTimes(1);
|
|
319
|
-
expect(mockCapNotificationError).toHaveBeenCalledWith(expect.objectContaining({ key: "email-upload-error"
|
|
319
|
+
expect(mockCapNotificationError).toHaveBeenCalledWith(expect.objectContaining({ key: "email-upload-error"}));
|
|
320
320
|
|
|
321
321
|
expect(mockProps.templatesActions.handleZipUpload).not.toHaveBeenCalled();
|
|
322
322
|
expect(mockProps.templatesActions.handleHtmlUpload).not.toHaveBeenCalled();
|
|
@@ -397,7 +397,7 @@ describe('useEmailWrapper', () => {
|
|
|
397
397
|
// selectedCreateMode is initially '' from hook's useState
|
|
398
398
|
};
|
|
399
399
|
const { result, rerender } = renderHook((props) => useEmailWrapper(props), {
|
|
400
|
-
|
|
400
|
+
initialProps: initialProps
|
|
401
401
|
});
|
|
402
402
|
|
|
403
403
|
// 4. Simulate user selecting a template ID via the exposed callback (useEditor)
|
|
@@ -448,11 +448,11 @@ describe('useEmailWrapper', () => {
|
|
|
448
448
|
|
|
449
449
|
it('sets selectedCreateMode in useEffect when in UPLOAD mode and CREATE_TEMPLATE_CONTENT step with EmailLayout', async () => {
|
|
450
450
|
const initialRenderProps = {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
451
|
+
...mockProps,
|
|
452
|
+
step: STEPS.MODE_SELECTION,
|
|
453
|
+
emailCreateMode: EMAIL_CREATE_MODES.UPLOAD,
|
|
454
|
+
EmailLayout: null,
|
|
455
|
+
};
|
|
456
456
|
|
|
457
457
|
const { result, rerender } = renderHook((props) => useEmailWrapper(props), {
|
|
458
458
|
initialProps: initialRenderProps
|
|
@@ -467,11 +467,11 @@ describe('useEmailWrapper', () => {
|
|
|
467
467
|
|
|
468
468
|
// Reset isEmpty to default before setting the specific mock for the effect
|
|
469
469
|
isEmpty.mockImplementation((val) => {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
470
|
+
if (val === null || val === undefined) return true;
|
|
471
|
+
if (typeof val === 'object') return Object.keys(val).length === 0;
|
|
472
|
+
if (typeof val === 'string') return val.trim().length === 0;
|
|
473
|
+
return !val;
|
|
474
|
+
});
|
|
475
475
|
// Mock isEmpty specifically for the EmailLayout check inside the useEffect
|
|
476
476
|
isEmpty.mockImplementationOnce(() => false); // Mock !isEmpty(EmailLayout) to be true
|
|
477
477
|
|
|
@@ -479,16 +479,16 @@ describe('useEmailWrapper', () => {
|
|
|
479
479
|
|
|
480
480
|
// Wait for the effect to run, set selectedCreateMode, and isShowEmailCreate to update
|
|
481
481
|
await waitFor(() => {
|
|
482
|
-
|
|
482
|
+
expect(result.current.isShowEmailCreate).toBe(true);
|
|
483
483
|
});
|
|
484
484
|
|
|
485
485
|
// Restore default isEmpty behavior after the specific mock is used
|
|
486
486
|
isEmpty.mockImplementation((val) => {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
487
|
+
if (val === null || val === undefined) return true;
|
|
488
|
+
if (typeof val === 'object') return Object.keys(val).length === 0;
|
|
489
|
+
if (typeof val === 'string') return val.trim().length === 0;
|
|
490
|
+
return !val;
|
|
491
|
+
});
|
|
492
492
|
isEmpty.mockClear(); // Clear any remaining mock state if needed
|
|
493
493
|
|
|
494
494
|
expect(mockProps.templatesActions.setEdmTemplate).not.toHaveBeenCalled();
|
|
@@ -533,11 +533,11 @@ describe('useEmailWrapper', () => {
|
|
|
533
533
|
|
|
534
534
|
// Reset isEmpty to default before setting the specific mock for the effect
|
|
535
535
|
isEmpty.mockImplementation((val) => {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
536
|
+
if (val === null || val === undefined) return true;
|
|
537
|
+
if (typeof val === 'object') return Object.keys(val).length === 0;
|
|
538
|
+
if (typeof val === 'string') return val.trim().length === 0;
|
|
539
|
+
return !val;
|
|
540
|
+
});
|
|
541
541
|
// Mock isEmpty specifically for the EmailLayout check inside the useEffect
|
|
542
542
|
isEmpty.mockImplementationOnce(() => false); // Mock !isEmpty(EmailLayout) to be true
|
|
543
543
|
|
|
@@ -545,16 +545,16 @@ describe('useEmailWrapper', () => {
|
|
|
545
545
|
|
|
546
546
|
// Wait for the effect to run, set selectedCreateMode, and isShowEmailCreate to update
|
|
547
547
|
await waitFor(() => {
|
|
548
|
-
|
|
548
|
+
expect(result.current.isShowEmailCreate).toBe(true);
|
|
549
549
|
});
|
|
550
550
|
|
|
551
551
|
// Restore default isEmpty behavior after the specific mock is used
|
|
552
552
|
isEmpty.mockImplementation((val) => {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
553
|
+
if (val === null || val === undefined) return true;
|
|
554
|
+
if (typeof val === 'object') return Object.keys(val).length === 0;
|
|
555
|
+
if (typeof val === 'string') return val.trim().length === 0;
|
|
556
|
+
return !val;
|
|
557
|
+
});
|
|
558
558
|
isEmpty.mockClear(); // Clear any remaining mock state if needed
|
|
559
559
|
|
|
560
560
|
// --- Case 3: EDITOR mode selected, Template becomes available -> true (via effect) ---
|
|
@@ -563,11 +563,11 @@ describe('useEmailWrapper', () => {
|
|
|
563
563
|
find.mockReturnValue(mockTemplate); // Ensure find is mocked for this case
|
|
564
564
|
|
|
565
565
|
const editorPropsInitial = {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
566
|
+
...mockProps,
|
|
567
|
+
step: STEPS.TEMPLATE_SELECTION,
|
|
568
|
+
emailCreateMode: EMAIL_CREATE_MODES.EDITOR,
|
|
569
|
+
CmsTemplates: [mockTemplate],
|
|
570
|
+
SelectedEdmDefaultTemplate: null,
|
|
571
571
|
};
|
|
572
572
|
rerender(editorPropsInitial);
|
|
573
573
|
|
|
@@ -579,12 +579,12 @@ describe('useEmailWrapper', () => {
|
|
|
579
579
|
expect(result.current.modeContent).toEqual({ id: templateId });
|
|
580
580
|
|
|
581
581
|
const editorPropsFinal = {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
582
|
+
...mockProps, // Use fresh props base
|
|
583
|
+
step: STEPS.CREATE_TEMPLATE_CONTENT, // Move to the create step
|
|
584
|
+
emailCreateMode: EMAIL_CREATE_MODES.EDITOR,
|
|
585
|
+
CmsTemplates: [mockTemplate],
|
|
586
|
+
SelectedEdmDefaultTemplate: null, // Template not yet selected in props
|
|
587
|
+
// modeContent state ({id: templateId}) should persist internally from the reactAct call
|
|
588
588
|
};
|
|
589
589
|
|
|
590
590
|
// Mock isEmpty specifically for the check within the useEffect triggered by rerender
|
|
@@ -372,7 +372,6 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
372
372
|
channel={this.props.channel}
|
|
373
373
|
disabled={this.props.disabled}
|
|
374
374
|
fetchingSchemaError={this?.state?.tagsError}
|
|
375
|
-
popoverPlacement={this.props.popoverPlacement}
|
|
376
375
|
/>
|
|
377
376
|
</div>
|
|
378
377
|
);
|
|
@@ -403,7 +402,6 @@ TagList.propTypes = {
|
|
|
403
402
|
disabled: PropTypes.bool,
|
|
404
403
|
fetchingSchemaError: PropTypes.bool,
|
|
405
404
|
eventContextTags: PropTypes.array,
|
|
406
|
-
popoverPlacement: PropTypes.string,
|
|
407
405
|
intl: PropTypes.shape({
|
|
408
406
|
formatMessage: PropTypes.func.isRequired,
|
|
409
407
|
locale: PropTypes.string,
|
|
@@ -937,11 +937,6 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
937
937
|
const zaloSelectedTemplateData = this.selectTemplate(parseInt(creativesParams._id, 10)) || {};
|
|
938
938
|
const { name = '' } = zaloSelectedTemplateData;
|
|
939
939
|
creativesParams.name = name
|
|
940
|
-
} else if (this.state.channel?.toLowerCase() === EMAIL_LOWERCASE) {
|
|
941
|
-
const emailSelectedTemplateData = this.selectTemplate(creativesParams._id) || {};
|
|
942
|
-
const activeTab = get(emailSelectedTemplateData, 'versions.base.activeTab', 'en');
|
|
943
|
-
const isDragDrop = get(emailSelectedTemplateData, `versions.base.${activeTab}.is_drag_drop`, false);
|
|
944
|
-
creativesParams.is_drag_drop = isDragDrop;
|
|
945
940
|
}
|
|
946
941
|
}
|
|
947
942
|
creativesParams.type = this.state.channel.toUpperCase();
|