@capillarytech/creatives-library 7.14.11 → 7.14.12
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 +2 -1
- package/package.json +2 -1
- package/v2Components/CapDocumentUpload/index.js +36 -3
- package/v2Components/CapDocumentUpload/index.scss +1 -1
- package/v2Components/CapVideoUpload/index.js +9 -11
- package/v2Containers/CreativesContainer/index.js +10 -2
- package/v2Containers/Whatsapp/styles.scss +1 -1
package/config/app.js
CHANGED
|
@@ -16,7 +16,8 @@ const config = {
|
|
|
16
16
|
accountConfig: (strs, accountId) => `${window.location.origin}/org/config/AccountAdd?q=a&channelId=2&accountId=${accountId}&edit=1`,
|
|
17
17
|
},
|
|
18
18
|
development: {
|
|
19
|
-
api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
|
|
19
|
+
//api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
|
|
20
|
+
api_endpoint: 'http://localhost:2022/arya/api/v1/creatives',
|
|
20
21
|
campaigns_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/campaigns',
|
|
21
22
|
campaigns_api_org_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/org/campaign',
|
|
22
23
|
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.
|
|
4
|
+
"version": "7.14.12",
|
|
5
5
|
"description": "Capillary creatives ui",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"module": "./index.es.js",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"node-html-parser": "^5.4.2-0",
|
|
29
29
|
"normalizr": "^3.2.3",
|
|
30
30
|
"papaparse": "^5.3.1",
|
|
31
|
+
"pdfjs-dist": "^2.3.200",
|
|
31
32
|
"pre-push": "^0.1.2",
|
|
32
33
|
"react-datepicker": "^0.46.0",
|
|
33
34
|
"react-dropzone": "^11.3.4",
|
|
@@ -11,6 +11,7 @@ import { injectIntl, FormattedMessage, intlShape} from 'react-intl';
|
|
|
11
11
|
import { isEmpty, get } from 'lodash';
|
|
12
12
|
import './index.scss';
|
|
13
13
|
import messages from './messages';
|
|
14
|
+
const PDFJS = require("pdfjs-dist");
|
|
14
15
|
|
|
15
16
|
function CapDocumentUpload(props) {
|
|
16
17
|
const {
|
|
@@ -39,13 +40,11 @@ function CapDocumentUpload(props) {
|
|
|
39
40
|
useEffect(() => {
|
|
40
41
|
const docDataObj = documentData[`uploadedAssetData${index}`];
|
|
41
42
|
if (!isEmpty(docDataObj)) {
|
|
42
|
-
const { secure_file_path = '', karixFileHandle = '', name = '', file_size = ''
|
|
43
|
+
const { secure_file_path = '', karixFileHandle = '', name = '', file_size = ''} = get(docDataObj, 'metaInfo', {});
|
|
43
44
|
setWhatsappDocParams({
|
|
44
45
|
...whatsappDocParams,
|
|
45
46
|
whatsappDocName: name,
|
|
46
47
|
whatsappDocSize: file_size,
|
|
47
|
-
whatsappDocPages: 2,
|
|
48
|
-
whatsappDocImg: 'https://play-lh.googleusercontent.com/BkRfMfIRPR9hUnmIYGDgHHKjow-g18-ouP6B2ko__VnyUHSi1spcc78UtZ4sVUtBH4g',
|
|
49
48
|
});
|
|
50
49
|
updateDocumentSrc(secure_file_path, karixFileHandle);
|
|
51
50
|
}
|
|
@@ -81,12 +80,46 @@ function CapDocumentUpload(props) {
|
|
|
81
80
|
const fileParams = {
|
|
82
81
|
error: false, // checking error based on file size
|
|
83
82
|
};
|
|
83
|
+
convertPdfToImages(file);
|
|
84
84
|
submitAction({file, type: 'document', fileParams}, incorrectFile);
|
|
85
85
|
if (e) {
|
|
86
86
|
const event = e;
|
|
87
87
|
event.target.value = null;
|
|
88
88
|
}
|
|
89
89
|
}, []);
|
|
90
|
+
const readFileData = (file) => new Promise((resolve, reject) => {
|
|
91
|
+
const reader = new FileReader();
|
|
92
|
+
reader.onload = (e) => {
|
|
93
|
+
resolve(e.target.result);
|
|
94
|
+
};
|
|
95
|
+
reader.onerror = (err) => {
|
|
96
|
+
reject(err);
|
|
97
|
+
};
|
|
98
|
+
reader.readAsDataURL(file);
|
|
99
|
+
});
|
|
100
|
+
const convertPdfToImages = async (file) => {
|
|
101
|
+
const data = await readFileData(file);
|
|
102
|
+
return PDFJS.getDocument(data)
|
|
103
|
+
.then(async function (pdf) {
|
|
104
|
+
const numberOfPages = pdf.numPages;
|
|
105
|
+
const canvas = document.createElement("canvas");
|
|
106
|
+
const page = await pdf.getPage(1);
|
|
107
|
+
const viewport = page.getViewport({ scale: 1 });
|
|
108
|
+
const context = canvas.getContext("2d");
|
|
109
|
+
canvas.height = viewport.height;
|
|
110
|
+
canvas.width = viewport.width;
|
|
111
|
+
await page.render({ canvasContext: context, viewport: viewport }).promise;
|
|
112
|
+
const image = (canvas.toDataURL('image/jpeg', 1.0));
|
|
113
|
+
canvas.remove();
|
|
114
|
+
setWhatsappDocParams({
|
|
115
|
+
...whatsappDocParams,
|
|
116
|
+
whatsappDocImg: image,
|
|
117
|
+
whatsappDocPages: numberOfPages,
|
|
118
|
+
});
|
|
119
|
+
return image;
|
|
120
|
+
})
|
|
121
|
+
.catch((error) => Promise.reject(error));
|
|
122
|
+
};
|
|
90
123
|
|
|
91
124
|
const submitAction = useCallback((data, incorrectFile) => {
|
|
92
125
|
const {
|
|
@@ -242,7 +242,7 @@ function CapVideoUpload(props) {
|
|
|
242
242
|
<FormattedMessage {...messages.imageReUpload} />
|
|
243
243
|
</CapButton>
|
|
244
244
|
</div>
|
|
245
|
-
<div className=
|
|
245
|
+
<div className="video-panel">
|
|
246
246
|
<video
|
|
247
247
|
width="230"
|
|
248
248
|
poster={previewUrl}
|
|
@@ -257,16 +257,14 @@ function CapVideoUpload(props) {
|
|
|
257
257
|
>
|
|
258
258
|
<source src={videoSrc} type="video/mp4" />
|
|
259
259
|
</video>
|
|
260
|
-
|
|
261
|
-
<
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
</div>
|
|
269
|
-
}
|
|
260
|
+
<div className="video-info">
|
|
261
|
+
<CapHeading type="h6">
|
|
262
|
+
{videoName}
|
|
263
|
+
</CapHeading>
|
|
264
|
+
<CapHeading type="h6">
|
|
265
|
+
{videoDuration}
|
|
266
|
+
</CapHeading>
|
|
267
|
+
</div>
|
|
270
268
|
</div>
|
|
271
269
|
</Fragment>
|
|
272
270
|
);
|
|
@@ -400,7 +400,10 @@ export class Creatives extends React.Component {
|
|
|
400
400
|
case (WHATSAPP_MEDIA_TYPES.DOCUMENT):
|
|
401
401
|
mediaParams = {
|
|
402
402
|
documentUrl: whatsappMedia?.url,
|
|
403
|
-
whatsappDocParams:
|
|
403
|
+
whatsappDocParams: {
|
|
404
|
+
...whatsappMedia?.docParams,
|
|
405
|
+
whatsappDocImg: whatsappMedia?.previewUrl,
|
|
406
|
+
},
|
|
404
407
|
};
|
|
405
408
|
break;
|
|
406
409
|
default:
|
|
@@ -672,7 +675,12 @@ export class Creatives extends React.Component {
|
|
|
672
675
|
case (WHATSAPP_MEDIA_TYPES.DOCUMENT):
|
|
673
676
|
whatsappMedia = {
|
|
674
677
|
url: documentUrl,
|
|
675
|
-
|
|
678
|
+
previewUrl: whatsappDocParams?.whatsappDocImg,
|
|
679
|
+
docParams: {
|
|
680
|
+
whatsappDocName: whatsappDocParams?.whatsappDocName,
|
|
681
|
+
whatsappDocSize: whatsappDocParams?.whatsappDocSize,
|
|
682
|
+
whatsappDocPages: whatsappDocParams?.whatsappDocPages,
|
|
683
|
+
},
|
|
676
684
|
};
|
|
677
685
|
break;
|
|
678
686
|
default:
|