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