@capillarytech/creatives-library 8.0.118 → 8.0.121
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
|
@@ -1129,7 +1129,13 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1129
1129
|
};
|
|
1130
1130
|
|
|
1131
1131
|
const onSuccess = (contentToSubmit) => {
|
|
1132
|
-
this.
|
|
1132
|
+
const channel = this.props.channel || this.props?.schema?.channel?.toUpperCase();
|
|
1133
|
+
if(channel === EMAIL) {
|
|
1134
|
+
const content = this.state.formData?.base?.[this.props.baseLanguage]?.["template-content"] || "";
|
|
1135
|
+
this.handleLiquidTemplateSubmit(content);
|
|
1136
|
+
} else {
|
|
1137
|
+
this.handleLiquidTemplateSubmit(contentToSubmit);
|
|
1138
|
+
}
|
|
1133
1139
|
};
|
|
1134
1140
|
|
|
1135
1141
|
// Call the common validation function
|
package/v2Components/mockdata.js
CHANGED
|
@@ -69,8 +69,8 @@ export default {
|
|
|
69
69
|
status: 'approved',
|
|
70
70
|
templateId: 'HTee0274fb8dfdd45427bb678f875b0d54',
|
|
71
71
|
hostName: 'twiliowhatsapptrans',
|
|
72
|
-
accessToken: '
|
|
73
|
-
accountId: '
|
|
72
|
+
accessToken: 'asdf', //false positive
|
|
73
|
+
accountId: 'asdf', //false positive
|
|
74
74
|
templateEditor: false,
|
|
75
75
|
mediaType: 'TEXT',
|
|
76
76
|
languages: [
|
|
@@ -250,7 +250,7 @@ export const Whatsapp = (props) => {
|
|
|
250
250
|
margin-left: -32px;
|
|
251
251
|
padding: ${CAP_SPACE_32} ${CAP_SPACE_24};
|
|
252
252
|
z-index: 1;
|
|
253
|
-
|
|
253
|
+
|
|
254
254
|
.ant-btn {
|
|
255
255
|
margin-right: ${CAP_SPACE_16};
|
|
256
256
|
}
|
|
@@ -602,7 +602,7 @@ export const Whatsapp = (props) => {
|
|
|
602
602
|
// } else {
|
|
603
603
|
// setPreviewUrl('');
|
|
604
604
|
// }
|
|
605
|
-
// }
|
|
605
|
+
// }
|
|
606
606
|
// }, [updatedSmsEditor])
|
|
607
607
|
|
|
608
608
|
// const debounceFn = useCallback(
|
|
@@ -697,7 +697,7 @@ export const Whatsapp = (props) => {
|
|
|
697
697
|
}
|
|
698
698
|
handleCarouselValueChange(carouselIndex, [...tagFields, {fieldName: "varMap", value: carouselVarMap}, {fieldName: "updatedBodyText", value: arr}])
|
|
699
699
|
break;
|
|
700
|
-
default:
|
|
700
|
+
default:
|
|
701
701
|
varMap[areaId] = messageData;
|
|
702
702
|
setUpdatedSmsEditor(arr);
|
|
703
703
|
}
|
|
@@ -845,7 +845,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
845
845
|
return overallLength;
|
|
846
846
|
}
|
|
847
847
|
};
|
|
848
|
-
|
|
848
|
+
|
|
849
849
|
//used by create and edit
|
|
850
850
|
const renderMessageLength = (type, currentLength, carousel) => (
|
|
851
851
|
<CapHeading type="label1" className="whatsapp-render-message-length">
|
|
@@ -1306,7 +1306,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
1306
1306
|
} else {
|
|
1307
1307
|
errorMessage = variableErrorHandling(value, MESSAGE_TEXT);
|
|
1308
1308
|
}
|
|
1309
|
-
//we are not allowing user input incase of authentication flow
|
|
1309
|
+
//we are not allowing user input incase of authentication flow
|
|
1310
1310
|
if(isAuthenticationTemplate){
|
|
1311
1311
|
errorMessage = false;
|
|
1312
1312
|
}
|
|
@@ -1596,7 +1596,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
1596
1596
|
});
|
|
1597
1597
|
};
|
|
1598
1598
|
const isMediatypeValid =()=> ((isMediaTypeImage && whatsappImageSrc === "") || (isMediaTypeVideo && whatsappVideoSrcAndPreview?.whatsappVideoSrc === "") || (isMediaTypeDoc && whatsappDocSource === ""));
|
|
1599
|
-
|
|
1599
|
+
|
|
1600
1600
|
const isDisableDone = () => {
|
|
1601
1601
|
//if template name is not entered
|
|
1602
1602
|
if (templateName.trim() === '' || templateNameError) {
|
|
@@ -1615,7 +1615,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
1615
1615
|
return true;
|
|
1616
1616
|
}
|
|
1617
1617
|
//if media type is image, video or document and the mediaType file is not uploaded
|
|
1618
|
-
|
|
1618
|
+
|
|
1619
1619
|
if (!isMediaTypeText && isMediatypeValid() ) {
|
|
1620
1620
|
return true;
|
|
1621
1621
|
}
|
|
@@ -1643,16 +1643,16 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
1643
1643
|
return true;
|
|
1644
1644
|
}
|
|
1645
1645
|
if (isBtnTypeQuickReply) {
|
|
1646
|
-
// Disable button if there are no quick reply buttons or if any button is not saved
|
|
1646
|
+
// Disable button if there are no quick reply buttons or if any button is not saved
|
|
1647
1647
|
return !quickReplyData?.length || !quickReplyData.every(qr => qr?.isSaved);
|
|
1648
1648
|
}
|
|
1649
1649
|
if (isMediaTypeCarousel) {
|
|
1650
1650
|
const carouselDisableCheck = carouselData.some((data) => {
|
|
1651
1651
|
return (
|
|
1652
|
-
data?.bodyError ||
|
|
1653
|
-
data?.bodyText === "" ||
|
|
1654
|
-
(carouselMediaType === IMAGE.toLowerCase() && !data?.imageSrc) ||
|
|
1655
|
-
(carouselMediaType === VIDEO.toLowerCase() && !data?.videoSrc) ||
|
|
1652
|
+
data?.bodyError ||
|
|
1653
|
+
data?.bodyText === "" ||
|
|
1654
|
+
(carouselMediaType === IMAGE.toLowerCase() && !data?.imageSrc) ||
|
|
1655
|
+
(carouselMediaType === VIDEO.toLowerCase() && !data?.videoSrc) ||
|
|
1656
1656
|
!data?.buttons.every((button) => button?.isSaved === true)
|
|
1657
1657
|
);
|
|
1658
1658
|
});
|
|
@@ -1672,7 +1672,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
1672
1672
|
|
|
1673
1673
|
const handleCarouselMediaOptions = ({ target: { value = ''} = {} }) => {
|
|
1674
1674
|
setCarouselData(CAROUSEL_INITIAL_DATA);
|
|
1675
|
-
setCarouselMediaType(value);
|
|
1675
|
+
setCarouselMediaType(value);
|
|
1676
1676
|
}
|
|
1677
1677
|
|
|
1678
1678
|
const onTabChange = (index) => {
|
|
@@ -1874,7 +1874,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
1874
1874
|
const addContent = () => {
|
|
1875
1875
|
const updatedCarouselData = cloneDeep(carouselData); // Shallow copy, assuming carouselData isn't deeply nested
|
|
1876
1876
|
const firstCarouselButtonData = updatedCarouselData[0]?.buttons;
|
|
1877
|
-
|
|
1877
|
+
|
|
1878
1878
|
const buttonArray = firstCarouselButtonData.map((button) => {
|
|
1879
1879
|
switch (button?.buttonType) {
|
|
1880
1880
|
case PHONE_NUMBER:
|
|
@@ -1889,7 +1889,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
1889
1889
|
newCard.buttons = buttonArray;
|
|
1890
1890
|
setCarouselData([...updatedCarouselData, newCard]);
|
|
1891
1891
|
};
|
|
1892
|
-
|
|
1892
|
+
|
|
1893
1893
|
const checkDisableAddCarouselButton = () => {
|
|
1894
1894
|
return carouselData?.[0]?.buttons.some((button) => button?.isSaved === true);
|
|
1895
1895
|
}
|
|
@@ -1954,7 +1954,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
1954
1954
|
options={getCategoryOptions(host)}
|
|
1955
1955
|
onChange={onTemplateCategoryChange}
|
|
1956
1956
|
value={templateCategory}
|
|
1957
|
-
/>
|
|
1957
|
+
/>
|
|
1958
1958
|
</CapColumn>
|
|
1959
1959
|
{/* template media type */}
|
|
1960
1960
|
<CapColumn span={12}>
|
|
@@ -2352,6 +2352,15 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
2352
2352
|
// on change event of Text Area
|
|
2353
2353
|
const textAreaValueChange = ({ target: { value, id } }, type, carousel) => {
|
|
2354
2354
|
const numId = Number(id.slice(id.indexOf("_") + 1));
|
|
2355
|
+
// Validation: Prevent empty or only-space values
|
|
2356
|
+
const isInvalidValue = value.trim() === "";
|
|
2357
|
+
let errorMsg = false;
|
|
2358
|
+
if (isInvalidValue) {
|
|
2359
|
+
errorMsg = formatMessage(messages.emptyVariableValueErrorMessage || {
|
|
2360
|
+
id: 'whatsapp.emptyVariableValueErrorMessage',
|
|
2361
|
+
defaultMessage: 'Variable value cannot be empty or only spaces.'
|
|
2362
|
+
});
|
|
2363
|
+
}
|
|
2355
2364
|
//assign entered value to varMap
|
|
2356
2365
|
if (type === HEADER_TEXT) {
|
|
2357
2366
|
const arr = [...updatedHeaderData];
|
|
@@ -2359,16 +2368,19 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
2359
2368
|
...prevState,
|
|
2360
2369
|
[id]: value,
|
|
2361
2370
|
}));
|
|
2362
|
-
if (
|
|
2371
|
+
if (isInvalidValue) {
|
|
2363
2372
|
arr[numId] = id.slice(0, id.indexOf("_"));
|
|
2364
2373
|
} else {
|
|
2365
2374
|
arr[numId] = value;
|
|
2366
2375
|
}
|
|
2367
2376
|
setUpdatedHeaderData(arr);
|
|
2377
|
+
// Set error for header variable if needed
|
|
2378
|
+
if (errorMsg) setTemplateHeaderError(errorMsg);
|
|
2379
|
+
else setTemplateHeaderError(false);
|
|
2368
2380
|
} else if (type === CAROUSEL_TEXT) {
|
|
2369
2381
|
const carouselUpdatedBodyTextData = carousel?.data?.updatedBodyText || [];
|
|
2370
2382
|
const arr = [...carouselUpdatedBodyTextData];
|
|
2371
|
-
if (
|
|
2383
|
+
if (isInvalidValue) {
|
|
2372
2384
|
arr[numId] = id.slice(0, id.indexOf("_"));
|
|
2373
2385
|
} else {
|
|
2374
2386
|
arr[numId] = value;
|
|
@@ -2380,16 +2392,21 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
2380
2392
|
tagFields = tagValidation(arr, carouselBodyVarRegex, CAROUSEL_TEXT) || [];
|
|
2381
2393
|
}
|
|
2382
2394
|
handleCarouselValueChange(carousel?.carouselIndex, [...tagFields, {fieldName: "varMap", value: bodyVarMapData}, {fieldName: 'updatedBodyText', value: arr}])
|
|
2395
|
+
// Set error for carousel variable if needed
|
|
2396
|
+
// (You may want to add a state for carousel variable errors if not present)
|
|
2383
2397
|
} else {
|
|
2384
2398
|
const arr = [...updatedSmsEditor];
|
|
2385
2399
|
varMap[id] = value;
|
|
2386
2400
|
//based on entered value update updatedSmsEditor
|
|
2387
|
-
if (
|
|
2401
|
+
if (isInvalidValue) {
|
|
2388
2402
|
arr[numId] = id.slice(0, id.indexOf("_"));
|
|
2389
2403
|
} else {
|
|
2390
2404
|
arr[numId] = value;
|
|
2391
2405
|
}
|
|
2392
2406
|
setUpdatedSmsEditor(arr);
|
|
2407
|
+
// Set error for message variable if needed
|
|
2408
|
+
if (errorMsg) setTemplateMessageError(errorMsg);
|
|
2409
|
+
else setTemplateMessageError(false);
|
|
2393
2410
|
}
|
|
2394
2411
|
};
|
|
2395
2412
|
|
|
@@ -2796,10 +2813,10 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
2796
2813
|
if (isMediaTypeCarousel) {
|
|
2797
2814
|
carouselDisableCheck = carouselData.some((data) => {
|
|
2798
2815
|
return (
|
|
2799
|
-
data.carouselTagValidationErr ||
|
|
2800
|
-
Object.values(data.varMap).some((inputValue) => inputValue === "") ||
|
|
2816
|
+
data.carouselTagValidationErr ||
|
|
2817
|
+
Object.values(data.varMap).some((inputValue) => inputValue === "") ||
|
|
2801
2818
|
computeTextLength(CAROUSEL_TEXT, data) > TEMPLATE_MESSAGE_MAX_LENGTH ||
|
|
2802
|
-
(carouselMediaType === IMAGE.toLowerCase() && !data.imageSrc) ||
|
|
2819
|
+
(carouselMediaType === IMAGE.toLowerCase() && !data.imageSrc) ||
|
|
2803
2820
|
(carouselMediaType === VIDEO.toLowerCase() && !data.videoSrc) ||
|
|
2804
2821
|
data?.buttons.some((btn) => btn?.url?.includes("{{1}}"))
|
|
2805
2822
|
);
|