@capillarytech/creatives-library 8.0.292-alpha.1 → 8.0.292-alpha.2
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
|
@@ -98,11 +98,11 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
98
98
|
// Library mode: on Done click (transition to isGetFormData), run extractTags only when no existing validation errors (braces, personalization, etc.)
|
|
99
99
|
if (nextProps.isGetFormData && !this.props.isGetFormData && !nextProps.isFullMode) {
|
|
100
100
|
// If form already has validation errors (braces, personalization tags, etc.), do not call extractTags; just fail
|
|
101
|
-
if (!this.state.isFormValid && nextProps.onValidationFail) {
|
|
101
|
+
if (!this.state.isFormValid && typeof nextProps.onValidationFail === 'function') {
|
|
102
102
|
nextProps.onValidationFail();
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
105
|
-
if (nextProps.getLiquidTags && nextProps.showLiquidErrorInFooter && nextProps.onValidationFail) {
|
|
105
|
+
if (typeof nextProps.getLiquidTags === 'function' && typeof nextProps.showLiquidErrorInFooter === 'function' && typeof nextProps.onValidationFail === 'function') {
|
|
106
106
|
const formDataArr = [this.state.formData?.[0], this.state.formData?.[1]];
|
|
107
107
|
validateMobilePushContent(formDataArr, {
|
|
108
108
|
currentTab: this.state.currentTab,
|
|
@@ -115,21 +115,27 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
115
115
|
const toArray = (v) => (Array.isArray(v) ? v : (v && typeof v === 'object' ? [].concat(...Object.values(v)) : []));
|
|
116
116
|
const STANDARD_ERROR_MSG = toArray(standardErrors);
|
|
117
117
|
const LIQUID_ERROR_MSG = toArray(liquidErrors);
|
|
118
|
-
nextProps.showLiquidErrorInFooter
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
if (typeof nextProps.showLiquidErrorInFooter === 'function') {
|
|
119
|
+
nextProps.showLiquidErrorInFooter(
|
|
120
|
+
{ STANDARD_ERROR_MSG, LIQUID_ERROR_MSG },
|
|
121
|
+
this.state.currentTab
|
|
122
|
+
);
|
|
123
|
+
}
|
|
122
124
|
// Only trigger onValidationFail when there are actual errors; skip when helper called onError with empty arrays (reset case)
|
|
123
|
-
if (STANDARD_ERROR_MSG.length > 0 || LIQUID_ERROR_MSG.length > 0) {
|
|
125
|
+
if ((STANDARD_ERROR_MSG.length > 0 || LIQUID_ERROR_MSG.length > 0) && typeof nextProps.onValidationFail === 'function') {
|
|
124
126
|
nextProps.onValidationFail();
|
|
125
127
|
}
|
|
126
128
|
},
|
|
127
129
|
onSuccess: () => {
|
|
128
|
-
nextProps.getFormLibraryData
|
|
130
|
+
if (typeof nextProps.getFormLibraryData === 'function') {
|
|
131
|
+
nextProps.getFormLibraryData(this.getFormData());
|
|
132
|
+
}
|
|
129
133
|
},
|
|
130
134
|
});
|
|
131
|
-
} else {
|
|
135
|
+
} else if (typeof nextProps.getFormLibraryData === 'function') {
|
|
132
136
|
nextProps.getFormLibraryData(this.getFormData());
|
|
137
|
+
} else if (typeof nextProps.onValidationFail === 'function') {
|
|
138
|
+
nextProps.onValidationFail();
|
|
133
139
|
}
|
|
134
140
|
} else if (nextProps.isGetFormData && this.props.isGetFormData !== nextProps.isGetFormData && this.props.isFullMode && !this.props.Create.createTemplateInProgress) {
|
|
135
141
|
this.startValidation();
|
|
@@ -69,6 +69,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
69
69
|
schema: {},
|
|
70
70
|
currentTab: 1,
|
|
71
71
|
editData: {},
|
|
72
|
+
errorData: [],
|
|
72
73
|
loading: false,
|
|
73
74
|
isFormValid: true,
|
|
74
75
|
injectedTags: {},
|
|
@@ -133,11 +134,11 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
133
134
|
// Library mode: on Done click (transition to isGetFormData), run extractTags only when no existing validation errors (braces, personalization, etc.)
|
|
134
135
|
if (nextProps.isGetFormData && !this.props.isGetFormData && !nextProps.isFullMode) {
|
|
135
136
|
// If form already has validation errors (braces, personalization tags, etc.), do not call extractTags; just fail
|
|
136
|
-
if (!this.state.isFormValid
|
|
137
|
-
nextProps.onValidationFail();
|
|
137
|
+
if (!this.state.isFormValid) {
|
|
138
|
+
nextProps.onValidationFail?.();
|
|
138
139
|
return;
|
|
139
140
|
}
|
|
140
|
-
if (nextProps.getLiquidTags && nextProps.showLiquidErrorInFooter
|
|
141
|
+
if (nextProps.getLiquidTags && nextProps.showLiquidErrorInFooter) {
|
|
141
142
|
const formDataArr = [this.state.formData?.[0], this.state.formData?.[1]];
|
|
142
143
|
validateMobilePushContent(formDataArr, {
|
|
143
144
|
currentTab: this.state.currentTab,
|
|
@@ -156,8 +157,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
156
157
|
);
|
|
157
158
|
// Only treat as validation failure when there are actual errors; skip when helper called onError with empty reset payload
|
|
158
159
|
const hasErrors = STANDARD_ERROR_MSG.length > 0 || LIQUID_ERROR_MSG.length > 0;
|
|
159
|
-
if (hasErrors
|
|
160
|
-
nextProps.onValidationFail();
|
|
160
|
+
if (hasErrors) {
|
|
161
|
+
nextProps.onValidationFail?.();
|
|
161
162
|
}
|
|
162
163
|
},
|
|
163
164
|
onSuccess: () => {
|
|
@@ -745,8 +746,8 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
745
746
|
const errorMessage = {key: 'validation-error', message: intl.formatMessage(messages.validationError)};
|
|
746
747
|
if (!_.isEmpty(this.state.formData) && !this.state.isFormValid) {
|
|
747
748
|
let tab = this.state.currentTab;
|
|
748
|
-
const isAndroidInvalid = Object.values(errorData[0] || {}).includes(true);
|
|
749
|
-
const isIosInvalid = Object.values(errorData[1] || {}).includes(true);
|
|
749
|
+
const isAndroidInvalid = Object.values(errorData?.[0] || {}).includes(true);
|
|
750
|
+
const isIosInvalid = Object.values(errorData?.[1] || {}).includes(true);
|
|
750
751
|
const isIosTabVisible = get(schema, 'containers[0].panes[1].isSupported', true) !== false;
|
|
751
752
|
if (isAndroidInvalid) {
|
|
752
753
|
tab = 1;
|