@capillarytech/creatives-library 7.17.82-alpha.0 → 7.17.82-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/containers/Cap/sagas.js +7 -5
- package/containers/Cap/tests/saga.test.js +81 -1
- package/package.json +2 -2
- package/services/api.js +5 -0
- package/services/tests/api.test.js +9 -1
- package/v2Components/CapWhatsappQuickReply/index.js +96 -83
- package/v2Components/CapWhatsappQuickReply/index.scss +4 -1
- package/v2Components/CapWhatsappQuickReply/messages.js +4 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +23 -0
- package/v2Components/TemplatePreview/index.js +43 -23
- package/v2Components/TemplatePreview/messages.js +4 -0
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +0 -14
- package/v2Containers/CreativesContainer/index.js +22 -2
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +4 -4
- package/v2Containers/Templates/index.js +3 -3
- package/v2Containers/Whatsapp/actions.js +16 -0
- package/v2Containers/Whatsapp/constants.js +8 -1
- package/v2Containers/Whatsapp/index.js +347 -253
- package/v2Containers/Whatsapp/index.scss +12 -1
- package/v2Containers/Whatsapp/messages.js +10 -1
- package/v2Containers/Whatsapp/reducer.js +19 -0
- package/v2Containers/Whatsapp/sagas.js +40 -1
- package/v2Containers/Whatsapp/styles.scss +6 -3
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +12145 -51281
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +20 -20
- package/v2Containers/Whatsapp/tests/actions.test.js +21 -0
- package/v2Containers/Whatsapp/tests/index.test.js +8 -0
- package/v2Containers/Whatsapp/tests/mockData.js +6 -0
- package/v2Containers/Whatsapp/tests/reducer.test.js +67 -0
- package/v2Containers/Whatsapp/tests/saga.test.js +90 -0
- package/v2Containers/Whatsapp/utils.js +13 -13
- package/v2Containers/mockdata.js +8 -18
|
@@ -70,10 +70,11 @@ import {
|
|
|
70
70
|
DOCUMENT_FORMAT,
|
|
71
71
|
DOCUMENT_SIZE,
|
|
72
72
|
TEMPLATE_HEADER_MAX_LENGTH,
|
|
73
|
-
|
|
73
|
+
QUICK_REPLY_BUTTON_TEXT_MAX_LENGTH,
|
|
74
74
|
HEADER_TEXT,
|
|
75
75
|
FOOTER_TEXT,
|
|
76
|
-
MESSAGE_TEXT
|
|
76
|
+
MESSAGE_TEXT,
|
|
77
|
+
BUTTON_TEXT
|
|
77
78
|
} from './constants';
|
|
78
79
|
import { DATE_DISPLAY_FORMAT, TIME_DISPLAY_FORMAT } from '../App/constants';
|
|
79
80
|
import messages from './messages';
|
|
@@ -135,11 +136,11 @@ export const Whatsapp = (props) => {
|
|
|
135
136
|
WHATSAPP_MEDIA_TYPES.TEXT,
|
|
136
137
|
);
|
|
137
138
|
const [templateMessage, setTemplateMessage] = useState('');
|
|
139
|
+
const [templateMessageError, setTemplateMessageError] = useState(false);
|
|
138
140
|
const [templateHeader, setTemplateHeader] = useState('');
|
|
139
141
|
const [templateHeaderError, setTemplateHeaderError] = useState(false);
|
|
140
142
|
const [templateFooter, setTemplateFooter] = useState('');
|
|
141
143
|
const [templateFooterError, setTemplateFooterError] = useState(false);
|
|
142
|
-
const [templateMessageError, setTemplateMessageError] = useState(false);
|
|
143
144
|
const [addedVarCount, setAddedVarCount] = useState(0);
|
|
144
145
|
const [accountId, setAccountId] = useState('');
|
|
145
146
|
const [accessToken, setAccessToken] = useState('');
|
|
@@ -177,11 +178,15 @@ export const Whatsapp = (props) => {
|
|
|
177
178
|
const [tempHeaderData, setTempHeaderData] = useState([]);
|
|
178
179
|
const [headerVarMappedData, setHeaderVarMappedData] = useState({});
|
|
179
180
|
const [updatedHeaderData, setUpdatedHeaderData] = useState([]);
|
|
180
|
-
const [headerTextAreaId, setHeaderTextAreaId] = useState();
|
|
181
|
+
const [headerTextAreaId, setHeaderTextAreaId] = useState('');
|
|
181
182
|
const [isHeaderTagValidationError, updateIsHeaderTagValidationError] =
|
|
182
183
|
useState(false);
|
|
184
|
+
const [isPreviewUrl, setIsPreviewUrl] = useState(false);
|
|
185
|
+
const [previewUrl, setPreviewUrl] = useState('');
|
|
183
186
|
|
|
184
187
|
const validVarRegex = /{{([1-9]|1[0-9])}}/g;
|
|
188
|
+
const headerValidVarRegex = /{{(1)}}/g;
|
|
189
|
+
const urlMatchingRegex = /(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])/g;
|
|
185
190
|
|
|
186
191
|
const isBtnTypeCta = buttonType === WHATSAPP_BUTTON_TYPES.CTA;
|
|
187
192
|
const isBtnTypeQuickReply = buttonType === WHATSAPP_BUTTON_TYPES.QUICK_REPLY;
|
|
@@ -189,6 +194,7 @@ export const Whatsapp = (props) => {
|
|
|
189
194
|
const isMediaTypeImage = templateMediaType === WHATSAPP_MEDIA_TYPES.IMAGE;
|
|
190
195
|
const isMediaTypeVideo = templateMediaType === WHATSAPP_MEDIA_TYPES.VIDEO;
|
|
191
196
|
const isMediaTypeDoc = templateMediaType === WHATSAPP_MEDIA_TYPES.DOCUMENT;
|
|
197
|
+
const isHostIsNotTwilio = host !== HOST_TWILIO;
|
|
192
198
|
const WhatsappFooter = styled.div`
|
|
193
199
|
background-color: ${CAP_WHITE};
|
|
194
200
|
position: fixed;
|
|
@@ -265,6 +271,7 @@ export const Whatsapp = (props) => {
|
|
|
265
271
|
videoPreviewImg = '',
|
|
266
272
|
whatsappDocParams = {},
|
|
267
273
|
whatsappMedia: { header = '', footer = '' } = {},
|
|
274
|
+
isPreviewUrl: showUrlPreview = false,
|
|
268
275
|
} = editContent;
|
|
269
276
|
setTemplateCategory(category);
|
|
270
277
|
setTemplateStatus(status);
|
|
@@ -288,6 +295,7 @@ export const Whatsapp = (props) => {
|
|
|
288
295
|
setButtonType(btnType);
|
|
289
296
|
setTemplateFooter(footer);
|
|
290
297
|
setTemplateHeader(header);
|
|
298
|
+
setIsPreviewUrl(showUrlPreview);
|
|
291
299
|
if (btnType === WHATSAPP_BUTTON_TYPES.CTA && buttons.length > 0) {
|
|
292
300
|
setCtadata(
|
|
293
301
|
buttons.map((cta) => {
|
|
@@ -314,35 +322,41 @@ export const Whatsapp = (props) => {
|
|
|
314
322
|
}),
|
|
315
323
|
);
|
|
316
324
|
}
|
|
317
|
-
if (btnType === WHATSAPP_BUTTON_TYPES.QUICK_REPLY && buttons
|
|
325
|
+
if (btnType === WHATSAPP_BUTTON_TYPES.QUICK_REPLY && buttons?.length > 0) {
|
|
318
326
|
setQuickReplyData(buttons);
|
|
319
327
|
}
|
|
320
328
|
computeTempMsgArray();
|
|
321
|
-
if (header) {
|
|
329
|
+
if (header && (mediaType === WHATSAPP_MEDIA_TYPES.TEXT && isHostIsNotTwilio)) {
|
|
322
330
|
computeHeaderMsgArray();
|
|
323
331
|
}
|
|
324
332
|
}
|
|
325
333
|
}, [editData.templateDetails || templateData]);
|
|
326
334
|
|
|
327
|
-
const
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
const templateHeaderArray = [];
|
|
331
|
-
while (msg.length !== 0) {
|
|
335
|
+
const converStringToVarArr = (validVarArr, content) => {
|
|
336
|
+
const templateVarArray = [];
|
|
337
|
+
while (content?.length !== 0) {
|
|
332
338
|
//converting content string to an array split at var
|
|
333
|
-
const index =
|
|
339
|
+
const index = content.indexOf(validVarArr?.[0]);
|
|
334
340
|
if (index !== -1) {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
validVarArr
|
|
341
|
+
templateVarArray.push(content.substring(0, index)); //push string before var
|
|
342
|
+
templateVarArray.push(validVarArr?.[0]); //push var
|
|
343
|
+
content = content.substring(index + validVarArr?.[0]?.length, content?.length); //remaining str
|
|
344
|
+
validVarArr?.shift(); //remove considered var
|
|
339
345
|
} else {
|
|
340
|
-
|
|
346
|
+
templateVarArray.push(content); //remaining str
|
|
341
347
|
break;
|
|
342
348
|
}
|
|
343
349
|
}
|
|
350
|
+
return templateVarArray;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const computeHeaderMsgArray = () => {
|
|
354
|
+
let msg = get(editContent, `whatsappMedia.header`, '');
|
|
355
|
+
const validVarArr = msg?.match(headerValidVarRegex) || [];
|
|
356
|
+
//conerting msg string to variable arr
|
|
357
|
+
const templateHeaderArray = converStringToVarArr(validVarArr, msg);
|
|
344
358
|
setTempHeaderData(templateHeaderArray);
|
|
345
|
-
if (templateHeaderArray
|
|
359
|
+
if (templateHeaderArray?.length !== 0) {
|
|
346
360
|
let headerVarMap = {};
|
|
347
361
|
const {
|
|
348
362
|
whatsappMedia: { headerVarMapped = {} },
|
|
@@ -350,11 +364,11 @@ export const Whatsapp = (props) => {
|
|
|
350
364
|
if (!isEmpty(headerVarMapped)) {
|
|
351
365
|
headerVarMap = cloneDeep(headerVarMapped);
|
|
352
366
|
} else {
|
|
353
|
-
|
|
354
|
-
if (
|
|
355
|
-
headerVarMap[`${
|
|
367
|
+
templateHeaderArray?.forEach((headerValue, i) => {
|
|
368
|
+
if (headerValue?.match(headerValidVarRegex)?.length > 0) {
|
|
369
|
+
headerVarMap[`${headerValue}_${i}`] = '';
|
|
356
370
|
}
|
|
357
|
-
}
|
|
371
|
+
})
|
|
358
372
|
}
|
|
359
373
|
const arr = [...templateHeaderArray];
|
|
360
374
|
for (const key in headerVarMap) {
|
|
@@ -372,7 +386,6 @@ export const Whatsapp = (props) => {
|
|
|
372
386
|
const validVarArr = msg.match(validVarRegex) || [];
|
|
373
387
|
const unsubscribeRegex1 = /Click {{([1-9]|1[0-9])}} to unsubscribe/g;
|
|
374
388
|
const unsubscribeRegex2 = /Click {{unsubscribe}} to unsubscribe/g;
|
|
375
|
-
const templateMessageArray = [];
|
|
376
389
|
//removing $'' which was added for twilio enter handling
|
|
377
390
|
// msg = msg.slice(2, -1);
|
|
378
391
|
if (
|
|
@@ -392,19 +405,8 @@ export const Whatsapp = (props) => {
|
|
|
392
405
|
}
|
|
393
406
|
setUnsubscribeRequired(true);
|
|
394
407
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
const index = msg.indexOf(validVarArr[0]);
|
|
398
|
-
if (index !== -1) {
|
|
399
|
-
templateMessageArray.push(msg.substring(0, index)); //push string before var
|
|
400
|
-
templateMessageArray.push(validVarArr[0]); //push var
|
|
401
|
-
msg = msg.substring(index + validVarArr[0].length, msg.length); //remaining str
|
|
402
|
-
validVarArr.shift(); //remove considered var
|
|
403
|
-
} else {
|
|
404
|
-
templateMessageArray.push(msg); //remaining str
|
|
405
|
-
break;
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
+
//conerting msg string to variable arr
|
|
409
|
+
const templateMessageArray = converStringToVarArr(validVarArr, msg);
|
|
408
410
|
updateTempMsgArray(templateMessageArray.filter((i) => i === 0 || i));
|
|
409
411
|
};
|
|
410
412
|
|
|
@@ -428,6 +430,12 @@ export const Whatsapp = (props) => {
|
|
|
428
430
|
arr[key.slice(key.indexOf('_') + 1)] = varMap[key];
|
|
429
431
|
}
|
|
430
432
|
}
|
|
433
|
+
if (arr?.length) {
|
|
434
|
+
const validUrls = arr.join("").match(urlMatchingRegex) || [];
|
|
435
|
+
if (validUrls && validUrls?.length) {
|
|
436
|
+
setPreviewUrl(validUrls?.[0] || '')
|
|
437
|
+
}
|
|
438
|
+
}
|
|
431
439
|
setUpdatedSmsEditor(arr);
|
|
432
440
|
}
|
|
433
441
|
}, [tempMsgArray]);
|
|
@@ -468,45 +476,64 @@ export const Whatsapp = (props) => {
|
|
|
468
476
|
}
|
|
469
477
|
}, [metaEntities, isEditFlow]);
|
|
470
478
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
!isFullMode &&
|
|
475
|
-
updatedSmsEditor?.length > 0 &&
|
|
476
|
-
!updatedSmsEditor.join('').match(validVarRegex)
|
|
477
|
-
) {
|
|
478
|
-
tagValidationResponse =
|
|
479
|
+
const tagValidation = (contentData, regex, type) => {
|
|
480
|
+
if (contentData?.length > 0 && !contentData.join("").match(regex)) {
|
|
481
|
+
let validationResponse =
|
|
479
482
|
validateTags({
|
|
480
|
-
content:
|
|
483
|
+
content: contentData.join(""),
|
|
481
484
|
tagsParam: tags,
|
|
482
485
|
injectedTagsParams: injectedTags,
|
|
483
486
|
location,
|
|
484
487
|
tagModule: getDefaultTags,
|
|
485
488
|
}) || {};
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
+
if (type === HEADER_TEXT) {
|
|
490
|
+
headerTagValidationResponse = validationResponse;
|
|
491
|
+
updateIsHeaderTagValidationError(
|
|
492
|
+
validationResponse?.unsupportedTags?.length > 0
|
|
493
|
+
);
|
|
494
|
+
} else {
|
|
495
|
+
tagValidationResponse = validationResponse;
|
|
496
|
+
updateIsTagValidationError(
|
|
497
|
+
validationResponse?.unsupportedTags?.length > 0
|
|
498
|
+
);
|
|
499
|
+
}
|
|
489
500
|
}
|
|
490
|
-
}
|
|
501
|
+
};
|
|
491
502
|
|
|
492
503
|
useEffect(() => {
|
|
493
|
-
if (
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
504
|
+
if (updatedSmsEditor?.length > 0) {
|
|
505
|
+
const previewUrlArr = updatedSmsEditor.join("").match(urlMatchingRegex) || [];
|
|
506
|
+
if (previewUrlArr && previewUrlArr?.length) {
|
|
507
|
+
setPreviewUrl(previewUrlArr[0]);
|
|
508
|
+
} else {
|
|
509
|
+
setPreviewUrl('');
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}, [updatedSmsEditor])
|
|
513
|
+
|
|
514
|
+
useEffect(() => {
|
|
515
|
+
if (!isEmpty(previewUrl) && isPreviewUrl) {
|
|
516
|
+
const watingTimeFn = setTimeout(() => {
|
|
517
|
+
actions.getMetaTags({
|
|
518
|
+
previewUrl,
|
|
519
|
+
callBack: actionCallback,
|
|
520
|
+
})
|
|
521
|
+
}, 1000);
|
|
522
|
+
return () => clearTimeout(watingTimeFn);
|
|
523
|
+
} else {
|
|
524
|
+
actions.resetMetaTags();
|
|
509
525
|
}
|
|
526
|
+
}, [previewUrl, isPreviewUrl])
|
|
527
|
+
|
|
528
|
+
//performs tag validation
|
|
529
|
+
useEffect(() => {
|
|
530
|
+
if (!isFullMode)
|
|
531
|
+
tagValidation(updatedSmsEditor, validVarRegex, MESSAGE_TEXT);
|
|
532
|
+
}, [updatedSmsEditor, tags]);
|
|
533
|
+
|
|
534
|
+
useEffect(() => {
|
|
535
|
+
if (!isFullMode)
|
|
536
|
+
tagValidation(updatedHeaderData, headerValidVarRegex, HEADER_TEXT);
|
|
510
537
|
}, [updatedHeaderData, tags]);
|
|
511
538
|
|
|
512
539
|
const handleOnTagsContextChange = (data) => {
|
|
@@ -524,43 +551,59 @@ export const Whatsapp = (props) => {
|
|
|
524
551
|
globalActions.fetchSchemaForEntity(query);
|
|
525
552
|
};
|
|
526
553
|
|
|
527
|
-
const onTagSelect = (
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
554
|
+
const onTagSelect = (tagSelectData) => {
|
|
555
|
+
const {
|
|
556
|
+
data = "",
|
|
557
|
+
type = MESSAGE_TEXT,
|
|
558
|
+
mapData = {},
|
|
559
|
+
updatedData = [],
|
|
560
|
+
areaId = "",
|
|
561
|
+
regex,
|
|
562
|
+
} = tagSelectData;
|
|
563
|
+
if (mapData && updatedData) {
|
|
564
|
+
const numId = Number(areaId?.slice(areaId?.indexOf("_") + 1));
|
|
565
|
+
if (!isNaN(numId)) {
|
|
566
|
+
const arr = [...updatedData];
|
|
532
567
|
//when trying to insert tag in empty textarea,{#var#} is replaced with "" and then tag is added
|
|
533
|
-
if (arr[numId]?.match(
|
|
534
|
-
arr[numId] =
|
|
568
|
+
if (arr?.[numId]?.match(regex)?.length > 0) {
|
|
569
|
+
arr[numId] = "";
|
|
535
570
|
}
|
|
536
571
|
const messageData = `${arr[numId]}{{${data}}}`;
|
|
537
572
|
arr[numId] = messageData;
|
|
538
|
-
|
|
539
|
-
|
|
573
|
+
if (type === HEADER_TEXT) {
|
|
574
|
+
setHeaderVarMappedData((prevState) => ({
|
|
575
|
+
...prevState,
|
|
576
|
+
[areaId]: messageData,
|
|
577
|
+
}));
|
|
578
|
+
setUpdatedHeaderData(arr);
|
|
579
|
+
} else {
|
|
580
|
+
varMap[areaId] = messageData;
|
|
581
|
+
setUpdatedSmsEditor(arr);
|
|
582
|
+
}
|
|
540
583
|
}
|
|
541
584
|
}
|
|
542
585
|
};
|
|
543
586
|
|
|
587
|
+
const onMessageTagSelect = (data) => {
|
|
588
|
+
onTagSelect({
|
|
589
|
+
data,
|
|
590
|
+
type: MESSAGE_TEXT,
|
|
591
|
+
mapData: varMap,
|
|
592
|
+
updatedData: updatedSmsEditor,
|
|
593
|
+
areaId: textAreaId,
|
|
594
|
+
regex: validVarRegex,
|
|
595
|
+
});
|
|
596
|
+
};
|
|
597
|
+
|
|
544
598
|
const onHeaderTagSelect = (data) => {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
arr[numId] = '';
|
|
554
|
-
}
|
|
555
|
-
const messageData = `${arr[numId]}{{${data}}}`;
|
|
556
|
-
arr[numId] = messageData;
|
|
557
|
-
setHeaderVarMappedData((prevState) => ({
|
|
558
|
-
...prevState,
|
|
559
|
-
[textAreaId]: messageData,
|
|
560
|
-
}));
|
|
561
|
-
setUpdatedHeaderData(arr);
|
|
562
|
-
}
|
|
563
|
-
}
|
|
599
|
+
onTagSelect({
|
|
600
|
+
data,
|
|
601
|
+
type: HEADER_TEXT,
|
|
602
|
+
mapData: headerVarMappedData,
|
|
603
|
+
updatedData: updatedHeaderData,
|
|
604
|
+
areaId: headerTextAreaId,
|
|
605
|
+
regex: headerValidVarRegex,
|
|
606
|
+
});
|
|
564
607
|
};
|
|
565
608
|
|
|
566
609
|
//setting the id of currently selected text area, is used onTagSelect
|
|
@@ -679,6 +722,32 @@ export const Whatsapp = (props) => {
|
|
|
679
722
|
});
|
|
680
723
|
};
|
|
681
724
|
|
|
725
|
+
const computeTextLength = (type) => {
|
|
726
|
+
switch (type) {
|
|
727
|
+
case MESSAGE_TEXT:
|
|
728
|
+
let whatsappContentLen = 0;
|
|
729
|
+
whatsappContentLen = isEditFlow
|
|
730
|
+
? updatedSmsEditor?.join("")?.length
|
|
731
|
+
: templateMessage?.length;
|
|
732
|
+
whatsappContentLen += unsubscribeRequired ? UNSUBSCRIBE_TEXT_LENGTH : 0;
|
|
733
|
+
return whatsappContentLen;
|
|
734
|
+
case HEADER_TEXT:
|
|
735
|
+
let headerContentLen = 0;
|
|
736
|
+
headerContentLen = isEditFlow
|
|
737
|
+
? updatedHeaderData?.join("")?.length
|
|
738
|
+
: templateHeader?.length;
|
|
739
|
+
return headerContentLen || 0;
|
|
740
|
+
case FOOTER_TEXT:
|
|
741
|
+
return templateFooter?.length || 0;
|
|
742
|
+
default:
|
|
743
|
+
let overallLength =
|
|
744
|
+
computeTextLength(MESSAGE_TEXT) +
|
|
745
|
+
computeTextLength(HEADER_TEXT) +
|
|
746
|
+
computeTextLength(FOOTER_TEXT);
|
|
747
|
+
return overallLength;
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
|
|
682
751
|
//used by create and edit
|
|
683
752
|
const renderMessageLength = (type, currentLength) => (
|
|
684
753
|
<CapHeading type="label1" className="whatsapp-render-message-length">
|
|
@@ -726,9 +795,6 @@ export const Whatsapp = (props) => {
|
|
|
726
795
|
<>
|
|
727
796
|
<div
|
|
728
797
|
className="whatsapp-button-quick-reply"
|
|
729
|
-
style={{
|
|
730
|
-
marginTop: "24px",
|
|
731
|
-
}}
|
|
732
798
|
>
|
|
733
799
|
<CapHeading type="h4">
|
|
734
800
|
{formatMessage(messages.btnTypeQuickReply)}
|
|
@@ -745,6 +811,7 @@ export const Whatsapp = (props) => {
|
|
|
745
811
|
)}
|
|
746
812
|
</>
|
|
747
813
|
),
|
|
814
|
+
disabled: host === HOST_TWILIO
|
|
748
815
|
},
|
|
749
816
|
];
|
|
750
817
|
|
|
@@ -760,6 +827,10 @@ export const Whatsapp = (props) => {
|
|
|
760
827
|
setTemplateMessageError(error);
|
|
761
828
|
};
|
|
762
829
|
|
|
830
|
+
const previewUrlHandler = ({ target: { checked } }) => {
|
|
831
|
+
setIsPreviewUrl(checked);
|
|
832
|
+
}
|
|
833
|
+
|
|
763
834
|
const renderUnsubscribeText = () => {
|
|
764
835
|
const isDisabled =
|
|
765
836
|
isEditFlow ||
|
|
@@ -799,32 +870,6 @@ export const Whatsapp = (props) => {
|
|
|
799
870
|
);
|
|
800
871
|
};
|
|
801
872
|
|
|
802
|
-
const computeTextLength = (type) => {
|
|
803
|
-
switch (type) {
|
|
804
|
-
case MESSAGE_TEXT:
|
|
805
|
-
let whatsappContentLen = 0;
|
|
806
|
-
whatsappContentLen = isEditFlow
|
|
807
|
-
? updatedSmsEditor.join("").length
|
|
808
|
-
: templateMessage.length;
|
|
809
|
-
whatsappContentLen += unsubscribeRequired ? UNSUBSCRIBE_TEXT_LENGTH : 0;
|
|
810
|
-
return whatsappContentLen;
|
|
811
|
-
case HEADER_TEXT:
|
|
812
|
-
let headerContentLen = 0;
|
|
813
|
-
headerContentLen = isEditFlow
|
|
814
|
-
? updatedHeaderData.join("").length
|
|
815
|
-
: templateHeader.length;
|
|
816
|
-
return headerContentLen || 0;
|
|
817
|
-
case FOOTER_TEXT:
|
|
818
|
-
return templateFooter.length || 0;
|
|
819
|
-
default:
|
|
820
|
-
let overallLength =
|
|
821
|
-
computeTextLength(MESSAGE_TEXT) +
|
|
822
|
-
computeTextLength(HEADER_TEXT) +
|
|
823
|
-
computeTextLength(FOOTER_TEXT);
|
|
824
|
-
return overallLength;
|
|
825
|
-
}
|
|
826
|
-
};
|
|
827
|
-
|
|
828
873
|
const maxLengthByType = (type) => {
|
|
829
874
|
switch (type) {
|
|
830
875
|
case MESSAGE_TEXT:
|
|
@@ -832,8 +877,8 @@ export const Whatsapp = (props) => {
|
|
|
832
877
|
case HEADER_TEXT:
|
|
833
878
|
case FOOTER_TEXT:
|
|
834
879
|
return TEMPLATE_HEADER_MAX_LENGTH;
|
|
835
|
-
case
|
|
836
|
-
return
|
|
880
|
+
case BUTTON_TEXT:
|
|
881
|
+
return QUICK_REPLY_BUTTON_TEXT_MAX_LENGTH;
|
|
837
882
|
}
|
|
838
883
|
};
|
|
839
884
|
|
|
@@ -1012,33 +1057,38 @@ export const Whatsapp = (props) => {
|
|
|
1012
1057
|
setTemplateMediaType(value);
|
|
1013
1058
|
};
|
|
1014
1059
|
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1017
|
-
const tempMsg = `${templateMessage}{{${validVarArr.length + 1}}}`;
|
|
1018
|
-
const error = templateMessageErrorHandler(tempMsg);
|
|
1019
|
-
setTemplateMessage(tempMsg);
|
|
1020
|
-
setTemplateMessageError(error);
|
|
1060
|
+
const onMessageAddVar = () => {
|
|
1061
|
+
onAddVar(MESSAGE_TEXT, templateMessage, validVarRegex);
|
|
1021
1062
|
};
|
|
1022
1063
|
|
|
1023
1064
|
const onHeaderAddVar = () => {
|
|
1024
|
-
|
|
1025
|
-
const tempMsg = `${templateHeader}{{${validVarArr.length + 1}}}`;
|
|
1026
|
-
const error = templateHeaderErrorHandler(tempMsg);
|
|
1027
|
-
setTemplateHeader(tempMsg);
|
|
1028
|
-
setTemplateHeaderError(error);
|
|
1065
|
+
onAddVar(HEADER_TEXT, templateHeader, headerValidVarRegex);
|
|
1029
1066
|
};
|
|
1030
1067
|
|
|
1031
|
-
const
|
|
1032
|
-
const
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1068
|
+
const onAddVar = (type, messageContent, regex) => {
|
|
1069
|
+
const validVarArr = messageContent.match(regex) || [];
|
|
1070
|
+
const tempMsg = `${messageContent}{{${validVarArr.length + 1}}}`;
|
|
1071
|
+
const error = type === HEADER_TEXT ? templateHeaderErrorHandler(tempMsg) : templateMessageErrorHandler(tempMsg);
|
|
1072
|
+
if (type === HEADER_TEXT) {
|
|
1073
|
+
setTemplateHeader(tempMsg);
|
|
1074
|
+
setTemplateHeaderError(error);
|
|
1075
|
+
} else {
|
|
1076
|
+
setTemplateMessage(tempMsg);
|
|
1077
|
+
setTemplateMessageError(error);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1036
1080
|
|
|
1037
|
-
const
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1081
|
+
const onTemplateValueChange = ({ target: { value } }, type) => {
|
|
1082
|
+
if (type === HEADER_TEXT) {
|
|
1083
|
+
const error = templateHeaderErrorHandler(value);
|
|
1084
|
+
setTemplateHeader(value);
|
|
1085
|
+
setTemplateHeaderError(error);
|
|
1086
|
+
} else {
|
|
1087
|
+
const error = templateMessageErrorHandler(value);
|
|
1088
|
+
setTemplateMessage(value);
|
|
1089
|
+
setTemplateMessageError(error);
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1042
1092
|
|
|
1043
1093
|
const onTemplateFooterChanges = ({ target: { value } }) => {
|
|
1044
1094
|
let error = false;
|
|
@@ -1076,7 +1126,7 @@ export const Whatsapp = (props) => {
|
|
|
1076
1126
|
|
|
1077
1127
|
const variableErrorHandling = (value, type) => {
|
|
1078
1128
|
let errorMessage = false;
|
|
1079
|
-
const validVarArr = value.match(validVarRegex) || [];
|
|
1129
|
+
const validVarArr = value.match(type === HEADER_TEXT ? headerValidVarRegex : validVarRegex) || [];
|
|
1080
1130
|
const validVarSet = [...new Set(validVarArr)];
|
|
1081
1131
|
|
|
1082
1132
|
const invalidVarRegex = /{{(.*?)}}/g;
|
|
@@ -1094,10 +1144,14 @@ export const Whatsapp = (props) => {
|
|
|
1094
1144
|
errorMessage = formatMessage(messages.repetativeVars);
|
|
1095
1145
|
} else if (invalidVarSet?.length !== validVarSet?.length) {
|
|
1096
1146
|
//checks for invalid vars like Hi {{abcd}}, offer for you {{^_^}}
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1147
|
+
if (type === HEADER_TEXT) {
|
|
1148
|
+
errorMessage = formatMessage(messages.headerUnknownVars);
|
|
1149
|
+
} else {
|
|
1150
|
+
errorMessage = formatMessage(messages.unknownVars, {
|
|
1151
|
+
one: "{{1}}",
|
|
1152
|
+
nineteen: "{{19}}",
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1101
1155
|
} else if (value.match(noContentBetweenVars)?.length > 0) {
|
|
1102
1156
|
//checks for text between vars like Hi {{1}}{{2}}
|
|
1103
1157
|
errorMessage = formatMessage(messages.noContentBetweenVars);
|
|
@@ -1227,10 +1281,18 @@ export const Whatsapp = (props) => {
|
|
|
1227
1281
|
buttons: getQuickReplyData(),
|
|
1228
1282
|
}),
|
|
1229
1283
|
whatsappMedia: {
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1284
|
+
...(isMediaTypeText && isHostIsNotTwilio && {
|
|
1285
|
+
header: isEditFlow && !isFullMode ? updatedHeaderData.join("") : templateHeader,
|
|
1286
|
+
headerVarMapped: !isFullMode ? headerVarMappedData : {},
|
|
1287
|
+
headerTemplate: !isFullMode && tempHeaderData.join(""),
|
|
1288
|
+
}),
|
|
1289
|
+
...(isHostIsNotTwilio && {
|
|
1290
|
+
footer: templateFooter || ""
|
|
1291
|
+
}),
|
|
1233
1292
|
},
|
|
1293
|
+
...(isEditFlow && !isFullMode && {
|
|
1294
|
+
isPreviewUrl
|
|
1295
|
+
})
|
|
1234
1296
|
},
|
|
1235
1297
|
},
|
|
1236
1298
|
},
|
|
@@ -1302,6 +1364,9 @@ export const Whatsapp = (props) => {
|
|
|
1302
1364
|
if (!isMediaTypeText && host === HOST_KARIX && karixFileHandle === '') {
|
|
1303
1365
|
return true;
|
|
1304
1366
|
}
|
|
1367
|
+
if (templateHeaderError || templateFooterError) {
|
|
1368
|
+
return true;
|
|
1369
|
+
}
|
|
1305
1370
|
//cta
|
|
1306
1371
|
if (isBtnTypeCta) {
|
|
1307
1372
|
if (ctaData.length === 1 && ctaData[0].isSaved) {
|
|
@@ -1320,7 +1385,7 @@ export const Whatsapp = (props) => {
|
|
|
1320
1385
|
}
|
|
1321
1386
|
|
|
1322
1387
|
if (isBtnTypeQuickReply) {
|
|
1323
|
-
return !quickReplyData.every((quickReply) => quickReply
|
|
1388
|
+
return !quickReplyData.every((quickReply) => quickReply?.isSaved === true);
|
|
1324
1389
|
}
|
|
1325
1390
|
return false;
|
|
1326
1391
|
};
|
|
@@ -1354,9 +1419,7 @@ export const Whatsapp = (props) => {
|
|
|
1354
1419
|
<CapHeading type="h4">
|
|
1355
1420
|
{formatMessage(globalMessages.templateNameLabel)}
|
|
1356
1421
|
<CapTooltipWithInfo
|
|
1357
|
-
|
|
1358
|
-
style: { marginLeft: CAP_SPACE_04 },
|
|
1359
|
-
}}
|
|
1422
|
+
className="whatsapp-text-field_spacing"
|
|
1360
1423
|
autoAdjustOverflow
|
|
1361
1424
|
title={<FormattedMessage {...messages.templateNameTooltip} />}
|
|
1362
1425
|
/>
|
|
@@ -1400,53 +1463,62 @@ export const Whatsapp = (props) => {
|
|
|
1400
1463
|
{/* template media type */}
|
|
1401
1464
|
{renderMediaSection()}
|
|
1402
1465
|
{renderMediaComponent()}
|
|
1403
|
-
{/*
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1466
|
+
{/* this section is for header section in create mode */}
|
|
1467
|
+
{isMediaTypeText && isHostIsNotTwilio && (
|
|
1468
|
+
<>
|
|
1469
|
+
<CapHeader
|
|
1470
|
+
title={
|
|
1471
|
+
<CapHeading type="h4" className="whatsapp-create-mode-heading">
|
|
1472
|
+
{formatMessage(messages.templateHeaderLabel)}
|
|
1473
|
+
<CapTooltipWithInfo
|
|
1474
|
+
placement="right"
|
|
1475
|
+
className="whatsapp-text-field_spacing"
|
|
1476
|
+
autoAdjustOverflow
|
|
1477
|
+
title={
|
|
1478
|
+
<FormattedMessage {...messages.templateHeaderTooltip} />
|
|
1479
|
+
}
|
|
1480
|
+
/>
|
|
1481
|
+
<CapHeading className="whatsapp-optional-label1 align-item-center">
|
|
1482
|
+
{formatMessage(messages.optional)}
|
|
1483
|
+
</CapHeading>
|
|
1484
|
+
</CapHeading>
|
|
1485
|
+
}
|
|
1486
|
+
suffix={
|
|
1487
|
+
<CapButton
|
|
1488
|
+
type="flat"
|
|
1489
|
+
isAddBtn
|
|
1490
|
+
onClick={onHeaderAddVar}
|
|
1491
|
+
disabled={
|
|
1492
|
+
((templateHeader.match(headerValidVarRegex) || []).length >
|
|
1493
|
+
0 ||
|
|
1494
|
+
templateHeaderError) &&
|
|
1495
|
+
templateHeader
|
|
1496
|
+
}
|
|
1497
|
+
>
|
|
1498
|
+
{formatMessage(messages.addVar)}
|
|
1499
|
+
</CapButton>
|
|
1500
|
+
}
|
|
1501
|
+
/>
|
|
1502
|
+
<CapRow className="whatsapp-create-template-message-input whatsapp-create-template-header-input">
|
|
1503
|
+
<TextArea
|
|
1504
|
+
id="whatsapp-create-template-message-input"
|
|
1505
|
+
autosize={{ minRows: 1, maxRows: 5 }}
|
|
1506
|
+
placeholder={formatMessage(messages.templateMessagePlaceholder)}
|
|
1507
|
+
onChange={(e) => onTemplateValueChange(e, HEADER_TEXT)}
|
|
1508
|
+
errorMessage={
|
|
1509
|
+
templateHeaderError && (
|
|
1510
|
+
<CapError className="whatsapp-template-message-error">
|
|
1511
|
+
{templateHeaderError}
|
|
1512
|
+
</CapError>
|
|
1513
|
+
)
|
|
1514
|
+
}
|
|
1515
|
+
value={templateHeader || ""}
|
|
1416
1516
|
/>
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
suffix={
|
|
1423
|
-
<CapButton
|
|
1424
|
-
type="flat"
|
|
1425
|
-
isAddBtn
|
|
1426
|
-
onClick={onHeaderAddVar}
|
|
1427
|
-
disabled={templateHeaderError && templateHeader}
|
|
1428
|
-
>
|
|
1429
|
-
{formatMessage(messages.addVar)}
|
|
1430
|
-
</CapButton>
|
|
1431
|
-
}
|
|
1432
|
-
/>
|
|
1433
|
-
<CapRow className="whatsapp-create-template-message-input whatsapp-create-template-header-input">
|
|
1434
|
-
<TextArea
|
|
1435
|
-
id="whatsapp-create-template-message-input"
|
|
1436
|
-
autosize={{ minRows: 1, maxRows: 5 }}
|
|
1437
|
-
placeholder={formatMessage(messages.templateMessagePlaceholder)}
|
|
1438
|
-
onChange={onTemplateHeaderChanges}
|
|
1439
|
-
errorMessage={
|
|
1440
|
-
templateHeaderError && (
|
|
1441
|
-
<CapError className="whatsapp-template-message-error">
|
|
1442
|
-
{templateHeaderError}
|
|
1443
|
-
</CapError>
|
|
1444
|
-
)
|
|
1445
|
-
}
|
|
1446
|
-
value={templateHeader || ""}
|
|
1447
|
-
/>
|
|
1448
|
-
</CapRow>
|
|
1449
|
-
{renderMessageLength(HEADER_TEXT)}
|
|
1517
|
+
</CapRow>
|
|
1518
|
+
{renderMessageLength(HEADER_TEXT)}
|
|
1519
|
+
</>
|
|
1520
|
+
)}
|
|
1521
|
+
{/* template message create flow */}
|
|
1450
1522
|
<CapHeader
|
|
1451
1523
|
className={`${isMediaTypeImage ? "whatsapp-heading-spacing" : ""}`}
|
|
1452
1524
|
title={
|
|
@@ -1454,9 +1526,7 @@ export const Whatsapp = (props) => {
|
|
|
1454
1526
|
{formatMessage(messages.templateMessageLabel)}
|
|
1455
1527
|
<CapTooltipWithInfo
|
|
1456
1528
|
placement="right"
|
|
1457
|
-
|
|
1458
|
-
style: { marginLeft: CAP_SPACE_04 },
|
|
1459
|
-
}}
|
|
1529
|
+
className="whatsapp-text-field_spacing"
|
|
1460
1530
|
autoAdjustOverflow
|
|
1461
1531
|
title={
|
|
1462
1532
|
<FormattedMessage
|
|
@@ -1474,7 +1544,7 @@ export const Whatsapp = (props) => {
|
|
|
1474
1544
|
<CapButton
|
|
1475
1545
|
type="flat"
|
|
1476
1546
|
isAddBtn
|
|
1477
|
-
onClick={
|
|
1547
|
+
onClick={onMessageAddVar}
|
|
1478
1548
|
disabled={
|
|
1479
1549
|
(addedVarCount >= 19 || templateMessageError) && templateMessage
|
|
1480
1550
|
}
|
|
@@ -1488,7 +1558,7 @@ export const Whatsapp = (props) => {
|
|
|
1488
1558
|
id="whatsapp-create-template-message-input"
|
|
1489
1559
|
autosize={{ minRows: 3, maxRows: 5 }}
|
|
1490
1560
|
placeholder={formatMessage(messages.templateMessagePlaceholder)}
|
|
1491
|
-
onChange={
|
|
1561
|
+
onChange={(e) => onTemplateValueChange(e, MESSAGE_TEXT)}
|
|
1492
1562
|
errorMessage={
|
|
1493
1563
|
templateMessageError && (
|
|
1494
1564
|
<CapError className="whatsapp-template-message-error">
|
|
@@ -1501,42 +1571,47 @@ export const Whatsapp = (props) => {
|
|
|
1501
1571
|
{renderUnsubscribeText()}
|
|
1502
1572
|
</CapRow>
|
|
1503
1573
|
{renderMessageLength(MESSAGE_TEXT)}
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
<
|
|
1508
|
-
{
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1574
|
+
{/* this section if for footer in create mode */}
|
|
1575
|
+
{isHostIsNotTwilio && (
|
|
1576
|
+
<>
|
|
1577
|
+
<CapHeader
|
|
1578
|
+
className={`${isMediaTypeImage ? "whatsapp-heading-spacing" : ""}`}
|
|
1579
|
+
title={
|
|
1580
|
+
<CapHeading type="h4" className="whatsapp-create-mode-heading">
|
|
1581
|
+
{formatMessage(messages.templateFooterLabel)}
|
|
1582
|
+
<CapTooltipWithInfo
|
|
1583
|
+
placement="right"
|
|
1584
|
+
className="whatsapp-text-field_spacing"
|
|
1585
|
+
autoAdjustOverflow
|
|
1586
|
+
title={
|
|
1587
|
+
<FormattedMessage {...messages.templateFooterTooltip} />
|
|
1588
|
+
}
|
|
1589
|
+
/>
|
|
1590
|
+
<CapHeading className="whatsapp-optional-label1 align-item-center">
|
|
1591
|
+
{formatMessage(messages.optional)}
|
|
1592
|
+
</CapHeading>
|
|
1593
|
+
</CapHeading>
|
|
1594
|
+
}
|
|
1595
|
+
/>
|
|
1596
|
+
<CapRow className="whatsapp-create-template-message-input whatsapp-create-template-header-input">
|
|
1597
|
+
<TextArea
|
|
1598
|
+
id="whatsapp-create-template-message-input"
|
|
1599
|
+
autosize={{ minRows: 1, maxRows: 5 }}
|
|
1600
|
+
placeholder={formatMessage(messages.templateMessagePlaceholder)}
|
|
1601
|
+
onChange={onTemplateFooterChanges}
|
|
1602
|
+
errorMessage={
|
|
1603
|
+
templateFooterError && (
|
|
1604
|
+
<CapError className="whatsapp-template-message-error">
|
|
1605
|
+
{templateFooterError}
|
|
1606
|
+
</CapError>
|
|
1607
|
+
)
|
|
1608
|
+
}
|
|
1609
|
+
value={templateFooter || ""}
|
|
1516
1610
|
/>
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
}
|
|
1522
|
-
/>
|
|
1523
|
-
<CapRow className="whatsapp-create-template-message-input whatsapp-create-template-header-input">
|
|
1524
|
-
<TextArea
|
|
1525
|
-
id="whatsapp-create-template-message-input"
|
|
1526
|
-
autosize={{ minRows: 1, maxRows: 5 }}
|
|
1527
|
-
placeholder={formatMessage(messages.templateMessagePlaceholder)}
|
|
1528
|
-
onChange={onTemplateFooterChanges}
|
|
1529
|
-
errorMessage={
|
|
1530
|
-
templateFooterError && (
|
|
1531
|
-
<CapError className="whatsapp-template-message-error">
|
|
1532
|
-
{templateFooterError}
|
|
1533
|
-
</CapError>
|
|
1534
|
-
)
|
|
1535
|
-
}
|
|
1536
|
-
value={templateFooter || ""}
|
|
1537
|
-
/>
|
|
1538
|
-
</CapRow>
|
|
1539
|
-
{renderMessageLength(FOOTER_TEXT)}
|
|
1611
|
+
</CapRow>
|
|
1612
|
+
{renderMessageLength(FOOTER_TEXT)}
|
|
1613
|
+
</>
|
|
1614
|
+
)}
|
|
1540
1615
|
{renderButtonsSection()}
|
|
1541
1616
|
</>
|
|
1542
1617
|
);
|
|
@@ -1655,7 +1730,7 @@ export const Whatsapp = (props) => {
|
|
|
1655
1730
|
? updatedHeaderData[idValue]
|
|
1656
1731
|
: updatedSmsEditor[idValue];
|
|
1657
1732
|
//if value is there and it is not a variable return it
|
|
1658
|
-
if (value && (value.match(validVarRegex) || []).length === 0) {
|
|
1733
|
+
if (value && (value.match(type === HEADER_TEXT ? headerValidVarRegex : validVarRegex) || []).length === 0) {
|
|
1659
1734
|
return value;
|
|
1660
1735
|
}
|
|
1661
1736
|
}
|
|
@@ -1668,7 +1743,7 @@ export const Whatsapp = (props) => {
|
|
|
1668
1743
|
let varCount = 0;
|
|
1669
1744
|
messageData.forEach((elem, index) => {
|
|
1670
1745
|
// if var return textarea else return text
|
|
1671
|
-
if (elem.match(validVarRegex)?.length > 0) {
|
|
1746
|
+
if (elem.match(type === HEADER_TEXT ? headerValidVarRegex : validVarRegex)?.length > 0) {
|
|
1672
1747
|
varCount += 1;
|
|
1673
1748
|
renderArray.push(
|
|
1674
1749
|
<TextArea
|
|
@@ -1697,7 +1772,9 @@ export const Whatsapp = (props) => {
|
|
|
1697
1772
|
}
|
|
1698
1773
|
});
|
|
1699
1774
|
}
|
|
1700
|
-
|
|
1775
|
+
if (type !== HEADER_TEXT) {
|
|
1776
|
+
renderArray.push(renderUnsubscribeText());
|
|
1777
|
+
}
|
|
1701
1778
|
return renderArray;
|
|
1702
1779
|
};
|
|
1703
1780
|
|
|
@@ -1743,7 +1820,8 @@ export const Whatsapp = (props) => {
|
|
|
1743
1820
|
{renderLabel("mediaLabel")}
|
|
1744
1821
|
<CapLabel type="label15">{capitalizeString(templateMediaType)}</CapLabel>
|
|
1745
1822
|
{renderMediaComponent()}
|
|
1746
|
-
{
|
|
1823
|
+
{/* this section is for render header section */}
|
|
1824
|
+
{(templateHeader && isMediaTypeText && isHostIsNotTwilio) && (
|
|
1747
1825
|
<>
|
|
1748
1826
|
<CapRow className="whatsapp-render-heading">
|
|
1749
1827
|
<CapHeader
|
|
@@ -1779,12 +1857,10 @@ export const Whatsapp = (props) => {
|
|
|
1779
1857
|
</CapTooltip>
|
|
1780
1858
|
{renderMessageLength(HEADER_TEXT)}
|
|
1781
1859
|
{isHeaderTagValidationError && tagValidationErrorMessage(HEADER_TEXT)}
|
|
1782
|
-
{computeTextLength(HEADER_TEXT) > TEMPLATE_HEADER_MAX_LENGTH
|
|
1860
|
+
{computeTextLength(HEADER_TEXT) > TEMPLATE_HEADER_MAX_LENGTH && (
|
|
1783
1861
|
<CapError>
|
|
1784
|
-
{formatMessage(messages.
|
|
1862
|
+
{formatMessage(messages.templateHeaderLengthError)}
|
|
1785
1863
|
</CapError>
|
|
1786
|
-
) : (
|
|
1787
|
-
""
|
|
1788
1864
|
)}
|
|
1789
1865
|
</>
|
|
1790
1866
|
)}
|
|
@@ -1799,7 +1875,7 @@ export const Whatsapp = (props) => {
|
|
|
1799
1875
|
templateStatus === WHATSAPP_STATUSES.approved && (
|
|
1800
1876
|
<TagList
|
|
1801
1877
|
label={formatMessage(globalMessages.addLabels)}
|
|
1802
|
-
onTagSelect={
|
|
1878
|
+
onTagSelect={onMessageTagSelect}
|
|
1803
1879
|
location={location}
|
|
1804
1880
|
tags={tags || []}
|
|
1805
1881
|
onContextChange={handleOnTagsContextChange}
|
|
@@ -1830,7 +1906,20 @@ export const Whatsapp = (props) => {
|
|
|
1830
1906
|
) : (
|
|
1831
1907
|
""
|
|
1832
1908
|
)}
|
|
1833
|
-
|
|
1909
|
+
<CapRow>
|
|
1910
|
+
<CapCheckbox
|
|
1911
|
+
className={`whatsapp-unsubscribe-checkbox ${'whatsapp-create-unsubscribe-checkbox'}`}
|
|
1912
|
+
onChange={previewUrlHandler}
|
|
1913
|
+
checked={isPreviewUrl}
|
|
1914
|
+
disabled={!isMediaTypeText}
|
|
1915
|
+
autoFocus={true}
|
|
1916
|
+
>
|
|
1917
|
+
<span className="whatsapp-render-url-preview-textt">
|
|
1918
|
+
{formatMessage(messages.showUrlPreview)}
|
|
1919
|
+
</span>
|
|
1920
|
+
</CapCheckbox>
|
|
1921
|
+
</CapRow>
|
|
1922
|
+
{templateFooter && isHostIsNotTwilio && (
|
|
1834
1923
|
<>
|
|
1835
1924
|
<CapHeader
|
|
1836
1925
|
className={`${isMediaTypeImage ? "whatsapp-heading-spacing" : ""}`}
|
|
@@ -1893,6 +1982,7 @@ export const Whatsapp = (props) => {
|
|
|
1893
1982
|
|
|
1894
1983
|
//used by create and edit
|
|
1895
1984
|
const getPreviewSection = () => {
|
|
1985
|
+
const { metaTagsDetails = {} } = editData || {};
|
|
1896
1986
|
const templateMsg = (
|
|
1897
1987
|
<>
|
|
1898
1988
|
<CapLabel type="label5">
|
|
@@ -1944,6 +2034,10 @@ export const Whatsapp = (props) => {
|
|
|
1944
2034
|
...(isBtnTypeQuickReply && {
|
|
1945
2035
|
quickReplyData,
|
|
1946
2036
|
}),
|
|
2037
|
+
...(isMediaTypeText && isPreviewUrl && {
|
|
2038
|
+
isPreviewUrl,
|
|
2039
|
+
metaTagsDetails,
|
|
2040
|
+
}),
|
|
1947
2041
|
}}
|
|
1948
2042
|
whatsappContentLen={computeTextLength()}
|
|
1949
2043
|
whatsappAccountName={accountName}
|