@capillarytech/creatives-library 7.14.8 → 7.14.9

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/config/app.js CHANGED
@@ -17,7 +17,6 @@ const config = {
17
17
  },
18
18
  development: {
19
19
  api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
20
- //api_endpoint: "http://localhost:2022/arya/api/v1/creatives",
21
20
  campaigns_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/campaigns',
22
21
  campaigns_api_org_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/org/campaign',
23
22
  auth_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/auth',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "7.14.8",
4
+ "version": "7.14.9",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -1,8 +1,6 @@
1
1
  /* eslint-disable camelcase */
2
2
  import React, { useState, useEffect, useCallback } from 'react';
3
3
  import PropTypes from "prop-types";
4
- import "@react-pdf-viewer/core/lib/styles/index.css";
5
- import "@react-pdf-viewer/default-layout/lib/styles/index.css";
6
4
  import LabelHOC from '@capillarytech/cap-ui-library/assets/HOCs/ComponentWithLabelHOC';
7
5
  import {
8
6
  CapUploader,
@@ -123,22 +121,23 @@ function CapDocumentUpload(props) {
123
121
 
124
122
  const getDocumentSection = useCallback(() => {
125
123
  if (documentSrc === "") {
126
- return (<>
127
- <CapUploader.CapDragger
128
- customRequest={capUploaderCustomRequest}
129
- className="form-builder-dragger whatsapp-background"
130
- showUploadList={!isDocError}
131
- >
132
- <CapHeading className="dragger-title" type="h7">
133
- <FormattedMessage {...messages.dragAndDrop} />
134
- </CapHeading>
135
- <CapHeading className="dragger-or" type="label6">
136
- <FormattedMessage {...messages.or} />
137
- </CapHeading>
138
- <CapButton className="dragger-button upload-doc" type="secondary">
139
- <FormattedMessage {...messages.uploadComputer} />
140
- </CapButton>
141
- </CapUploader.CapDragger>
124
+ return (
125
+ <>
126
+ <CapUploader.CapDragger
127
+ customRequest={capUploaderCustomRequest}
128
+ className="form-builder-dragger whatsapp-background"
129
+ showUploadList={!isDocError}
130
+ >
131
+ <CapHeading className="dragger-title" type="h7">
132
+ <FormattedMessage {...messages.dragAndDrop} />
133
+ </CapHeading>
134
+ <CapHeading className="dragger-or" type="label6">
135
+ <FormattedMessage {...messages.or} />
136
+ </CapHeading>
137
+ <CapButton className="dragger-button upload-doc" type="secondary">
138
+ <FormattedMessage {...messages.uploadComputer} />
139
+ </CapButton>
140
+ </CapUploader.CapDragger>
142
141
  </>
143
142
  );
144
143
  }
@@ -159,8 +158,7 @@ function CapDocumentUpload(props) {
159
158
  <WithLabel
160
159
  key={`with-label`}
161
160
  errorMessage={isDocError} ifError={!!isDocError}
162
-
163
- />
161
+ />
164
162
  <form encType="multipart/form-data" id={`form`} className={className}>
165
163
  <input
166
164
  key={`docFile`}
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+ import { injectIntl } from 'react-intl';
3
+ import '@testing-library/jest-dom';
4
+ import {
5
+ render,
6
+ screen,
7
+ fireEvent,
8
+ waitFor,
9
+ } from '../../../utils/test-utils';
10
+ import CapDocumentUpload from '../index';
11
+
12
+ const ComponentToRender = injectIntl(CapDocumentUpload);
13
+ const renderComponent = (props) => render(
14
+ <ComponentToRender {...props} />
15
+ );
16
+
17
+ describe("test for document upload", () => {
18
+ const props = {
19
+ allowedExtensionsRegex: (/\.(pdf)$/i),
20
+ documentSize: 16000000,
21
+ uploadAsset: jest.fn(),
22
+ documentSrc: '',
23
+ updateDocumentSrc: jest.fn(),
24
+ updateOnReUpload: jest.fn(),
25
+ index: 0,
26
+ className: 'cap-custom-document-upload',
27
+ documentData: {},
28
+ channel: 'WHATSAPP',
29
+ channelSpecificStyle: null,
30
+ whatsappDocParams: {},
31
+ setWhatsappDocParams: jest.fn(),
32
+ docPreview: <></>,
33
+ };
34
+ it("test for cap document upload", () => {
35
+ renderComponent(props);
36
+ expect(true).toBe(true);
37
+ });
38
+ it("test for cap document upload 1", () => {
39
+ const props1 = {
40
+ ...props,
41
+ documentData: {
42
+ uploadedAssetData0: {
43
+ file_size: 134532,
44
+ name: 'sample.pdf',
45
+ secure_file_path: "https://www.africau.edu/images/default/sample.pdf",
46
+ karixFileHandle: 'abcd',
47
+ },
48
+ },
49
+ documentSrc: "https://www.africau.edu/images/default/sample.pdf",
50
+ whatsappDocParams: {
51
+ whatsappDocName: 'sample.pdf',
52
+ whatsappDocSize: 134532,
53
+ whatsappDocPages: 2,
54
+ whatsappDocImg: 'https://play-lh.googleusercontent.com/BkRfMfIRPR9hUnmIYGDgHHKjow-g18-ouP6B2ko__VnyUHSi1spcc78UtZ4sVUtBH4g',
55
+ },
56
+ };
57
+ renderComponent(props1);
58
+ expect(true).toBe(true);
59
+ });
60
+ });
@@ -56,6 +56,7 @@ function CapVideoUpload(props) {
56
56
  } = uploadedAssetList;
57
57
 
58
58
  const [isTemplateDrawerRequired, updateTemplateDrawerRequirement] = useState(false);
59
+
59
60
  const uploadVideo = useCallback((e, { files }) => {
60
61
  if (e) {
61
62
  e.preventDefault();
@@ -0,0 +1,59 @@
1
+ import React from 'react';
2
+ import { injectIntl } from 'react-intl';
3
+ import '@testing-library/jest-dom';
4
+ import {
5
+ render,
6
+ screen,
7
+ fireEvent,
8
+ waitFor,
9
+ } from '../../../utils/test-utils';
10
+ import CapVideoUpload from '../index';
11
+
12
+ const ComponentToRender = injectIntl(CapVideoUpload);
13
+ const renderComponent = (props) => render(
14
+ <ComponentToRender {...props} />
15
+ );
16
+
17
+ describe("test for document upload", () => {
18
+ const props = {
19
+ allowedExtensionsRegex: (/\.(mp4|3gpp)$/i),
20
+ videoSize: 16000000,
21
+ uploadAsset: jest.fn(),
22
+ supportedExtensions: '',
23
+ videoSrc: '',
24
+ uploadedAssetList: {},
25
+ updateDocumentSrc: jest.fn(),
26
+ updateOnReUpload: jest.fn(),
27
+ index: 0,
28
+ className: 'cap-custom-video-upload',
29
+ videoData: {},
30
+ channel: 'WHATSAPP',
31
+ onVideoUploadUpdateAssestList: jest.fn(),
32
+ };
33
+ it("test for cap document upload", () => {
34
+ renderComponent(props);
35
+ expect(true).toBe(true);
36
+ });
37
+ it("test for cap document upload 1", () => {
38
+ const props1 = {
39
+ ...props,
40
+ documentData: {
41
+ uploadedAssetData0: {
42
+ file_size: 134532,
43
+ name: 'sample.pdf',
44
+ secure_file_path: "https://www.africau.edu/images/default/sample.pdf",
45
+ karixFileHandle: 'abcd',
46
+ },
47
+ },
48
+ documentSrc: "https://www.africau.edu/images/default/sample.pdf",
49
+ whatsappDocParams: {
50
+ whatsappDocName: 'sample.pdf',
51
+ whatsappDocSize: 134532,
52
+ whatsappDocPages: 2,
53
+ whatsappDocImg: 'https://play-lh.googleusercontent.com/BkRfMfIRPR9hUnmIYGDgHHKjow-g18-ouP6B2ko__VnyUHSi1spcc78UtZ4sVUtBH4g',
54
+ },
55
+ };
56
+ renderComponent(props1);
57
+ expect(true).toBe(true);
58
+ });
59
+ });
@@ -31,7 +31,7 @@ import { IMAGE as LINE_IMAGE, IMAGE_MAP, IMAGE_CAROUSEL, VIDEO as LINE_VIDEO, TE
31
31
  import {IMAGE, VIDEO } from '../Facebook/Advertisement/constant';
32
32
  import { CREATIVE } from '../Facebook/constants';
33
33
  import { LOYALTY } from '../App/constants';
34
- import { WHATSAPP_STATUSES } from '../Whatsapp/constants';
34
+ import { WHATSAPP_STATUSES, WHATSAPP_MEDIA_TYPES } from '../Whatsapp/constants';
35
35
 
36
36
  import { updateImagesInHtml } from '../../utils/cdnTransformation';
37
37
 
@@ -381,9 +381,25 @@ export class Creatives extends React.Component {
381
381
  buttonType = 'NONE',
382
382
  buttons = [],
383
383
  mediaType = 'TEXT',
384
- whatsappMedia: { url: imageUrl = '' } = {},
384
+ whatsappMedia = {},
385
385
  } = {},
386
386
  } = templateData;
387
+ let mediaParams = {};
388
+ if (mediaType === WHATSAPP_MEDIA_TYPES.IMAGE) {
389
+ mediaParams = {
390
+ imageUrl: whatsappMedia?.url,
391
+ };
392
+ } else if (mediaType === WHATSAPP_MEDIA_TYPES.VIDEO) {
393
+ mediaParams = {
394
+ videoUrl: whatsappMedia?.url,
395
+ videoPreviewImg: whatsappMedia?.previewUrl,
396
+ };
397
+ } else if (mediaType === WHATSAPP_MEDIA_TYPES.DOCUMENT) {
398
+ mediaParams = {
399
+ documentUrl: whatsappMedia?.url,
400
+ whatsappDocParams: whatsappMedia?.docParams,
401
+ };
402
+ }
387
403
  const modifiedButtons = cloneDeep(buttons).map((btn) => {
388
404
  if (btn.type === 'PHONE_NUMBER') {
389
405
  btn.phone_number = btn.phoneNumber;
@@ -410,7 +426,7 @@ export class Creatives extends React.Component {
410
426
  category,
411
427
  varMapped,
412
428
  mediaType,
413
- imageUrl,
429
+ ...mediaParams,
414
430
  buttonType,
415
431
  buttons: modifiedButtons,
416
432
  languages: [
@@ -606,6 +622,10 @@ export class Creatives extends React.Component {
606
622
  buttonType = 'NONE',
607
623
  buttons = [],
608
624
  imageUrl = '',
625
+ videoUrl = '',
626
+ documentUrl = '',
627
+ videoPreviewImg = '',
628
+ whatsappDocParams = {},
609
629
  } = cloneDeep(versions.base.content.whatsapp);
610
630
 
611
631
  const modifiedButtons = cloneDeep(buttons).map((btn) => {
@@ -630,7 +650,22 @@ export class Creatives extends React.Component {
630
650
  varMapped[`{{${Object.keys(varMapped).length + 1}}}_unsubscribe`] =
631
651
  "{{unsubscribe}}";
632
652
  }
633
-
653
+ let whatsappMedia;
654
+ if (mediaType === WHATSAPP_MEDIA_TYPES.IMAGE) {
655
+ whatsappMedia = {
656
+ url: imageUrl,
657
+ };
658
+ } else if (mediaType === WHATSAPP_MEDIA_TYPES.VIDEO) {
659
+ whatsappMedia = {
660
+ url: videoUrl,
661
+ previewUrl: videoPreviewImg,
662
+ };
663
+ } else if (mediaType === WHATSAPP_MEDIA_TYPES.DOCUMENT) {
664
+ whatsappMedia = {
665
+ url: documentUrl,
666
+ docParams: whatsappDocParams,
667
+ };
668
+ }
634
669
  templateData = {
635
670
  channel,
636
671
  accountId,
@@ -646,9 +681,7 @@ export class Creatives extends React.Component {
646
681
  buttonType,
647
682
  buttons: modifiedButtons,
648
683
  mediaType,
649
- whatsappMedia: {
650
- url: imageUrl,
651
- },
684
+ whatsappMedia,
652
685
  },
653
686
  };
654
687
  }
@@ -3,6 +3,7 @@ import {
3
3
  getWhatsappStatus,
4
4
  getWhatsappCategory,
5
5
  getWhatsappCta,
6
+ bytesConversion,
6
7
  } from '../utils';
7
8
  import mockdata from '../../mockdata';
8
9
 
@@ -19,6 +20,7 @@ describe('Test utils', () => {
19
20
  expect(getWhatsappContent(whatsappPreviewTemplateData)).toMatchSnapshot();
20
21
  expect(getWhatsappContent(whatsappPreviewTemplateData2)).toMatchSnapshot();
21
22
  expect(getWhatsappContent({})).toMatchSnapshot();
23
+ expect(bytesConversion(1024)).toEqual('1.0 KB');
22
24
  });
23
25
 
24
26
  it('test getWhatsappContent for preview', () => {
@@ -19,7 +19,7 @@ import {
19
19
  import './styles.scss';
20
20
  import pdfIcon from "../../assets/pdfIcon.svg";
21
21
 
22
- function bytesConversion(x) {
22
+ export function bytesConversion(x) {
23
23
  let l;
24
24
  l = 0;
25
25
  let n;