@capillarytech/creatives-library 7.13.30 → 7.13.32-alpha.1
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/config/app.js +2 -1
- package/package.json +1 -1
- package/services/api.js +5 -0
- package/utils/cdnTransformation.js +93 -21
- package/utils/tagValidations.js +5 -0
- package/v2Containers/CreativesContainer/index.js +9 -4
- package/v2Containers/Email/actions.js +8 -0
- package/v2Containers/Email/constants.js +1 -0
- package/v2Containers/Email/index.js +4 -2
- package/v2Containers/Email/reducer.js +2 -0
- package/v2Containers/Email/sagas.js +18 -1
- package/v2Containers/Line/Container/Text/index.js +4 -5
- package/v2Containers/Rcs/index.js +4 -4
- package/v2Containers/Viber/index.js +5 -5
- package/v2Containers/Whatsapp/index.js +3 -3
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +10 -10
package/config/app.js
CHANGED
|
@@ -16,7 +16,8 @@ const config = {
|
|
|
16
16
|
accountConfig: (strs, accountId) => `${window.location.origin}/org/config/AccountAdd?q=a&channelId=2&accountId=${accountId}&edit=1`,
|
|
17
17
|
},
|
|
18
18
|
development: {
|
|
19
|
-
api_endpoint: '
|
|
19
|
+
api_endpoint: 'http://localhost:2022/arya/api/v1/creatives',
|
|
20
|
+
// api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
|
|
20
21
|
campaigns_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/campaigns',
|
|
21
22
|
campaigns_api_org_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/org/campaign',
|
|
22
23
|
auth_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/auth',
|
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -489,4 +489,9 @@ export const getSenderDetails = (channel, orgUnitId) => {
|
|
|
489
489
|
export const getCdnTransformationConfig = () => {
|
|
490
490
|
const url = `${API_ENDPOINT}/common/getCdnTransformationConfig`;
|
|
491
491
|
return request(url, getAPICallObject('GET'));
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
export const getS3UrlFileSizes = (data) => {
|
|
495
|
+
const url = `${API_ENDPOINT}/assets/files/metadata`;
|
|
496
|
+
return request(url, getAPICallObject('POST', data));
|
|
492
497
|
}
|
|
@@ -3,7 +3,7 @@ import isEmpty from "lodash/isEmpty";
|
|
|
3
3
|
import forOwn from "lodash/forOwn";
|
|
4
4
|
import isNumber from "lodash/isNumber";
|
|
5
5
|
import Bugsnag from '@bugsnag/js';
|
|
6
|
-
|
|
6
|
+
import * as Api from '../services/api';
|
|
7
7
|
/* eslint-disable no-unused-expressions */
|
|
8
8
|
import { parse } from "node-html-parser";
|
|
9
9
|
import { EMAIL } from '../v2Containers/CreativesContainer/constants';
|
|
@@ -266,16 +266,21 @@ export const getCdnUrl = ({
|
|
|
266
266
|
/**
|
|
267
267
|
*
|
|
268
268
|
* @param {string} htmlContents accepts htmlContents - strigified.
|
|
269
|
-
* @returns htmlContents with updated urls in image tag
|
|
269
|
+
* @returns {Promise} htmlContents with updated urls in image tag
|
|
270
270
|
*/
|
|
271
|
-
export const updateImagesInHtml = (htmlContents) => {
|
|
271
|
+
export const updateImagesInHtml = async (htmlContents) => {
|
|
272
272
|
if(!htmlContents || typeof htmlContents !== "string"){
|
|
273
273
|
return htmlContents;
|
|
274
274
|
}
|
|
275
275
|
const copiedHtmlContents = htmlContents;
|
|
276
276
|
try {
|
|
277
277
|
const root = parse(htmlContents);
|
|
278
|
-
const isEmailQualityOverridden = getLocalStorageItem(CREATIVES_CDN_OVERRIDE_DEFAULT_EMAIL_QUALITY_KEY)
|
|
278
|
+
const isEmailQualityOverridden = getLocalStorageItem(CREATIVES_CDN_OVERRIDE_DEFAULT_EMAIL_QUALITY_KEY);
|
|
279
|
+
let urlQualityMappings;
|
|
280
|
+
if(isEmailQualityOverridden){
|
|
281
|
+
const urlList = root?.querySelectorAll("img")?.map(element=>element.getAttribute("src"));
|
|
282
|
+
urlQualityMappings = await getUrlsToQualityMapping(urlList);
|
|
283
|
+
}
|
|
279
284
|
root?.querySelectorAll("img")?.forEach((element) => {
|
|
280
285
|
const imageSrc = element.getAttribute("src");
|
|
281
286
|
const height = element.getAttribute("height");
|
|
@@ -283,8 +288,8 @@ export const updateImagesInHtml = (htmlContents) => {
|
|
|
283
288
|
|
|
284
289
|
let emailOverrideQuality = null;
|
|
285
290
|
if (isEmailQualityOverridden) {
|
|
286
|
-
const tempQuality =
|
|
287
|
-
if (tempQuality !== -1) {
|
|
291
|
+
const tempQuality = urlQualityMappings?.[imageSrc];
|
|
292
|
+
if (tempQuality && tempQuality !== -1) {
|
|
288
293
|
emailOverrideQuality = tempQuality;
|
|
289
294
|
}
|
|
290
295
|
}
|
|
@@ -314,17 +319,21 @@ export const updateImagesInHtml = (htmlContents) => {
|
|
|
314
319
|
* @returns
|
|
315
320
|
* Transforms the email template's html by images replacing the s3 url / cdn url with cdn url.
|
|
316
321
|
*/
|
|
317
|
-
export
|
|
322
|
+
export function transformEmailTemplates(contents){
|
|
318
323
|
const contentsCopy = cloneDeep(contents);
|
|
319
324
|
try {
|
|
320
325
|
const base = contentsCopy?.versions?.base;
|
|
321
326
|
const languages = base?.selectedLanguages;
|
|
327
|
+
let promises = [];
|
|
322
328
|
languages?.forEach((lang) => {
|
|
323
329
|
const htmlContents = base?.[lang]?.["template-content"];
|
|
324
|
-
|
|
325
|
-
|
|
330
|
+
promises.push(
|
|
331
|
+
updateImagesInHtml(htmlContents).then(newHtmlContents=>{
|
|
332
|
+
base[lang]["template-content"] = newHtmlContents;
|
|
333
|
+
})
|
|
334
|
+
)
|
|
326
335
|
});
|
|
327
|
-
return contentsCopy;
|
|
336
|
+
return Promise.all(promises).then(_=>contentsCopy);
|
|
328
337
|
} catch (e) {
|
|
329
338
|
Bugsnag.leaveBreadcrumb(
|
|
330
339
|
"Some error has occured while transforming email templates"
|
|
@@ -508,11 +517,12 @@ export function checkValidUrl(url){
|
|
|
508
517
|
|
|
509
518
|
const isValidUrl = regexWithExtension.test(url);
|
|
510
519
|
const isCdnUrl = url.includes(CREATIVES_CDN_BASE_URL);
|
|
511
|
-
|
|
520
|
+
const isS3Url = isValidUrl && !isCdnUrl;
|
|
512
521
|
|
|
513
522
|
return {
|
|
514
523
|
isValidUrl,
|
|
515
524
|
isCdnUrl,
|
|
525
|
+
isS3Url,
|
|
516
526
|
}
|
|
517
527
|
}
|
|
518
528
|
|
|
@@ -548,23 +558,24 @@ export function getCdnEmailImageQuality(url) {
|
|
|
548
558
|
* 1. If it is s3 url, it returns quality inversly proportional to its filesize.
|
|
549
559
|
* 2. If it is cdn url, it extracts quality from url and returns the same.
|
|
550
560
|
*/
|
|
551
|
-
export function
|
|
561
|
+
export function getS3EmailImageQuality(url){
|
|
552
562
|
if(!url || typeof url !== "string") return -1;
|
|
553
563
|
|
|
554
|
-
const {isValidUrl, isCdnUrl} = checkValidUrl(url);
|
|
555
|
-
|
|
556
|
-
if(!isValidUrl) return -1;
|
|
557
|
-
|
|
558
|
-
if(isCdnUrl){
|
|
559
|
-
return getCdnEmailImageQuality(url);
|
|
560
|
-
}
|
|
561
|
-
|
|
562
564
|
const fileSize = getFizeSizeFromUrl(url);
|
|
563
565
|
|
|
564
|
-
if(!fileSize) return
|
|
566
|
+
if(!fileSize) return;
|
|
565
567
|
|
|
566
568
|
return getEmailImageOverrideQuality(fileSize);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
export function getS3EmailImageQualityMapping(urlToFileSizeMapping){
|
|
572
|
+
if(typeof urlToFileSizeMapping !== "object" || !urlToFileSizeMapping) return {};
|
|
567
573
|
|
|
574
|
+
const urlToImageQualityMapping = {};
|
|
575
|
+
for (let url of Object.keys(urlToFileSizeMapping)) {
|
|
576
|
+
urlToImageQualityMapping[url] = getEmailImageOverrideQuality(urlToFileSizeMapping[url]);
|
|
577
|
+
}
|
|
578
|
+
return urlToImageQualityMapping;
|
|
568
579
|
}
|
|
569
580
|
|
|
570
581
|
/**
|
|
@@ -615,4 +626,65 @@ export function getEmailImageOverrideQuality(fileSize) {
|
|
|
615
626
|
} catch (e) {
|
|
616
627
|
return -1;
|
|
617
628
|
}
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
*
|
|
633
|
+
* @param {array} urlList ex ['1.jpg','2.jpg'] // these can be any urls (s3, cdn or others)
|
|
634
|
+
*
|
|
635
|
+
*/
|
|
636
|
+
export async function getUrlsToQualityMapping(urlList){
|
|
637
|
+
if(!urlList?.length) return {};
|
|
638
|
+
|
|
639
|
+
const urlQualityMapping = {};
|
|
640
|
+
|
|
641
|
+
const nonSelectedS3Urls = []; //we do not know file sizes of these s3 urls yet.
|
|
642
|
+
|
|
643
|
+
urlList?.forEach(url=>{
|
|
644
|
+
const {isS3Url, isCdnUrl} = checkValidUrl(url);
|
|
645
|
+
|
|
646
|
+
if (isCdnUrl){
|
|
647
|
+
urlQualityMapping[url] = getCdnEmailImageQuality(url);
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
if(isS3Url){
|
|
651
|
+
const s3FileQuality = getS3EmailImageQuality(url);
|
|
652
|
+
if(s3FileQuality){
|
|
653
|
+
urlQualityMapping[url] = s3FileQuality;
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
if(!s3FileQuality){
|
|
657
|
+
nonSelectedS3Urls.push(url)
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
})
|
|
661
|
+
|
|
662
|
+
if(nonSelectedS3Urls?.length){
|
|
663
|
+
let nonSelectedS3UrlMapping = await getS3FileSizesFromUrl(nonSelectedS3Urls)
|
|
664
|
+
const nonSelectedS3UrlQualityMapping = getS3EmailImageQualityMapping(nonSelectedS3UrlMapping)
|
|
665
|
+
let x = {...urlQualityMapping,...nonSelectedS3UrlQualityMapping};
|
|
666
|
+
return x;
|
|
667
|
+
}
|
|
668
|
+
return urlQualityMapping;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
export async function getS3FileSizesFromUrl(urlList) {
|
|
672
|
+
if(!urlList?.length){
|
|
673
|
+
return {}
|
|
674
|
+
}
|
|
675
|
+
try{
|
|
676
|
+
let data = await Api.getS3UrlFileSizes({ keys: urlList });
|
|
677
|
+
if (data?.status?.code === 200 && data?.success && data?.response) {
|
|
678
|
+
const result = data?.response;
|
|
679
|
+
const urlMapping = {};
|
|
680
|
+
for (let url of Object.keys(result)) {
|
|
681
|
+
urlMapping[url] = result[url];
|
|
682
|
+
}
|
|
683
|
+
return urlMapping;
|
|
684
|
+
} else {
|
|
685
|
+
return {};
|
|
686
|
+
}
|
|
687
|
+
}catch(e){
|
|
688
|
+
return {};
|
|
689
|
+
}
|
|
618
690
|
}
|
package/utils/tagValidations.js
CHANGED
|
@@ -29,6 +29,7 @@ export const validateTags = ({
|
|
|
29
29
|
valid: true,
|
|
30
30
|
missingTags: [],
|
|
31
31
|
unsupportedTags: [],
|
|
32
|
+
isBraceError: false,
|
|
32
33
|
};
|
|
33
34
|
if(tags && tags.length) {
|
|
34
35
|
lodashForEach(tags, ({
|
|
@@ -78,6 +79,10 @@ export const validateTags = ({
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
}
|
|
82
|
+
response.isBraceError = !validateIfTagClosed(content);
|
|
83
|
+
// response should not be valid if there is unbalanced bracket error, as
|
|
84
|
+
// validations (eg button) are handled on valid property coming from the response.
|
|
85
|
+
response.isBraceError ? response.valid = false : response.valid = true;
|
|
81
86
|
return response;
|
|
82
87
|
}
|
|
83
88
|
|
|
@@ -460,7 +460,7 @@ export class Creatives extends React.Component {
|
|
|
460
460
|
return templateData || null;
|
|
461
461
|
}
|
|
462
462
|
|
|
463
|
-
getCreativesData = (channel, template, templateRecords) => { //from creatives to consumers
|
|
463
|
+
getCreativesData = async (channel, template, templateRecords) => { //from creatives to consumers
|
|
464
464
|
let templateData = { channel };
|
|
465
465
|
switch (channel) {
|
|
466
466
|
case constants.SMS:
|
|
@@ -499,7 +499,7 @@ export class Creatives extends React.Component {
|
|
|
499
499
|
if (!html_content) {
|
|
500
500
|
emailBase = templateRecords.base;
|
|
501
501
|
}
|
|
502
|
-
const newHtmlContent = updateImagesInHtml(html_content);
|
|
502
|
+
const newHtmlContent = await updateImagesInHtml(html_content);
|
|
503
503
|
templateData = {...templateData, ...emailBase, emailBody: newHtmlContent, emailSubject: (emailBase && emailBase.subject) ? emailBase.subject : ''};
|
|
504
504
|
delete templateData.html_content;
|
|
505
505
|
delete templateData.subject;
|
|
@@ -821,11 +821,16 @@ export class Creatives extends React.Component {
|
|
|
821
821
|
isGetFormData: false,
|
|
822
822
|
},
|
|
823
823
|
() => {
|
|
824
|
+
console.log("hello getFormData")
|
|
824
825
|
const templateData = this.state.templateData ? this.state.templateData : template; //select existing or create new content
|
|
825
826
|
const channel = templateData.type;
|
|
827
|
+
// this.props.actions.showCreativesContainerLoader();
|
|
826
828
|
const creativesData = this.getCreativesData(channel, template, templateData );// convers data to consumer understandable format
|
|
827
|
-
|
|
828
|
-
|
|
829
|
+
creativesData.then(data=>{
|
|
830
|
+
this.logGTMEvent(channel, data);
|
|
831
|
+
this.props.getCreativesData(data);// send data to consumer
|
|
832
|
+
// this.props.actions.hideCreativesContanerLoader();
|
|
833
|
+
})
|
|
829
834
|
},
|
|
830
835
|
);
|
|
831
836
|
}
|
|
@@ -36,3 +36,4 @@ export const DUPLICATE_TEMPLATE_REQUEST = 'app/v2Containers/Email/DUPLICATE_TEMP
|
|
|
36
36
|
export const DUPLICATE_TEMPLATE_SUCCESS = 'app/v2Containers/Email/DUPLICATE_TEMPLATE_SUCCESS';
|
|
37
37
|
export const DUPLICATE_TEMPLATE_FAILURE = 'app/v2Containers/Email/DUPLICATE_TEMPLATE_FAILURE';
|
|
38
38
|
|
|
39
|
+
export const TRANSFORM_EMAIL_TEMPLATE_REQUEST = 'app/v2Containers/Email/TRANSFORM_EMAIL_TEMPLATE_REQUEST';
|
|
@@ -2403,8 +2403,10 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2403
2403
|
|
|
2404
2404
|
// if (saveCount === 0) {
|
|
2405
2405
|
|
|
2406
|
-
const newEmail = transformEmailTemplates(obj);
|
|
2407
|
-
this.props.actions.
|
|
2406
|
+
// const newEmail = transformEmailTemplates(obj);
|
|
2407
|
+
this.props.actions.transformEmailTemplate(obj, (newEmail)=>{
|
|
2408
|
+
this.props.actions.createTemplate(newEmail, this.onUpdateTemplateComplete);
|
|
2409
|
+
});
|
|
2408
2410
|
// } else {
|
|
2409
2411
|
// this.setState({saveObj: obj, targetSaveCount: saveCount, mode: "save", saveEdmDataMode: 'save'}, () => {
|
|
2410
2412
|
// _.forEach(data.selectedLanguages, (language, langIndex) => {
|
|
@@ -140,6 +140,8 @@ function emailReducer(state = initialState, action) {
|
|
|
140
140
|
.set('fetchingCmsData', false)
|
|
141
141
|
.set('duplicateResponse', fromJS({}))
|
|
142
142
|
.set('cmsData', '');
|
|
143
|
+
case types.TRANSFORM_EMAIL_TEMPLATE_REQUEST:
|
|
144
|
+
return state.set("createTemplateInProgress", true);
|
|
143
145
|
default:
|
|
144
146
|
return state;
|
|
145
147
|
}
|
|
@@ -2,7 +2,7 @@ import { take, cancel, call, put, takeLatest, takeEvery } from 'redux-saga/effec
|
|
|
2
2
|
import { LOCATION_CHANGE } from 'react-router-redux';
|
|
3
3
|
import * as Api from '../../services/api';
|
|
4
4
|
import * as types from './constants';
|
|
5
|
-
import { storeS3FileSizeDetails } from '../../utils/cdnTransformation';
|
|
5
|
+
import { transformEmailTemplates, storeS3FileSizeDetails } from '../../utils/cdnTransformation';
|
|
6
6
|
|
|
7
7
|
export function* createTemplate(template) {
|
|
8
8
|
let errorMsg;
|
|
@@ -20,6 +20,15 @@ export function* createTemplate(template) {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export function* transformEmailTemplate({template, callback}) {
|
|
24
|
+
try {
|
|
25
|
+
const result = yield call(transformEmailTemplates, template);
|
|
26
|
+
yield callback(result);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
yield callback(template);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
23
32
|
export function* duplicateTemplate(id, channel) {
|
|
24
33
|
let errorMsg;
|
|
25
34
|
try {
|
|
@@ -89,6 +98,13 @@ function* watchCreateTemplate() {
|
|
|
89
98
|
yield cancel(watcher);
|
|
90
99
|
}
|
|
91
100
|
|
|
101
|
+
function* watchTransformEmailTemplate() {
|
|
102
|
+
const watcher = yield takeLatest(types.TRANSFORM_EMAIL_TEMPLATE_REQUEST, transformEmailTemplate);
|
|
103
|
+
yield take(LOCATION_CHANGE);
|
|
104
|
+
yield cancel(watcher);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
92
108
|
function* watchGetTemplateDetails() {
|
|
93
109
|
const watcher = yield takeLatest(types.GET_TEMPLATE_DETAILS_REQUEST, getTemplateDetails);
|
|
94
110
|
yield take(LOCATION_CHANGE);
|
|
@@ -128,6 +144,7 @@ function* watchDuplicateTemplate() {
|
|
|
128
144
|
// All sagas to be loaded
|
|
129
145
|
export default [
|
|
130
146
|
watchCreateTemplate,
|
|
147
|
+
watchTransformEmailTemplate,
|
|
131
148
|
watchGetTemplateDetails,
|
|
132
149
|
watchGetAllAssets,
|
|
133
150
|
watchGetCmsSetting,
|
|
@@ -15,7 +15,7 @@ import messages from './messages';
|
|
|
15
15
|
import style from './style';
|
|
16
16
|
import withStyles from '../../../../hoc/withStyles';
|
|
17
17
|
import globalMessages from '../../../Cap/messages';
|
|
18
|
-
import {
|
|
18
|
+
import { validateTags } from '../../../../utils/tagValidations';
|
|
19
19
|
|
|
20
20
|
const { TextArea } = CapInput;
|
|
21
21
|
const {CapCustomCardList} = CapCustomCard;
|
|
@@ -118,7 +118,7 @@ export const LineText = ({
|
|
|
118
118
|
|
|
119
119
|
const updateTextContentError = (value) => {
|
|
120
120
|
let errorMessage = false;
|
|
121
|
-
const { valid } = validateTags({
|
|
121
|
+
const { valid, isBraceError } = validateTags({
|
|
122
122
|
content: value,
|
|
123
123
|
tagsParam: tags,
|
|
124
124
|
injectedTagsParams: injectedTags,
|
|
@@ -129,12 +129,11 @@ export const LineText = ({
|
|
|
129
129
|
errorMessage = formatMessage(messages.emptyTitleErrorMessage);
|
|
130
130
|
} else if (value.length > charLimit) {
|
|
131
131
|
errorMessage = formatMessage(messages.limitExceededContentErrorMessage);
|
|
132
|
+
} else if (isBraceError) {
|
|
133
|
+
errorMessage = formatMessage(globalMessages.unbalanacedCurlyBraces);
|
|
132
134
|
} else if (!valid && !isFullMode) {
|
|
133
135
|
errorMessage = formatMessage(messages.invalidTagError);
|
|
134
136
|
}
|
|
135
|
-
else if (!validateIfTagClosed(value)) {
|
|
136
|
-
errorMessage = formatMessage(globalMessages.unbalanacedCurlyBraces);
|
|
137
|
-
}
|
|
138
137
|
updateErrorMessageTextArea(errorMessage);
|
|
139
138
|
}
|
|
140
139
|
|
|
@@ -80,7 +80,7 @@ import addCreativesIcon from '../Assets/images/addCreativesIllustration.svg';
|
|
|
80
80
|
import Templates from '../Templates';
|
|
81
81
|
import SmsTraiEdit from '../SmsTrai/Edit';
|
|
82
82
|
import TagList from '../TagList';
|
|
83
|
-
import { validateTags
|
|
83
|
+
import { validateTags } from '../../utils/tagValidations';
|
|
84
84
|
import { getCdnUrl } from '../../utils/cdnTransformation';
|
|
85
85
|
const { Group: CapCheckboxGroup } = CapCheckbox;
|
|
86
86
|
export const Rcs = (props) => {
|
|
@@ -416,7 +416,7 @@ export const Rcs = (props) => {
|
|
|
416
416
|
|
|
417
417
|
const templateDescErrorHandler = (value) => {
|
|
418
418
|
let errorMessage = false;
|
|
419
|
-
const { unsupportedTags } =
|
|
419
|
+
const { unsupportedTags, isBraceError } =
|
|
420
420
|
validateTags({
|
|
421
421
|
content: value,
|
|
422
422
|
tagsParam: tags,
|
|
@@ -435,8 +435,8 @@ export const Rcs = (props) => {
|
|
|
435
435
|
unsupportedTags,
|
|
436
436
|
},
|
|
437
437
|
);
|
|
438
|
-
}
|
|
439
|
-
if (
|
|
438
|
+
}
|
|
439
|
+
if (isBraceError){
|
|
440
440
|
errorMessage = formatMessage(globalMessages.unbalanacedCurlyBraces);
|
|
441
441
|
}
|
|
442
442
|
return errorMessage;
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from '@capillarytech/cap-ui-library';
|
|
24
24
|
import { makeSelectViber, makeSelectCreateViber } from './selectors';
|
|
25
25
|
import * as viberActions from './actions';
|
|
26
|
-
import {
|
|
26
|
+
import { validateTags } from '../../utils/tagValidations';
|
|
27
27
|
import TemplatePreview from '../../v2Components/TemplatePreview';
|
|
28
28
|
import {
|
|
29
29
|
CAP_G09,
|
|
@@ -213,7 +213,7 @@ const Viber = (props) => {
|
|
|
213
213
|
// validation on Text area and tags validation
|
|
214
214
|
const updateTextContentError = (value) => {
|
|
215
215
|
let errorMessage = false;
|
|
216
|
-
const { valid } = validateTags({
|
|
216
|
+
const { valid, isBraceError } = validateTags({
|
|
217
217
|
content: value,
|
|
218
218
|
tagsParam: tags,
|
|
219
219
|
injectedTagsParams: injectedTags,
|
|
@@ -224,12 +224,12 @@ const Viber = (props) => {
|
|
|
224
224
|
errorMessage = formatMessage(messages.emptyContentErrorMessage);
|
|
225
225
|
} else if (value.length > charLimit) {
|
|
226
226
|
errorMessage = formatMessage(messages.limitExceededContentErrorMessage);
|
|
227
|
+
} else if (isBraceError){
|
|
228
|
+
errorMessage = formatMessage(globalMessages.unbalanacedCurlyBraces);
|
|
227
229
|
} else if (!valid) {
|
|
228
230
|
errorMessage = formatMessage(messages.invalidTagError);
|
|
229
231
|
}
|
|
230
|
-
|
|
231
|
-
errorMessage = formatMessage(globalMessages.unbalanacedCurlyBraces);
|
|
232
|
-
}
|
|
232
|
+
|
|
233
233
|
updateErrorMessageTextArea(errorMessage);
|
|
234
234
|
};
|
|
235
235
|
|
|
@@ -67,7 +67,7 @@ import withCreatives from '../../hoc/withCreatives';
|
|
|
67
67
|
import TemplatePreview from '../../v2Components/TemplatePreview';
|
|
68
68
|
import CapImageUpload from '../../v2Components/CapImageUpload';
|
|
69
69
|
import TagList from '../TagList';
|
|
70
|
-
import { validateTags
|
|
70
|
+
import { validateTags } from '../../utils/tagValidations';
|
|
71
71
|
import { capitalizeString } from '../../utils/Formatter';
|
|
72
72
|
import CapWhatsappCTA from '../../v2Components/CapWhatsappCTA';
|
|
73
73
|
import {
|
|
@@ -1227,14 +1227,14 @@ export const Whatsapp = (props) => {
|
|
|
1227
1227
|
};
|
|
1228
1228
|
|
|
1229
1229
|
const tagValidationErrorMessage = () => {
|
|
1230
|
-
const { unsupportedTags = [] } = tagValidationResponse;
|
|
1230
|
+
const { unsupportedTags = [] , isBraceError} = tagValidationResponse;
|
|
1231
1231
|
let tagError = '';
|
|
1232
1232
|
if (unsupportedTags.length > 0) {
|
|
1233
1233
|
tagError = formatMessage(globalMessages.unsupportedTagsValidationError, {
|
|
1234
1234
|
unsupportedTags,
|
|
1235
1235
|
});
|
|
1236
1236
|
}
|
|
1237
|
-
if (
|
|
1237
|
+
if (isBraceError){
|
|
1238
1238
|
tagError = formatMessage(globalMessages.unbalanacedCurlyBraces);
|
|
1239
1239
|
}
|
|
1240
1240
|
return <CapError>{tagError}</CapError>;
|
|
@@ -310724,12 +310724,6 @@ exports[`Creatives Whatsapp test1/> template message 8`] = `
|
|
|
310724
310724
|
"id": "creatives.containersV2.Whatsapp.btnDisabledTooltip",
|
|
310725
310725
|
},
|
|
310726
310726
|
],
|
|
310727
|
-
Array [
|
|
310728
|
-
Object {
|
|
310729
|
-
"defaultMessage": "Invalid label, please close all curly braces",
|
|
310730
|
-
"id": "creatives.componentsV2.unbalanacedCurlyBraces",
|
|
310731
|
-
},
|
|
310732
|
-
],
|
|
310733
310727
|
Array [
|
|
310734
310728
|
Object {
|
|
310735
310729
|
"defaultMessage": "Select",
|
|
@@ -312515,10 +312509,6 @@ exports[`Creatives Whatsapp test1/> template message 8`] = `
|
|
|
312515
312509
|
"type": "return",
|
|
312516
312510
|
"value": undefined,
|
|
312517
312511
|
},
|
|
312518
|
-
Object {
|
|
312519
|
-
"type": "return",
|
|
312520
|
-
"value": undefined,
|
|
312521
|
-
},
|
|
312522
312512
|
],
|
|
312523
312513
|
},
|
|
312524
312514
|
}
|
|
@@ -317503,6 +317493,7 @@ exports[`Creatives Whatsapp test1/> template message 8`] = `
|
|
|
317503
317493
|
size="large"
|
|
317504
317494
|
suffix={
|
|
317505
317495
|
<CapButton
|
|
317496
|
+
disabled={false}
|
|
317506
317497
|
isAddBtn={true}
|
|
317507
317498
|
onClick={[Function]}
|
|
317508
317499
|
type="flat"
|
|
@@ -318285,6 +318276,7 @@ exports[`Creatives Whatsapp test1/> template message 8`] = `
|
|
|
318285
318276
|
</CapHeading>
|
|
318286
318277
|
</div>
|
|
318287
318278
|
<CapButton
|
|
318279
|
+
disabled={false}
|
|
318288
318280
|
isAddBtn={true}
|
|
318289
318281
|
onClick={[Function]}
|
|
318290
318282
|
type="flat"
|
|
@@ -318292,6 +318284,7 @@ exports[`Creatives Whatsapp test1/> template message 8`] = `
|
|
|
318292
318284
|
<Button
|
|
318293
318285
|
block={false}
|
|
318294
318286
|
className="cap-button-v2 flat-btn add-btn has-icon"
|
|
318287
|
+
disabled={false}
|
|
318295
318288
|
ghost={false}
|
|
318296
318289
|
htmlType="button"
|
|
318297
318290
|
loading={false}
|
|
@@ -318301,6 +318294,7 @@ exports[`Creatives Whatsapp test1/> template message 8`] = `
|
|
|
318301
318294
|
<Wave>
|
|
318302
318295
|
<button
|
|
318303
318296
|
className="ant-btn cap-button-v2 flat-btn add-btn has-icon ant-btn-flat"
|
|
318297
|
+
disabled={false}
|
|
318304
318298
|
onClick={[Function]}
|
|
318305
318299
|
type="button"
|
|
318306
318300
|
>
|
|
@@ -318380,6 +318374,7 @@ exports[`Creatives Whatsapp test1/> template message 8`] = `
|
|
|
318380
318374
|
"minRows": 3,
|
|
318381
318375
|
}
|
|
318382
318376
|
}
|
|
318377
|
+
errorMessage={false}
|
|
318383
318378
|
id="whatsapp-create-template-message-input"
|
|
318384
318379
|
key=".0"
|
|
318385
318380
|
labelPosition="top"
|
|
@@ -318388,6 +318383,7 @@ exports[`Creatives Whatsapp test1/> template message 8`] = `
|
|
|
318388
318383
|
>
|
|
318389
318384
|
<ComponentWithLabelHOC__CapComponentStyled
|
|
318390
318385
|
className="component-with-label"
|
|
318386
|
+
errorMessage={false}
|
|
318391
318387
|
labelPosition="top"
|
|
318392
318388
|
>
|
|
318393
318389
|
<div
|
|
@@ -318406,6 +318402,7 @@ exports[`Creatives Whatsapp test1/> template message 8`] = `
|
|
|
318406
318402
|
"minRows": 3,
|
|
318407
318403
|
}
|
|
318408
318404
|
}
|
|
318405
|
+
errorMessage={false}
|
|
318409
318406
|
id="whatsapp-create-template-message-input"
|
|
318410
318407
|
onChange={[Function]}
|
|
318411
318408
|
size="large"
|
|
@@ -318426,6 +318423,7 @@ exports[`Creatives Whatsapp test1/> template message 8`] = `
|
|
|
318426
318423
|
}
|
|
318427
318424
|
}
|
|
318428
318425
|
cols={35}
|
|
318426
|
+
errorMessage={false}
|
|
318429
318427
|
id="whatsapp-create-template-message-input"
|
|
318430
318428
|
onChange={[Function]}
|
|
318431
318429
|
onKeyDown={[Function]}
|
|
@@ -318442,6 +318440,7 @@ exports[`Creatives Whatsapp test1/> template message 8`] = `
|
|
|
318442
318440
|
}
|
|
318443
318441
|
className="TextArea__StyledTextArea-sc-177dfyt-2 bSaDoB"
|
|
318444
318442
|
cols={35}
|
|
318443
|
+
errorMessage={false}
|
|
318445
318444
|
id="whatsapp-create-template-message-input"
|
|
318446
318445
|
onChange={[Function]}
|
|
318447
318446
|
onKeyDown={[Function]}
|
|
@@ -318456,6 +318455,7 @@ exports[`Creatives Whatsapp test1/> template message 8`] = `
|
|
|
318456
318455
|
<textarea
|
|
318457
318456
|
className="ant-input TextArea__StyledTextArea-sc-177dfyt-2 bSaDoB"
|
|
318458
318457
|
cols={35}
|
|
318458
|
+
errorMessage={false}
|
|
318459
318459
|
id="whatsapp-create-template-message-input"
|
|
318460
318460
|
onChange={[Function]}
|
|
318461
318461
|
onKeyDown={[Function]}
|