@capillarytech/creatives-library 7.5.4 → 7.5.6
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/assets/facebookEmptyPlaceholder.png +0 -0
- package/config/app.js +2 -0
- package/index.js +6 -0
- package/package.json +1 -1
- package/reducers.js +2 -1
- package/routes.js +5 -0
- package/services/api.js +34 -1
- package/utils/common.js +13 -1
- package/v2Components/CapImageUpload/index.js +260 -0
- package/v2Components/CapImageUpload/index.scss +32 -0
- package/v2Components/CapImageUpload/messages.js +49 -0
- package/v2Components/CapRadioCardCustom/index.js +66 -0
- package/v2Components/CapVideoUpload/index.js +299 -0
- package/v2Components/CapVideoUpload/index.scss +29 -0
- package/v2Components/CapVideoUpload/messages.js +54 -0
- package/v2Components/TemplatePreview/index.js +19 -2
- package/v2Containers/App/constants.js +21 -0
- package/v2Containers/Cap/messages.js +30 -0
- package/v2Containers/CapFacebookPreview/actions.js +31 -0
- package/v2Containers/CapFacebookPreview/constants.js +21 -0
- package/v2Containers/CapFacebookPreview/index.js +396 -0
- package/v2Containers/CapFacebookPreview/messages.js +138 -0
- package/v2Containers/CapFacebookPreview/reducer.js +37 -0
- package/v2Containers/CapFacebookPreview/sagas.js +99 -0
- package/v2Containers/CapFacebookPreview/selectors.js +25 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +55 -1
- package/v2Containers/CreativesContainer/index.js +19 -9
- package/v2Containers/Facebook/Advertisement/constant.js +12 -0
- package/v2Containers/Facebook/Advertisement/index.js +955 -0
- package/v2Containers/Facebook/Advertisement/index.scss +49 -0
- package/v2Containers/Facebook/Advertisement/messages.js +155 -0
- package/v2Containers/Facebook/Advertisement/video.js +0 -0
- package/v2Containers/Facebook/actions.js +62 -0
- package/v2Containers/Facebook/constants.js +25 -1
- package/v2Containers/Facebook/index.js +133 -107
- package/v2Containers/Facebook/reducer.js +95 -1
- package/v2Containers/Facebook/sagas.js +136 -0
- package/v2Containers/Facebook/selectors.js +10 -0
- package/v2Containers/Line/Container/Video/index.js +38 -41
- package/v2Containers/Templates/_templates.scss +26 -0
- package/v2Containers/Templates/actions.js +14 -1
- package/v2Containers/Templates/constants.js +8 -0
- package/v2Containers/Templates/index.js +117 -10
- package/v2Containers/Templates/messages.js +8 -4
- package/v2Containers/Templates/reducer.js +22 -0
- package/v2Containers/Templates/sagas.js +26 -1
- package/v2Containers/TemplatesV2/index.js +13 -13
- package/v2Containers/Viber/index.js +2 -1
|
Binary file
|
package/config/app.js
CHANGED
|
@@ -5,6 +5,7 @@ const config = {
|
|
|
5
5
|
production: {
|
|
6
6
|
api_endpoint: '/arya/api/v1/creatives',
|
|
7
7
|
campaigns_api_endpoint: '/iris/v2/campaigns',
|
|
8
|
+
campaigns_api_org_endpoint: '/iris/v2/org/campaign',
|
|
8
9
|
auth_endpoint: '/arya/api/v1/auth',
|
|
9
10
|
arya_endpoint: '/arya/api/v1',
|
|
10
11
|
login_url: '/auth/login',
|
|
@@ -17,6 +18,7 @@ const config = {
|
|
|
17
18
|
development: {
|
|
18
19
|
api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
|
|
19
20
|
campaigns_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/campaigns',
|
|
21
|
+
campaigns_api_org_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/org/campaign',
|
|
20
22
|
auth_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/auth',
|
|
21
23
|
arya_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1',
|
|
22
24
|
subscription_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/org-settings/subscription',
|
package/index.js
CHANGED
|
@@ -75,6 +75,10 @@ import viberSaga from './v2Containers/Viber/sagas';
|
|
|
75
75
|
|
|
76
76
|
import TemplatesV2 from './v2Containers/TemplatesV2/index';
|
|
77
77
|
|
|
78
|
+
import FacebookPreview from './v2Containers/CapFacebookPreview';
|
|
79
|
+
import FacebookPreviewReducer from './v2Containers/CapFacebookPreview/reducer';
|
|
80
|
+
import FacebookPreviewSaga from './v2Containers/CapFacebookPreview/sagas';
|
|
81
|
+
|
|
78
82
|
import CreativesContainer from './v2Containers/CreativesContainer';
|
|
79
83
|
import CreativesContainerReducer from './v2Containers/CreativesContainer/reducer';
|
|
80
84
|
import { updateCharCount } from './utils/smsCharCountV2';
|
|
@@ -101,6 +105,7 @@ const LineCreateContainer = {LineCreate, lineCreateReducer, lineCreateSaga};
|
|
|
101
105
|
const TemplatesV2Container = {TemplatesV2, templateReducer, templateSaga};
|
|
102
106
|
const FacebookContainer = {Facebook, facebookReducer, facebookSaga};
|
|
103
107
|
const ViberContainer = {Viber, viberReducer, viberSaga};
|
|
108
|
+
const FacebookPreviewContainer = { FacebookPreview, FacebookPreviewReducer, FacebookPreviewSaga };
|
|
104
109
|
|
|
105
110
|
const GalleryContainer = {Gallery, galleryReducer, gallerySagas};
|
|
106
111
|
const FTPContainer = {FTP, FTPReducer, FTPSagas};
|
|
@@ -145,4 +150,5 @@ export { CapContainer,
|
|
|
145
150
|
GalleryContainer,
|
|
146
151
|
FTPContainer,
|
|
147
152
|
ViberContainer,
|
|
153
|
+
FacebookPreviewContainer,
|
|
148
154
|
};
|
package/package.json
CHANGED
package/reducers.js
CHANGED
|
@@ -9,7 +9,7 @@ import { LOCATION_CHANGE } from 'react-router-redux';
|
|
|
9
9
|
|
|
10
10
|
import languageProviderReducer from 'v2Containers/LanguageProvider/reducer';
|
|
11
11
|
import beeEditorReducer from 'v2Containers/BeeEditor/reducer';
|
|
12
|
-
|
|
12
|
+
import CapFacebookPreviewReducer from 'v2Containers/CapFacebookPreview/reducer';
|
|
13
13
|
|
|
14
14
|
import capReducer from 'containers/Cap/reducer';
|
|
15
15
|
import appReducer from 'containers/App/reducer';
|
|
@@ -64,6 +64,7 @@ export default function createReducer(asyncReducers) {
|
|
|
64
64
|
email: emailReducer,
|
|
65
65
|
ebill: ebillReducer,
|
|
66
66
|
beeEditor: beeEditorReducer,
|
|
67
|
+
facebookPreview: CapFacebookPreviewReducer,
|
|
67
68
|
FTP: ftpReducer,
|
|
68
69
|
...asyncReducers,
|
|
69
70
|
});
|
package/routes.js
CHANGED
|
@@ -637,6 +637,8 @@ export default function createRoutes(store) {
|
|
|
637
637
|
import('v2Containers/Line/Container/reducer'),
|
|
638
638
|
import('v2Containers/Viber/sagas'),
|
|
639
639
|
import('v2Containers/Viber/reducer'),
|
|
640
|
+
import('v2Containers/CapFacebookPreview/sagas'),
|
|
641
|
+
import('v2Containers/CapFacebookPreview/reducer'),
|
|
640
642
|
]);
|
|
641
643
|
|
|
642
644
|
const renderRoute = loadModule(cb);
|
|
@@ -658,6 +660,7 @@ export default function createRoutes(store) {
|
|
|
658
660
|
facebookSagas, facebookReducer,
|
|
659
661
|
lineCreateSagas, lineCreateReducer,
|
|
660
662
|
viberSagas, viberReducer,
|
|
663
|
+
capFacebookPreviewSagas, capFacebookPreviewReducer,
|
|
661
664
|
]) => {
|
|
662
665
|
injectReducer('templates', reducer.default);
|
|
663
666
|
injectReducer('cap', capReducer.default);
|
|
@@ -675,6 +678,7 @@ export default function createRoutes(store) {
|
|
|
675
678
|
injectReducer('facebook', facebookReducer.default);
|
|
676
679
|
injectReducer('lineCreate', lineCreateReducer.default);
|
|
677
680
|
injectReducer('viber', viberReducer.default);
|
|
681
|
+
injectReducer('facebookPreview', capFacebookPreviewReducer.default);
|
|
678
682
|
injectSagas(gallerySagas.default);
|
|
679
683
|
injectSagas(sagas.default);
|
|
680
684
|
injectSagas(capSagas.default);
|
|
@@ -691,6 +695,7 @@ export default function createRoutes(store) {
|
|
|
691
695
|
injectSagas(facebookSagas.default);
|
|
692
696
|
injectSagas(lineCreateSagas.default);
|
|
693
697
|
injectSagas(viberSagas.default);
|
|
698
|
+
injectSagas(capFacebookPreviewSagas.default);
|
|
694
699
|
renderRoute(component);
|
|
695
700
|
});
|
|
696
701
|
importModules.catch(errorLoading);
|
package/services/api.js
CHANGED
|
@@ -11,12 +11,15 @@ import { GA } from '@capillarytech/cap-ui-utils';
|
|
|
11
11
|
let API_ENDPOINT = config.development.api_endpoint;
|
|
12
12
|
let EXPORT_API_ENDPOINT = config.development.exports_api_endpoint;
|
|
13
13
|
let CAMPAIGNS_API_ENDPOINT = config.development.campaigns_api_endpoint;
|
|
14
|
+
let CAMPAIGNS_API_ORG_ENDPOINT = config.development.campaigns_api_org_endpoint;
|
|
15
|
+
|
|
14
16
|
let API_AUTH_ENDPOINT = config.development.auth_endpoint;
|
|
15
17
|
let ARYA_ENDPOINT = config.development.arya_endpoint;
|
|
16
18
|
let SUBSCRIPTION_API_ENDPOINT = config.development.subscription_api_endpoint;
|
|
17
19
|
if (process.env.NODE_ENV === 'production') {
|
|
18
20
|
API_ENDPOINT = config.production.api_endpoint;
|
|
19
21
|
CAMPAIGNS_API_ENDPOINT = config.production.campaigns_api_endpoint;
|
|
22
|
+
CAMPAIGNS_API_ORG_ENDPOINT = config.production.campaigns_api_org_endpoint;
|
|
20
23
|
API_AUTH_ENDPOINT = config.production.auth_endpoint;
|
|
21
24
|
ARYA_ENDPOINT = config.production.arya_endpoint;
|
|
22
25
|
SUBSCRIPTION_API_ENDPOINT = config.production.subscription_api_endpoint;
|
|
@@ -203,6 +206,7 @@ export const createWeChatTemplate = ({template}) => {
|
|
|
203
206
|
const url = `${API_ENDPOINT}/templates/WECHAT`;
|
|
204
207
|
return request(url, getAPICallObject('POST', template));
|
|
205
208
|
};
|
|
209
|
+
|
|
206
210
|
export const createMobilePushTemplate = ({template}) => {
|
|
207
211
|
console.log('in api.js', template);
|
|
208
212
|
const url = `${API_ENDPOINT}/templates/MOBILEPUSH`;
|
|
@@ -245,7 +249,6 @@ export const getTemplateDetails = ({id, channel}) => {
|
|
|
245
249
|
};
|
|
246
250
|
|
|
247
251
|
export const getAllTemplates = ({channel, queryParams}) => {
|
|
248
|
-
console.log('in api.js', channel, queryParams);
|
|
249
252
|
const url = `${API_ENDPOINT}/templates/${channel}?query=${encodeURIComponent(JSON.stringify(queryParams))}`;
|
|
250
253
|
return request(url, getAPICallObject('GET'));
|
|
251
254
|
};
|
|
@@ -370,6 +373,11 @@ export const createViberTemplate = ({template}) => {
|
|
|
370
373
|
return request(url, getAPICallObject('POST', template));
|
|
371
374
|
};
|
|
372
375
|
|
|
376
|
+
export const createFacebookADTemplate = ({template}) => {
|
|
377
|
+
const url = `${API_ENDPOINT}/templates/FACEBOOK`;
|
|
378
|
+
return request(url, getAPICallObject('POST', template));
|
|
379
|
+
};
|
|
380
|
+
|
|
373
381
|
export const getLocizMessage = async (locale) => {
|
|
374
382
|
const appName = 'creatives_v2';
|
|
375
383
|
const url = `${ARYA_ENDPOINT}/translations/${appName}/${locale}`;
|
|
@@ -403,3 +411,28 @@ export const createCustomRow = (data) => {
|
|
|
403
411
|
const url = `${API_ENDPOINT}/cms/saveRows`;
|
|
404
412
|
return request(url, getAPICallObject('POST', data));
|
|
405
413
|
};
|
|
414
|
+
|
|
415
|
+
export const getImageFacebookPreview = ({previewData}) => {
|
|
416
|
+
const url = `${API_ENDPOINT}/facebook/getImagePreview`;
|
|
417
|
+
return request(url, getAPICallObject('POST', previewData));
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
export const getVideoFacebookPreview = ({previewData}) => {
|
|
421
|
+
const url = `${API_ENDPOINT}/facebook/getVideoPreview`;
|
|
422
|
+
return request(url, getAPICallObject('POST', previewData));
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
export const getCarouselFacebookPreview = ({previewData}) => {
|
|
426
|
+
const url = `${API_ENDPOINT}/facebook/getCarouselPreview`;
|
|
427
|
+
return request(url, getAPICallObject('POST', previewData));
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
export const getOrgOUs = ({ orgID }) => {
|
|
431
|
+
const url = `${ARYA_ENDPOINT}/org/${orgID}/oulist`;
|
|
432
|
+
return request(url, getAPICallObject('GET'));
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
export const getOrgLevelCampaignSettings = () => {
|
|
436
|
+
const url = `${CAMPAIGNS_API_ORG_ENDPOINT}/settings`;
|
|
437
|
+
return request(url, getAPICallObject('GET', null, false, true));
|
|
438
|
+
};
|
package/utils/common.js
CHANGED
|
@@ -49,7 +49,7 @@ export function getTreeStructuredTags({tagsList, userLocale = 'en', offerDetails
|
|
|
49
49
|
name: tag.label[userLocale] || tag.label.en,
|
|
50
50
|
value: tag.value,
|
|
51
51
|
};
|
|
52
|
-
} else if (tag['tag-header'] && mainTags[tag.value]) {
|
|
52
|
+
} else if (tag['tag-header'] && mainTags[tag.value]) {
|
|
53
53
|
// to check it this tag header is already available in mainTags object,
|
|
54
54
|
//If yes, it will concat the subtag
|
|
55
55
|
mainTags[tag.value].subtags = _.concat(mainTags[tag.value].subtags, tag.subtags);
|
|
@@ -215,3 +215,15 @@ function getSubTags(subtagsParam) {
|
|
|
215
215
|
});
|
|
216
216
|
return result;
|
|
217
217
|
}
|
|
218
|
+
|
|
219
|
+
export const bytes2Size = (bytes, decimals = 2) => {
|
|
220
|
+
if (bytes === 0) return '0 Bytes';
|
|
221
|
+
|
|
222
|
+
const k = 1024;
|
|
223
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
224
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
225
|
+
|
|
226
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
227
|
+
|
|
228
|
+
return `${Math.ceil((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
229
|
+
};
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* CapImageUpload
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { useState, useEffect, useCallback } from 'react';
|
|
8
|
+
import PropTypes from "prop-types";
|
|
9
|
+
|
|
10
|
+
import LabelHOC from '@capillarytech/cap-ui-library/assets/HOCs/ComponentWithLabelHOC';
|
|
11
|
+
import {
|
|
12
|
+
CapDrawer,
|
|
13
|
+
CapUploader,
|
|
14
|
+
CapHeading,
|
|
15
|
+
CapButton,
|
|
16
|
+
CapImage,
|
|
17
|
+
} from '@capillarytech/cap-ui-library';
|
|
18
|
+
import { injectIntl, FormattedMessage, intlShape} from 'react-intl';
|
|
19
|
+
import get from 'lodash/get';
|
|
20
|
+
import './index.scss';
|
|
21
|
+
import Gallery from '../../v2Containers/Assets/Gallery';
|
|
22
|
+
|
|
23
|
+
import messages from './messages';
|
|
24
|
+
function CapImageUpload(props) {
|
|
25
|
+
const {
|
|
26
|
+
intl,
|
|
27
|
+
allowedExtensionsRegex,
|
|
28
|
+
imgWidth,
|
|
29
|
+
imgHeight,
|
|
30
|
+
imgSize,
|
|
31
|
+
uploadAsset,
|
|
32
|
+
supportedExtensions,
|
|
33
|
+
isFullMode,
|
|
34
|
+
style,
|
|
35
|
+
imageSrc,
|
|
36
|
+
updateImageSrc,
|
|
37
|
+
updateOnReUpload,
|
|
38
|
+
index,
|
|
39
|
+
className,
|
|
40
|
+
imageData,
|
|
41
|
+
} = props;
|
|
42
|
+
const {
|
|
43
|
+
formatMessage,
|
|
44
|
+
} = intl || {};
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (imageData[`uploadedAssetData${index}`] && Object.keys(imageData[`uploadedAssetData${index}`]).length) {
|
|
49
|
+
const imgSrc = get(imageData, `uploadedAssetData${index}.metaInfo.secure_file_path`, '');
|
|
50
|
+
updateImageSrc(imgSrc);
|
|
51
|
+
}
|
|
52
|
+
}, [imageData[`uploadedAssetData${index}`]]);
|
|
53
|
+
|
|
54
|
+
const [isImageError, updateImageErrorMessage] = useState(false);
|
|
55
|
+
const [isDrawerRequired, updateDrawerRequirement] = useState(false);
|
|
56
|
+
|
|
57
|
+
const {CapHeadingSpan} = CapHeading;
|
|
58
|
+
const ImageComponent = useCallback(() => (<>
|
|
59
|
+
<div
|
|
60
|
+
className={`image-container upload ${props.ifError ? 'error' : ''}`}
|
|
61
|
+
>
|
|
62
|
+
{imageSrc !== "" && (<CapImage src={imageSrc || ""} alt="upload-image-src" height="400" />)}
|
|
63
|
+
</div></>
|
|
64
|
+
), []);
|
|
65
|
+
|
|
66
|
+
const WithLabel = LabelHOC(ImageComponent);
|
|
67
|
+
|
|
68
|
+
const uploadImages = useCallback((e, {files}) => {
|
|
69
|
+
if (e) {
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
}
|
|
72
|
+
const _URL = window.URL || window.webkitURL;
|
|
73
|
+
let incorrectFile = false;
|
|
74
|
+
const file = files[0];
|
|
75
|
+
if (!allowedExtensionsRegex.test(file.name)) {
|
|
76
|
+
incorrectFile = true;
|
|
77
|
+
}
|
|
78
|
+
const img = new Image();
|
|
79
|
+
img.src = _URL.createObjectURL(file);
|
|
80
|
+
img.onload = () => {
|
|
81
|
+
const fileParams = {
|
|
82
|
+
width: img.width,
|
|
83
|
+
height: img.height,
|
|
84
|
+
error: file && (file.size / (1e+6) > 3), // checking error based on file size
|
|
85
|
+
};
|
|
86
|
+
submitAction({file, type: 'image', fileParams}, incorrectFile);
|
|
87
|
+
};
|
|
88
|
+
if (e) {
|
|
89
|
+
const event = e;
|
|
90
|
+
event.target.value = null;
|
|
91
|
+
}
|
|
92
|
+
}, []);
|
|
93
|
+
|
|
94
|
+
const submitAction = useCallback((data, incorrectFile) => {
|
|
95
|
+
const {
|
|
96
|
+
file: {size},
|
|
97
|
+
fileParams: {
|
|
98
|
+
height,
|
|
99
|
+
width,
|
|
100
|
+
},
|
|
101
|
+
} = data;
|
|
102
|
+
if (incorrectFile || size > imgSize || height > imgHeight || width > imgWidth) {
|
|
103
|
+
updateImageErrorMessage(formatMessage(messages.imageIncorrectSize));
|
|
104
|
+
} else {
|
|
105
|
+
updateImageErrorMessage('');
|
|
106
|
+
uploadAsset(
|
|
107
|
+
data.file,
|
|
108
|
+
data.type,
|
|
109
|
+
data.fileParams,
|
|
110
|
+
index,
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
}, [isImageError]);
|
|
114
|
+
|
|
115
|
+
const capUploaderCustomRequest = useCallback((uploadData) => {
|
|
116
|
+
uploadImages(undefined, {files: [uploadData.file]});
|
|
117
|
+
}, []);
|
|
118
|
+
|
|
119
|
+
const setDrawerVisibility = useCallback((drawervisibleFlag) => updateDrawerRequirement(drawervisibleFlag), [isDrawerRequired]);
|
|
120
|
+
|
|
121
|
+
const onGalleryClick = useCallback((event) => {
|
|
122
|
+
event.stopPropagation();
|
|
123
|
+
setDrawerVisibility(true);
|
|
124
|
+
}, []);
|
|
125
|
+
|
|
126
|
+
const onReUpload = useCallback(() => {
|
|
127
|
+
updateImageSrc('');
|
|
128
|
+
updateOnReUpload();
|
|
129
|
+
}, []);
|
|
130
|
+
|
|
131
|
+
const onGalleryImageSelect = useCallback((imageTemplate) => {
|
|
132
|
+
const image = get(imageTemplate, 'metaInfo.secure_file_path');
|
|
133
|
+
updateDrawerRequirement(false);
|
|
134
|
+
if (!allowedExtensionsRegex.test(image)) {
|
|
135
|
+
updateImageErrorMessage(formatMessage(messages.imageIncorrectSize));
|
|
136
|
+
} else {
|
|
137
|
+
updateImageErrorMessage('');
|
|
138
|
+
updateImageSrc(image);
|
|
139
|
+
}
|
|
140
|
+
}, [isImageError, isDrawerRequired]);
|
|
141
|
+
|
|
142
|
+
const getGalleryDrawerContent = useCallback(() => {
|
|
143
|
+
const locationGallery = {
|
|
144
|
+
pathname: `/assets`,
|
|
145
|
+
search: '',
|
|
146
|
+
query: !isFullMode ? {type: 'embedded', module: 'library'} : {},
|
|
147
|
+
};
|
|
148
|
+
return (
|
|
149
|
+
<>
|
|
150
|
+
<CapHeading type="h3">
|
|
151
|
+
{formatMessage(messages.imageGallery)}
|
|
152
|
+
</CapHeading>
|
|
153
|
+
<Gallery
|
|
154
|
+
location={locationGallery}
|
|
155
|
+
isFullMode={isFullMode}
|
|
156
|
+
isLineAsset
|
|
157
|
+
onGalleryImageSelect={onGalleryImageSelect}
|
|
158
|
+
/>
|
|
159
|
+
</>
|
|
160
|
+
);
|
|
161
|
+
}, []);
|
|
162
|
+
|
|
163
|
+
const getImageSection = useCallback(() => {
|
|
164
|
+
if (imageSrc === "") {
|
|
165
|
+
return (<>
|
|
166
|
+
<CapUploader.CapDragger
|
|
167
|
+
customRequest={capUploaderCustomRequest}
|
|
168
|
+
className="form-builder-dragger"
|
|
169
|
+
>
|
|
170
|
+
<CapHeading className="dragger-title" type="h7">
|
|
171
|
+
<FormattedMessage {...messages.dragAndDrop} />
|
|
172
|
+
</CapHeading>
|
|
173
|
+
<CapHeading className="dragger-or" type="label6">
|
|
174
|
+
<FormattedMessage {...messages.or} />
|
|
175
|
+
</CapHeading>
|
|
176
|
+
<CapButton className="dragger-button upload-image" type="secondary">
|
|
177
|
+
<FormattedMessage {...messages.uploadComputer} />
|
|
178
|
+
</CapButton>
|
|
179
|
+
<CapButton
|
|
180
|
+
className="dragger-button gallery-select"
|
|
181
|
+
type="secondary"
|
|
182
|
+
onClick={onGalleryClick}
|
|
183
|
+
>
|
|
184
|
+
<FormattedMessage {...messages.uploadGallery} />
|
|
185
|
+
</CapButton>
|
|
186
|
+
</CapUploader.CapDragger>
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
</>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
return (
|
|
193
|
+
<CapButton
|
|
194
|
+
className="dragger-button re-upload"
|
|
195
|
+
type="flat"
|
|
196
|
+
onClick={onReUpload}
|
|
197
|
+
>
|
|
198
|
+
<FormattedMessage {...messages.imageReUpload} />
|
|
199
|
+
</CapButton>
|
|
200
|
+
);
|
|
201
|
+
}, []);
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<div style={style} className="cap-custom-image-upload">
|
|
205
|
+
<WithLabel
|
|
206
|
+
key={`with-label`}
|
|
207
|
+
errorMessage={isImageError} ifError={!!isImageError}
|
|
208
|
+
|
|
209
|
+
/>
|
|
210
|
+
<form encType="multipart/form-data" id={`form`} className={className}>
|
|
211
|
+
<input
|
|
212
|
+
key={`imgFile`}
|
|
213
|
+
style={{ display: 'none' }}
|
|
214
|
+
id="fileName"
|
|
215
|
+
type="file"
|
|
216
|
+
onChange={(e) => uploadImages(e, { files: e.target.files })}
|
|
217
|
+
accept={supportedExtensions || "image/*"}
|
|
218
|
+
/>
|
|
219
|
+
{getImageSection()}
|
|
220
|
+
<CapDrawer
|
|
221
|
+
content={getGalleryDrawerContent()}
|
|
222
|
+
visible={isDrawerRequired}
|
|
223
|
+
width={430}
|
|
224
|
+
onClose={() => updateDrawerRequirement(false)}
|
|
225
|
+
/>
|
|
226
|
+
</form>
|
|
227
|
+
<div className="image-info-wrapper">
|
|
228
|
+
<CapHeadingSpan type="label2" className="image-dimension">
|
|
229
|
+
<FormattedMessage {...messages.imageDimenstionDescription} values={{ width: imgWidth, height: imgHeight}}/>
|
|
230
|
+
</CapHeadingSpan>
|
|
231
|
+
<CapHeadingSpan type="label2" className="image-aspect-ratio">
|
|
232
|
+
<FormattedMessage {...messages.aspectRatio} />
|
|
233
|
+
</CapHeadingSpan>
|
|
234
|
+
<CapHeadingSpan type="label2" className="image-format">
|
|
235
|
+
<FormattedMessage {...messages.format} />
|
|
236
|
+
</CapHeadingSpan>
|
|
237
|
+
</div>
|
|
238
|
+
</div>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
CapImageUpload.propTypes = {
|
|
243
|
+
allowedExtensionsRegex: PropTypes.any,
|
|
244
|
+
imgWidth: PropTypes.number,
|
|
245
|
+
imgHeight: PropTypes.number,
|
|
246
|
+
imgSize: PropTypes.number,
|
|
247
|
+
uploadAsset: PropTypes.func,
|
|
248
|
+
supportedExtensions: PropTypes.any,
|
|
249
|
+
style: PropTypes.any,
|
|
250
|
+
imageSrc: PropTypes.string,
|
|
251
|
+
updateImageSrc: PropTypes.func,
|
|
252
|
+
intl: intlShape,
|
|
253
|
+
isFullMode: PropTypes.bool,
|
|
254
|
+
className: PropTypes.string,
|
|
255
|
+
updateOnReUpload: PropTypes.func,
|
|
256
|
+
imageData: PropTypes.object,
|
|
257
|
+
index: PropTypes.number,
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
export default injectIntl(CapImageUpload);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@import '~@capillarytech/cap-ui-library/styles/_variables.scss';
|
|
2
|
+
|
|
3
|
+
$classPrefix: cap-custom-image-upload;
|
|
4
|
+
|
|
5
|
+
.#{$classPrefix} {
|
|
6
|
+
.image-container{
|
|
7
|
+
.upload{
|
|
8
|
+
margin-top: 20;
|
|
9
|
+
background-color: $CAP_G09;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
.upload-image{
|
|
13
|
+
margin-right: $CAP_SPACE_08
|
|
14
|
+
}
|
|
15
|
+
.gallery-select{
|
|
16
|
+
margin-left: $CAP_SPACE_08
|
|
17
|
+
}
|
|
18
|
+
.image-format{
|
|
19
|
+
float: right;
|
|
20
|
+
}
|
|
21
|
+
.image-aspect-ratio{
|
|
22
|
+
margin-top: $CAP_SPACE_12;
|
|
23
|
+
margin-left: 64px;
|
|
24
|
+
}
|
|
25
|
+
.image-dimension{
|
|
26
|
+
margin-top: $CAP_SPACE_12;
|
|
27
|
+
margin-right: 46px;
|
|
28
|
+
}
|
|
29
|
+
.image-info-wrapper{
|
|
30
|
+
margin-bottom: 15px;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl';
|
|
2
|
+
const scope = `creatives.componentsV2.CapImageUpload`;
|
|
3
|
+
|
|
4
|
+
export default defineMessages({
|
|
5
|
+
uploadGallery: {
|
|
6
|
+
id: `${scope}.uploadGallery`,
|
|
7
|
+
defaultMessage: 'Gallery',
|
|
8
|
+
},
|
|
9
|
+
uploadComputer: {
|
|
10
|
+
id: `${scope}.uploadComputer`,
|
|
11
|
+
defaultMessage: 'Your computer',
|
|
12
|
+
},
|
|
13
|
+
or: {
|
|
14
|
+
id: `${scope}.or`,
|
|
15
|
+
defaultMessage: 'OR',
|
|
16
|
+
},
|
|
17
|
+
dragAndDrop: {
|
|
18
|
+
id: `${scope}.dragAndDrop`,
|
|
19
|
+
defaultMessage: 'Drag and drop image here',
|
|
20
|
+
},
|
|
21
|
+
uploadImageDescription: {
|
|
22
|
+
id: `${scope}.uploadImageDescription`,
|
|
23
|
+
defaultMessage: 'The relevant image that complements the message context.',
|
|
24
|
+
},
|
|
25
|
+
imageReUpload: {
|
|
26
|
+
id: `${scope}.imageReUpload`,
|
|
27
|
+
defaultMessage: 'Re upload',
|
|
28
|
+
},
|
|
29
|
+
imageDimenstionDescription: {
|
|
30
|
+
id: `${scope}.imageDimenstionDescription`,
|
|
31
|
+
defaultMessage: 'Dimensions: {width}px x {height}px',
|
|
32
|
+
},
|
|
33
|
+
format: {
|
|
34
|
+
id: `${scope}.format`,
|
|
35
|
+
defaultMessage: 'Format: JPG, PNG',
|
|
36
|
+
},
|
|
37
|
+
imageIncorrectSize: {
|
|
38
|
+
id: `${scope}.imageIncorrectSize`,
|
|
39
|
+
defaultMessage: 'Please upload the image with correct type, size and dimension',
|
|
40
|
+
},
|
|
41
|
+
imageGallery: {
|
|
42
|
+
id: `${scope}.imageGallery`,
|
|
43
|
+
defaultMessage: 'Gallery',
|
|
44
|
+
},
|
|
45
|
+
aspectRatio: {
|
|
46
|
+
id: `${scope}.aspectRatio`,
|
|
47
|
+
defaultMessage: 'Aspect ratio: 1:1',
|
|
48
|
+
},
|
|
49
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* CapRadioCardCustom
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
import PropTypes from "prop-types";
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import {
|
|
9
|
+
CAP_G06,
|
|
10
|
+
CAP_COLOR_06,
|
|
11
|
+
CAP_WHITE,
|
|
12
|
+
CAP_SPACE_08,
|
|
13
|
+
CAP_SPACE_12,
|
|
14
|
+
CAP_SPACE_04,
|
|
15
|
+
} from '@capillarytech/cap-ui-library/styled/variables';
|
|
16
|
+
|
|
17
|
+
import styled from 'styled-components';
|
|
18
|
+
import { CapDivider } from "@capillarytech/cap-ui-library";
|
|
19
|
+
function CapRadioCardCustom(props) {
|
|
20
|
+
const {
|
|
21
|
+
showSelected,
|
|
22
|
+
wrapperStyle,
|
|
23
|
+
component,
|
|
24
|
+
} = props;
|
|
25
|
+
const RadioLeftContainer = styled.div`
|
|
26
|
+
width: 62px;
|
|
27
|
+
height: 64px;
|
|
28
|
+
margin: 0 ${CAP_SPACE_12} ${CAP_SPACE_04} 0;
|
|
29
|
+
padding: 5px 0 0;
|
|
30
|
+
border-radius: ${CAP_SPACE_08};
|
|
31
|
+
border: solid 1px ${CAP_G06};
|
|
32
|
+
background-color: ${CAP_WHITE};
|
|
33
|
+
`;
|
|
34
|
+
const BottomContainer = styled.div`
|
|
35
|
+
width: 60px;
|
|
36
|
+
height: 41px;
|
|
37
|
+
padding: 9px 20px ${CAP_SPACE_08};
|
|
38
|
+
border-bottom-left-radius: ${CAP_SPACE_08};
|
|
39
|
+
border-bottom-right-radius: ${CAP_SPACE_08};
|
|
40
|
+
background-color: ${(styledProps) => styledProps.selected ? CAP_COLOR_06 : CAP_WHITE};
|
|
41
|
+
`;
|
|
42
|
+
const TopContainer = styled.div`
|
|
43
|
+
width: ${(styledProps) => styledProps.width};
|
|
44
|
+
height: 5px;
|
|
45
|
+
margin: 0 25px 2px 2px;
|
|
46
|
+
background-color: ${CAP_G06};
|
|
47
|
+
`;
|
|
48
|
+
return (
|
|
49
|
+
<RadioLeftContainer>
|
|
50
|
+
<TopContainer width="13px"/>
|
|
51
|
+
<TopContainer width="38px"/>
|
|
52
|
+
<CapDivider style={{margin: '4px 0px -1px'}}></CapDivider>
|
|
53
|
+
<BottomContainer style={wrapperStyle} selected={showSelected}>
|
|
54
|
+
{component}
|
|
55
|
+
</BottomContainer>
|
|
56
|
+
</RadioLeftContainer>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
CapRadioCardCustom.propTypes = {
|
|
61
|
+
component: PropTypes.any,
|
|
62
|
+
wrapperStyle: PropTypes.any,
|
|
63
|
+
showSelected: PropTypes.string,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default CapRadioCardCustom;
|