@capillarytech/creatives-library 8.0.125-alpha.6 → 8.0.125
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/containers/App/constants.js +0 -1
- package/containers/Email/index.js +5 -5
- package/containers/WeChat/RichmediaTemplates/Create/index.js +1 -1
- package/package.json +1 -1
- package/services/api.js +1 -1
- package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +3 -8
- package/tests/integration/TemplateCreation/api-response.js +0 -5
- package/tests/integration/TemplateCreation/msw-handler.js +63 -42
- package/utils/common.js +0 -7
- package/utils/commonUtils.js +6 -2
- package/v2Components/CapImageUpload/index.js +45 -51
- package/v2Components/CapInAppCTA/index.js +0 -1
- package/v2Components/CapTagList/index.js +120 -177
- package/v2Components/CapVideoUpload/constants.js +0 -3
- package/v2Components/CapVideoUpload/index.js +110 -167
- package/v2Components/CapVideoUpload/messages.js +0 -16
- package/v2Components/Carousel/index.js +13 -15
- package/v2Components/ErrorInfoNote/style.scss +0 -1
- package/v2Components/MobilePushPreviewV2/index.js +5 -37
- package/v2Components/TemplatePreview/_templatePreview.scss +72 -114
- package/v2Components/TemplatePreview/index.js +50 -178
- package/v2Components/TemplatePreview/messages.js +0 -4
- package/v2Containers/CreativesContainer/SlideBoxContent.js +8 -8
- package/v2Containers/CreativesContainer/index.js +138 -194
- package/v2Containers/Email/index.js +5 -5
- package/v2Containers/InApp/constants.js +0 -1
- package/v2Containers/InApp/index.js +13 -13
- package/v2Containers/MobilePush/Create/index.js +0 -1
- package/v2Containers/MobilePush/commonMethods.js +14 -7
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +5 -5
- package/v2Containers/TagList/index.js +10 -56
- package/v2Containers/Templates/_templates.scss +1 -101
- package/v2Containers/Templates/index.js +35 -147
- package/v2Containers/Templates/messages.js +0 -8
- package/v2Containers/Templates/sagas.js +0 -2
- package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +1 -1
- package/v2Containers/Whatsapp/constants.js +0 -1
- package/utils/createPayload.js +0 -270
- package/utils/tests/createPayload.test.js +0 -761
- package/v2Components/CapMpushCTA/constants.js +0 -25
- package/v2Components/CapMpushCTA/index.js +0 -332
- package/v2Components/CapMpushCTA/index.scss +0 -95
- package/v2Components/CapMpushCTA/messages.js +0 -89
- package/v2Components/TemplatePreview/assets/images/Android _ With date and time.svg +0 -29
- package/v2Components/TemplatePreview/assets/images/android.svg +0 -9
- package/v2Components/TemplatePreview/assets/images/iOS _ With date and time.svg +0 -26
- package/v2Components/TemplatePreview/assets/images/ios.svg +0 -9
- package/v2Containers/MobilePushNew/actions.js +0 -116
- package/v2Containers/MobilePushNew/components/CtaButtons.js +0 -170
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +0 -686
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +0 -279
- package/v2Containers/MobilePushNew/components/index.js +0 -5
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +0 -779
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +0 -2114
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +0 -343
- package/v2Containers/MobilePushNew/constants.js +0 -115
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +0 -1299
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -1223
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +0 -246
- package/v2Containers/MobilePushNew/hooks/useUpload.js +0 -709
- package/v2Containers/MobilePushNew/index.js +0 -2170
- package/v2Containers/MobilePushNew/index.scss +0 -308
- package/v2Containers/MobilePushNew/messages.js +0 -226
- package/v2Containers/MobilePushNew/reducer.js +0 -160
- package/v2Containers/MobilePushNew/sagas.js +0 -198
- package/v2Containers/MobilePushNew/selectors.js +0 -55
- package/v2Containers/MobilePushNew/tests/reducer.test.js +0 -741
- package/v2Containers/MobilePushNew/tests/sagas.test.js +0 -863
- package/v2Containers/MobilePushNew/tests/selectors.test.js +0 -425
- package/v2Containers/MobilePushNew/tests/utils.test.js +0 -322
- package/v2Containers/MobilePushNew/utils.js +0 -33
|
@@ -18,7 +18,6 @@ export const JP_LOCALE_HIDE_FEATURE = 'JP_LOCALE_HIDE_FEATURE';
|
|
|
18
18
|
export const ENABLE_WECHAT = 'ENABLE_WECHAT';
|
|
19
19
|
export const ENABLE_CUSTOMER_BARCODE_TAG = "ENABLE_CUSTOMER_BARCODE_TAG";
|
|
20
20
|
export const EMAIL_UNSUBSCRIBE_TAG_MANDATORY = "EMAIL_UNSUBSCRIBE_TAG_MANDATORY";
|
|
21
|
-
export const ENABLE_NEW_MPUSH = "ENABLE_NEW_MPUSH";
|
|
22
21
|
|
|
23
22
|
export const CARD_RELATED_TAGS = [
|
|
24
23
|
'card_series',
|
|
@@ -1049,7 +1049,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
1049
1049
|
}
|
|
1050
1050
|
this.edmEvent = undefined;
|
|
1051
1051
|
} else if (this.state.editorInstanse) {
|
|
1052
|
-
this.state.editorInstanse.insertHtml(`<img src='${nextProps.Email.uploadedAssetData.metaInfo.secure_file_path}' alt='
|
|
1052
|
+
this.state.editorInstanse.insertHtml(`<img src='${nextProps.Email.uploadedAssetData.metaInfo.secure_file_path}' alt='Image'>`);
|
|
1053
1053
|
//this.resetCkEditorInstance(this.state.currentTab, this.state.formData, true, nextProps.Email.uploadedAssetData, true);
|
|
1054
1054
|
}
|
|
1055
1055
|
this.setState({showImageSelectionBox: false});
|
|
@@ -1620,7 +1620,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
1620
1620
|
if (onInsert && !isImage) {
|
|
1621
1621
|
this.state.editorInstanse.insertHtml(`{{${value}}}`);
|
|
1622
1622
|
} else if (onInsert) {
|
|
1623
|
-
this.state.editorInstanse.insertHtml(`<img src='${value.metaInfo.secure_file_path}' alt='
|
|
1623
|
+
this.state.editorInstanse.insertHtml(`<img src='${value.metaInfo.secure_file_path}' alt='Image'>`);
|
|
1624
1624
|
}
|
|
1625
1625
|
}
|
|
1626
1626
|
});
|
|
@@ -1979,7 +1979,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
1979
1979
|
// if (this.state.isDragDrop) {
|
|
1980
1980
|
//
|
|
1981
1981
|
// } else {
|
|
1982
|
-
// this.state.editorInstanse.insertHtml(`<img src='${data.metaInfo.public_url}' alt='
|
|
1982
|
+
// this.state.editorInstanse.insertHtml(`<img src='${data.metaInfo.public_url}' alt='Image'>`);
|
|
1983
1983
|
// }
|
|
1984
1984
|
// }
|
|
1985
1985
|
}
|
|
@@ -2070,7 +2070,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2070
2070
|
}
|
|
2071
2071
|
this.edmEvent = undefined;
|
|
2072
2072
|
} else if (this.state.editorInstanse) {
|
|
2073
|
-
this.state.editorInstanse.insertHtml(`<img src='${data.metaInfo.secure_file_path}' alt='
|
|
2073
|
+
this.state.editorInstanse.insertHtml(`<img src='${data.metaInfo.secure_file_path}' alt='Image'>`);
|
|
2074
2074
|
//this.resetCkEditorInstance(this.state.currentTab, this.state.formData, true, data, true);
|
|
2075
2075
|
}
|
|
2076
2076
|
}
|
|
@@ -2446,7 +2446,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2446
2446
|
|
|
2447
2447
|
selectAsset = (asset) => {
|
|
2448
2448
|
if (this.state.editorInstanse) {
|
|
2449
|
-
this.state.editorInstanse.insertHtml(`<img src='${asset}' alt='
|
|
2449
|
+
this.state.editorInstanse.insertHtml(`<img src='${asset}' alt='Image'>`);
|
|
2450
2450
|
}
|
|
2451
2451
|
}
|
|
2452
2452
|
|
|
@@ -903,7 +903,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
903
903
|
}
|
|
904
904
|
updateContentData = () => {
|
|
905
905
|
if (this.state.editorInstanse) {
|
|
906
|
-
this.state.editorInstanse.insertHtml(`<img src='${this.props.ContentImageData.metaInfo.wechatUrl}' alt='
|
|
906
|
+
this.state.editorInstanse.insertHtml(`<img src='${this.props.ContentImageData.metaInfo.wechatUrl}' alt='Image'>`);
|
|
907
907
|
}
|
|
908
908
|
this.props.actions.clearContentImageStore();
|
|
909
909
|
this.setState({loading: false});
|
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -231,7 +231,7 @@ export const createWeChatTemplate = ({template}) => {
|
|
|
231
231
|
return request(url, getAPICallObject('POST', template));
|
|
232
232
|
};
|
|
233
233
|
|
|
234
|
-
export const createMobilePushTemplate = (template) => {
|
|
234
|
+
export const createMobilePushTemplate = ({template}) => {
|
|
235
235
|
const url = `${API_ENDPOINT}/templates/MOBILEPUSH`;
|
|
236
236
|
return request(url, getAPICallObject('POST', template));
|
|
237
237
|
};
|
|
@@ -32,7 +32,7 @@ jest.mock('@capillarytech/cap-ui-utils', () => ({
|
|
|
32
32
|
},
|
|
33
33
|
}));
|
|
34
34
|
|
|
35
|
-
jest.setTimeout(
|
|
35
|
+
jest.setTimeout(30000);
|
|
36
36
|
|
|
37
37
|
const initializeCreatives = () => {
|
|
38
38
|
const store = configureStore(mockInitialState, initialReducer, history);
|
|
@@ -51,12 +51,6 @@ beforeEach(() => {
|
|
|
51
51
|
server.listen();
|
|
52
52
|
localStorage.clear();
|
|
53
53
|
localStorage.setItem('token', true);
|
|
54
|
-
|
|
55
|
-
// Mock cap auth
|
|
56
|
-
window.capAuth = {
|
|
57
|
-
hasFeatureAccess: jest.fn().mockReturnValue(false),
|
|
58
|
-
isInitialized: jest.fn().mockReturnValue(true),
|
|
59
|
-
};
|
|
60
54
|
});
|
|
61
55
|
|
|
62
56
|
// clean up once the tests are done
|
|
@@ -68,6 +62,7 @@ afterAll(() => {
|
|
|
68
62
|
});
|
|
69
63
|
|
|
70
64
|
describe("Creatives testing template creation", () => {
|
|
65
|
+
jest.useFakeTimers();
|
|
71
66
|
it("Should navigate from creatives home page and create template in RCS channel", async () => {
|
|
72
67
|
initializeCreatives();
|
|
73
68
|
const creativesScreen = await helper.getCreativesScreen();
|
|
@@ -98,7 +93,7 @@ describe("Creatives testing template creation", () => {
|
|
|
98
93
|
name: globalMessages.email.defaultMessage,
|
|
99
94
|
});
|
|
100
95
|
await userEvent.click(whatsapp);
|
|
101
|
-
|
|
96
|
+
waitFor(() => {
|
|
102
97
|
expect(
|
|
103
98
|
creativesScreen.getByText(
|
|
104
99
|
/Whatsapp accounts are not setup for your brand/i
|
|
@@ -20418,8 +20418,3 @@ export const tag = {
|
|
|
20418
20418
|
}
|
|
20419
20419
|
};
|
|
20420
20420
|
|
|
20421
|
-
export const cdnTransformationConfig = {
|
|
20422
|
-
enabled: false,
|
|
20423
|
-
transformations: [],
|
|
20424
|
-
};
|
|
20425
|
-
|
|
@@ -4,52 +4,73 @@ import 'whatwg-fetch';
|
|
|
4
4
|
import * as apiResponse from './api-response';
|
|
5
5
|
|
|
6
6
|
import config from '../../../config/app';
|
|
7
|
-
import { MOBILE_PUSH } from '../../../v2Containers/CreativesContainer/constants';
|
|
8
7
|
const API_ENDPOINT = config.development.api_endpoint;
|
|
9
8
|
const AUTH_ENDPOINT = config.development.auth_endpoint;
|
|
10
9
|
const CAMPAIGNS_API_ENDPOINT = config.development.campaigns_api_org_endpoint;
|
|
11
10
|
|
|
12
11
|
export const server = setupServer(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
12
|
+
rest.options('*', (req, res, ctx) =>
|
|
13
|
+
res(
|
|
14
|
+
ctx.status(200),
|
|
15
|
+
ctx.set('access-control-allow-origin', '*'),
|
|
16
|
+
ctx.set('Access-Control-Allow-Headers', 'x-cap-org'),
|
|
17
|
+
ctx.set('Access-Control-Allow-Headers', 'x-cap-remote-user'),
|
|
18
|
+
ctx.set('Access-Control-Allow-Headers', 'x-cap-api-data-context-org-id'),
|
|
19
|
+
ctx.set('Access-Control-Allow-Headers', 'x-cap-api-auth-org-id'),
|
|
20
|
+
),
|
|
21
|
+
),
|
|
22
|
+
rest.get(`${AUTH_ENDPOINT}/auth/org/:orgId/users`, (req, res, ctx) => {
|
|
23
|
+
const { orgId } = req.params;
|
|
24
|
+
switch (orgId) {
|
|
25
|
+
case '50146':
|
|
26
|
+
return res(ctx.status(200), ctx.json(apiResponse.authOrgUsersReonData));
|
|
27
|
+
}
|
|
28
|
+
}),
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
rest.get(`${AUTH_ENDPOINT}/user`, (req, res, ctx) =>
|
|
31
|
+
res(ctx.status(200), ctx.json(apiResponse.authUserReonData)),
|
|
32
|
+
),
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
)
|
|
34
|
+
rest.get(`${AUTH_ENDPOINT}/org/users`, (req, res, ctx) =>
|
|
35
|
+
res(ctx.status(200), ctx.json(apiResponse.authOrgUsersReonData)),
|
|
36
|
+
),
|
|
37
|
+
rest.get(`${API_ENDPOINT}/templates/Sms`, (req, res, ctx) =>
|
|
38
|
+
res(ctx.status(200), ctx.json(apiResponse.smsTemplates)),
|
|
39
|
+
),
|
|
40
|
+
rest.get(`${API_ENDPOINT}/templates/v1/Sms`, (req, res, ctx) =>
|
|
41
|
+
res(ctx.status(200), ctx.json(apiResponse.smsTemplates)),
|
|
42
|
+
),
|
|
43
|
+
rest.get(`${API_ENDPOINT}/templates/Rcs`, (req, res, ctx) =>
|
|
44
|
+
res(ctx.status(200), ctx.json(apiResponse.rcsTemplates)),
|
|
45
|
+
),
|
|
46
|
+
rest.get(`${API_ENDPOINT}/templates/v1/Rcs`, (req, res, ctx) =>
|
|
47
|
+
res(ctx.status(200), ctx.json(apiResponse.rcsTemplates)),
|
|
48
|
+
),
|
|
49
|
+
rest.get(`${API_ENDPOINT}/meta/wecrm`, (req, res, ctx) =>
|
|
50
|
+
res(ctx.status(200), ctx.json(apiResponse.viberAccount)),
|
|
51
|
+
),
|
|
52
|
+
rest.get(`${API_ENDPOINT}/meta/wecrm`, (req, res, ctx) =>
|
|
53
|
+
res(ctx.status(200), ctx.json(apiResponse.whatsappAccount)),
|
|
54
|
+
),
|
|
55
|
+
rest.get(`${API_ENDPOINT}/meta/wecrm`, (req, res, ctx) =>
|
|
56
|
+
res(ctx.status(200), ctx.json(apiResponse.mpushAccount)),
|
|
57
|
+
),
|
|
58
|
+
rest.get(`${API_ENDPOINT}/assets/image`, (req, res, ctx) =>
|
|
59
|
+
res(ctx.status(200), ctx.json(apiResponse.gallery)),
|
|
60
|
+
),
|
|
61
|
+
rest.get(`${API_ENDPOINT}/templates/v1/Line`, (req, res, ctx) =>
|
|
62
|
+
res(ctx.status(200), ctx.json(apiResponse.lineTemplates)),
|
|
63
|
+
),
|
|
64
|
+
rest.get(`${API_ENDPOINT}/templates/v1/Viber`, (req, res, ctx) =>
|
|
65
|
+
res(ctx.status(200), ctx.json(apiResponse.viberTemplates)),
|
|
66
|
+
),
|
|
67
|
+
rest.get(`${API_ENDPOINT}/templates/v1/Email`, (req, res, ctx) =>
|
|
68
|
+
res(ctx.status(200), ctx.json(apiResponse.emailTemplates)),
|
|
69
|
+
),
|
|
70
|
+
rest.get(`${API_ENDPOINT}/meta/TAG`, (req, res, ctx) =>
|
|
71
|
+
res(ctx.status(200), ctx.json(apiResponse.tag)),
|
|
72
|
+
),
|
|
73
|
+
rest.get(`${CAMPAIGNS_API_ENDPOINT}/meta/domainProperties`, (req, res, ctx) =>
|
|
74
|
+
res(ctx.status(200), ctx.json(apiResponse.domainProperties)),
|
|
75
|
+
),
|
|
76
|
+
);
|
package/utils/common.js
CHANGED
|
@@ -22,7 +22,6 @@ import {
|
|
|
22
22
|
BADGES_ISSUE,
|
|
23
23
|
ENABLE_WECHAT,
|
|
24
24
|
LIQUID_SUPPORT,
|
|
25
|
-
ENABLE_NEW_MPUSH,
|
|
26
25
|
} from '../containers/App/constants';
|
|
27
26
|
import { apiMessageFormatHandler } from './commonUtils';
|
|
28
27
|
|
|
@@ -125,12 +124,6 @@ export const isEmailUnsubscribeTagMandatory = Auth.hasFeatureAccess.bind(
|
|
|
125
124
|
null,
|
|
126
125
|
EMAIL_UNSUBSCRIBE_TAG_MANDATORY,
|
|
127
126
|
);
|
|
128
|
-
|
|
129
|
-
export const hasNewMobilePushFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
130
|
-
null,
|
|
131
|
-
ENABLE_NEW_MPUSH,
|
|
132
|
-
);
|
|
133
|
-
|
|
134
127
|
//filtering tags based on scope
|
|
135
128
|
export const filterTags = (tagsToFilter, tagsList) => tagsList?.filter(
|
|
136
129
|
(tag) => !tagsToFilter?.includes(tag?.definition?.value)
|
package/utils/commonUtils.js
CHANGED
|
@@ -35,7 +35,7 @@ export const addBaseToTemplate = (template) => {
|
|
|
35
35
|
...template.versions,
|
|
36
36
|
base: {
|
|
37
37
|
...history[0],
|
|
38
|
-
...( get(template, 'versions.base.subject') ? {subject: get(template, 'versions.base.subject')} :
|
|
38
|
+
...( get(template, 'versions.base.subject') ? {subject : get(template, 'versions.base.subject')} :{ subject:history?.[0]?.subject }),
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
41
|
});
|
|
@@ -151,7 +151,7 @@ export const validateLiquidTemplateContent = async (
|
|
|
151
151
|
const emptyBodyError = formatMessage(messages?.emailBodyEmptyError);
|
|
152
152
|
const somethingWrongMsg = formatMessage(messages?.somethingWentWrong);
|
|
153
153
|
// Empty content check
|
|
154
|
-
|
|
154
|
+
|
|
155
155
|
if (!content || content.trim() === "") {
|
|
156
156
|
onError({
|
|
157
157
|
standardErrors: [emptyBodyError],
|
|
@@ -170,6 +170,7 @@ export const validateLiquidTemplateContent = async (
|
|
|
170
170
|
|
|
171
171
|
const {askAiraResponse: result, isError} = await getLiquidTagsAsync(content);
|
|
172
172
|
const validString = /\S/.test(content);
|
|
173
|
+
|
|
173
174
|
// Handle API errors or empty content
|
|
174
175
|
if (result?.errors?.length > 0 || !validString || isError) {
|
|
175
176
|
let standardErrors = [];
|
|
@@ -301,6 +302,7 @@ export const _validatePlatformSpecificContent = async (
|
|
|
301
302
|
if (singleTab === IOS) {
|
|
302
303
|
isAndroidValid = true;
|
|
303
304
|
}
|
|
305
|
+
|
|
304
306
|
return isAndroidValid && isIosValid; // Overall success
|
|
305
307
|
};
|
|
306
308
|
|
|
@@ -338,6 +340,7 @@ export const validateMobilePushContent = async (formData, options) => {
|
|
|
338
340
|
if (iosContent) return [iosContent, IOS?.toLowerCase()];
|
|
339
341
|
return ["", ""];
|
|
340
342
|
};
|
|
343
|
+
|
|
341
344
|
if (overallSuccess) {
|
|
342
345
|
const [contentToSubmit, tabTypeToSubmit] = getContentToSubmit();
|
|
343
346
|
// Call the FINAL onSuccess only ONCE here
|
|
@@ -370,6 +373,7 @@ export const validateInAppContent = async (formData, options) => {
|
|
|
370
373
|
onSuccess, // FINAL success callback
|
|
371
374
|
...restOptions // Options for validateLiquidTemplateContent
|
|
372
375
|
} = options;
|
|
376
|
+
|
|
373
377
|
// Clear previous errors with new structure
|
|
374
378
|
onError({
|
|
375
379
|
standardErrors: {
|
|
@@ -22,9 +22,7 @@ import { isEmpty, get } from 'lodash';
|
|
|
22
22
|
import './index.scss';
|
|
23
23
|
import Gallery from '../../v2Containers/Assets/Gallery';
|
|
24
24
|
import { MAX_SUPPORTED_IMAGE_SIZE } from './constants';
|
|
25
|
-
import {
|
|
26
|
-
FACEBOOK, INAPP, RCS, WHATSAPP, VIBER,
|
|
27
|
-
} from "../../v2Containers/CreativesContainer/constants";
|
|
25
|
+
import { FACEBOOK, INAPP, RCS, WHATSAPP, VIBER } from "../../v2Containers/CreativesContainer/constants";
|
|
28
26
|
|
|
29
27
|
import messages from './messages';
|
|
30
28
|
function CapImageUpload(props) {
|
|
@@ -50,14 +48,14 @@ function CapImageUpload(props) {
|
|
|
50
48
|
} = props;
|
|
51
49
|
const {
|
|
52
50
|
formatMessage,
|
|
53
|
-
|
|
51
|
+
} = intl || {};
|
|
54
52
|
|
|
55
53
|
|
|
56
54
|
useEffect(() => {
|
|
57
55
|
const imageDataObj = imageData[`uploadedAssetData${index}`];
|
|
58
56
|
if (!isEmpty(imageDataObj)) {
|
|
59
|
-
const { secure_file_path = '' } = get(imageDataObj, 'metaInfo', {});
|
|
60
|
-
updateImageSrc(secure_file_path);
|
|
57
|
+
const { secure_file_path = '', karixFileHandle = '' } = get(imageDataObj, 'metaInfo', {});
|
|
58
|
+
updateImageSrc(secure_file_path, karixFileHandle);
|
|
61
59
|
}
|
|
62
60
|
}, [imageData[`uploadedAssetData${index}`]]);
|
|
63
61
|
|
|
@@ -67,7 +65,7 @@ function CapImageUpload(props) {
|
|
|
67
65
|
const {CapHeadingSpan} = CapHeading;
|
|
68
66
|
const ImageComponent = useCallback(
|
|
69
67
|
() => (
|
|
70
|
-
|
|
68
|
+
<>
|
|
71
69
|
{
|
|
72
70
|
!isEmpty(imageSrc) ? (
|
|
73
71
|
<div className={`image-container upload ${props.ifError ? 'error' : ''}`}>
|
|
@@ -76,10 +74,10 @@ function CapImageUpload(props) {
|
|
|
76
74
|
)}
|
|
77
75
|
</div>
|
|
78
76
|
) : null}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
</>
|
|
78
|
+
),
|
|
79
|
+
[imageSrc],
|
|
80
|
+
);
|
|
83
81
|
|
|
84
82
|
const WithLabel = LabelHOC(ImageComponent);
|
|
85
83
|
|
|
@@ -149,13 +147,10 @@ function CapImageUpload(props) {
|
|
|
149
147
|
const onReUpload = useCallback(() => {
|
|
150
148
|
updateImageSrc('');
|
|
151
149
|
updateOnReUpload();
|
|
152
|
-
// Don't automatically trigger file dialog - let user choose between computer and gallery
|
|
153
150
|
}, []);
|
|
154
151
|
|
|
155
152
|
const onGalleryImageSelect = useCallback((imageTemplate) => {
|
|
156
|
-
const {
|
|
157
|
-
secure_file_path: image, width, height, file_size: size,
|
|
158
|
-
} = get(imageTemplate, 'metaInfo', {});
|
|
153
|
+
const {secure_file_path: image, width, height, file_size: size} = get(imageTemplate, 'metaInfo', {});
|
|
159
154
|
updateDrawerRequirement(false);
|
|
160
155
|
if (!allowedExtensionsRegex.test(image) || height > imgHeight || width > imgWidth || size > imgSize ) {
|
|
161
156
|
updateImageErrorMessage(formatMessage(messages.imageErrorDesc));
|
|
@@ -181,7 +176,7 @@ function CapImageUpload(props) {
|
|
|
181
176
|
isFullMode={isFullMode}
|
|
182
177
|
isLineAsset
|
|
183
178
|
onGalleryImageSelect={onGalleryImageSelect}
|
|
184
|
-
|
|
179
|
+
/>
|
|
185
180
|
</>
|
|
186
181
|
);
|
|
187
182
|
}, []);
|
|
@@ -199,35 +194,34 @@ function CapImageUpload(props) {
|
|
|
199
194
|
|
|
200
195
|
const getImageSection = useCallback(() => {
|
|
201
196
|
if (imageSrc === "") {
|
|
202
|
-
return (
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
>
|
|
209
|
-
<
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
<
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
<
|
|
216
|
-
|
|
197
|
+
return (<>
|
|
198
|
+
<CapUploader.CapDragger
|
|
199
|
+
customRequest={capUploaderCustomRequest}
|
|
200
|
+
className="form-builder-dragger grey-background"
|
|
201
|
+
showUploadList={!isImageError}
|
|
202
|
+
>
|
|
203
|
+
<CapHeading className="dragger-title" type="h7">
|
|
204
|
+
<FormattedMessage {...messages.dragAndDrop} />
|
|
205
|
+
</CapHeading>
|
|
206
|
+
<CapHeading className="dragger-or" type="label6">
|
|
207
|
+
<FormattedMessage {...messages.or} />
|
|
208
|
+
</CapHeading>
|
|
209
|
+
<CapButton className="dragger-button upload-image" type="secondary">
|
|
210
|
+
<FormattedMessage {...messages.uploadComputer} />
|
|
211
|
+
</CapButton>
|
|
212
|
+
{channel !== WHATSAPP && (
|
|
213
|
+
<CapButton
|
|
214
|
+
className="dragger-button gallery-select"
|
|
215
|
+
type="secondary"
|
|
216
|
+
onClick={onGalleryClick}
|
|
217
|
+
>
|
|
218
|
+
<FormattedMessage {...messages.uploadGallery} />
|
|
217
219
|
</CapButton>
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
>
|
|
224
|
-
<FormattedMessage {...messages.uploadGallery} />
|
|
225
|
-
</CapButton>
|
|
226
|
-
)}
|
|
227
|
-
</CapUploader.CapDragger>
|
|
228
|
-
<CapError type="error" className="upload-image-error">
|
|
229
|
-
{isImageError}
|
|
230
|
-
</CapError>
|
|
220
|
+
)}
|
|
221
|
+
</CapUploader.CapDragger>
|
|
222
|
+
<CapError type="error" className="upload-image-error">
|
|
223
|
+
{isImageError}
|
|
224
|
+
</CapError>
|
|
231
225
|
</>
|
|
232
226
|
);
|
|
233
227
|
}
|
|
@@ -248,26 +242,26 @@ function CapImageUpload(props) {
|
|
|
248
242
|
return (
|
|
249
243
|
<div style={style} className="cap-custom-image-upload">
|
|
250
244
|
<WithLabel
|
|
251
|
-
key=
|
|
245
|
+
key={`with-label`}
|
|
252
246
|
ifError={!!isImageError}
|
|
253
247
|
|
|
254
|
-
|
|
255
|
-
<form encType="multipart/form-data" id=
|
|
248
|
+
/>
|
|
249
|
+
<form encType="multipart/form-data" id={`form`} className={className}>
|
|
256
250
|
<input
|
|
257
|
-
key=
|
|
251
|
+
key={`imgFile`}
|
|
258
252
|
style={{ display: 'none' }}
|
|
259
|
-
id="
|
|
253
|
+
id="fileName"
|
|
260
254
|
type="file"
|
|
261
255
|
onChange={(e) => uploadImages(e, { files: e.target.files })}
|
|
262
256
|
accept={supportedExtensions || "image/*"}
|
|
263
|
-
|
|
257
|
+
/>
|
|
264
258
|
{getImageSection()}
|
|
265
259
|
<CapDrawer
|
|
266
260
|
content={getGalleryDrawerContent()}
|
|
267
261
|
visible={isDrawerRequired}
|
|
268
262
|
width={430}
|
|
269
263
|
onClose={() => updateDrawerRequirement(false)}
|
|
270
|
-
|
|
264
|
+
/>
|
|
271
265
|
</form>
|
|
272
266
|
<div className="image-info-wrapper">
|
|
273
267
|
{channel === WHATSAPP && (
|