@capillarytech/creatives-library 7.17.39-alpha.2 → 7.17.39-alpha.4
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/package.json +1 -1
- package/v2Containers/CreativesContainer/index.js +7 -0
- package/v2Containers/Templates/messages.js +1 -1
- package/v2Containers/Zalo/index.js +39 -14
- package/v2Containers/Zalo/messages.js +1 -1
- package/v2Containers/Zalo/tests/index.test.js +4 -32
- package/v2Containers/Zalo/tests/mockData.js +10 -55
package/package.json
CHANGED
|
@@ -504,6 +504,6 @@ export default defineMessages({
|
|
|
504
504
|
},
|
|
505
505
|
"zaloOnlyApprovedTemplates": {
|
|
506
506
|
id: `${scope}.zaloOnlyApprovedTemplates`,
|
|
507
|
-
defaultMessage: 'Only enabled templates are shown here',
|
|
507
|
+
defaultMessage: 'Only enabled/approved templates are shown here',
|
|
508
508
|
},
|
|
509
509
|
});
|
|
@@ -80,6 +80,7 @@ export const Zalo = (props) => {
|
|
|
80
80
|
const [textAreaId, updateTextAreaId] = useState('');
|
|
81
81
|
const { zaloTemplateInfoValue = {}, zaloTemplateInfoStatus = REQUEST } =
|
|
82
82
|
editData;
|
|
83
|
+
const { _id, templateConfigs: { varMapped = {} } = {} } = templateData;
|
|
83
84
|
const ZaloFooter = styled.div`
|
|
84
85
|
background-color: ${CAP_WHITE};
|
|
85
86
|
position: fixed;
|
|
@@ -111,39 +112,63 @@ export const Zalo = (props) => {
|
|
|
111
112
|
|
|
112
113
|
//gets template details
|
|
113
114
|
useEffect(() => {
|
|
114
|
-
|
|
115
|
-
if (id && oa_id && token && username) {
|
|
115
|
+
if (_id && oa_id && token && username && isEmpty(varMapped)) {
|
|
116
116
|
actions.getTemplateInfoById({
|
|
117
117
|
username,
|
|
118
118
|
oa_id,
|
|
119
119
|
token,
|
|
120
|
-
id,
|
|
120
|
+
id: _id,
|
|
121
121
|
actionCallback,
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
|
-
}, [
|
|
124
|
+
}, [_id, oa_id, token, username]);
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
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) => {
|
|
128
139
|
const {
|
|
129
140
|
name = '',
|
|
130
|
-
_id = '',
|
|
141
|
+
_id: id = '',
|
|
131
142
|
versions: {
|
|
132
143
|
base: {
|
|
133
144
|
content: {
|
|
134
|
-
zalo: {
|
|
145
|
+
zalo: {
|
|
146
|
+
listParams: paramsData = [],
|
|
147
|
+
previewUrl = '',
|
|
148
|
+
status = '',
|
|
149
|
+
} = {},
|
|
135
150
|
} = {},
|
|
136
151
|
} = {},
|
|
137
152
|
} = {},
|
|
138
153
|
} = zaloTemplateInfoValue;
|
|
139
154
|
setTemplateName(name);
|
|
140
|
-
setTemplateId(
|
|
141
|
-
setTemplateListParams(
|
|
155
|
+
setTemplateId(id);
|
|
156
|
+
setTemplateListParams(setValues ? handleSetValues(paramsData) : paramsData);
|
|
142
157
|
setTemplatePreviewUrl(previewUrl);
|
|
143
158
|
setZaloTemplateStatus(status);
|
|
144
|
-
updateTextAreaId(
|
|
159
|
+
updateTextAreaId(paramsData[0]?.name);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// in creatives
|
|
163
|
+
useEffect(() => {
|
|
164
|
+
isFullMode && !isEmpty(zaloTemplateInfoValue) && setDataForEdit(false);
|
|
145
165
|
}, [zaloTemplateInfoValue]);
|
|
146
166
|
|
|
167
|
+
// in campaigns
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
!isFullMode && !isEmpty(varMapped) && setDataForEdit(true);
|
|
170
|
+
}, [varMapped]);
|
|
171
|
+
|
|
147
172
|
useEffect(() => {
|
|
148
173
|
let tag = get(metaEntities, `tags.standard`, []);
|
|
149
174
|
const { type, module } = location?.query || {};
|
|
@@ -319,10 +344,10 @@ export const Zalo = (props) => {
|
|
|
319
344
|
return disableCheck;
|
|
320
345
|
};
|
|
321
346
|
const createPayload = () => {
|
|
322
|
-
const
|
|
347
|
+
const varMap = {};
|
|
323
348
|
templateListParams.forEach((listParam) => {
|
|
324
349
|
const { name, value } = listParam;
|
|
325
|
-
|
|
350
|
+
varMap[name] = value;
|
|
326
351
|
});
|
|
327
352
|
const payload = {
|
|
328
353
|
channel: ZALO,
|
|
@@ -332,7 +357,7 @@ export const Zalo = (props) => {
|
|
|
332
357
|
_id: templateId,
|
|
333
358
|
name: templateName,
|
|
334
359
|
template: templatePreviewUrl,
|
|
335
|
-
varMapped,
|
|
360
|
+
varMapped: varMap,
|
|
336
361
|
},
|
|
337
362
|
};
|
|
338
363
|
return payload;
|
|
@@ -28,7 +28,7 @@ export default defineMessages({
|
|
|
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: {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
injectedTags,
|
|
14
14
|
accountData,
|
|
15
15
|
templateData,
|
|
16
|
+
templateConfigs,
|
|
16
17
|
} from './mockData';
|
|
17
18
|
import { render, screen, fireEvent } from '../../../utils/test-utils';
|
|
18
19
|
|
|
@@ -112,7 +113,8 @@ describe('Test activity zalo container', () => {
|
|
|
112
113
|
).toBeInTheDocument();
|
|
113
114
|
});
|
|
114
115
|
|
|
115
|
-
it('test case for
|
|
116
|
+
it('test case for set template data', async () => {
|
|
117
|
+
templateData.templateConfigs = templateConfigs;
|
|
116
118
|
renderComponent({
|
|
117
119
|
actions: mockActions,
|
|
118
120
|
globalActions: mockGlobalActions,
|
|
@@ -141,34 +143,4 @@ describe('Test activity zalo container', () => {
|
|
|
141
143
|
),
|
|
142
144
|
).toBeInTheDocument();
|
|
143
145
|
});
|
|
144
|
-
|
|
145
|
-
it('test case for length check', async () => {
|
|
146
|
-
renderComponent({
|
|
147
|
-
actions: mockActions,
|
|
148
|
-
globalActions: mockGlobalActions,
|
|
149
|
-
editData,
|
|
150
|
-
metaEntities,
|
|
151
|
-
location,
|
|
152
|
-
getDefaultTags,
|
|
153
|
-
injectedTags,
|
|
154
|
-
accountData,
|
|
155
|
-
templateData,
|
|
156
|
-
isFullMode: true,
|
|
157
|
-
});
|
|
158
|
-
const inputBox = await screen.findAllByPlaceholderText(
|
|
159
|
-
'Add labels or text or combination of both',
|
|
160
|
-
);
|
|
161
|
-
fireEvent.change(inputBox[0], {
|
|
162
|
-
target: {
|
|
163
|
-
value:
|
|
164
|
-
'Hello, welcome user. Habata itara modoranai to ittta Mezashita no wa aoi aoi ano sora',
|
|
165
|
-
},
|
|
166
|
-
});
|
|
167
|
-
inputBox[0].focus();
|
|
168
|
-
expect(
|
|
169
|
-
screen.getByText(
|
|
170
|
-
'Character count for this variable should be in between 0 to 30',
|
|
171
|
-
),
|
|
172
|
-
).toBeInTheDocument();
|
|
173
|
-
});
|
|
174
|
-
});
|
|
146
|
+
});
|
|
@@ -11466,61 +11466,16 @@ export const accountData = {
|
|
|
11466
11466
|
|
|
11467
11467
|
export const templateData = {
|
|
11468
11468
|
_id: 463745,
|
|
11469
|
+
};
|
|
11470
|
+
|
|
11471
|
+
export const templateConfigs = {
|
|
11472
|
+
_id: 268532,
|
|
11469
11473
|
name: 'Test QR - Thông báo thanh toán thành công',
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
listParams: [
|
|
11477
|
-
{
|
|
11478
|
-
name: 'danh_xung',
|
|
11479
|
-
require: true,
|
|
11480
|
-
type: 'STRING',
|
|
11481
|
-
maxLength: 30,
|
|
11482
|
-
minLength: 0,
|
|
11483
|
-
acceptNull: false,
|
|
11484
|
-
error: '',
|
|
11485
|
-
value: '',
|
|
11486
|
-
},
|
|
11487
|
-
{
|
|
11488
|
-
name: 'name',
|
|
11489
|
-
require: true,
|
|
11490
|
-
type: 'STRING',
|
|
11491
|
-
maxLength: 20,
|
|
11492
|
-
minLength: 0,
|
|
11493
|
-
acceptNull: false,
|
|
11494
|
-
error: '',
|
|
11495
|
-
value: '',
|
|
11496
|
-
},
|
|
11497
|
-
{
|
|
11498
|
-
name: 'ma_so',
|
|
11499
|
-
require: true,
|
|
11500
|
-
type: 'NUMBER',
|
|
11501
|
-
maxLength: 10,
|
|
11502
|
-
minLength: 0,
|
|
11503
|
-
acceptNull: false,
|
|
11504
|
-
error: '',
|
|
11505
|
-
value: '',
|
|
11506
|
-
},
|
|
11507
|
-
{
|
|
11508
|
-
name: 'ma_so1',
|
|
11509
|
-
require: true,
|
|
11510
|
-
type: 'DATE',
|
|
11511
|
-
maxLength: 30,
|
|
11512
|
-
minLength: 0,
|
|
11513
|
-
acceptNull: false,
|
|
11514
|
-
error: '',
|
|
11515
|
-
value: '',
|
|
11516
|
-
},
|
|
11517
|
-
],
|
|
11518
|
-
previewUrl:
|
|
11519
|
-
'https://account.zalo.cloud/znspreview/-e0cMil4NU5WUUAVzP7T_g==',
|
|
11520
|
-
status: 'ENABLE',
|
|
11521
|
-
},
|
|
11522
|
-
},
|
|
11523
|
-
},
|
|
11474
|
+
template: 'https://account.zalo.cloud/znspreview/-e0cMil4NU5WUUAVzP7T_g==',
|
|
11475
|
+
varMapped: {
|
|
11476
|
+
danh_xung: '1',
|
|
11477
|
+
name: '2',
|
|
11478
|
+
ma_so: '3',
|
|
11479
|
+
ma_so1: '4',
|
|
11524
11480
|
},
|
|
11525
|
-
type: 'ZALO',
|
|
11526
11481
|
};
|