@capillarytech/creatives-library 4.0.0 → 4.0.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.
@@ -27,12 +27,6 @@ import {updateCharCount, checkUnicode} from "../../utils/smsCharCountV2";
27
27
  import messages from './messages';
28
28
  const TabPane = Tabs.TabPane;
29
29
  const {Column} = Table;
30
-
31
- const errorMessageForTags = {
32
- UNSUPPORTED_TAG_ERROR: 'unsupportedTagsError',
33
- MISSING_TAG_ERROR: 'missingTagsError',
34
- GENERIC_VALIDATION_ERROR: 'genericValidationError',
35
- };
36
30
  // import styled from 'styled-components';
37
31
 
38
32
  // import { FormattedMessage } from 'react-intl';
@@ -443,9 +437,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
443
437
  if (tagValidationResponse.valid) {
444
438
  errorData[count][`sms-editor${index > 1 ? index : ''}`] = false;
445
439
  } else {
446
- const { MISSING_TAG_ERROR, UNSUPPORTED_TAG_ERROR, GENERIC_VALIDATION_ERROR } = errorMessageForTags;
447
- const { missingTags, unsupportedTags} = tagValidationResponse;
448
- errorData[count][`sms-editor${index > 1 ? index : ''}`] = missingTags.length ? MISSING_TAG_ERROR : ( unsupportedTags.length ? UNSUPPORTED_TAG_ERROR : GENERIC_VALIDATION_ERROR);
440
+
441
+ errorData[count][`sms-editor${index > 1 ? index : ''}`] = true;
449
442
  isValid = false;
450
443
  }
451
444
  if(content !== '' && (ifUnicode && !unicodeCheck)) {
@@ -453,7 +446,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
453
446
  isValid = false;
454
447
  } else if (content === '') {
455
448
 
456
- errorData[count][`sms-editor${index > 1 ? index : ''}`] = errorMessageForTags.GENERIC_VALIDATION_ERROR;
449
+ errorData[count][`sms-editor${index > 1 ? index : ''}`] = true;
457
450
  isValid = false;
458
451
  } else {
459
452
  errorData[count][`unicode-validity${index > 1 ? index : ''}`] = false;
@@ -2125,18 +2118,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2125
2118
  });
2126
2119
  }
2127
2120
 
2128
- getMissingTagsName = (content = '') => {
2129
- const tagValidationResponse = this.validateTags(content);
2130
- const errorString = tagValidationResponse.missingTags.join(', ').toString();
2131
- return errorString;
2132
- };
2133
-
2134
- getUnsupportedTagsName = (content = '') => {
2135
- const tagValidationResponse = this.validateTags(content);
2136
- const errorString = tagValidationResponse.unsupportedTags.join(', ').toString();
2137
- return errorString;
2138
- };
2139
-
2140
2121
  renderColLabelSection(section, childIndex) {
2141
2122
  // const schema = this.props.schema
2142
2123
  const fields = [];
@@ -2214,29 +2195,18 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2214
2195
  break;
2215
2196
  case "textarea":
2216
2197
  ifError = this.state.checkValidation && (isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id]);
2217
- const messageContent = isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id];
2218
- const errorType = (isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id]);
2219
- const { MISSING_TAG_ERROR, UNSUPPORTED_TAG_ERROR } = errorMessageForTags;
2220
- let errorMessage = false;
2221
- if (errorType && errorType === MISSING_TAG_ERROR) {
2222
- errorMessage = this.props.intl.formatMessage(messages.missingTagsValidationError, {missingTags: this.getMissingTagsName(messageContent)});
2223
- } else if (errorType && errorType === UNSUPPORTED_TAG_ERROR) {
2224
- errorMessage = this.props.intl.formatMessage(messages.unsupportedTagsValidationError, {unsupportedTags: this.getUnsupportedTagsName(messageContent)});
2225
- } else if (errorType) {
2226
- errorMessage = this.props.intl.formatMessage(messages.genericTagsValidationError);
2227
- }
2228
2198
  if (styling === 'semantic') {
2229
2199
  columns.push(
2230
2200
  <Col key="input" span={val.width}>
2231
2201
  <CapTextArea
2232
2202
  id={val.id}
2233
2203
  className={`${ifError ? 'error' : ''}`}
2234
- errorMessage={errorMessage}
2204
+ errorMessage={val.errorMessage ? val.errorMessage : ''}
2235
2205
  autosize={val.autosize ? val.autosizeParams : false}
2236
2206
  onChange={(e) => this.updateFormData(e.target.value, val)}
2237
2207
  style={val.style ? val.style : {}}
2238
- defaultValue={messageContent}
2239
- value={messageContent}
2208
+ defaultValue={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
2209
+ value={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
2240
2210
  rows={20}
2241
2211
  disabled={val.disabled}
2242
2212
  cols={20}
@@ -2582,17 +2552,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2582
2552
  break;
2583
2553
  case "textarea":
2584
2554
  ifError = this.state.checkValidation && (isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id]);
2585
- const errorType = (isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id]);
2586
- const messageContent = isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id];
2587
- const { MISSING_TAG_ERROR, UNSUPPORTED_TAG_ERROR } = errorMessageForTags;
2588
- let errorMessage = false;
2589
- if (errorType && errorType === MISSING_TAG_ERROR) {
2590
- errorMessage = this.props.intl.formatMessage(messages.missingTagsValidationError, {missingTags: this.getMissingTagsName(messageContent)});
2591
- } else if (errorType && errorType === UNSUPPORTED_TAG_ERROR) {
2592
- errorMessage = this.props.intl.formatMessage(messages.unsupportedTagsValidationError, {unsupportedTags: this.getUnsupportedTagsName(messageContent)});
2593
- } else if (errorType) {
2594
- errorMessage = this.props.intl.formatMessage(messages.genericTagsValidationError);
2595
- }
2596
2555
  if (styling === 'semantic') {
2597
2556
  columns.push(
2598
2557
  <Col key="input" span={val.width} offset={val.offset}>
@@ -2601,12 +2560,12 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2601
2560
  placeholder={val.placeholder ? val.placeholder : ''}
2602
2561
  disabled={val.disabled}
2603
2562
  className={`${ifError ? 'error' : ''}`}
2604
- errorMessage={errorMessage}
2563
+ errorMessage={val.errorMessage ? val.errorMessage : ''}
2605
2564
  autosize={val.autosize ? val.autosizeParams : false}
2606
2565
  onChange={(e) => this.updateFormData(e.target.value, val)}
2607
2566
  style={val.style ? val.style : {}}
2608
- defaultValue={messageContent || ''}
2609
- value={messageContent || ''}
2567
+ defaultValue={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
2568
+ value={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
2610
2569
  rows={10}
2611
2570
  cols={2}
2612
2571
  />
@@ -22,18 +22,6 @@ export default defineMessages({
22
22
  id: 'creatives.components.FormBuilder.unsupportedTags',
23
23
  defaultMessage: 'Unsupported tags are:',
24
24
  },
25
- missingTagsValidationError: {
26
- id: 'creatives.components.FormBuilder.missingTagsValidationError',
27
- defaultMessage: 'Missing tags: {missingTags}. Please add them to this message.',
28
- },
29
- unsupportedTagsValidationError: {
30
- id: 'creatives.components.FormBuilder.unsupportedTagsValidationError',
31
- defaultMessage: 'Unsupported tags: {unsupportedTags}. Please remove them from this message.',
32
- },
33
- genericTagsValidationError: {
34
- id: 'creatives.components.FormBuilder.genericTagsValidationError',
35
- defaultMessage: 'Please check the message content for unsupported/missing tags',
36
- },
37
25
  layoutSelection: {
38
26
  id: 'creatives.components.FormBuilder.layoutSelection',
39
27
  defaultMessage: 'Layout Selection',
@@ -72,7 +72,7 @@ export default defineMessages({
72
72
  },
73
73
  "Template content has unsupported/missing tags!": {
74
74
  id: 'creatives.containers.Create.tagsErrorMessage',
75
- defaultMessage: '"Optout" label is mandatory. Please add "Optout" label to this message',
75
+ defaultMessage: 'Please check the message content for unsupported/missing tags',
76
76
  },
77
77
  "Please input sms template content.": {
78
78
  id: 'creatives.containers.Create.smsEditorPlaceholder',
@@ -76,7 +76,7 @@ export default defineMessages({
76
76
  },
77
77
  "Template content has unsupported/missing tags!": {
78
78
  id: 'creatives.containers.Edit.tagsErrorMessage',
79
- defaultMessage: '"Optout" label is mandatory. Please add "Optout" label to this message',
79
+ defaultMessage: 'Please check the message content for unsupported/missing tags',
80
80
  },
81
81
  "Please input sms template content.": {
82
82
  id: 'creatives.containers.Edit.smsEditorPlaceholder',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "4.0.0",
4
+ "version": "4.0.2",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -32,12 +32,6 @@ const {TextArea} = CapInput;
32
32
  const {CapRadioGroup} = CapRadio;
33
33
  // import styled from 'styled-components';
34
34
 
35
- const errorMessageForTags = {
36
- UNSUPPORTED_TAG_ERROR: 'unsupportedTagsError',
37
- MISSING_TAG_ERROR: 'missingTagsError',
38
- GENERIC_VALIDATION_ERROR: 'genericValidationError',
39
- };
40
-
41
35
  const isUrl = (str) => {
42
36
  // eslint-disable-next-line no-useless-escape
43
37
  const res = str.match(/(http(s)?:\/\/.)(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g);
@@ -474,16 +468,15 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
474
468
  errorData[count][`sms-editor${index > 1 ? index : ''}`] = false;
475
469
  } else {
476
470
  errorData[count]['invalid-tags'] = tagValidationResponse.unsupportedTags;
477
- const { MISSING_TAG_ERROR, UNSUPPORTED_TAG_ERROR, GENERIC_VALIDATION_ERROR } = errorMessageForTags;
478
- const { missingTags, unsupportedTags} = tagValidationResponse;
479
- errorData[count][`sms-editor${index > 1 ? index : ''}`] = missingTags.length ? MISSING_TAG_ERROR : ( unsupportedTags.length ? UNSUPPORTED_TAG_ERROR : GENERIC_VALIDATION_ERROR);
471
+ errorData[count][`sms-editor${index > 1 ? index : ''}`] = true;
480
472
  isValid = false;
481
473
  }
482
474
  if(content !== '' && (ifUnicode && !unicodeCheck)) {
483
475
  errorData[count][`unicode-validity${index > 1 ? index : ''}`] = true;
484
476
  isValid = false;
485
477
  } else if (content === '') {
486
- errorData[count][`sms-editor${index > 1 ? index : ''}`] = errorMessageForTags.GENERIC_VALIDATION_ERROR;
478
+
479
+ errorData[count][`sms-editor${index > 1 ? index : ''}`] = true;
487
480
  isValid = false;
488
481
  } else {
489
482
  errorData[count][`unicode-validity${index > 1 ? index : ''}`] = false;
@@ -2238,18 +2231,6 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2238
2231
  });
2239
2232
  }
2240
2233
 
2241
- getMissingTagsName = (content = '') => {
2242
- const tagValidationResponse = this.validateTags(content);
2243
- const errorString = tagValidationResponse.missingTags.join(', ').toString();
2244
- return errorString;
2245
- };
2246
-
2247
- getUnsupportedTagsName = (content = '') => {
2248
- const tagValidationResponse = this.validateTags(content);
2249
- const errorString = tagValidationResponse.unsupportedTags.join(', ').toString();
2250
- return errorString;
2251
- };
2252
-
2253
2234
  renderColLabelSection(section, childIndex) {
2254
2235
  // const schema = this.props.schema
2255
2236
  const fields = [];
@@ -2312,30 +2293,20 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2312
2293
  break;
2313
2294
  case "textarea":
2314
2295
  ifError = this.state.checkValidation && (isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id]);
2315
- const messageContent = isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id];
2316
- const errorType = (isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id]);
2317
- const { MISSING_TAG_ERROR, UNSUPPORTED_TAG_ERROR } = errorMessageForTags;
2318
- let errorMessageText = false;
2319
- if (errorType && errorType === MISSING_TAG_ERROR) {
2320
- errorMessageText = this.props.intl.formatMessage(messages.missingTagsValidationError, {missingTags: this.getMissingTagsName(messageContent)});
2321
- } else if (errorType && errorType === UNSUPPORTED_TAG_ERROR) {
2322
- errorMessageText = this.props.intl.formatMessage(messages.unsupportedTagsValidationError, {unsupportedTags: this.getUnsupportedTagsName(messageContent)});
2323
- } else if (errorType) {
2324
- errorMessageText = this.props.intl.formatMessage(messages.genericTagsValidationError);
2325
- }
2296
+ const value = isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id];
2326
2297
  if (styling === 'semantic') {
2327
2298
  columns.push(
2328
2299
  <CapColumn key="input" span={val.width}>
2329
2300
  <TextArea
2330
2301
  id={val.id}
2331
2302
  className={`${ifError ? 'error' : ''}`}
2332
- errorMessage={errorMessageText}
2303
+ errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
2333
2304
  label={val.label}
2334
2305
  autosize={val.autosize ? val.autosizeParams : false}
2335
2306
  onChange={(e) => this.updateFormData(e.target.value, val)}
2336
2307
  style={val.style ? val.style : {}}
2337
- defaultValue={messageContent || ''}
2338
- value={messageContent || ""}
2308
+ defaultValue={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
2309
+ value={value || ""}
2339
2310
  rows={20}
2340
2311
  disabled={val.disabled}
2341
2312
  cols={20}
@@ -2757,17 +2728,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2757
2728
 
2758
2729
  case "textarea":
2759
2730
  ifError = this.state.checkValidation && (isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id]);
2760
- const messageContent = isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id];
2761
- const errorType = (isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id]);
2762
- const { MISSING_TAG_ERROR, UNSUPPORTED_TAG_ERROR } = errorMessageForTags;
2763
- let errorMessageText = false;
2764
- if (errorType && errorType === MISSING_TAG_ERROR) {
2765
- errorMessageText = this.props.intl.formatMessage(messages.missingTagsValidationError, {missingTags: this.getMissingTagsName(messageContent)});
2766
- } else if (errorType && errorType === UNSUPPORTED_TAG_ERROR) {
2767
- errorMessageText = this.props.intl.formatMessage(messages.unsupportedTagsValidationError, {unsupportedTags: this.getUnsupportedTagsName(messageContent)});
2768
- } else if (errorType) {
2769
- errorMessageText = this.props.intl.formatMessage(messages.genericTagsValidationError);
2770
- }
2731
+ const textValue = isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id];
2771
2732
  if (styling === 'semantic') {
2772
2733
  columns.push(
2773
2734
  <CapColumn key="input" span={val.width} offset={val.offset}>
@@ -2776,13 +2737,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2776
2737
  placeholder={val.placeholder ? val.placeholder : ''}
2777
2738
  disabled={val.disabled}
2778
2739
  className={`${ifError ? 'error' : ''}`}
2779
- errorMessage={errorMessageText}
2740
+ errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
2780
2741
  label={val.label}
2781
2742
  autosize={val.autosize ? val.autosizeParams : false}
2782
2743
  onChange={(e) => this.updateFormData(e.target.value, val)}
2783
2744
  style={val.style ? val.style : {}}
2784
- defaultValue={messageContent || ''}
2785
- value={messageContent || ""}
2745
+ defaultValue={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
2746
+ value={textValue || ""}
2786
2747
  rows={10}
2787
2748
  cols={2}
2788
2749
  />
@@ -22,18 +22,6 @@ export default defineMessages({
22
22
  id: 'creatives.componentsV2.FormBuilder.ok',
23
23
  defaultMessage: 'Ok',
24
24
  },
25
- missingTagsValidationError: {
26
- id: 'creatives.components.FormBuilder.missingTagsValidationError',
27
- defaultMessage: 'Missing tags: {missingTags}. Please add them to this message.',
28
- },
29
- unsupportedTagsValidationError: {
30
- id: 'creatives.components.FormBuilder.unsupportedTagsValidationError',
31
- defaultMessage: 'Unsupported tags: {unsupportedTags}. Please remove them from this message.',
32
- },
33
- genericTagsValidationError: {
34
- id: 'creatives.components.FormBuilder.genericTagsValidationError',
35
- defaultMessage: 'Please check the message content for unsupported/missing tags',
36
- },
37
25
  contentNotValidLanguage: {
38
26
  id: 'creatives.componentsV2.FormBuilder.contentNotValidLanguage',
39
27
  defaultMessage: 'Content is not valid for language:',