@capillarytech/creatives-library 8.0.348 → 8.0.350

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.
Files changed (40) hide show
  1. package/constants/unified.js +1 -0
  2. package/package.json +1 -1
  3. package/services/api.js +20 -0
  4. package/services/tests/api.test.js +59 -0
  5. package/utils/common.js +6 -0
  6. package/utils/tests/v2Common.test.js +46 -1
  7. package/utils/v2common.js +18 -0
  8. package/v2Components/CapCustomSkeleton/index.js +1 -1
  9. package/v2Components/CapCustomSkeleton/tests/__snapshots__/index.test.js.snap +12 -12
  10. package/v2Components/CommonTestAndPreview/UnifiedPreview/WhatsAppPreviewContent.js +6 -18
  11. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +0 -27
  12. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/WhatsAppPreviewContent.test.js +0 -48
  13. package/v2Components/TemplatePreview/_templatePreview.scss +0 -21
  14. package/v2Components/TemplatePreview/index.js +6 -18
  15. package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +0 -1
  16. package/v2Containers/Assets/images/archive_Empty_Illustration.svg +9 -0
  17. package/v2Containers/CreativesContainer/SlideBoxFooter.js +3 -1
  18. package/v2Containers/CreativesContainer/index.js +6 -9
  19. package/v2Containers/CreativesContainer/messages.js +4 -0
  20. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +3 -0
  21. package/v2Containers/Templates/ChannelTypeIllustration.js +23 -6
  22. package/v2Containers/Templates/_templates.scss +180 -24
  23. package/v2Containers/Templates/actions.js +44 -0
  24. package/v2Containers/Templates/constants.js +31 -0
  25. package/v2Containers/Templates/index.js +364 -60
  26. package/v2Containers/Templates/messages.js +96 -0
  27. package/v2Containers/Templates/reducer.js +84 -1
  28. package/v2Containers/Templates/sagas.js +64 -0
  29. package/v2Containers/Templates/selectors.js +12 -0
  30. package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +12 -0
  31. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1176 -1122
  32. package/v2Containers/Templates/tests/index.test.js +6 -0
  33. package/v2Containers/Templates/tests/reducer.test.js +178 -0
  34. package/v2Containers/Templates/tests/sagas.test.js +390 -8
  35. package/v2Containers/Templates/tests/selector.test.js +32 -0
  36. package/v2Containers/TemplatesV2/TemplatesV2.style.js +1 -1
  37. package/v2Containers/Whatsapp/constants.js +0 -8
  38. package/v2Containers/Whatsapp/index.js +5 -142
  39. package/v2Containers/Whatsapp/index.scss +0 -8
  40. package/v2Containers/Whatsapp/messages.js +0 -16
@@ -319,14 +319,6 @@ export const WHATSAPP_MEDIA_TYPES = {
319
319
  DOCUMENT: 'DOCUMENT',
320
320
  CAROUSEL: 'CAROUSEL',
321
321
  };
322
-
323
- export const WHATSAPP_IMAGE_SOURCE = {
324
- UPLOAD: 'UPLOAD_IMAGE',
325
- URL: 'ADD_IMAGE_URL',
326
- };
327
-
328
- export const ADD_IMAGE_URL_PREVIEW_MARKER = '__add_image_url__';
329
- export const TEMPLATE_VARIABLE_REGEX = /\{\{.*?\}\}/;
330
322
  export const NONE = 'NONE';
331
323
  export const CTA = 'CTA';
332
324
  export const QUICK_REPLY = 'QUICK_REPLY';
@@ -104,8 +104,7 @@ import {
104
104
  VIDEO,
105
105
  URL,
106
106
  REQUEST,
107
- HOST_KARIX,
108
- WHATSAPP_IMAGE_SOURCE,
107
+ HOST_KARIX
109
108
  } from './constants';
110
109
  import { transformAssetData, transformToVendorFormat, VENDOR_TYPES, resolveCarouselVideoUpdateFields } from '../../utils/vendorDataTransformers';
111
110
  import { validateCarouselCards } from '../../utils/commonUtils';
@@ -253,15 +252,12 @@ export const Whatsapp = (props) => {
253
252
  const [headerTextAreaId, setHeaderTextAreaId] = useState('');
254
253
  const [isHeaderTagValidationError, updateIsHeaderTagValidationError] =
255
254
  useState(false);
256
- const [imageURLCursorPosition, setImageURLCursorPosition] = useState(0);
257
255
  const [showUrlPreview, setShowUrlPreview] = useState(false);
258
256
  const [previewUrl, setPreviewUrl] = useState('');
259
257
  const [carouselMediaType, setCarouselMediaType] = useState('image');
260
258
  const [carouselData, setCarouselData] = useState(CAROUSEL_INITIAL_DATA);
261
259
  const [activeIndex, setActiveIndex] = useState(defaultActiveIndex);
262
260
  const [carouselValidateTag, setCarouselValidateTag] = useState(false);
263
- const [mediaTypeSelection, setMediaTypeSelection] = useState(WHATSAPP_IMAGE_SOURCE.UPLOAD);
264
- const [imageURL, setImageURL] = useState('');
265
261
  // TestAndPreviewSlidebox state
266
262
  const [showTestAndPreviewSlidebox, setShowTestAndPreviewSlidebox] = useState(false);
267
263
  const [isTestAndPreviewMode, setIsTestAndPreviewMode] = useState(false);
@@ -368,7 +364,6 @@ export const Whatsapp = (props) => {
368
364
  whatsappMedia: { header = '', footer = '', headerVarMapped = [] } = {},
369
365
  isPreviewUrl = false,
370
366
  carouselData : editCarouselData = [],
371
- isAddImageUrl = false,
372
367
  } = editContent;
373
368
  setTemplateCategory(category);
374
369
  setTemplateStatus(status);
@@ -383,14 +378,6 @@ export const Whatsapp = (props) => {
383
378
  });
384
379
  setWhatsappDocSource(documentUrl);
385
380
  setWhatsappDocParams(whatsappDocParams);
386
- if (mediaType === WHATSAPP_MEDIA_TYPES.IMAGE) {
387
- if (isAddImageUrl) {
388
- setMediaTypeSelection(WHATSAPP_IMAGE_SOURCE.URL);
389
- setImageURL(imageUrl);
390
- } else {
391
- setMediaTypeSelection(WHATSAPP_IMAGE_SOURCE.UPLOAD);
392
- }
393
- }
394
381
  if (host === HOST_HAPTIC) {
395
382
  updateAssetList(transformToVendorFormat({
396
383
  ...assetList,
@@ -813,15 +800,6 @@ export const Whatsapp = (props) => {
813
800
  });
814
801
  }
815
802
 
816
- const onImageURLTagSelect = (data) => {
817
- const currentURL = imageURL || '';
818
- const tag = `{{${data}}}`;
819
- const newURL = currentURL.slice(0, imageURLCursorPosition) + tag + currentURL.slice(imageURLCursorPosition);
820
- setImageURL(newURL);
821
- setWhatsappImageSrc(newURL);
822
- setImageURLCursorPosition(imageURLCursorPosition + tag.length);
823
- };
824
-
825
803
  //setting the id of currently selected text area, is used onTagSelect
826
804
  const setTextAreaId = ({ target: { id } }, type, carouselIndex) => {
827
805
  if (type === HEADER_TEXT) {
@@ -1173,9 +1151,6 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1173
1151
  );
1174
1152
  } else {
1175
1153
  setWhatsappImageSrc(filePath);
1176
- if (mediaTypeSelection !== WHATSAPP_IMAGE_SOURCE.URL) {
1177
- setMediaTypeSelection(WHATSAPP_IMAGE_SOURCE.UPLOAD);
1178
- }
1179
1154
  if (isHaptic) {
1180
1155
  setHapticFileHandle(fileHandle);
1181
1156
  } else {
@@ -1184,7 +1159,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1184
1159
  }
1185
1160
  actions.clearWhatsappAsset(0);
1186
1161
  },
1187
- [whatsappImageSrc, isMediaTypeCarousel, activeIndex, carouselData, isHaptic, mediaTypeSelection],
1162
+ [whatsappImageSrc, isMediaTypeCarousel, activeIndex, carouselData, isHaptic],
1188
1163
  );
1189
1164
 
1190
1165
  const updateOnWhatsappImageReUpload = useCallback(() => {
@@ -1651,10 +1626,8 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1651
1626
  const { whatsappVideoSrc = '', whatsappVideoPreviewImg = '' } = whatsappVideoSrcAndPreview;
1652
1627
  switch (templateMediaType) {
1653
1628
  case WHATSAPP_MEDIA_TYPES.IMAGE:
1654
- const isImageUrlMode = mediaTypeSelection === WHATSAPP_IMAGE_SOURCE.URL;
1655
1629
  mediaParams = {
1656
1630
  imageUrl: getCdnUrl({ url: whatsappImageSrc, channelName: WHATSAPP }),
1657
- ...(isImageUrlMode && { isAddImageUrl: true }),
1658
1631
  };
1659
1632
  break;
1660
1633
  case WHATSAPP_MEDIA_TYPES.VIDEO:
@@ -1673,6 +1646,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1673
1646
  break;
1674
1647
  }
1675
1648
 
1649
+ // Add the correct file handle based on host
1676
1650
  if (isHaptic && hapticFileHandle) {
1677
1651
  mediaParams.hapticFileHandle = hapticFileHandle;
1678
1652
  } else if (!isHaptic && karixFileHandle) {
@@ -1784,21 +1758,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1784
1758
  type: WHATSAPP,
1785
1759
  });
1786
1760
  };
1787
- const isMediatypeValid =()=> {
1788
- if (isMediaTypeImage) {
1789
- if (mediaTypeSelection === WHATSAPP_IMAGE_SOURCE.URL) {
1790
- return isEditFlow ? !imageURL?.trim() : !whatsappImageSrc?.trim();
1791
- }
1792
- return !whatsappImageSrc?.trim();
1793
- }
1794
- if (isMediaTypeVideo) {
1795
- return !whatsappVideoSrcAndPreview?.whatsappVideoSrc?.trim();
1796
- }
1797
- if (isMediaTypeDoc) {
1798
- return !whatsappDocSource?.trim();
1799
- }
1800
- return false;
1801
- };
1761
+ const isMediatypeValid =()=> ((isMediaTypeImage && whatsappImageSrc === "") || (isMediaTypeVideo && whatsappVideoSrcAndPreview?.whatsappVideoSrc === "") || (isMediaTypeDoc && whatsappDocSource === ""));
1802
1762
 
1803
1763
  const isDisableDone = () => {
1804
1764
  // Snapshot removed
@@ -1875,106 +1835,9 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1875
1835
  return false;
1876
1836
  };
1877
1837
 
1878
- const renderImageURLComponent = () => (
1879
- <>
1880
- {templateStatus === WHATSAPP_STATUSES.approved && !isAuthenticationTemplate && (
1881
- <CapRow className="whatsapp-render-heading">
1882
- <CapHeader
1883
- title={
1884
- <CapHeading type="h4">
1885
- {formatMessage(messages.mediaImage)}
1886
- </CapHeading>
1887
- }
1888
- suffix={
1889
- <TagList
1890
- label={formatMessage(globalMessages.addLabels)}
1891
- onTagSelect={onImageURLTagSelect}
1892
- location={location}
1893
- tags={tags || []}
1894
- onContextChange={handleOnTagsContextChange}
1895
- injectedTags={injectedTags || {}}
1896
- selectedOfferDetails={selectedOfferDetails}
1897
- eventContextTags={eventContextTags}
1898
- />
1899
- }
1900
- />
1901
- </CapRow>
1902
- )}
1903
- <CapRow className="whatsapp-image-url-container">
1904
- <CapInput
1905
- id="whatsapp-image-url-input"
1906
- placeholder={formatMessage(messages.imageUrlInputPlaceholder)}
1907
- value={imageURL}
1908
- disabled={isEditFlow && isFullMode}
1909
- onChange={e => {
1910
- setImageURL(e.target.value);
1911
- setWhatsappImageSrc(e.target.value);
1912
- }}
1913
- onFocus={(e) => {
1914
- setImageURLCursorPosition(e.target.selectionStart || e.target.value.length);
1915
- }}
1916
- onSelect={(e) => {
1917
- setImageURLCursorPosition(e.target.selectionStart || e.target.value.length);
1918
- }}
1919
- />
1920
- </CapRow>
1921
- </>
1922
- );
1923
-
1924
- const handleMediaChange = (e) => {
1925
- if (templateStatus === WHATSAPP_STATUSES.approved || isEditFlow) {
1926
- return;
1927
- }
1928
- setMediaTypeSelection(e.target.value);
1929
- if (e.target.value === WHATSAPP_IMAGE_SOURCE.UPLOAD) {
1930
- setImageURL('');
1931
- } else if (e.target.value === WHATSAPP_IMAGE_SOURCE.URL) {
1932
- setWhatsappImageSrc('');
1933
- if (isHaptic) {
1934
- setHapticFileHandle('');
1935
- } else {
1936
- setKarixFileHandle('');
1937
- }
1938
- }
1939
- };
1940
-
1941
1838
  const renderMediaComponent = () => (
1942
1839
  <>
1943
- {isMediaTypeImage && (
1944
- <CapRow className="whatsapp-dynamic-url-selection-container">
1945
- <CapHeading type="h4" className="whatsapp-dynamic-url-selection-heading">
1946
- {formatMessage(messages.mediaImage)}
1947
- </CapHeading>
1948
- <CapRadioGroup
1949
- options={[
1950
- {
1951
- value: WHATSAPP_IMAGE_SOURCE.UPLOAD,
1952
- label: formatMessage(messages.imageSourceUpload),
1953
- },
1954
- {
1955
- value: WHATSAPP_IMAGE_SOURCE.URL,
1956
- label: (
1957
- <CapLabel.CapLabelInline type="label2">
1958
- {formatMessage(messages.imageSourceUrl)}{' '}
1959
- <CapTooltip
1960
- placement="top"
1961
- title={formatMessage(messages.imageSourceUrlTooltip)}
1962
- >
1963
- <CapIcon type="info-circle" size="s" style={{ cursor: 'pointer' }} />
1964
- </CapTooltip>
1965
- </CapLabel.CapLabelInline>
1966
- ),
1967
- },
1968
- ]}
1969
- value={mediaTypeSelection}
1970
- onChange={handleMediaChange}
1971
- className="whatsapp-media-radio"
1972
- disabled={templateStatus === WHATSAPP_STATUSES.approved || isEditFlow}
1973
- />
1974
- </CapRow>
1975
- )}
1976
- {isMediaTypeImage && (mediaTypeSelection === WHATSAPP_IMAGE_SOURCE.UPLOAD || !isEditFlow) && renderImageComponent()}
1977
- {isMediaTypeImage && mediaTypeSelection === WHATSAPP_IMAGE_SOURCE.URL && isEditFlow && renderImageURLComponent()}
1840
+ {isMediaTypeImage && renderImageComponent()}
1978
1841
  {isMediaTypeVideo && renderVideoComonent()}
1979
1842
  {isMediaTypeDoc && renderDocumentComponent()}
1980
1843
  </>
@@ -9,14 +9,6 @@
9
9
  margin-top: $CAP_SPACE_16;
10
10
  }
11
11
 
12
- .whatsapp-dynamic-url-selection-container {
13
- margin-bottom: $CAP_SPACE_08;
14
- margin-top: $CAP_SPACE_32;
15
- .whatsapp-dynamic-url-selection-heading {
16
- margin-bottom: $CAP_SPACE_08;
17
- }
18
- }
19
-
20
12
  .whatsapp-render-heading {
21
13
  margin-top: $CAP_SPACE_16;
22
14
  margin-bottom: $CAP_SPACE_06;
@@ -138,22 +138,6 @@ export default defineMessages({
138
138
  id: `${prefix}.mediaCarousel`,
139
139
  defaultMessage: 'Carousel',
140
140
  },
141
- imageSourceUpload: {
142
- id: `${prefix}.imageSourceUpload`,
143
- defaultMessage: 'Upload image',
144
- },
145
- imageSourceUrl: {
146
- id: `${prefix}.imageSourceUrl`,
147
- defaultMessage: 'Dynamic image',
148
- },
149
- imageSourceUrlTooltip: {
150
- id: `${prefix}.imageSourceUrlTooltip`,
151
- defaultMessage: 'Post template approval, the image placeholder is replaceable with image URL',
152
- },
153
- imageUrlInputPlaceholder: {
154
- id: `${prefix}.imageUrlInputPlaceholder`,
155
- defaultMessage: 'Enter image URL',
156
- },
157
141
  disabledFeatureTooltip: {
158
142
  id: `${prefix}.disabledFeatureTooltip`,
159
143
  defaultMessage: 'Not yet enabled. Coming soon!',