@capillarytech/creatives-library 8.0.292-alpha.2 → 8.0.292-alpha.3

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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.292-alpha.2",
4
+ "version": "8.0.292-alpha.3",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -97,12 +97,19 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
97
97
  componentWillReceiveProps = (nextProps) => {
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
- // If form already has validation errors (braces, personalization tags, etc.), do not call extractTags; just fail
101
- if (!this.state.isFormValid && typeof nextProps.onValidationFail === 'function') {
102
- nextProps.onValidationFail();
100
+ // If form already has validation errors (braces, personalization tags, etc.), do not call extractTags or return payload; always return early
101
+ if (!this.state.isFormValid) {
102
+ if (typeof nextProps.onValidationFail === 'function') {
103
+ nextProps.onValidationFail();
104
+ }
103
105
  return;
104
106
  }
105
- if (typeof nextProps.getLiquidTags === 'function' && typeof nextProps.showLiquidErrorInFooter === 'function' && typeof nextProps.onValidationFail === 'function') {
107
+ const hasAllValidationCallbacks =
108
+ typeof nextProps.getLiquidTags === 'function' &&
109
+ typeof nextProps.showLiquidErrorInFooter === 'function' &&
110
+ typeof nextProps.onValidationFail === 'function';
111
+
112
+ if (hasAllValidationCallbacks) {
106
113
  const formDataArr = [this.state.formData?.[0], this.state.formData?.[1]];
107
114
  validateMobilePushContent(formDataArr, {
108
115
  currentTab: this.state.currentTab,
@@ -127,15 +134,16 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
127
134
  }
128
135
  },
129
136
  onSuccess: () => {
130
- if (typeof nextProps.getFormLibraryData === 'function') {
137
+ if (this.state.isFormValid && typeof nextProps.getFormLibraryData === 'function') {
131
138
  nextProps.getFormLibraryData(this.getFormData());
132
139
  }
133
140
  },
134
141
  });
135
- } else if (typeof nextProps.getFormLibraryData === 'function') {
136
- nextProps.getFormLibraryData(this.getFormData());
137
- } else if (typeof nextProps.onValidationFail === 'function') {
138
- nextProps.onValidationFail();
142
+ } else {
143
+ // Fail closed: require full validation callback set; treat any missing callback as validation failure
144
+ if (typeof nextProps.onValidationFail === 'function') {
145
+ nextProps.onValidationFail();
146
+ }
139
147
  }
140
148
  } else if (nextProps.isGetFormData && this.props.isGetFormData !== nextProps.isGetFormData && this.props.isFullMode && !this.props.Create.createTemplateInProgress) {
141
149
  this.startValidation();