@capillarytech/creatives-library 7.12.39 → 7.12.40
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 +1 -1
- package/v2Components/TemplatePreview/index.js +5 -6
- package/v2Components/TemplatePreview/messages.js +0 -8
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +3 -12
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +1 -6
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +40 -240
- package/v2Containers/Whatsapp/index.js +64 -30
- package/v2Containers/Whatsapp/index.scss +6 -2
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +19589 -19483
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +2 -12
- package/v2Containers/Whatsapp/utils.js +46 -47
|
@@ -239,17 +239,21 @@ export const Whatsapp = (props) => {
|
|
|
239
239
|
const computeTempMsgArray = () => {
|
|
240
240
|
let msg = get(editContent, `languages[0].content`, '');
|
|
241
241
|
const validVarArr = msg.match(validVarRegex) || [];
|
|
242
|
+
const unsubscribePresent = /Click {{([1-9]|1[0-9])}} to unsubscribe/g;
|
|
242
243
|
const templateMessageArray = [];
|
|
243
244
|
//removing $'' which was added for twilio enter handling
|
|
244
245
|
// msg = msg.slice(2, -1);
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
246
|
+
if (msg.match(unsubscribePresent)?.length > 0) {
|
|
247
|
+
//removing Click {{unsubscribe}} to unsubscribe
|
|
248
|
+
msg = msg.replace(
|
|
249
|
+
`\nClick ${validVarArr[validVarArr.length - 1]} to unsubscribe`,
|
|
250
|
+
'',
|
|
251
|
+
);
|
|
252
|
+
//removing last var added for Click {{unsubscribe}} to unsubscribe
|
|
253
|
+
if (isFullMode) {
|
|
254
|
+
validVarArr.pop();
|
|
255
|
+
}
|
|
256
|
+
setUnsubscribeRequired(true);
|
|
253
257
|
}
|
|
254
258
|
while (msg.length !== 0) {
|
|
255
259
|
//converting content string to an array split at var
|
|
@@ -524,18 +528,26 @@ export const Whatsapp = (props) => {
|
|
|
524
528
|
|
|
525
529
|
const unsubscribeHandler = ({ target: { checked } }) => {
|
|
526
530
|
setUnsubscribeRequired(checked);
|
|
531
|
+
const error = templateMessageErrorHandler(templateMessage);
|
|
532
|
+
setTemplateMessageError(error);
|
|
527
533
|
};
|
|
528
534
|
|
|
529
535
|
const renderUnsubscribeText = () => (
|
|
530
536
|
<>
|
|
531
537
|
<CapColumn span={12}>
|
|
532
538
|
<CapCheckbox
|
|
533
|
-
className={`whatsapp-
|
|
534
|
-
isEditFlow
|
|
539
|
+
className={`whatsapp-unsubscribe-checkbox ${
|
|
540
|
+
isEditFlow
|
|
541
|
+
? 'whatsapp-edit-unsubscribe-checkbox'
|
|
542
|
+
: 'whatsapp-create-unsubscribe-checkbox'
|
|
535
543
|
}`}
|
|
536
544
|
onChange={unsubscribeHandler}
|
|
537
545
|
checked={unsubscribeRequired}
|
|
538
|
-
disabled={
|
|
546
|
+
disabled={
|
|
547
|
+
isEditFlow ||
|
|
548
|
+
templateMessage.length + UNSUBSCRIBE_TEXT_LENGTH >
|
|
549
|
+
TEMPLATE_MESSAGE_MAX_LENGTH
|
|
550
|
+
}
|
|
539
551
|
autoFocus={true}
|
|
540
552
|
>
|
|
541
553
|
<CapTooltip
|
|
@@ -554,13 +566,20 @@ export const Whatsapp = (props) => {
|
|
|
554
566
|
</>
|
|
555
567
|
);
|
|
556
568
|
|
|
569
|
+
const computeLength = () => {
|
|
570
|
+
let whatsappContentLen = 0;
|
|
571
|
+
whatsappContentLen = isEditFlow
|
|
572
|
+
? updatedSmsEditor.join('').length
|
|
573
|
+
: templateMessage.length;
|
|
574
|
+
whatsappContentLen += unsubscribeRequired ? UNSUBSCRIBE_TEXT_LENGTH : 0;
|
|
575
|
+
return whatsappContentLen;
|
|
576
|
+
};
|
|
577
|
+
|
|
557
578
|
//used by create and edit
|
|
558
579
|
const renderMessageLength = () => (
|
|
559
580
|
<CapHeading type="label1" className="whatsapp-render-message-length">
|
|
560
581
|
{formatMessage(messages.templateMessageLength, {
|
|
561
|
-
currentLength:
|
|
562
|
-
? updatedSmsEditor?.join('')?.length + UNSUBSCRIBE_TEXT_LENGTH
|
|
563
|
-
: templateMessage?.length + UNSUBSCRIBE_TEXT_LENGTH,
|
|
582
|
+
currentLength: computeLength(),
|
|
564
583
|
maxLength: TEMPLATE_MESSAGE_MAX_LENGTH,
|
|
565
584
|
})}
|
|
566
585
|
</CapHeading>
|
|
@@ -641,7 +660,7 @@ export const Whatsapp = (props) => {
|
|
|
641
660
|
if (value === '') {
|
|
642
661
|
errorMessage = formatMessage(messages.emptyTemplateMessageErrorMessage);
|
|
643
662
|
} else if (
|
|
644
|
-
|
|
663
|
+
value?.length + (unsubscribeRequired ? UNSUBSCRIBE_TEXT_LENGTH : 0) >
|
|
645
664
|
TEMPLATE_MESSAGE_MAX_LENGTH
|
|
646
665
|
) {
|
|
647
666
|
errorMessage = formatMessage(messages.templateMessageLengthError);
|
|
@@ -653,7 +672,7 @@ export const Whatsapp = (props) => {
|
|
|
653
672
|
const invalidVarArr = value.match(invalidVarRegex) || [];
|
|
654
673
|
const invalidVarSet = [...new Set(invalidVarArr)];
|
|
655
674
|
|
|
656
|
-
const noContentBetweenVars = /}}
|
|
675
|
+
const noContentBetweenVars = /}}\s*{{/g;
|
|
657
676
|
const moreThanTwoBrackets = /{{3,}([1-9]|1[0-9])}{3,}/g;
|
|
658
677
|
|
|
659
678
|
if (validVarArr?.length > 0 || invalidVarArr?.length > 0) {
|
|
@@ -684,15 +703,29 @@ export const Whatsapp = (props) => {
|
|
|
684
703
|
}
|
|
685
704
|
return errorMessage;
|
|
686
705
|
};
|
|
687
|
-
|
|
688
|
-
const getPayloadContent = () =>
|
|
689
|
-
isEditFlow && !isFullMode
|
|
690
|
-
|
|
706
|
+
|
|
707
|
+
const getPayloadContent = () => {
|
|
708
|
+
if (isEditFlow && !isFullMode) {
|
|
709
|
+
//campaigns edit flow + unsubscribeRequired
|
|
710
|
+
if (unsubscribeRequired) {
|
|
711
|
+
return `${updatedSmsEditor.join('')}\n${formatMessage(
|
|
691
712
|
messages.templateMessageUnsubscribeText,
|
|
692
|
-
)}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
713
|
+
)}`;
|
|
714
|
+
}
|
|
715
|
+
//campaigns edit flow + unsubscribeNotRequired
|
|
716
|
+
return updatedSmsEditor.join('');
|
|
717
|
+
} else if (unsubscribeRequired) {
|
|
718
|
+
//creatives create and edit flow + unsubscribeRequired
|
|
719
|
+
return `${templateMessage}\n${formatMessage(
|
|
720
|
+
messages.modifiedUnsubscribeText,
|
|
721
|
+
{
|
|
722
|
+
value: `{{${addedVarCount + 1}}}`,
|
|
723
|
+
},
|
|
724
|
+
)}`;
|
|
725
|
+
}
|
|
726
|
+
//creatives create and edit flow + unsubscribeNotRequired
|
|
727
|
+
return templateMessage;
|
|
728
|
+
};
|
|
696
729
|
|
|
697
730
|
const getCtaPayload = () =>
|
|
698
731
|
ctaData.map((cta) => {
|
|
@@ -1078,6 +1111,7 @@ export const Whatsapp = (props) => {
|
|
|
1078
1111
|
}
|
|
1079
1112
|
return <CapError>{tagError}</CapError>;
|
|
1080
1113
|
};
|
|
1114
|
+
|
|
1081
1115
|
const editModeContent = (
|
|
1082
1116
|
<>
|
|
1083
1117
|
{templateStatus && (
|
|
@@ -1139,9 +1173,11 @@ export const Whatsapp = (props) => {
|
|
|
1139
1173
|
<CapLabel type="label5">
|
|
1140
1174
|
{isEditFlow ? updatedSmsEditor.join('') : templateMessage}
|
|
1141
1175
|
</CapLabel>
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1176
|
+
{unsubscribeRequired && (
|
|
1177
|
+
<CapLabel type="label5">
|
|
1178
|
+
{formatMessage(messages.templateMessageUnsubscribeText)}
|
|
1179
|
+
</CapLabel>
|
|
1180
|
+
)}
|
|
1145
1181
|
</>
|
|
1146
1182
|
);
|
|
1147
1183
|
return (
|
|
@@ -1153,9 +1189,7 @@ export const Whatsapp = (props) => {
|
|
|
1153
1189
|
ctaData,
|
|
1154
1190
|
}),
|
|
1155
1191
|
}}
|
|
1156
|
-
whatsappContentLen={
|
|
1157
|
-
isEditFlow ? updatedSmsEditor.join('').length : templateMessage.length
|
|
1158
|
-
}
|
|
1192
|
+
whatsappContentLen={computeLength()}
|
|
1159
1193
|
whatsappAccountName={accountName}
|
|
1160
1194
|
/>
|
|
1161
1195
|
);
|
|
@@ -10,17 +10,21 @@
|
|
|
10
10
|
margin-bottom: 6px;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
.whatsapp-
|
|
13
|
+
.whatsapp-unsubscribe-checkbox {
|
|
14
14
|
.ant-checkbox-inner {
|
|
15
15
|
height: 16px;
|
|
16
16
|
width: 16px;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
.whatsapp-create-unsubscribe {
|
|
20
|
+
.whatsapp-create-unsubscribe-checkbox {
|
|
21
21
|
margin: $CAP_SPACE_08 0px $CAP_SPACE_08 16px;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
.whatsapp-edit-unsubscribe-checkbox {
|
|
25
|
+
margin: $CAP_SPACE_08 0px;
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
.whatsapp-render-unsubscribe-text {
|
|
25
29
|
color: $FONT_COLOR_02;
|
|
26
30
|
font-size: 14px;
|