@capillarytech/creatives-library 8.0.127-alpha.1 → 8.0.128
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/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 +46 -59
- 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 +9 -9
- package/v2Containers/CreativesContainer/index.js +136 -191
- 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/Whatsapp/constants.js +0 -1
- package/utils/createPayload.js +0 -272
- 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 -754
- 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 -726
- package/v2Containers/MobilePushNew/index.js +0 -2280
- 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',
|
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -277,7 +277,7 @@ export const createWeChatTemplate = ({template}) => {
|
|
|
277
277
|
return request(url, getAPICallObject('POST', template));
|
|
278
278
|
};
|
|
279
279
|
|
|
280
|
-
export const createMobilePushTemplate = (template) => {
|
|
280
|
+
export const createMobilePushTemplate = ({template}) => {
|
|
281
281
|
const url = `${API_ENDPOINT}/templates/MOBILEPUSH`;
|
|
282
282
|
return request(url, getAPICallObject('POST', template));
|
|
283
283
|
};
|
|
@@ -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) {
|
|
@@ -47,25 +45,19 @@ function CapImageUpload(props) {
|
|
|
47
45
|
channel,
|
|
48
46
|
channelSpecificStyle,
|
|
49
47
|
showReUploadButton = true,
|
|
50
|
-
disableAutoRestore = false, // New prop to disable automatic restoration
|
|
51
48
|
} = props;
|
|
52
49
|
const {
|
|
53
50
|
formatMessage,
|
|
54
|
-
|
|
51
|
+
} = intl || {};
|
|
55
52
|
|
|
56
53
|
|
|
57
54
|
useEffect(() => {
|
|
58
|
-
// Skip automatic restoration if disableAutoRestore is true
|
|
59
|
-
if (disableAutoRestore) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
55
|
const imageDataObj = imageData[`uploadedAssetData${index}`];
|
|
64
56
|
if (!isEmpty(imageDataObj)) {
|
|
65
|
-
const { secure_file_path = '' } = get(imageDataObj, 'metaInfo', {});
|
|
66
|
-
updateImageSrc(secure_file_path);
|
|
57
|
+
const { secure_file_path = '', karixFileHandle = '' } = get(imageDataObj, 'metaInfo', {});
|
|
58
|
+
updateImageSrc(secure_file_path, karixFileHandle);
|
|
67
59
|
}
|
|
68
|
-
}, [imageData[`uploadedAssetData${index}`]
|
|
60
|
+
}, [imageData[`uploadedAssetData${index}`]]);
|
|
69
61
|
|
|
70
62
|
const [isImageError, updateImageErrorMessage] = useState(false);
|
|
71
63
|
const [isDrawerRequired, updateDrawerRequirement] = useState(false);
|
|
@@ -73,7 +65,7 @@ function CapImageUpload(props) {
|
|
|
73
65
|
const {CapHeadingSpan} = CapHeading;
|
|
74
66
|
const ImageComponent = useCallback(
|
|
75
67
|
() => (
|
|
76
|
-
|
|
68
|
+
<>
|
|
77
69
|
{
|
|
78
70
|
!isEmpty(imageSrc) ? (
|
|
79
71
|
<div className={`image-container upload ${props.ifError ? 'error' : ''}`}>
|
|
@@ -82,10 +74,10 @@ function CapImageUpload(props) {
|
|
|
82
74
|
)}
|
|
83
75
|
</div>
|
|
84
76
|
) : null}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
77
|
+
</>
|
|
78
|
+
),
|
|
79
|
+
[imageSrc],
|
|
80
|
+
);
|
|
89
81
|
|
|
90
82
|
const WithLabel = LabelHOC(ImageComponent);
|
|
91
83
|
|
|
@@ -155,13 +147,10 @@ function CapImageUpload(props) {
|
|
|
155
147
|
const onReUpload = useCallback(() => {
|
|
156
148
|
updateImageSrc('');
|
|
157
149
|
updateOnReUpload();
|
|
158
|
-
// Don't automatically trigger file dialog - let user choose between computer and gallery
|
|
159
150
|
}, []);
|
|
160
151
|
|
|
161
152
|
const onGalleryImageSelect = useCallback((imageTemplate) => {
|
|
162
|
-
const {
|
|
163
|
-
secure_file_path: image, width, height, file_size: size,
|
|
164
|
-
} = get(imageTemplate, 'metaInfo', {});
|
|
153
|
+
const {secure_file_path: image, width, height, file_size: size} = get(imageTemplate, 'metaInfo', {});
|
|
165
154
|
updateDrawerRequirement(false);
|
|
166
155
|
if (!allowedExtensionsRegex.test(image) || height > imgHeight || width > imgWidth || size > imgSize ) {
|
|
167
156
|
updateImageErrorMessage(formatMessage(messages.imageErrorDesc));
|
|
@@ -187,7 +176,7 @@ function CapImageUpload(props) {
|
|
|
187
176
|
isFullMode={isFullMode}
|
|
188
177
|
isLineAsset
|
|
189
178
|
onGalleryImageSelect={onGalleryImageSelect}
|
|
190
|
-
|
|
179
|
+
/>
|
|
191
180
|
</>
|
|
192
181
|
);
|
|
193
182
|
}, []);
|
|
@@ -205,35 +194,34 @@ function CapImageUpload(props) {
|
|
|
205
194
|
|
|
206
195
|
const getImageSection = useCallback(() => {
|
|
207
196
|
if (imageSrc === "") {
|
|
208
|
-
return (
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
>
|
|
215
|
-
<
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
<
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
<
|
|
222
|
-
|
|
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} />
|
|
223
219
|
</CapButton>
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
>
|
|
230
|
-
<FormattedMessage {...messages.uploadGallery} />
|
|
231
|
-
</CapButton>
|
|
232
|
-
)}
|
|
233
|
-
</CapUploader.CapDragger>
|
|
234
|
-
<CapError type="error" className="upload-image-error">
|
|
235
|
-
{isImageError}
|
|
236
|
-
</CapError>
|
|
220
|
+
)}
|
|
221
|
+
</CapUploader.CapDragger>
|
|
222
|
+
<CapError type="error" className="upload-image-error">
|
|
223
|
+
{isImageError}
|
|
224
|
+
</CapError>
|
|
237
225
|
</>
|
|
238
226
|
);
|
|
239
227
|
}
|
|
@@ -254,26 +242,26 @@ function CapImageUpload(props) {
|
|
|
254
242
|
return (
|
|
255
243
|
<div style={style} className="cap-custom-image-upload">
|
|
256
244
|
<WithLabel
|
|
257
|
-
key=
|
|
245
|
+
key={`with-label`}
|
|
258
246
|
ifError={!!isImageError}
|
|
259
247
|
|
|
260
|
-
|
|
261
|
-
<form encType="multipart/form-data" id=
|
|
248
|
+
/>
|
|
249
|
+
<form encType="multipart/form-data" id={`form`} className={className}>
|
|
262
250
|
<input
|
|
263
|
-
key=
|
|
251
|
+
key={`imgFile`}
|
|
264
252
|
style={{ display: 'none' }}
|
|
265
|
-
id="
|
|
253
|
+
id="fileName"
|
|
266
254
|
type="file"
|
|
267
255
|
onChange={(e) => uploadImages(e, { files: e.target.files })}
|
|
268
256
|
accept={supportedExtensions || "image/*"}
|
|
269
|
-
|
|
257
|
+
/>
|
|
270
258
|
{getImageSection()}
|
|
271
259
|
<CapDrawer
|
|
272
260
|
content={getGalleryDrawerContent()}
|
|
273
261
|
visible={isDrawerRequired}
|
|
274
262
|
width={430}
|
|
275
263
|
onClose={() => updateDrawerRequirement(false)}
|
|
276
|
-
|
|
264
|
+
/>
|
|
277
265
|
</form>
|
|
278
266
|
<div className="image-info-wrapper">
|
|
279
267
|
{channel === WHATSAPP && (
|
|
@@ -321,7 +309,6 @@ CapImageUpload.propTypes = {
|
|
|
321
309
|
index: PropTypes.number,
|
|
322
310
|
channel: PropTypes.string,
|
|
323
311
|
channelSpecificStyle: PropTypes.bool,
|
|
324
|
-
disableAutoRestore: PropTypes.bool,
|
|
325
312
|
};
|
|
326
313
|
|
|
327
314
|
export default injectIntl(CapImageUpload);
|