@capillarytech/creatives-library 8.0.87-alpha.6 → 8.0.87-alpha.7
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
CHANGED
package/services/api.js
CHANGED
|
@@ -569,13 +569,9 @@ export const getLiquidTags = (content) => {
|
|
|
569
569
|
return request(url, getAPICallObject("POST", { content }, false, true));
|
|
570
570
|
};
|
|
571
571
|
|
|
572
|
-
export const
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
return {
|
|
576
|
-
status: true,
|
|
577
|
-
metaId: "2334",
|
|
578
|
-
};
|
|
572
|
+
export const createCentralCommsMetaId = (payload) => {
|
|
573
|
+
console.log("createCentralCommsMetaId: API call: ", { payload });
|
|
574
|
+
const url = `${API_ENDPOINT}/createCentralCommsMetaId/TRANSACTION`;
|
|
579
575
|
return request(url, getAPICallObject('POST', payload));
|
|
580
576
|
};
|
|
581
577
|
|
|
@@ -82,7 +82,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
82
82
|
super(props);
|
|
83
83
|
this.state = {
|
|
84
84
|
formData: {},
|
|
85
|
-
prevFormData: {},
|
|
86
85
|
errorData: {},
|
|
87
86
|
currentTab: 1,
|
|
88
87
|
currentLangTab: 'en',
|
|
@@ -141,14 +140,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
141
140
|
componentWillMount() {
|
|
142
141
|
this.setState({usingTabContainer: this.props.usingTabContainer ? this.props.usingTabContainer : false});
|
|
143
142
|
if (this.props.formData && (this.props.isEdit || (!this.props.isEdit && !_.isEmpty(this.props.formData)))) {
|
|
144
|
-
|
|
145
|
-
formData: this.props.formData,
|
|
146
|
-
prevFormData: this.props.formData
|
|
147
|
-
});
|
|
148
|
-
this.setState({
|
|
149
|
-
formData: this.props.formData,
|
|
150
|
-
prevFormData: this.props.formData
|
|
151
|
-
}, () => {
|
|
143
|
+
this.setState({formData: this.props.formData}, () => {
|
|
152
144
|
// if (!this.props.isNewVersionFlow) {
|
|
153
145
|
this.initialiseForm(this.props.schema, false, true);
|
|
154
146
|
// }
|
|
@@ -180,32 +172,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
180
172
|
// }
|
|
181
173
|
if (nextProps.isEdit) {
|
|
182
174
|
if (!_.isEqual(nextProps.formData, this.state.formData) && !_.isEmpty(nextProps.formData)) {
|
|
183
|
-
|
|
184
|
-
const oldContent = convert(this.state.prevFormData?.base?.en?.["template-content"]);
|
|
185
|
-
const newContent = convert(this.state.formData?.base?.en?.["template-content"]);
|
|
186
|
-
console.log("**** componentWillReceiveProps: ", {
|
|
187
|
-
formData: this.state.formData,
|
|
188
|
-
prevFormData: this.state.prevFormData,
|
|
189
|
-
nextPropsFormData: nextProps.formData
|
|
190
|
-
});
|
|
191
|
-
if (!_.isEmpty(oldContent)){
|
|
192
|
-
console.log("**** oldContent is empty: ", {
|
|
193
|
-
oldContent,
|
|
194
|
-
newContent
|
|
195
|
-
});
|
|
196
|
-
this.setState({
|
|
197
|
-
prevFormData: nextProps.formData
|
|
198
|
-
});
|
|
199
|
-
} else if (oldContent !== newContent) {
|
|
200
|
-
console.log("**** oldContent !== newContent: ", {
|
|
201
|
-
oldContent,
|
|
202
|
-
newContent
|
|
203
|
-
});
|
|
204
|
-
this.setState({
|
|
205
|
-
prevFormData: this.state.formData
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
175
|
if (type === 'embedded' && !isLibraryModule) { //TODO: has to be checked and changed.
|
|
210
176
|
this.setState({checkValidation: true, formData: nextProps.formData}, () => {
|
|
211
177
|
this.validateForm();
|
|
@@ -1100,7 +1066,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1100
1066
|
if(templateContent){this.setState((prevState) => {
|
|
1101
1067
|
console.log('**** handleLiquidTemplateSubmit: ', { prevState, templateContent });
|
|
1102
1068
|
return {
|
|
1103
|
-
// prevFormData: { ...prevState.formData },
|
|
1104
1069
|
formData: {
|
|
1105
1070
|
...prevState?.formData,
|
|
1106
1071
|
base: {
|
|
@@ -1116,23 +1081,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1116
1081
|
this.metaIDSaveWrapper();
|
|
1117
1082
|
});}
|
|
1118
1083
|
}
|
|
1119
|
-
|
|
1120
|
-
checkDiffInContent = () => {
|
|
1121
|
-
//oldCOntent will be prop based
|
|
1122
|
-
//newContent will be state based
|
|
1123
|
-
//newcontent is this.state.formData?.base?.en?.["template-content"]
|
|
1124
|
-
//oldContent is this.props.formData?.base?.en?.["template-content"]
|
|
1125
|
-
//will check if the new content has any new tags or not
|
|
1126
|
-
const oldContent = convert(this.state.prevFormData?.base?.en?.["template-content"]);
|
|
1127
|
-
const newContent = convert(this.state.formData?.base?.en?.["template-content"]);
|
|
1128
|
-
console.log("**** checkDiffInContent", { oldContent, newContent });
|
|
1129
|
-
if (_.isEmpty(oldContent)) {
|
|
1130
|
-
return false;
|
|
1131
|
-
} else if (!_.isEqual(oldContent, newContent)) {
|
|
1132
|
-
return true;
|
|
1133
|
-
}
|
|
1134
|
-
return false;
|
|
1135
|
-
};
|
|
1136
1084
|
|
|
1137
1085
|
metaIDSaveWrapper = () => {
|
|
1138
1086
|
const {
|
|
@@ -1142,27 +1090,45 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1142
1090
|
clientName,
|
|
1143
1091
|
module,
|
|
1144
1092
|
metaId,
|
|
1145
|
-
setMetaId,
|
|
1093
|
+
setMetaId = () => {},
|
|
1146
1094
|
} = this.props.loyaltyMetaData;
|
|
1095
|
+
const { formatMessage } = this.props.intl;
|
|
1147
1096
|
const handleMetaIDResult = (result) => {
|
|
1148
1097
|
console.log("**** handleMetaIDResult: 1", { result });
|
|
1149
|
-
if (result.status && this.props.onSubmit) {
|
|
1150
|
-
console.log("**** handleMetaIDResult: 2", { result });
|
|
1098
|
+
if (result.status === 200 && this.props.onSubmit) {
|
|
1099
|
+
console.log("**** handleMetaIDResult: 2.1", { result });
|
|
1151
1100
|
setMetaId(result?.metaId);
|
|
1152
1101
|
this.props.onSubmit(this.state.formData);
|
|
1153
1102
|
} else {
|
|
1154
1103
|
// this.setState({ metaID: null });
|
|
1155
|
-
|
|
1104
|
+
console.log("**** handleMetaIDResult: 2.2 ", { result });
|
|
1105
|
+
this.setState(
|
|
1106
|
+
prevState => ({
|
|
1107
|
+
liquidErrorMessage: {
|
|
1108
|
+
...prevState.liquidErrorMessage,
|
|
1109
|
+
STANDARD_ERROR_MSG: result?.errors?.length > 0
|
|
1110
|
+
? [
|
|
1111
|
+
...(prevState.liquidErrorMessage?.STANDARD_ERROR_MSG || []),
|
|
1112
|
+
formatMessage(messages.emailBodyEmptyError)
|
|
1113
|
+
]
|
|
1114
|
+
: prevState.liquidErrorMessage?.STANDARD_ERROR_MSG,
|
|
1115
|
+
LIQUID_ERROR_MSG: result?.errors?.map(
|
|
1116
|
+
error => error?.message
|
|
1117
|
+
) ?? [formatMessage(messages.somethingWentWrong)]
|
|
1118
|
+
}
|
|
1119
|
+
}),
|
|
1120
|
+
() => {
|
|
1121
|
+
this.props.showLiquidErrorInFooter(this.state.liquidErrorMessage);
|
|
1122
|
+
}
|
|
1123
|
+
);
|
|
1156
1124
|
this.props.stopValidation();
|
|
1157
1125
|
return;
|
|
1158
1126
|
}
|
|
1159
1127
|
};
|
|
1160
1128
|
console.log("**** metaIDSaveWrapper: BODY", { actionName, actionId, ouId, clientName, module, metaId, setMetaId, messageDetails: this.props.messageDetails });
|
|
1161
1129
|
const content = this.state.formData?.base?.en?.["template-content"] || "";
|
|
1162
|
-
console.log("**** metaIDSaveWrapper: checkDiffInContent: ", this.checkDiffInContent());
|
|
1163
1130
|
// Only generate metaId for loyalty module and specific action
|
|
1164
1131
|
if (this.props.isLoyaltyModule && actionName === 'SEND_COMMUNICATION_ACTION') {
|
|
1165
|
-
if (this.checkDiffInContent()) {
|
|
1166
1132
|
//need to pass payload , this will be same as the payload for template creation/edit api
|
|
1167
1133
|
const payload = {
|
|
1168
1134
|
ouId: ouId || -1,
|
|
@@ -1179,10 +1145,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1179
1145
|
props: this.props,
|
|
1180
1146
|
state: this.state
|
|
1181
1147
|
});
|
|
1182
|
-
this.props.actions.
|
|
1183
|
-
} else {
|
|
1184
|
-
this.props.onSubmit(this.state.formData);
|
|
1185
|
-
}
|
|
1148
|
+
this.props.actions.createCentralCommsMetaId(payload, handleMetaIDResult);
|
|
1186
1149
|
} else {
|
|
1187
1150
|
this.props.onSubmit(this.state.formData);
|
|
1188
1151
|
}
|
|
@@ -86,10 +86,10 @@ export const getLiquidTags = (data,callback) => {
|
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
export const
|
|
90
|
-
console.log("
|
|
89
|
+
export const createCentralCommsMetaId = (data, callback) => {
|
|
90
|
+
console.log("createCentralCommsMetaId action", data, callback);
|
|
91
91
|
return {
|
|
92
|
-
type: types.
|
|
92
|
+
type: types.CREATE_CENTRAL_COMMS_META_ID_REQUEST,
|
|
93
93
|
data,
|
|
94
94
|
callback,
|
|
95
95
|
};
|
|
@@ -64,6 +64,6 @@ export const GET_LIQUID_TAGS_FAILURE = 'cap/GET_LIQUID_TAGS_FAILURE_V2';
|
|
|
64
64
|
export const GET_LIQUID_TAGS_REQUEST = 'cap/GET_LIQUID_TAGS_REQUEST_V2';
|
|
65
65
|
export const GET_LIQUID_TAGS_SUCCESS = 'cap/GET_LIQUID_TAGS_SUCCESS_V2';
|
|
66
66
|
|
|
67
|
-
export const
|
|
68
|
-
export const
|
|
69
|
-
export const
|
|
67
|
+
export const CREATE_CENTRAL_COMMS_META_ID_FAILURE = 'cap/CREATE_CENTRAL_COMMS_META_ID_FAILURE_V2';
|
|
68
|
+
export const CREATE_CENTRAL_COMMS_META_ID_REQUEST = 'cap/CREATE_CENTRAL_COMMS_META_ID_REQUEST_V2';
|
|
69
|
+
export const CREATE_CENTRAL_COMMS_META_ID_SUCCESS = 'cap/CREATE_CENTRAL_COMMS_META_ID_SUCCESS_V2';
|
|
@@ -199,11 +199,11 @@ function capReducer(state = fromJS(initialState.cap), action) {
|
|
|
199
199
|
return state
|
|
200
200
|
.set('demoVideoAndLinkJSONStatus', types.FAILURE)
|
|
201
201
|
.set('demoVideoAndLinkJSONError', action?.error);
|
|
202
|
-
case types.
|
|
202
|
+
case types.CREATE_CENTRAL_COMMS_META_ID_REQUEST:
|
|
203
203
|
return state.set('metaTagsStatus', types.REQUEST);
|
|
204
|
-
case types.
|
|
204
|
+
case types.CREATE_CENTRAL_COMMS_META_ID_SUCCESS:
|
|
205
205
|
return state.set('metaTagsStatus', types.SUCCESS);
|
|
206
|
-
case types.
|
|
206
|
+
case types.CREATE_CENTRAL_COMMS_META_ID_FAILURE:
|
|
207
207
|
return state.set('metaTagsStatus', types.FAILURE);
|
|
208
208
|
default:
|
|
209
209
|
return state;
|
|
@@ -186,25 +186,21 @@ const getTopbarData = (parentModule) => {
|
|
|
186
186
|
}
|
|
187
187
|
};
|
|
188
188
|
|
|
189
|
-
export function*
|
|
189
|
+
export function* createCentralCommsMetaId(action) {
|
|
190
190
|
try {
|
|
191
|
-
console.log("
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
status: true,
|
|
195
|
-
metaId: "2334",
|
|
196
|
-
};
|
|
197
|
-
console.log("postMetaId saga result", result);
|
|
191
|
+
console.log("createCentralCommsMetaId saga", action);
|
|
192
|
+
const result = yield call(Api.createCentralCommsMetaId, action?.data);
|
|
193
|
+
console.log("createCentralCommsMetaId saga result", result);
|
|
198
194
|
if (result) {
|
|
199
195
|
if (action?.callback) {
|
|
200
196
|
yield call(action?.callback, result);
|
|
201
197
|
}
|
|
202
|
-
yield put({ type: types.
|
|
198
|
+
yield put({ type: types.CREATE_CENTRAL_COMMS_META_ID_SUCCESS, result });
|
|
203
199
|
} else {
|
|
204
|
-
yield put({ type: types.
|
|
200
|
+
yield put({ type: types.CREATE_CENTRAL_COMMS_META_ID_FAILURE });
|
|
205
201
|
}
|
|
206
202
|
} catch (error) {
|
|
207
|
-
yield put({ type: types.
|
|
203
|
+
yield put({ type: types.CREATE_CENTRAL_COMMS_META_ID_FAILURE, error });
|
|
208
204
|
}
|
|
209
205
|
}
|
|
210
206
|
|
|
@@ -248,7 +244,7 @@ export function* watchLiquidEntity() {
|
|
|
248
244
|
}
|
|
249
245
|
|
|
250
246
|
export function* watchMetaId() {
|
|
251
|
-
yield takeLatest(types.
|
|
247
|
+
yield takeLatest(types.CREATE_CENTRAL_COMMS_META_ID_REQUEST, createCentralCommsMetaId);
|
|
252
248
|
}
|
|
253
249
|
|
|
254
250
|
function* watchForOrgChange() {
|