@capillarytech/creatives-library 8.0.89 → 8.0.90-alpha.0
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
package/utils/commonUtils.js
CHANGED
|
@@ -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 {
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
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
|
-
|
|
481
|
-
className="zalo-warning-message"
|
|
482
|
-
/>
|
|
493
|
+
</CapRow>
|
|
483
494
|
</CapRow>
|
|
484
495
|
</CapColumn>
|
|
485
496
|
<CapColumn span={10}>
|