@capillarytech/creatives-library 7.17.201 → 7.17.202

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": "7.17.201",
4
+ "version": "7.17.202",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -98,7 +98,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
98
98
  customPopoverVisible: false,
99
99
  isDrawerVisible: false,
100
100
  translationLang: 'en',
101
- showLiquidValidation: false,
102
101
  liquidErrorMessage: {
103
102
  STANDARD_ERROR_MSG: [],
104
103
  LIQUID_ERROR_MSG: [],
@@ -494,7 +493,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
494
493
  const type = (this.props.location && this.props.location.query.type) ? this.props.location.query.type : 'full';
495
494
  const currentModule = (this.props.location && this.props.location.query.module) ? this.props.location.query.module : 'default';
496
495
  let errorData = _.cloneDeep(this.state.errorData);
497
- const stateFormData = _.cloneDeep(this.state.formData);
498
496
  if (channel && channel.toUpperCase() === SMS) {
499
497
  for (let count = 0; count < this.state.tabCount; count += 1) {
500
498
  if (_.isEmpty(errorData[count])) {
@@ -961,7 +959,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
961
959
  } else if(index === 'template-version' && data !== '') {
962
960
  errorData[index] = false;
963
961
  }
964
-
962
+ isLiquidValid = isValid; // Existing validations support for liquid enabled orgs
965
963
  // Check error for the versions
966
964
  if (!isNaN(index) || index === 'base') {
967
965
  if (errorData[index] === undefined) {
@@ -1002,7 +1000,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1002
1000
  // Adds a bypass for cases where content is initially empty in the creation flow.
1003
1001
  if(this.liquidFlow && !this.props.isEdit){
1004
1002
  errorString = "";
1005
- isValid = true;
1006
1003
  isLiquidValid = true;
1007
1004
  }
1008
1005
  }
@@ -1013,7 +1010,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1013
1010
  if (this.liquidFlow) {
1014
1011
  this.setState(
1015
1012
  (prevState) => ({
1016
- showLiquidValidation: true,
1017
1013
  liquidErrorMessage: {
1018
1014
  ...prevState.liquidErrorMessage,
1019
1015
  STANDARD_ERROR_MSG: [errorString],
@@ -1036,15 +1032,16 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1036
1032
  }
1037
1033
  });
1038
1034
  }
1035
+
1036
+ const isTemplateValid = this.liquidFlow ? isLiquidValid : isValid;
1039
1037
  //Updating the state with the error data
1040
1038
  this.setState((prevState) => ({
1041
- isFormValid: isValid,
1042
- showLiquidValidation: prevState.liquidErrorMessage?.LIQUID_ERROR_MSG?.length > 0 ? true : !isLiquidValid,
1039
+ isFormValid: isTemplateValid,
1043
1040
  liquidErrorMessage: {
1044
1041
  //Do not update the LIQUID_ERROR_MSG validation error message
1045
1042
  ...prevState.liquidErrorMessage,
1046
1043
  //update Standard error message based on the updated content
1047
- STANDARD_ERROR_MSG: isValid ? [] : prevState.liquidErrorMessage?.STANDARD_ERROR_MSG,
1044
+ STANDARD_ERROR_MSG: isTemplateValid ? [] : prevState.liquidErrorMessage?.STANDARD_ERROR_MSG,
1048
1045
  },
1049
1046
  errorData,
1050
1047
  }), () => {
@@ -1054,8 +1051,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1054
1051
  }
1055
1052
  });
1056
1053
 
1057
- this.props.onFormValidityChange(isValid, errorData);
1058
- return isValid;
1054
+ this.props.onFormValidityChange(isTemplateValid, errorData);
1055
+ return isTemplateValid;
1059
1056
  }
1060
1057
 
1061
1058
  indexOfEnd(targetString, string) {
@@ -1083,9 +1080,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1083
1080
  */
1084
1081
  const handleResult = (result) => {
1085
1082
  const {formatMessage} = this.props.intl;
1083
+ // Checks for errors in the result and displays them if any are found.
1086
1084
  if (result?.errors?.length > 0) {
1087
1085
  this.setState((prevState) => ({
1088
- showLiquidValidation: true,
1089
1086
  liquidErrorMessage: {
1090
1087
  ...prevState.liquidErrorMessage,
1091
1088
  LIQUID_ERROR_MSG: result?.errors?.map(error => error?.message) ?? [formatMessage(messages.somethingWentWrong)],
@@ -1096,8 +1093,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1096
1093
  this.props.stopValidation();
1097
1094
  return;
1098
1095
  }
1099
- else if (result?.data?.length > 0) {
1100
- const extractedLiquidTags = extractNames(result?.data);
1096
+ // Extracts the supported liquid tags from the given content and do the necessary checks.
1097
+ else {
1098
+ const extractedLiquidTags = extractNames(result?.data || []);
1101
1099
  // Extracts the supported liquid tags from the given content.
1102
1100
  const supportedLiquidTags = checkSupport(
1103
1101
  result,
@@ -1111,7 +1109,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1111
1109
  ) {
1112
1110
  this.setState(
1113
1111
  (prevState) => ({
1114
- showLiquidValidation: true,
1115
1112
  liquidErrorMessage: {
1116
1113
  ...prevState.liquidErrorMessage,
1117
1114
  LIQUID_ERROR_MSG: [formatMessage(messages.unsupportedTagsValidationError, {
@@ -3425,7 +3422,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3425
3422
  <CapColumn
3426
3423
  style={val.colStyle ? val.colStyle : {border : ""}}
3427
3424
  span={val.width}
3428
- className={`${this.state.showLiquidValidation && this.liquidFlow && "error-boundary"} `}
3425
+ className={`${(this.state.liquidErrorMessage?.LIQUID_ERROR_MSG?.length || this.state.liquidErrorMessage?.STANDARD_ERROR_MSG?.length) && this.liquidFlow && "error-boundary"} `}
3429
3426
  >
3430
3427
  <CKEditor
3431
3428
  id={val.id}
@@ -3469,7 +3466,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3469
3466
  isModuleFilterEnabled = this.props.isFullMode;
3470
3467
  }
3471
3468
  columns.push(
3472
- <CapColumn style={val.colStyle ? val.colStyle : {}} span={val.width} className={`${this.state.showLiquidValidation && this.liquidFlow && "error-boundary"}`}>
3469
+ <CapColumn style={val.colStyle ? val.colStyle : {}} span={val.width} className={`${(this.state.liquidErrorMessage?.LIQUID_ERROR_MSG?.length || this.state.liquidErrorMessage?.STANDARD_ERROR_MSG?.length) && this.liquidFlow && "error-boundary"}`}>
3473
3470
  <BeeEditor
3474
3471
  uid={uuid}
3475
3472
  tokenData={beeToken}