@capillarytech/creatives-library 8.0.88-alpha.4 → 8.0.88
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
|
@@ -53,6 +53,7 @@ import injectReducer from '../../utils/injectReducer';
|
|
|
53
53
|
import * as globalActions from '../Cap/actions';
|
|
54
54
|
import v2ZaloReducer from './reducer';
|
|
55
55
|
import { v2ZaloSagas } from './saga';
|
|
56
|
+
import { CapIcon } from '@capillarytech/cap-ui-library';
|
|
56
57
|
|
|
57
58
|
export const Zalo = (props) => {
|
|
58
59
|
const {
|
|
@@ -234,24 +235,19 @@ export const Zalo = (props) => {
|
|
|
234
235
|
if (data && textAreaId) {
|
|
235
236
|
const updatedZaloTemplateInfo = templateListParams?.map((listParams) => {
|
|
236
237
|
const { name = '', value = '', minLength = '', maxLength = '' } = listParams;
|
|
237
|
-
console.log('******237',listParams);
|
|
238
238
|
if (name === textAreaId) {
|
|
239
239
|
const text = `${value}{{${data}}}`;
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
const containsTags = text && text.includes('{{') && text.includes('}}');
|
|
243
|
-
const isExceedingLength = text.length > maxLength;
|
|
240
|
+
const hasTag = text.includes('{{') && text.includes('}}');
|
|
241
|
+
const isLengthError = !hasTag && (text.length <= minLength || text.length > maxLength);
|
|
244
242
|
return {
|
|
245
243
|
...listParams,
|
|
246
244
|
value: text,
|
|
247
|
-
error: isLengthError
|
|
245
|
+
error: isLengthError
|
|
248
246
|
? formatMessage(messages.maxMinLengthMessage, {
|
|
249
247
|
minLength,
|
|
250
248
|
maxLength,
|
|
251
249
|
})
|
|
252
|
-
:
|
|
253
|
-
maxLength,
|
|
254
|
-
}) : '',
|
|
250
|
+
: '',
|
|
255
251
|
};
|
|
256
252
|
}
|
|
257
253
|
return listParams;
|
|
@@ -288,19 +284,13 @@ export const Zalo = (props) => {
|
|
|
288
284
|
const { minLength = '', maxLength = '' } = field;
|
|
289
285
|
let error = e ? tagValidationErrorMessage(e) : '';
|
|
290
286
|
|
|
291
|
-
//
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
if (!e || e.length <= minLength) {
|
|
287
|
+
// Only check length validation if there are no tags in the content
|
|
288
|
+
const hasTag = e && e.includes('{{') && e.includes('}}');
|
|
289
|
+
if (!hasTag && (!e || e.length <= minLength || e.length > maxLength)) {
|
|
295
290
|
error = formatMessage(messages.maxMinLengthMessage, {
|
|
296
291
|
minLength,
|
|
297
292
|
maxLength,
|
|
298
293
|
});
|
|
299
|
-
} else if (e.length > maxLength && !containsTags) {
|
|
300
|
-
error = formatMessage(messages.maxMinLengthMessage, {
|
|
301
|
-
minLength,
|
|
302
|
-
maxLength,
|
|
303
|
-
});
|
|
304
294
|
}
|
|
305
295
|
return error;
|
|
306
296
|
};
|
|
@@ -325,11 +315,7 @@ export const Zalo = (props) => {
|
|
|
325
315
|
};
|
|
326
316
|
|
|
327
317
|
const renderTextBoxesForListParams = (listParam) => {
|
|
328
|
-
const { name = '', error = '', value = ''
|
|
329
|
-
console.log('******324',listParam);
|
|
330
|
-
const containsTags = value && value.includes('{{') && value.includes('}}');
|
|
331
|
-
const isExceedingLength = value.length > maxLength;
|
|
332
|
-
console.log('***Length***326',containsTags, isExceedingLength);
|
|
318
|
+
const { name = '', error = '', value = '' } = listParam;
|
|
333
319
|
return (
|
|
334
320
|
<CapInput
|
|
335
321
|
id={`zalo-${name}`}
|
|
@@ -370,14 +356,11 @@ export const Zalo = (props) => {
|
|
|
370
356
|
let disableCheck = false;
|
|
371
357
|
templateListParams?.forEach((listParams) => {
|
|
372
358
|
const { error = '', value = '' } = listParams;
|
|
373
|
-
|
|
374
|
-
const errorMessage = !error
|
|
359
|
+
const hasTag = value && value.includes('{{') && value.includes('}}');
|
|
360
|
+
const errorMessage = !error && !hasTag
|
|
375
361
|
? handleErrorValidation(value, listParams)
|
|
376
362
|
: error;
|
|
377
|
-
|
|
378
|
-
// Only disable if there's an error and the value doesn't contain tags
|
|
379
|
-
const containsTags = value && value.includes('{{') && value.includes('}}');
|
|
380
|
-
if (errorMessage && !containsTags) {
|
|
363
|
+
if (errorMessage) {
|
|
381
364
|
disableCheck = true;
|
|
382
365
|
}
|
|
383
366
|
});
|
|
@@ -387,7 +370,6 @@ export const Zalo = (props) => {
|
|
|
387
370
|
const varMap = {};
|
|
388
371
|
templateListParams?.forEach((listParam) => {
|
|
389
372
|
const { name = '', value = '' } = listParam;
|
|
390
|
-
console.log('******390',listParam);
|
|
391
373
|
varMap[name] = value;
|
|
392
374
|
}
|
|
393
375
|
);
|
|
@@ -421,10 +403,8 @@ export const Zalo = (props) => {
|
|
|
421
403
|
const renderContent = () =>
|
|
422
404
|
templateListParams?.map((listParam) => {
|
|
423
405
|
const { name = '', value = '', maxLength = '' } = listParam;
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
const isExceedingLength = value.length > maxLength;
|
|
427
|
-
console.log('***Length***418',containsTags, isExceedingLength);
|
|
406
|
+
const hasTag = value && value.includes('{{') && value.includes('}}');
|
|
407
|
+
|
|
428
408
|
return (
|
|
429
409
|
<>
|
|
430
410
|
{renderTextBoxesForListParams(listParam)}
|
|
@@ -434,21 +414,13 @@ export const Zalo = (props) => {
|
|
|
434
414
|
name,
|
|
435
415
|
})}
|
|
436
416
|
</CapLabel>
|
|
437
|
-
<CapLabel
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
})
|
|
445
|
-
) : (
|
|
446
|
-
formatMessage(messages.charactersCount, {
|
|
447
|
-
variableLength: value.length,
|
|
448
|
-
maxLength,
|
|
449
|
-
})
|
|
450
|
-
)
|
|
451
|
-
}
|
|
417
|
+
<CapLabel className="variable-field-length">
|
|
418
|
+
{!hasTag && (
|
|
419
|
+
formatMessage(messages.charactersCount, {
|
|
420
|
+
variableLength: value.length,
|
|
421
|
+
maxLength,
|
|
422
|
+
})
|
|
423
|
+
)}
|
|
452
424
|
</CapLabel>
|
|
453
425
|
</CapRow>
|
|
454
426
|
</>
|
|
@@ -495,7 +467,21 @@ export const Zalo = (props) => {
|
|
|
495
467
|
}
|
|
496
468
|
/>
|
|
497
469
|
</CapRow>
|
|
498
|
-
<CapRow className="zalo-variable-list">
|
|
470
|
+
<CapRow className="zalo-variable-list">
|
|
471
|
+
{renderContent()}
|
|
472
|
+
</CapRow>
|
|
473
|
+
<CapAlert
|
|
474
|
+
message={
|
|
475
|
+
<CapRow>
|
|
476
|
+
<CapIcon type="warning" />
|
|
477
|
+
<CapLabel type="label2">
|
|
478
|
+
{formatMessage(messages.tagLengthWarning)}
|
|
479
|
+
</CapLabel>
|
|
480
|
+
</CapRow>
|
|
481
|
+
}
|
|
482
|
+
type="warning"
|
|
483
|
+
className="zalo-warning-message"
|
|
484
|
+
/>
|
|
499
485
|
</CapRow>
|
|
500
486
|
</CapColumn>
|
|
501
487
|
<CapColumn span={10}>
|
|
@@ -27,6 +27,10 @@
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
.zalo-warning-message {
|
|
31
|
+
margin-bottom: $CAP_SPACE_16;
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
.variable-field-container {
|
|
31
35
|
display: flex;
|
|
32
36
|
margin-top: $CAP_SPACE_08;
|
|
@@ -38,10 +42,6 @@
|
|
|
38
42
|
.variable-field-length {
|
|
39
43
|
position: absolute;
|
|
40
44
|
right: 0;
|
|
41
|
-
|
|
42
|
-
&.tag-length-warning {
|
|
43
|
-
color: $FONT_COLOR_02;
|
|
44
|
-
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -85,6 +85,6 @@ export default defineMessages({
|
|
|
85
85
|
},
|
|
86
86
|
tagLengthWarning: {
|
|
87
87
|
id: `${prefix}.tagLengthWarning`,
|
|
88
|
-
defaultMessage: "If the
|
|
88
|
+
defaultMessage: "If the resolved tag values in the variables exceed their character count limit, the message will fail to go out.",
|
|
89
89
|
},
|
|
90
90
|
});
|