@capillarytech/creatives-library 8.0.216 → 8.0.218

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.
@@ -106,7 +106,8 @@ import {
106
106
  REQUEST,
107
107
  HOST_KARIX
108
108
  } from './constants';
109
- import { transformAssetData, transformToVendorFormat, VENDOR_TYPES } from '../../utils/vendorDataTransformers';
109
+ import { transformAssetData, transformToVendorFormat, VENDOR_TYPES, resolveCarouselVideoUpdateFields } from '../../utils/vendorDataTransformers';
110
+ import { validateCarouselCards } from '../../utils/commonUtils';
110
111
  import { DATE_DISPLAY_FORMAT, TIME_DISPLAY_FORMAT } from '../App/constants';
111
112
  import messages from './messages';
112
113
  import globalMessages from '../Cap/messages';
@@ -455,7 +456,9 @@ export const Whatsapp = (props) => {
455
456
  videoSrc: carousel?.videoUrl,
456
457
  videoPreviewImg: carousel?.videoPreviewImg,
457
458
  }),
458
- karixFileHandle: carousel?.karixFileHandle || '',
459
+ // Preserve both vendor-specific file handles from edit data
460
+ karixFileHandle: carousel?.karixFileHandle || '',
461
+ hapticFileHandle: carousel?.hapticFileHandle || '',
459
462
  buttons: carousel?.buttons?.map((button) => ({
460
463
  ...button,
461
464
  buttonType: button?.type,
@@ -463,7 +466,7 @@ export const Whatsapp = (props) => {
463
466
  assetList: {
464
467
  previewUrl: carousel?.videoPreviewImg,
465
468
  videoSrc: carousel?.videoUrl,
466
- fileHandle: carousel?.karixFileHandle,
469
+ fileHandle: carousel?.hapticFileHandle || carousel?.karixFileHandle,
467
470
  }
468
471
  };
469
472
  })
@@ -1127,7 +1130,14 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1127
1130
  const setUpdateWhatsappImageSrc = useCallback(
1128
1131
  (filePath, fileHandle) => {
1129
1132
  if (isMediaTypeCarousel) {
1130
- handleCarouselValueChange(parseInt(activeIndex, 10), [{fieldName: "imageSrc", value: filePath}, {fieldName: "karixFileHandle", value: fileHandle}]);
1133
+ handleCarouselValueChange(
1134
+ parseInt(activeIndex, 10),
1135
+ [
1136
+ { fieldName: "imageSrc", value: filePath },
1137
+ { fieldName: "hapticFileHandle", value: host === HOST_HAPTIC ? fileHandle : '' },
1138
+ { fieldName: "karixFileHandle", value: (host === HOST_KARIX || host === HOST_GUPSHUP) ? fileHandle : '' },
1139
+ ]
1140
+ );
1131
1141
  } else {
1132
1142
  setWhatsappImageSrc(filePath);
1133
1143
  if (isHaptic) {
@@ -1143,7 +1153,14 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1143
1153
 
1144
1154
  const updateOnWhatsappImageReUpload = useCallback(() => {
1145
1155
  if (isMediaTypeCarousel) {
1146
- handleCarouselValueChange(parseInt(activeIndex, 10), [{fieldName: "imageSrc", value: ''}, {fieldName: "karixFileHandle", value: ''}]);
1156
+ handleCarouselValueChange(
1157
+ parseInt(activeIndex, 10),
1158
+ [
1159
+ { fieldName: "imageSrc", value: '' },
1160
+ { fieldName: "hapticFileHandle", value: '' },
1161
+ { fieldName: "karixFileHandle", value: '' },
1162
+ ]
1163
+ );
1147
1164
  } else {
1148
1165
  setWhatsappImageSrc('');
1149
1166
  if (isHaptic) {
@@ -1165,12 +1182,12 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1165
1182
 
1166
1183
  // Handle vendor-specific updates
1167
1184
  const handleVideoUploadUpdate = (index, data) => {
1168
- if (host === HOST_HAPTIC) {
1169
- // Transform back to HAPTIC format
1185
+ if (host === HOST_HAPTIC && !isMediaTypeCarousel) {
1186
+ // Non-carousel HAPTIC needs vendor meta for non-carousel state mapping
1170
1187
  const hapticData = transformToVendorFormat(data, VENDOR_TYPES.HAPTIC);
1171
1188
  setUpdateWhatsappVideoSrc(index, hapticData);
1172
1189
  } else {
1173
- // Use existing logic for other vendors
1190
+ // Carousel and other vendors use standard data so card.videoSrc is set
1174
1191
  setUpdateWhatsappVideoSrc(index, data);
1175
1192
  }
1176
1193
  };
@@ -1179,7 +1196,18 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1179
1196
  (index, data) => {
1180
1197
  const { videoSrc = '', previewUrl = '', fileHandle = '' } = data;
1181
1198
  if (isMediaTypeCarousel) {
1182
- handleCarouselValueChange(parseInt(activeIndex, 10), [{fieldName: "videoSrc", value: videoSrc}, {fieldName: "videoPreviewImg", value: previewUrl}, {fieldName: "assetList", value: data}, {fieldName: "karixFileHandle", value: fileHandle}]);
1199
+ const { updateFields } = resolveCarouselVideoUpdateFields({
1200
+ host,
1201
+ data,
1202
+ videoSrc,
1203
+ previewUrl,
1204
+ fileHandle,
1205
+ });
1206
+
1207
+ handleCarouselValueChange(
1208
+ parseInt(activeIndex, 10),
1209
+ updateFields
1210
+ );
1183
1211
  } else {
1184
1212
  setWhatsappVideoSrcAndPreview({
1185
1213
  whatsappVideoSrc: host === HOST_HAPTIC ? data?.metaInfo?.secure_file_path : videoSrc,
@@ -1547,7 +1575,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1547
1575
 
1548
1576
  const getCarouselPayload = () => {
1549
1577
  return carouselData.map((carousel) => {
1550
- const { bodyText = '', imageSrc = '', videoSrc = '', videoPreviewImg = '', karixFileHandle = '', buttons = [], varMap: carouselVarMap = {}, updatedBodyText = [], tempBodyData = [] } = carousel || {};
1578
+ const { bodyText = '', imageSrc = '', videoSrc = '', videoPreviewImg = '', karixFileHandle = '', hapticFileHandle: cardHapticFileHandle = '', buttons = [], varMap: carouselVarMap = {}, updatedBodyText = [], tempBodyData = [] } = carousel || {};
1551
1579
  const carouselButtons = buttons.map((button) => {
1552
1580
  const { text = '', buttonType: type = '', url = '', phone_number = '', urlType = '' } = button;
1553
1581
  return {
@@ -1571,7 +1599,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1571
1599
  videoUrl: videoSrc,
1572
1600
  videoPreviewImg,
1573
1601
  }),
1574
- karixFileHandle,
1602
+ ...(isHaptic ? { hapticFileHandle: cardHapticFileHandle } : { karixFileHandle }),
1575
1603
  buttons: carouselButtons,
1576
1604
  mediaType: carouselMediaType,
1577
1605
  ...(!isFullMode && {
@@ -1721,6 +1749,8 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1721
1749
  const isMediatypeValid =()=> ((isMediaTypeImage && whatsappImageSrc === "") || (isMediaTypeVideo && whatsappVideoSrcAndPreview?.whatsappVideoSrc === "") || (isMediaTypeDoc && whatsappDocSource === ""));
1722
1750
 
1723
1751
  const isDisableDone = () => {
1752
+ // Snapshot removed
1753
+
1724
1754
  //if template name is not entered
1725
1755
  if (templateName.trim() === '' || templateNameError) {
1726
1756
  return true;
@@ -1761,8 +1791,13 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1761
1791
  //if button type is cta and there are no buttons saved
1762
1792
  return true;
1763
1793
  }
1764
- //karix expiry minutes validation
1765
- if(host === HOST_KARIX && (expiryMinutes <=0 || expiryMinutes > 90)){
1794
+ //karix expiry minutes validation - only for authentication template
1795
+ if (
1796
+ host === HOST_KARIX &&
1797
+ isAuthenticationTemplate &&
1798
+ securityWarningReqd &&
1799
+ (expiryMinutes <= 0 || expiryMinutes > 90)
1800
+ ) {
1766
1801
  return true;
1767
1802
  }
1768
1803
 
@@ -1771,21 +1806,20 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1771
1806
  }
1772
1807
  if (isBtnTypeQuickReply) {
1773
1808
  // Disable button if there are no quick reply buttons or if any button is not saved
1774
- return !quickReplyData?.length || !quickReplyData.every(qr => qr?.isSaved);
1809
+ const ok = !!quickReplyData?.length && quickReplyData.every(qr => qr?.isSaved);
1810
+ if (!ok) {
1811
+ return true;
1812
+ }
1775
1813
  }
1776
1814
  if (isMediaTypeCarousel) {
1777
- const carouselDisableCheck = carouselData.some((data) => {
1778
- return (
1779
- data?.bodyError ||
1780
- data?.bodyText === "" ||
1781
- (carouselMediaType === IMAGE.toLowerCase() && !data?.imageSrc) ||
1782
- (carouselMediaType === VIDEO.toLowerCase() && !data?.videoSrc) ||
1783
- !data?.buttons.every((button) => button?.isSaved === true)
1784
- );
1815
+ const { isValid } = validateCarouselCards(carouselData, carouselMediaType, {
1816
+ imageConstant: IMAGE,
1817
+ videoConstant: VIDEO,
1785
1818
  });
1786
- return carouselDisableCheck;
1819
+ if (!isValid) {
1820
+ return true;
1821
+ }
1787
1822
  }
1788
-
1789
1823
  return false;
1790
1824
  };
1791
1825