@capillarytech/creatives-library 8.0.89 → 8.0.90

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.89",
4
+ "version": "8.0.90",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -81,3 +81,5 @@ export const transformCustomFieldsData = (customFields) => {
81
81
 
82
82
  return result;
83
83
  };
84
+
85
+ export const isTagIncluded = (value) => value && value.includes('{{') && value.includes('}}');
@@ -3,7 +3,7 @@
3
3
  import React, { useState, useEffect } from 'react';
4
4
  import { bindActionCreators } from 'redux';
5
5
  import { createStructuredSelector } from 'reselect';
6
- import { injectIntl, FormattedMessage } from 'react-intl';
6
+ import { FormattedMessage } from 'react-intl';
7
7
  import { get, isEmpty } from 'lodash';
8
8
  import styled from 'styled-components';
9
9
  import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
@@ -54,6 +54,7 @@ import * as globalActions from '../Cap/actions';
54
54
  import v2ZaloReducer from './reducer';
55
55
  import { v2ZaloSagas } from './saga';
56
56
  import { CapIcon } from '@capillarytech/cap-ui-library';
57
+ import { isTagIncluded } from '../../utils/commonUtils';
57
58
 
58
59
  export const Zalo = (props) => {
59
60
  const {
@@ -237,7 +238,7 @@ export const Zalo = (props) => {
237
238
  const { name = '', value = '', minLength = '', maxLength = '' } = listParams;
238
239
  if (name === textAreaId) {
239
240
  const text = `${value}{{${data}}}`;
240
- const hasTag = text.includes('{{') && text.includes('}}');
241
+ const hasTag = isTagIncluded(text);
241
242
  const isLengthError = !hasTag && (text.length <= minLength || text.length > maxLength);
242
243
  return {
243
244
  ...listParams,
@@ -285,7 +286,7 @@ export const Zalo = (props) => {
285
286
  let error = e ? tagValidationErrorMessage(e) : '';
286
287
 
287
288
  // Only check length validation if there are no tags in the content
288
- const hasTag = e && e.includes('{{') && e.includes('}}');
289
+ const hasTag = isTagIncluded(e);
289
290
  if (!hasTag && (!e || e.length <= minLength || e.length > maxLength)) {
290
291
  error = formatMessage(messages.maxMinLengthMessage, {
291
292
  minLength,
@@ -356,7 +357,7 @@ export const Zalo = (props) => {
356
357
  let disableCheck = false;
357
358
  templateListParams?.forEach((listParams) => {
358
359
  const { error = '', value = '' } = listParams;
359
- const hasTag = value && value.includes('{{') && value.includes('}}');
360
+ const hasTag = isTagIncluded(value);
360
361
  const errorMessage = !error && !hasTag
361
362
  ? handleErrorValidation(value, listParams)
362
363
  : error;
@@ -403,7 +404,7 @@ export const Zalo = (props) => {
403
404
  const renderContent = () =>
404
405
  templateListParams?.map((listParam) => {
405
406
  const { name = '', value = '', maxLength = '' } = listParam;
406
- const hasTag = value && value.includes('{{') && value.includes('}}');
407
+ const hasTag = isTagIncluded(value);
407
408
 
408
409
  return (
409
410
  <>
@@ -427,6 +428,12 @@ export const Zalo = (props) => {
427
428
  );
428
429
  });
429
430
 
431
+ const hasTag = templateListParams?.some((listParam) => {
432
+ const { value = '' } = listParam;
433
+ const isTagAvailable = isTagIncluded(value);
434
+ return isTagAvailable;
435
+ });
436
+
430
437
  return (
431
438
  <CapSpin spinning={zaloTemplateInfoStatus === REQUEST}>
432
439
  <CapRow type="flex" className="cap-zalo-creatives">
@@ -469,17 +476,21 @@ export const Zalo = (props) => {
469
476
  </CapRow>
470
477
  <CapRow className="zalo-variable-list">
471
478
  {renderContent()}
472
- </CapRow>
473
- <CapAlert
474
- message={
475
- <CapLabel type="label2">
476
- <CapIcon type="warning" />
477
- {formatMessage(messages.tagLengthWarning)}
478
- </CapLabel>
479
+ {
480
+ hasTag && (
481
+ <CapAlert
482
+ message={
483
+ <CapLabel type="label2">
484
+ <CapIcon type="warning" className="alert-icon-zalo" />
485
+ {formatMessage(messages.tagLengthWarning)}
486
+ </CapLabel>
487
+ }
488
+ type="warning"
489
+ className="zalo-warning-message"
490
+ />
491
+ )
479
492
  }
480
- type="warning"
481
- className="zalo-warning-message"
482
- />
493
+ </CapRow>
483
494
  </CapRow>
484
495
  </CapColumn>
485
496
  <CapColumn span={10}>
@@ -28,7 +28,11 @@
28
28
  }
29
29
 
30
30
  .zalo-warning-message {
31
- margin-bottom: $CAP_SPACE_16;
31
+ margin-top: $CAP_SPACE_24;
32
+
33
+ .alert-icon-zalo {
34
+ margin-right: $CAP_SPACE_08;
35
+ }
32
36
  }
33
37
 
34
38
  .variable-field-container {