@capillarytech/creatives-library 7.17.38 → 7.17.39-alpha.0
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/index.js +2 -2
- package/package.json +1 -1
- package/services/api.js +6 -6
- package/v2Components/CapTagList/index.js +2 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +12 -6
- package/v2Containers/CreativesContainer/index.js +46 -7
- package/v2Containers/TagList/index.js +2 -0
- package/v2Containers/Templates/index.js +17 -3
- package/v2Containers/Templates/messages.js +4 -0
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +28 -129
- package/v2Containers/TemplatesV2/tests/index.test.js +1 -0
- package/v2Containers/Zalo/constants.js +0 -1
- package/v2Containers/Zalo/index.js +278 -187
- package/v2Containers/Zalo/index.scss +3 -4
- package/v2Containers/Zalo/messages.js +16 -4
- package/v2Containers/Zalo/saga.js +10 -4
- package/v2Containers/Zalo/selectors.js +8 -10
- package/v2Containers/Zalo/tests/index.test.js +94 -47
- package/v2Containers/Zalo/tests/mockData.js +5101 -5045
- package/v2Containers/Zalo/tests/reducer.test.js +3 -3
- package/v2Containers/Zalo/tests/saga.test.js +5 -2
- package/v2Containers/Zalo/tests/selector.test.js +28 -0
- package/v2Containers/Zalo/tests/selectors.test.js +0 -52
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
/* eslint-disable
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
/* eslint-disable react/jsx-indent */
|
|
3
|
+
import React, { useState, useEffect } from 'react';
|
|
4
|
+
import { bindActionCreators } from 'redux';
|
|
5
|
+
import { createStructuredSelector } from 'reselect';
|
|
6
|
+
import { injectIntl, FormattedMessage } from 'react-intl';
|
|
7
|
+
import { get, isEmpty } from 'lodash';
|
|
7
8
|
import styled from 'styled-components';
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
import CapSpin from '@capillarytech/cap-ui-library/CapSpin';
|
|
10
|
+
import CapRow from '@capillarytech/cap-ui-library/CapRow';
|
|
11
|
+
import CapColumn from '@capillarytech/cap-ui-library/CapColumn';
|
|
12
|
+
import CapLabel from '@capillarytech/cap-ui-library/CapLabel';
|
|
13
|
+
import CapAlert from '@capillarytech/cap-ui-library/CapAlert';
|
|
14
|
+
import CapInput from '@capillarytech/cap-ui-library/CapInput';
|
|
15
|
+
import CapHeading from '@capillarytech/cap-ui-library/CapHeading';
|
|
16
|
+
import CapHeader from '@capillarytech/cap-ui-library/CapHeader';
|
|
17
|
+
import CapNotification from '@capillarytech/cap-ui-library/CapNotification';
|
|
18
|
+
import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
|
|
19
|
+
import CapTooltip from '@capillarytech/cap-ui-library/CapTooltip';
|
|
20
|
+
import CapButton from '@capillarytech/cap-ui-library/CapButton';
|
|
19
21
|
import {
|
|
20
22
|
CAP_SPACE_16,
|
|
21
23
|
CAP_SPACE_24,
|
|
22
24
|
CAP_SPACE_32,
|
|
23
25
|
CAP_WHITE,
|
|
24
26
|
} from '@capillarytech/cap-ui-library/styled/variables';
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
+
import { makeSelectZalo, makeSelectAccount } from './selectors';
|
|
28
|
+
import { makeSelectMetaEntities, setInjectedTags } from '../Cap/selectors';
|
|
29
|
+
import * as zaloActions from './actions';
|
|
30
|
+
import './index.scss';
|
|
27
31
|
import {
|
|
28
32
|
SUCCESS_ALERT,
|
|
29
33
|
REQUEST,
|
|
@@ -36,40 +40,46 @@ import {
|
|
|
36
40
|
ERROR_ALERT,
|
|
37
41
|
WARNING_ALERT,
|
|
38
42
|
ZALO_STATUSES,
|
|
39
|
-
|
|
40
|
-
} from
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
import {
|
|
46
|
-
import TagList from "../TagList";
|
|
47
|
-
import globalMessages from "../Cap/messages";
|
|
48
|
-
import { makeSelectMetaEntities, setInjectedTags } from "../Cap/selectors";
|
|
49
|
-
import * as globalActions from "../Cap/actions";
|
|
50
|
-
import { validateTags } from "../../utils/tagValidations";
|
|
51
|
-
|
|
43
|
+
} from './constants';
|
|
44
|
+
import { ZALO } from '../CreativesContainer/constants';
|
|
45
|
+
import messages from './messages';
|
|
46
|
+
import globalMessages from '../Cap/messages';
|
|
47
|
+
import withCreatives from '../../hoc/withCreatives';
|
|
48
|
+
import TagList from '../TagList';
|
|
49
|
+
import { validateTags } from '../../utils/tagValidations';
|
|
52
50
|
|
|
53
|
-
export const Zalo = ({
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
export const Zalo = (props) => {
|
|
52
|
+
const {
|
|
53
|
+
intl,
|
|
54
|
+
actions,
|
|
55
|
+
isFullMode,
|
|
56
|
+
templateData = {},
|
|
57
|
+
editData = {},
|
|
58
|
+
accountData = {},
|
|
59
|
+
globalActions,
|
|
60
|
+
location,
|
|
61
|
+
getDefaultTags,
|
|
62
|
+
supportedTags,
|
|
63
|
+
metaEntities,
|
|
64
|
+
injectedTags,
|
|
65
|
+
getFormData,
|
|
66
|
+
selectedOfferDetails,
|
|
67
|
+
} = props || {};
|
|
66
68
|
const { formatMessage } = intl;
|
|
67
|
-
const [
|
|
68
|
-
const [
|
|
69
|
+
const [oa_id, setOaId] = useState('');
|
|
70
|
+
const [token, setToken] = useState('');
|
|
71
|
+
const [username, setUsername] = useState('');
|
|
72
|
+
const [templateName, setTemplateName] = useState('');
|
|
73
|
+
const [templateId, setTemplateId] = useState('');
|
|
74
|
+
const [templateListParams, setTemplateListParams] = useState([]);
|
|
75
|
+
const [templatePreviewUrl, setTemplatePreviewUrl] = useState('');
|
|
76
|
+
const [templateStatus, setZaloTemplateStatus] = useState(
|
|
77
|
+
ZALO_STATUSES.ENABLE,
|
|
78
|
+
);
|
|
69
79
|
const [tags, updateTags] = useState([]);
|
|
70
|
-
const [textAreaId, updateTextAreaId] = useState(
|
|
71
|
-
const
|
|
72
|
-
|
|
80
|
+
const [textAreaId, updateTextAreaId] = useState('');
|
|
81
|
+
const { zaloTemplateInfoValue = {}, zaloTemplateInfoStatus = REQUEST } =
|
|
82
|
+
editData;
|
|
73
83
|
const ZaloFooter = styled.div`
|
|
74
84
|
background-color: ${CAP_WHITE};
|
|
75
85
|
position: fixed;
|
|
@@ -84,47 +94,55 @@ export const Zalo = ({
|
|
|
84
94
|
}
|
|
85
95
|
}
|
|
86
96
|
`;
|
|
87
|
-
|
|
88
|
-
const { zaloTemplateInfoStatus, zaloTemplateInfoValue } =
|
|
89
|
-
zaloTemplateInfoData;
|
|
90
|
-
|
|
91
|
-
// here listParams and previewUrl data will be setting in respective states. We got that data by destructring
|
|
97
|
+
//gets account details
|
|
92
98
|
useEffect(() => {
|
|
93
|
-
|
|
99
|
+
const accountObj = accountData.selectedZaloAccount || {};
|
|
100
|
+
if (!isEmpty(accountObj)) {
|
|
94
101
|
const {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
} = zaloTemplateInfoValue;
|
|
103
|
-
setZaloTemplateListParams(listParams);
|
|
104
|
-
setTemplatePreviewUrl(previewUrl);
|
|
105
|
-
setZaloTemplateStatus(status);
|
|
106
|
-
updateTextAreaId(listParams[0]?.name);
|
|
102
|
+
sourceAccountIdentifier = '',
|
|
103
|
+
configs: { token: accessToken = '' } = {},
|
|
104
|
+
name = '',
|
|
105
|
+
} = accountObj;
|
|
106
|
+
setOaId(sourceAccountIdentifier);
|
|
107
|
+
setToken(accessToken);
|
|
108
|
+
setUsername(name);
|
|
107
109
|
}
|
|
108
|
-
}, [
|
|
110
|
+
}, [accountData.selectedZaloAccount]);
|
|
109
111
|
|
|
112
|
+
//gets template details
|
|
110
113
|
useEffect(() => {
|
|
111
|
-
const {
|
|
112
|
-
weCrmAccounts: [
|
|
113
|
-
{
|
|
114
|
-
name,
|
|
115
|
-
sourceAccountIdentifier,
|
|
116
|
-
configs: { token },
|
|
117
|
-
},
|
|
118
|
-
],
|
|
119
|
-
} = template;
|
|
120
114
|
const { _id: id } = templateData;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
115
|
+
if (id && oa_id && token && username) {
|
|
116
|
+
actions.getTemplateInfoById({
|
|
117
|
+
username,
|
|
118
|
+
oa_id,
|
|
119
|
+
token,
|
|
120
|
+
id,
|
|
121
|
+
actionCallback,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}, [templateData._id, oa_id, token, username]);
|
|
125
|
+
|
|
126
|
+
// here listParams and previewUrl data will be setting in respective states. We got that data by destructring
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
const {
|
|
129
|
+
name = '',
|
|
130
|
+
_id = '',
|
|
131
|
+
versions: {
|
|
132
|
+
base: {
|
|
133
|
+
content: {
|
|
134
|
+
zalo: { listParams = [], previewUrl = '', status = '' } = {},
|
|
135
|
+
} = {},
|
|
136
|
+
} = {},
|
|
137
|
+
} = {},
|
|
138
|
+
} = isFullMode ? zaloTemplateInfoValue : templateData;
|
|
139
|
+
setTemplateName(name);
|
|
140
|
+
setTemplateId(_id);
|
|
141
|
+
setTemplateListParams(listParams);
|
|
142
|
+
setTemplatePreviewUrl(previewUrl);
|
|
143
|
+
setZaloTemplateStatus(status);
|
|
144
|
+
updateTextAreaId(listParams[0]?.name);
|
|
145
|
+
}, [zaloTemplateInfoValue, templateData]);
|
|
128
146
|
|
|
129
147
|
useEffect(() => {
|
|
130
148
|
let tag = get(metaEntities, `tags.standard`, []);
|
|
@@ -140,7 +158,7 @@ export const Zalo = ({
|
|
|
140
158
|
const { type, module } = location?.query || {};
|
|
141
159
|
const isEmbedded = type === EMBEDDED;
|
|
142
160
|
const query = {
|
|
143
|
-
layout:
|
|
161
|
+
layout: 'SMS',
|
|
144
162
|
type: TAG,
|
|
145
163
|
context: isEmbedded ? module : DEFAULT,
|
|
146
164
|
embedded: isEmbedded ? type : FULL,
|
|
@@ -148,44 +166,46 @@ export const Zalo = ({
|
|
|
148
166
|
if (getDefaultTags) {
|
|
149
167
|
query.context = getDefaultTags;
|
|
150
168
|
}
|
|
151
|
-
|
|
169
|
+
globalActions.fetchSchemaForEntity(query);
|
|
152
170
|
}, []);
|
|
153
171
|
|
|
154
172
|
const handleOnTagsContextChange = (data) => {
|
|
155
173
|
const { type } = location?.query || {};
|
|
156
174
|
const isEmbedded = type === EMBEDDED;
|
|
157
175
|
const query = {
|
|
158
|
-
layout:
|
|
176
|
+
layout: 'SMS',
|
|
159
177
|
type: TAG,
|
|
160
178
|
context:
|
|
161
|
-
(data ||
|
|
179
|
+
(data || '').toLowerCase() === ALL
|
|
162
180
|
? DEFAULT
|
|
163
|
-
: (data ||
|
|
181
|
+
: (data || '').toLowerCase(),
|
|
164
182
|
embedded: isEmbedded ? type : FULL,
|
|
165
183
|
};
|
|
166
|
-
|
|
184
|
+
globalActions.fetchSchemaForEntity(query);
|
|
167
185
|
};
|
|
168
186
|
|
|
169
187
|
const onTagSelect = (data) => {
|
|
170
188
|
if (data && textAreaId) {
|
|
171
|
-
const updatedZaloTemplateInfo =
|
|
172
|
-
|
|
173
|
-
|
|
189
|
+
const updatedZaloTemplateInfo = templateListParams?.map((listParams) => {
|
|
190
|
+
const { name = '', value = '', minLength, maxLength } = listParams;
|
|
191
|
+
if (name === textAreaId) {
|
|
192
|
+
const text = `${value}{{${data}}}`;
|
|
193
|
+
const isLengthError =
|
|
194
|
+
text.length <= minLength || text.length > maxLength;
|
|
174
195
|
return {
|
|
175
|
-
...
|
|
196
|
+
...listParams,
|
|
176
197
|
value: text,
|
|
177
|
-
error:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
maxLength: item?.maxLength,
|
|
198
|
+
error: isLengthError
|
|
199
|
+
? formatMessage(messages.maxMinLengthMessage, {
|
|
200
|
+
minLength,
|
|
201
|
+
maxLength,
|
|
182
202
|
})
|
|
183
|
-
|
|
203
|
+
: '',
|
|
184
204
|
};
|
|
185
205
|
}
|
|
186
|
-
return
|
|
206
|
+
return listParams;
|
|
187
207
|
});
|
|
188
|
-
|
|
208
|
+
setTemplateListParams(updatedZaloTemplateInfo);
|
|
189
209
|
}
|
|
190
210
|
};
|
|
191
211
|
|
|
@@ -199,7 +219,7 @@ export const Zalo = ({
|
|
|
199
219
|
tagModule: getDefaultTags,
|
|
200
220
|
}) || {};
|
|
201
221
|
const { unsupportedTags = [], isBraceError } = tagValidationResponse;
|
|
202
|
-
let tagError =
|
|
222
|
+
let tagError = '';
|
|
203
223
|
if (unsupportedTags.length > 0) {
|
|
204
224
|
tagError = formatMessage(globalMessages.unsupportedTagsValidationError, {
|
|
205
225
|
unsupportedTags,
|
|
@@ -211,38 +231,36 @@ export const Zalo = ({
|
|
|
211
231
|
return tagError;
|
|
212
232
|
};
|
|
213
233
|
|
|
234
|
+
//this function is used for checking errror validation in this it validate tags error and length error
|
|
235
|
+
const handleErrorValidation = (e, field) => {
|
|
236
|
+
const { minLength, maxLength } = field;
|
|
237
|
+
let error = e ? tagValidationErrorMessage(e) : '';
|
|
238
|
+
if (!e || e.length <= minLength || e.length > maxLength) {
|
|
239
|
+
error = formatMessage(messages.maxMinLengthMessage, {
|
|
240
|
+
minLength,
|
|
241
|
+
maxLength,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return error;
|
|
245
|
+
};
|
|
246
|
+
|
|
214
247
|
// this function is used for handle form data change in this also handle error validtion on change of value
|
|
215
248
|
const handleFormDataChange = (e, field) => {
|
|
216
249
|
const {
|
|
217
250
|
target: { value },
|
|
218
251
|
} = e;
|
|
219
|
-
const updatedZaloTemplateInfo =
|
|
220
|
-
if (
|
|
252
|
+
const updatedZaloTemplateInfo = templateListParams?.map((listParams) => {
|
|
253
|
+
if (listParams?.name === field?.name) {
|
|
221
254
|
const error = handleErrorValidation(value, field);
|
|
222
255
|
return {
|
|
223
|
-
...
|
|
256
|
+
...listParams,
|
|
224
257
|
value,
|
|
225
258
|
error,
|
|
226
259
|
};
|
|
227
260
|
}
|
|
228
|
-
return
|
|
261
|
+
return listParams;
|
|
229
262
|
});
|
|
230
|
-
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
//this function is used for checking errror validation in this it validate tags error and length error
|
|
234
|
-
const handleErrorValidation = (e, field) => {
|
|
235
|
-
const { minLength, maxLength } = field;
|
|
236
|
-
let error = tagValidationErrorMessage(e);
|
|
237
|
-
|
|
238
|
-
if (e.length <= minLength || e.length > maxLength) {
|
|
239
|
-
error = formatMessage(messages.maxMinLengthMessage, {
|
|
240
|
-
minLength,
|
|
241
|
-
maxLength,
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
return error;
|
|
263
|
+
setTemplateListParams(updatedZaloTemplateInfo);
|
|
246
264
|
};
|
|
247
265
|
|
|
248
266
|
const renderTextBoxesForListParams = (listParam) => {
|
|
@@ -253,10 +271,11 @@ export const Zalo = ({
|
|
|
253
271
|
onChange={(e) => handleFormDataChange(e, listParam)}
|
|
254
272
|
errorMessage={error}
|
|
255
273
|
placeholder={formatMessage(messages.addVariableWithMessage)}
|
|
256
|
-
defaultValue={value ||
|
|
257
|
-
value={value ||
|
|
274
|
+
defaultValue={value || ''}
|
|
275
|
+
value={value || ''}
|
|
258
276
|
size="default"
|
|
259
277
|
onFocus={() => setTextAreaId(name)}
|
|
278
|
+
disabled={isFullMode}
|
|
260
279
|
/>
|
|
261
280
|
);
|
|
262
281
|
};
|
|
@@ -266,7 +285,7 @@ export const Zalo = ({
|
|
|
266
285
|
};
|
|
267
286
|
|
|
268
287
|
const handlePreview = () => {
|
|
269
|
-
window.open(templatePreviewUrl,
|
|
288
|
+
window.open(templatePreviewUrl, '_blank');
|
|
270
289
|
};
|
|
271
290
|
|
|
272
291
|
const getTemplateStatusType = () => {
|
|
@@ -280,20 +299,93 @@ export const Zalo = ({
|
|
|
280
299
|
}
|
|
281
300
|
};
|
|
282
301
|
|
|
302
|
+
const actionCallback = () => {
|
|
303
|
+
CapNotification.error({
|
|
304
|
+
message: formatMessage(messages.zaloFailureNotificationTemplate),
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
const isEditDoneDisabled = () => {
|
|
309
|
+
let disableCheck = false;
|
|
310
|
+
templateListParams.forEach((listParams) => {
|
|
311
|
+
const { error, value } = listParams;
|
|
312
|
+
const errorMessage = !error
|
|
313
|
+
? handleErrorValidation(value, listParams)
|
|
314
|
+
: error;
|
|
315
|
+
if (errorMessage) {
|
|
316
|
+
disableCheck = true;
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
return disableCheck;
|
|
320
|
+
};
|
|
321
|
+
const createPayload = () => {
|
|
322
|
+
const varMapped = {};
|
|
323
|
+
templateListParams.forEach((listParam) => {
|
|
324
|
+
const { name, value } = listParam;
|
|
325
|
+
varMapped[name] = value;
|
|
326
|
+
});
|
|
327
|
+
const payload = {
|
|
328
|
+
channel: ZALO,
|
|
329
|
+
accountId: oa_id,
|
|
330
|
+
accountName: username,
|
|
331
|
+
templateConfigs: {
|
|
332
|
+
_id: templateId,
|
|
333
|
+
name: templateName,
|
|
334
|
+
template: templatePreviewUrl,
|
|
335
|
+
varMapped,
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
return payload;
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
const saveToMessage = () => {
|
|
342
|
+
getFormData({
|
|
343
|
+
value: createPayload(),
|
|
344
|
+
_id: templateId,
|
|
345
|
+
validity: true,
|
|
346
|
+
type: ZALO,
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
const renderContent = () =>
|
|
351
|
+
templateListParams?.map((listParam) => {
|
|
352
|
+
const { name = '', value = '', maxLength } = listParam;
|
|
353
|
+
return (
|
|
354
|
+
<>
|
|
355
|
+
{renderTextBoxesForListParams(listParam)}
|
|
356
|
+
<CapRow className="variable-field-container">
|
|
357
|
+
<CapLabel className="variable-field-name">
|
|
358
|
+
{formatMessage(messages.variableType, {
|
|
359
|
+
name,
|
|
360
|
+
})}
|
|
361
|
+
</CapLabel>
|
|
362
|
+
<CapLabel className="variable-field-length">
|
|
363
|
+
{formatMessage(messages.charactersCount, {
|
|
364
|
+
variableLength: value.length,
|
|
365
|
+
maxLength,
|
|
366
|
+
})}
|
|
367
|
+
</CapLabel>
|
|
368
|
+
</CapRow>
|
|
369
|
+
</>
|
|
370
|
+
);
|
|
371
|
+
});
|
|
372
|
+
|
|
283
373
|
return (
|
|
284
374
|
<CapSpin spinning={zaloTemplateInfoStatus === REQUEST}>
|
|
285
375
|
<CapRow type="flex" className="cap-zalo-creatives">
|
|
286
376
|
<CapColumn span={14}>
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
377
|
+
{templateStatus && (
|
|
378
|
+
<CapAlert
|
|
379
|
+
message={
|
|
380
|
+
<CapLabel type="label2">
|
|
381
|
+
{formatMessage(messages.approvedStatusMsg, {
|
|
382
|
+
status: formatMessage(messages?.[templateStatus]),
|
|
383
|
+
})}
|
|
384
|
+
</CapLabel>
|
|
385
|
+
}
|
|
386
|
+
type={getTemplateStatusType()}
|
|
387
|
+
/>
|
|
388
|
+
)}
|
|
297
389
|
<CapRow>
|
|
298
390
|
<CapRow className="whatsapp-render-heading">
|
|
299
391
|
<CapHeader
|
|
@@ -312,75 +404,74 @@ export const Zalo = ({
|
|
|
312
404
|
onContextChange={handleOnTagsContextChange}
|
|
313
405
|
injectedTags={injectedTags || {}}
|
|
314
406
|
selectedOfferDetails={selectedOfferDetails}
|
|
407
|
+
disabled={isFullMode}
|
|
315
408
|
/>
|
|
316
409
|
}
|
|
317
410
|
/>
|
|
318
411
|
</CapRow>
|
|
319
|
-
<CapRow className="zalo-variable-list">
|
|
320
|
-
{zaloTemplateListParams?.map((listParam) => {
|
|
321
|
-
const { name = "", maxLength, value = "" } = listParam;
|
|
322
|
-
return (
|
|
323
|
-
<>
|
|
324
|
-
{renderTextBoxesForListParams(listParam)}
|
|
325
|
-
<CapRow className="variable-field-container">
|
|
326
|
-
<CapLabel className="variable-field-name">
|
|
327
|
-
{formatMessage(messages.variableType, {
|
|
328
|
-
fieldName: name,
|
|
329
|
-
})}
|
|
330
|
-
</CapLabel>
|
|
331
|
-
<CapLabel className="variable-field-length">
|
|
332
|
-
{formatMessage(messages.charactersCount, {
|
|
333
|
-
variableLength: value?.length,
|
|
334
|
-
fixedLength: maxLength,
|
|
335
|
-
})}
|
|
336
|
-
</CapLabel>
|
|
337
|
-
</CapRow>
|
|
338
|
-
</>
|
|
339
|
-
);
|
|
340
|
-
})}
|
|
341
|
-
</CapRow>
|
|
412
|
+
<CapRow className="zalo-variable-list">{renderContent()}</CapRow>
|
|
342
413
|
</CapRow>
|
|
343
414
|
</CapColumn>
|
|
344
|
-
<CapColumn
|
|
345
|
-
<CapRow>
|
|
346
|
-
<
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
<
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
<
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
415
|
+
<CapColumn span={10}>
|
|
416
|
+
<CapRow className="zalo-preview-container">
|
|
417
|
+
<CapRow>
|
|
418
|
+
<CapLabel className="preview-head">
|
|
419
|
+
{formatMessage(messages.previewHead)}
|
|
420
|
+
</CapLabel>
|
|
421
|
+
</CapRow>
|
|
422
|
+
<CapRow>
|
|
423
|
+
<CapLabel className="preview-text">
|
|
424
|
+
{formatMessage(messages.previewText)}
|
|
425
|
+
</CapLabel>
|
|
426
|
+
</CapRow>
|
|
427
|
+
<CapRow>
|
|
428
|
+
<CapLabel
|
|
429
|
+
data-testid="preview-link-button"
|
|
430
|
+
onClick={handlePreview}
|
|
431
|
+
className="preview-link"
|
|
432
|
+
>
|
|
433
|
+
{formatMessage(messages.openPreview)}{' '}
|
|
434
|
+
<CapIcon type="open-in-new-light"></CapIcon>
|
|
435
|
+
</CapLabel>
|
|
436
|
+
</CapRow>
|
|
364
437
|
</CapRow>
|
|
365
438
|
</CapColumn>
|
|
366
439
|
</CapRow>
|
|
367
|
-
<ZaloFooter
|
|
440
|
+
<ZaloFooter>
|
|
441
|
+
{!isFullMode && (
|
|
442
|
+
<CapTooltip
|
|
443
|
+
title={
|
|
444
|
+
isEditDoneDisabled()
|
|
445
|
+
? formatMessage(messages.btnDisabledTooltip)
|
|
446
|
+
: ''
|
|
447
|
+
}
|
|
448
|
+
placement={'right'}
|
|
449
|
+
>
|
|
450
|
+
<div className="button-disabled-tooltip-wrapper">
|
|
451
|
+
<CapButton
|
|
452
|
+
onClick={saveToMessage}
|
|
453
|
+
disabled={isEditDoneDisabled()}
|
|
454
|
+
className="whatsapp-create-btn"
|
|
455
|
+
>
|
|
456
|
+
<FormattedMessage {...globalMessages.done} />
|
|
457
|
+
</CapButton>
|
|
458
|
+
</div>
|
|
459
|
+
</CapTooltip>
|
|
460
|
+
)}
|
|
461
|
+
</ZaloFooter>
|
|
368
462
|
</CapSpin>
|
|
369
463
|
);
|
|
370
464
|
};
|
|
371
465
|
|
|
372
466
|
const mapStateToProps = createStructuredSelector({
|
|
373
|
-
|
|
374
|
-
|
|
467
|
+
editData: makeSelectZalo(),
|
|
468
|
+
accountData: makeSelectAccount(),
|
|
375
469
|
metaEntities: makeSelectMetaEntities(),
|
|
376
470
|
injectedTags: setInjectedTags(),
|
|
377
471
|
});
|
|
378
472
|
|
|
379
473
|
const mapDispatchToProps = (dispatch) => ({
|
|
380
|
-
actions: bindActionCreators(
|
|
381
|
-
{ ...zaloActions, ...templateActions, ...globalActions },
|
|
382
|
-
dispatch
|
|
383
|
-
),
|
|
474
|
+
actions: bindActionCreators(zaloActions, dispatch),
|
|
384
475
|
});
|
|
385
476
|
|
|
386
477
|
export default withCreatives({
|
|
@@ -42,11 +42,10 @@
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
.zalo-preview-container {
|
|
45
|
-
text-align: center;
|
|
46
45
|
position: fixed;
|
|
47
|
-
|
|
48
|
-
padding-left:
|
|
49
|
-
padding-right:
|
|
46
|
+
text-align: center;
|
|
47
|
+
padding-left: 72px;
|
|
48
|
+
padding-right: 110px;
|
|
50
49
|
|
|
51
50
|
.preview-head {
|
|
52
51
|
font-weight: 500;
|
|
@@ -16,14 +16,14 @@ export default defineMessages({
|
|
|
16
16
|
},
|
|
17
17
|
variableType: {
|
|
18
18
|
id: `${prefix}.variableType`,
|
|
19
|
-
defaultMessage: "Variable type: <{
|
|
19
|
+
defaultMessage: "Variable type: <{name}>",
|
|
20
20
|
},
|
|
21
21
|
charactersCount: {
|
|
22
22
|
id: `${prefix}.charactersCount`,
|
|
23
|
-
defaultMessage: "Characters count {variableLength}/{
|
|
23
|
+
defaultMessage: "Characters count {variableLength}/{maxLength}",
|
|
24
24
|
},
|
|
25
25
|
maxMinLengthMessage: {
|
|
26
|
-
id: `${prefix}.
|
|
26
|
+
id: `${prefix}.maxMinLengthMessage`,
|
|
27
27
|
defaultMessage:
|
|
28
28
|
"Character count for this variable should be in between {minLength} to {maxLength}",
|
|
29
29
|
},
|
|
@@ -70,5 +70,17 @@ export default defineMessages({
|
|
|
70
70
|
PENDING_REVIEW: {
|
|
71
71
|
id: `${prefix}.PENDING_REVIEW`,
|
|
72
72
|
defaultMessage: 'pending review',
|
|
73
|
-
}
|
|
73
|
+
},
|
|
74
|
+
zaloFailureNotificationTemplate: {
|
|
75
|
+
id: `${prefix}.zaloFailureNotificationTemplate`,
|
|
76
|
+
defaultMessage: 'Unable to load zalo template',
|
|
77
|
+
},
|
|
78
|
+
zaloFailureNotificationPreview: {
|
|
79
|
+
id: `${prefix}.zaloFailureNotificationPreview`,
|
|
80
|
+
defaultMessage: 'Unable to load zalo preview',
|
|
81
|
+
},
|
|
82
|
+
btnDisabledTooltip: {
|
|
83
|
+
id: `${prefix}.btnDisabledTooltip`,
|
|
84
|
+
defaultMessage: 'Please add all mandatory fields to proceed further',
|
|
85
|
+
},
|
|
74
86
|
});
|