@capillarytech/creatives-library 8.0.333 → 8.0.334-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/package.json +1 -1
- package/v2Components/FormBuilder/index.js +2 -0
- package/v2Containers/BeeEditor/index.js +13 -1
- package/v2Containers/Email/index.js +75 -38
- package/v2Containers/Email/reducer.js +2 -2
- package/v2Containers/Email/sagas.js +4 -1
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +2 -1
package/package.json
CHANGED
|
@@ -3998,6 +3998,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
3998
3998
|
onContextChange={this.props.onContextChange}
|
|
3999
3999
|
moduleFilterEnabled={isModuleFilterEnabled}
|
|
4000
4000
|
eventContextTags={this.props?.eventContextTags}
|
|
4001
|
+
isGetBeeData={this.props?.isGetBeeData}
|
|
4002
|
+
getBEEData={this.props?.getBEEData}
|
|
4001
4003
|
/>
|
|
4002
4004
|
</CapColumn>
|
|
4003
4005
|
);
|
|
@@ -53,11 +53,14 @@ function BeeEditor(props) {
|
|
|
53
53
|
BEESelect,
|
|
54
54
|
currentOrgDetails,
|
|
55
55
|
eventContextTags,
|
|
56
|
+
isGetBeeData,
|
|
57
|
+
getBEEData,
|
|
56
58
|
} = props;
|
|
57
59
|
const { saveRowRequest } = BEESelect;
|
|
58
60
|
const {formatMessage} = intl;
|
|
59
61
|
const UNSUBSCRIBE = 'unsubscribe';
|
|
60
62
|
let beePluginInstance = null;
|
|
63
|
+
const isGetBeeDataRef = useRef(isGetBeeData);
|
|
61
64
|
const categoryOptions = [{key: 'cta', value: 'cta', label: formatMessage(messages.cta)},
|
|
62
65
|
{key: 'footer', value: 'footer', label: formatMessage(messages.footer)},
|
|
63
66
|
{key: 'header', value: 'header', label: formatMessage(messages.header)},
|
|
@@ -111,6 +114,10 @@ function BeeEditor(props) {
|
|
|
111
114
|
tokenDataRef.current = tokenData;
|
|
112
115
|
}, [tokenData]);
|
|
113
116
|
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
isGetBeeDataRef.current = isGetBeeData;
|
|
119
|
+
}, [isGetBeeData]);
|
|
120
|
+
|
|
114
121
|
useEffect(() => {
|
|
115
122
|
// Only initialize if we have both tokenData and beeJson
|
|
116
123
|
const currentTokenData = tokenDataRef.current;
|
|
@@ -220,7 +227,11 @@ function BeeEditor(props) {
|
|
|
220
227
|
},
|
|
221
228
|
},
|
|
222
229
|
onSave: (jsonFile, htmlFile) => {
|
|
223
|
-
|
|
230
|
+
if (isGetBeeDataRef.current) {
|
|
231
|
+
getBEEData(jsonFile, htmlFile);
|
|
232
|
+
} else {
|
|
233
|
+
saveBeeData(jsonFile, htmlFile);
|
|
234
|
+
}
|
|
224
235
|
},
|
|
225
236
|
onSaveRow: (rowJSON) => {
|
|
226
237
|
actions.createCustomRow(JSON.parse(rowJSON), callbackSaveRow);
|
|
@@ -414,6 +425,7 @@ BeeEditor.propTypes = {
|
|
|
414
425
|
onContextChange: PropTypes.func,
|
|
415
426
|
userLocale: PropTypes.string,
|
|
416
427
|
eventContextTags: PropTypes.array,
|
|
428
|
+
isGetBeeData: PropTypes.bool,
|
|
417
429
|
};
|
|
418
430
|
|
|
419
431
|
const mapStateToProps = () => createStructuredSelector({
|
|
@@ -91,6 +91,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
91
91
|
saveForm: false,
|
|
92
92
|
showTestAndPreviewSlidebox: false,
|
|
93
93
|
isTestAndPreviewMode: false, // Add flag to prevent validation during Test & Preview
|
|
94
|
+
isGetBeeData: false,
|
|
94
95
|
};
|
|
95
96
|
|
|
96
97
|
this.isTagLoaded = false;
|
|
@@ -509,6 +510,39 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
509
510
|
const formData = _.cloneDeep(this.state.formData);
|
|
510
511
|
|
|
511
512
|
const schema = _.cloneDeep(this.state.schema);
|
|
513
|
+
|
|
514
|
+
// Apply BEE/CK visibility synchronously into the schema before setState so that
|
|
515
|
+
// the committed state already has the correct display values — this prevents the
|
|
516
|
+
// race condition where hideEdmOptions (setTimeout) could be overwritten by a
|
|
517
|
+
// concurrent prop-triggered setState that clones the schema before it commits.
|
|
518
|
+
const isDragDropForHide = nextProps.Email.CmsSettings.isDragDrop && this.checkBeeEditorAllowedForLibrary();
|
|
519
|
+
_.forEach(schema.containers, (container) => {
|
|
520
|
+
if (container.isActive) {
|
|
521
|
+
_.forEach(container.tabBarExtraContent.sections[0].inputFields[0].cols, (col) => {
|
|
522
|
+
if (col.id === 'insert-image') {
|
|
523
|
+
col.style.display = isDragDropForHide ? 'none' : '';
|
|
524
|
+
}
|
|
525
|
+
if (col.id === 'tab-options-popover') {
|
|
526
|
+
col.colStyle.display = isDragDropForHide ? 'flex' : 'none';
|
|
527
|
+
_.forEach(col.content.sections[0].inputFields, (tabPopoverSection) => {
|
|
528
|
+
if (tabPopoverSection.cols[0].id === 'switch-editor-label') {
|
|
529
|
+
tabPopoverSection.cols[0].style.display = isDragDropForHide ? '' : 'none';
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
if (col.value && col.value.sections) {
|
|
533
|
+
_.forEach(col.value.sections[0].inputFields, (valueInputField) => {
|
|
534
|
+
_.forEach(valueInputField.cols, (valueCol) => {
|
|
535
|
+
if (valueCol.id === 'tab-option-icon') {
|
|
536
|
+
valueCol.colStyle = { ...valueCol.colStyle, display: hasSupportCKEditor() ? 'flex' : 'none' };
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
|
|
512
546
|
const langIndex = formData[this.state.currentTab - 1]?.selectedLanguages?.indexOf(langId);
|
|
513
547
|
|
|
514
548
|
const temp = (schema.containers || {})[this.state.currentTab - 1];
|
|
@@ -1957,7 +1991,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
1957
1991
|
}
|
|
1958
1992
|
|
|
1959
1993
|
switchEditor = () => {
|
|
1960
|
-
this.setState({showConfirmationModal: true});
|
|
1994
|
+
this.setState({showConfirmationModal: true, isGetBeeData: true});
|
|
1961
1995
|
}
|
|
1962
1996
|
|
|
1963
1997
|
renameVersion = () => {
|
|
@@ -2791,43 +2825,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2791
2825
|
// }
|
|
2792
2826
|
}
|
|
2793
2827
|
handleOk = () => {
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
const langIndex = formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(activeLangTab);
|
|
2797
|
-
|
|
2798
|
-
// Store current content before switching
|
|
2799
|
-
const currentContent = formData[`${this.state.currentTab - 1}`][activeLangTab]['template-content'];
|
|
2800
|
-
|
|
2801
|
-
// Update formData to mark as not drag-drop
|
|
2802
|
-
formData[`${this.state.currentTab - 1}`][activeLangTab].is_drag_drop = false;
|
|
2803
|
-
if (formData[`${this.state.currentTab - 1}`].base) {
|
|
2804
|
-
formData.base[activeLangTab].is_drag_drop = false;
|
|
2828
|
+
if (this.beeInstance) {
|
|
2829
|
+
this.beeInstance.save()
|
|
2805
2830
|
}
|
|
2806
|
-
|
|
2807
|
-
this.setState({
|
|
2808
|
-
mode: "switchEditor",
|
|
2809
|
-
formData
|
|
2810
|
-
}, () => {
|
|
2811
|
-
// No need to call handleEdmSave as we're switching to CKEditor
|
|
2812
|
-
let schema = _.cloneDeep(this.state.schema);
|
|
2813
|
-
_.forEach(schema.containers, (container, index) => {
|
|
2814
|
-
if (parseInt(index, 10) === (this.state.currentTab - 1)) {
|
|
2815
|
-
const temp = container;
|
|
2816
|
-
const langTab = formData[`${this.state.currentTab - 1}`].selectedLanguages.indexOf(activeLangTab);
|
|
2817
|
-
|
|
2818
|
-
temp.panes[langTab].sections[0].inputFields[0].cols[0].colStyle = {display: ""};
|
|
2819
|
-
temp.panes[langTab].sections[0].inputFields[0].cols[1].colStyle = {display: "none"};
|
|
2820
|
-
temp.tabBarExtraContent.sections[0].inputFields[0].cols[4].colStyle.display = "none";
|
|
2821
|
-
}
|
|
2822
|
-
});
|
|
2823
|
-
schema = this.showInsertImageButton(schema);
|
|
2824
|
-
|
|
2825
|
-
this.setState({
|
|
2826
|
-
schema,
|
|
2827
|
-
showConfirmationModal: false,
|
|
2828
|
-
isSchemaChanged: true
|
|
2829
|
-
});
|
|
2830
|
-
});
|
|
2831
2831
|
}
|
|
2832
2832
|
|
|
2833
2833
|
handleCancel = () => {
|
|
@@ -3034,6 +3034,42 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
3034
3034
|
saveBeeInstance = (instance) => {
|
|
3035
3035
|
this.beeInstance = instance;
|
|
3036
3036
|
}
|
|
3037
|
+
|
|
3038
|
+
getBEEData = (json, html) => {
|
|
3039
|
+
this.setState((prevState) => {
|
|
3040
|
+
const formData = _.cloneDeep(prevState.formData);
|
|
3041
|
+
const activeLangTab = formData[`${prevState.currentTab - 1}`].activeTab;
|
|
3042
|
+
|
|
3043
|
+
// Mark as not drag-drop and capture BEE content in one pass
|
|
3044
|
+
formData[`${prevState.currentTab - 1}`][activeLangTab].is_drag_drop = false;
|
|
3045
|
+
formData[`${prevState.currentTab - 1}`][activeLangTab]['template-content'] = html;
|
|
3046
|
+
formData[`${prevState.currentTab - 1}`][activeLangTab]['json-content'] = json;
|
|
3047
|
+
formData.base[activeLangTab].is_drag_drop = false;
|
|
3048
|
+
formData.base[activeLangTab]['template-content'] = html;
|
|
3049
|
+
formData.base[activeLangTab]['json-content'] = json;
|
|
3050
|
+
|
|
3051
|
+
return { mode: "switchEditor", formData };
|
|
3052
|
+
}, () => {
|
|
3053
|
+
const { formData, currentTab } = this.state;
|
|
3054
|
+
const activeLangTab = formData[`${currentTab - 1}`].activeTab;
|
|
3055
|
+
let schema = _.cloneDeep(this.state.schema);
|
|
3056
|
+
|
|
3057
|
+
_.forEach(schema.containers, (container, index) => {
|
|
3058
|
+
if (parseInt(index, 10) === (currentTab - 1)) {
|
|
3059
|
+
const langTab = formData[`${currentTab - 1}`].selectedLanguages.indexOf(activeLangTab);
|
|
3060
|
+
container.panes[langTab].sections[0].inputFields[0].cols[0].colStyle = { display: "" };
|
|
3061
|
+
container.panes[langTab].sections[0].inputFields[0].cols[1].colStyle = { display: "none" };
|
|
3062
|
+
container.tabBarExtraContent.sections[0].inputFields[0].cols[4].colStyle.display = "none";
|
|
3063
|
+
}
|
|
3064
|
+
});
|
|
3065
|
+
|
|
3066
|
+
schema = this.showInsertImageButton(schema);
|
|
3067
|
+
this.setState({ schema, showConfirmationModal: false, isSchemaChanged: true }, () => {
|
|
3068
|
+
this.injectEvents(schema);
|
|
3069
|
+
});
|
|
3070
|
+
});
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3037
3073
|
saveBeeData = (json, html) => {
|
|
3038
3074
|
// Update state with new content
|
|
3039
3075
|
this.setState((prevState) => {
|
|
@@ -3045,7 +3081,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
3045
3081
|
formData[currentTab - 1][activeTab]['json-content'] = json;
|
|
3046
3082
|
formData.base[activeTab]['template-content'] = html;
|
|
3047
3083
|
formData.base[activeTab]['json-content'] = json;
|
|
3048
|
-
|
|
3049
3084
|
return {
|
|
3050
3085
|
...prevState,
|
|
3051
3086
|
formData,
|
|
@@ -3136,6 +3171,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
3136
3171
|
eventContextTags={this.props?.eventContextTags}
|
|
3137
3172
|
forwardedTags={this.props?.forwardedTags}
|
|
3138
3173
|
isLoyaltyModule={this.props?.isLoyaltyModule}
|
|
3174
|
+
isGetBeeData={this.state.isGetBeeData}
|
|
3175
|
+
getBEEData={this.getBEEData}
|
|
3139
3176
|
isTestAndPreviewMode={this.state.isTestAndPreviewMode} // Add flag to prevent validation
|
|
3140
3177
|
/> : ''}
|
|
3141
3178
|
</Col>
|
|
@@ -11,7 +11,7 @@ import * as types from './constants';
|
|
|
11
11
|
const initialState = fromJS({
|
|
12
12
|
createTemplateInProgress: false,
|
|
13
13
|
createResponse: {},
|
|
14
|
-
isBeeEnabled:
|
|
14
|
+
isBeeEnabled: null,
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
function emailReducer(state = initialState, action) {
|
|
@@ -150,7 +150,7 @@ function emailReducer(state = initialState, action) {
|
|
|
150
150
|
.set('fetchingCmsData', false)
|
|
151
151
|
.set('duplicateResponse', fromJS({}))
|
|
152
152
|
.set('cmsData', '')
|
|
153
|
-
.set('isBeeEnabled',
|
|
153
|
+
.set('isBeeEnabled', null);
|
|
154
154
|
case types.TRANSFORM_EMAIL_TEMPLATE_REQUEST:
|
|
155
155
|
return state.set("createTemplateInProgress", true);
|
|
156
156
|
default:
|
|
@@ -107,7 +107,10 @@ export function* getCmsSetting({
|
|
|
107
107
|
}) {
|
|
108
108
|
try {
|
|
109
109
|
const result = yield call(Api.getCmsTemplateSettingsV2, cmsType, projectId, cmsMode, langId, isEdmSupport, isBEEAppEnable);
|
|
110
|
-
|
|
110
|
+
const cmsAccountDetail = result.data?.response.cmsDetails || {};
|
|
111
|
+
const isBeeEnabled = cmsAccountDetail?.type === cmsType;
|
|
112
|
+
console.log(isBeeEnabled, "isBeeEnabled");
|
|
113
|
+
yield put({ type: types.GET_CMS_ACCOUNTS_SUCCESS, isBeeEnabled });
|
|
111
114
|
yield put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: result.data.response.cmsDetails });
|
|
112
115
|
} catch (error) {
|
|
113
116
|
yield put({ type: types.GET_CMS_EDITOR_DETAILS_FAILURE, error });
|
|
@@ -231,6 +231,7 @@ const useEmailWrapper = ({
|
|
|
231
231
|
const hasTemplateDetails = Email?.templateDetails && !isEmpty(Email.templateDetails);
|
|
232
232
|
// Note: We check Email?.BEETemplate as a proxy, but the actual BEETemplate is in Templates reducer
|
|
233
233
|
// The Email component will detect it via this.props.Templates.BEETemplate
|
|
234
|
+
console.log(Email, "fkjhsgfgdkl");
|
|
234
235
|
const hasBEETemplate = Email?.BEETemplate && !isEmpty(Email.BEETemplate);
|
|
235
236
|
|
|
236
237
|
if (hasTemplateDetails && !hasBEETemplate && templatesActions?.setBEETemplate && !beeTemplateSetRef.current) {
|
|
@@ -251,7 +252,7 @@ const useEmailWrapper = ({
|
|
|
251
252
|
};
|
|
252
253
|
|
|
253
254
|
const isDragDrop = getIsDragDrop(editTemplateData);
|
|
254
|
-
|
|
255
|
+
console.log(isDragDrop, "isDragDrop");
|
|
255
256
|
// If it's a BEE template, set it in Templates.BEETemplate
|
|
256
257
|
if (isDragDrop) {
|
|
257
258
|
beeTemplateSetRef.current = true;
|