@capillarytech/creatives-library 7.17.177 → 7.17.178
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/services/api.js +2 -2
- package/v2Containers/CreativesContainer/index.js +2 -0
- package/v2Containers/Templates/index.js +20 -7
- package/v2Containers/Templates/sagas.js +2 -1
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +87 -522
- package/v2Containers/Templates/tests/index.test.js +1 -0
- package/v2Containers/Templates/tests/sagas.test.js +54 -1
- package/v2Containers/Zalo/index.js +11 -8
- package/v2Containers/Zalo/selectors.js +1 -1
- package/v2Containers/Zalo/tests/mockData.js +46 -0
- package/v2Containers/Zalo/tests/selector.test.js +3 -3
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -525,8 +525,8 @@ export const getS3UrlFileSizes = (data) => {
|
|
|
525
525
|
return request(url, getAPICallObject('POST', data));
|
|
526
526
|
};
|
|
527
527
|
|
|
528
|
-
export const getTemplateInfoById = ({id, username, oa_id, token}) => {
|
|
529
|
-
const url = `${API_ENDPOINT}/templates/v1/${id}/Zalo?username=${username}&oa_id=${oa_id}&token=${token}`;
|
|
528
|
+
export const getTemplateInfoById = ({id, username, oa_id, token, host}) => {
|
|
529
|
+
const url = `${API_ENDPOINT}/templates/v1/${id}/Zalo?username=${username}&oa_id=${oa_id}&token=${token}&host=${host}`;
|
|
530
530
|
const compressedTemplatesData = request(url, getAPICallObject('GET'));
|
|
531
531
|
return compressedTemplatesData.then((data) => {
|
|
532
532
|
const { response = '' } = data || {};
|
|
@@ -124,10 +124,12 @@ export class Creatives extends React.Component {
|
|
|
124
124
|
sourceAccountIdentifier = "",
|
|
125
125
|
configs: { token = "" } = {},
|
|
126
126
|
} = get(this.props, "Templates.selectedZaloAccount", {});
|
|
127
|
+
const { hostName = ''} = get(this.props, "Templates.senderDetails", {});
|
|
127
128
|
this.props.zaloActions.getTemplateInfoById({
|
|
128
129
|
username: name,
|
|
129
130
|
oa_id: sourceAccountIdentifier,
|
|
130
131
|
token,
|
|
132
|
+
host: hostName,
|
|
131
133
|
id: template?._id,
|
|
132
134
|
preview: true,
|
|
133
135
|
actionCallback: this.actionCallback,
|
|
@@ -305,6 +305,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
305
305
|
channel = 'Zalo';
|
|
306
306
|
activeMode = ACCOUNT_SELECTION_MODE;
|
|
307
307
|
this.props.actions.getWeCrmAccounts(channel);
|
|
308
|
+
this.props.actions.getSenderDetails({
|
|
309
|
+
channel: ZALO,
|
|
310
|
+
orgUnitId: -1,
|
|
311
|
+
});
|
|
308
312
|
break;
|
|
309
313
|
default:
|
|
310
314
|
channel = '';
|
|
@@ -619,18 +623,19 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
619
623
|
wecrm_token
|
|
620
624
|
} = configs || {};
|
|
621
625
|
if (weCrmChannels.includes(selectedChannel)) {
|
|
622
|
-
if ([WHATSAPP_LOWERCASE].includes(selectedChannel)) {
|
|
626
|
+
if ([WHATSAPP_LOWERCASE, ZALO_LOWERCASE].includes(selectedChannel)) {
|
|
623
627
|
if (hostName === '') {
|
|
624
628
|
return;
|
|
625
629
|
}
|
|
626
630
|
|
|
627
631
|
weCrmAccountsList[0].hostName = hostName;
|
|
628
632
|
nextProps.actions.setChannelAccount(selectedChannel.toUpperCase(), weCrmAccountsList[0]);
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
633
|
+
if (selectedChannel === ZALO_LOWERCASE) {
|
|
634
|
+
paramsDefault.username = name;
|
|
635
|
+
paramsDefault.oa_id = sourceAccountIdentifier;
|
|
636
|
+
paramsDefault.token = token;
|
|
637
|
+
paramsDefault.host = hostName || this.state.hostName;
|
|
638
|
+
}
|
|
634
639
|
} else {
|
|
635
640
|
paramsDefault.wecrmId = wecrm_app_id;
|
|
636
641
|
paramsDefault.wecrmToken = wecrm_token;
|
|
@@ -641,7 +646,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
641
646
|
}
|
|
642
647
|
|
|
643
648
|
}
|
|
644
|
-
this.setState({ defaultAccount: false, activeMode: TEMPLATES_MODE, selectedAccount: weCrmAccountsList[0].name, hostName });
|
|
649
|
+
this.setState({ defaultAccount: false, activeMode: TEMPLATES_MODE, selectedAccount: weCrmAccountsList[0].name, hostName: weCrmAccountsList[0].hostName });
|
|
645
650
|
this.getAllTemplates({params: paramsDefault}, true);
|
|
646
651
|
}
|
|
647
652
|
const zaloPreviewUrl = get(nextProps, 'Zalo.zaloTemplatePreviewData.versions.base.content.zalo.previewUrl', '');
|
|
@@ -695,11 +700,13 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
695
700
|
name = "",
|
|
696
701
|
sourceAccountIdentifier = "",
|
|
697
702
|
configs: { token = "" } = {},
|
|
703
|
+
hostName = "",
|
|
698
704
|
} = setAcc || {};
|
|
699
705
|
params.username = name;
|
|
700
706
|
params.oa_id = sourceAccountIdentifier;
|
|
701
707
|
params.token = token;
|
|
702
708
|
params.isAccountSelection = true;
|
|
709
|
+
params.host = hostName || this.state.hostName;
|
|
703
710
|
}
|
|
704
711
|
}
|
|
705
712
|
|
|
@@ -799,6 +806,8 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
799
806
|
if(this.state.channel.toLowerCase() !== ZALO_LOWERCASE) {
|
|
800
807
|
queryParams.name = this.state.searchText;
|
|
801
808
|
queryParams.sortBy = this.state.sortBy;
|
|
809
|
+
} else {
|
|
810
|
+
queryParams.host = this.props.Templates?.senderDetails?.hostName || this.props.Templates?.selectedZaloAccount?.hostName;
|
|
802
811
|
}
|
|
803
812
|
queryParams.page = this.state.page;
|
|
804
813
|
queryParams.perPage = this.state.perPageLimit;
|
|
@@ -853,10 +862,12 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
853
862
|
name = "",
|
|
854
863
|
sourceAccountIdentifier = "",
|
|
855
864
|
configs: { token = "" } = {},
|
|
865
|
+
hostName = "",
|
|
856
866
|
} = get(this.props, "Templates.selectedZaloAccount", {});
|
|
857
867
|
queryParams.username = name;
|
|
858
868
|
queryParams.oa_id = sourceAccountIdentifier;
|
|
859
869
|
queryParams.token = token;
|
|
870
|
+
queryParams.host = hostName || this.state.hostName;
|
|
860
871
|
}
|
|
861
872
|
this.setState({ page, templatesCount }, () => {
|
|
862
873
|
queryParams.page = page;
|
|
@@ -2102,11 +2113,13 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2102
2113
|
name = "",
|
|
2103
2114
|
sourceAccountIdentifier = "",
|
|
2104
2115
|
configs: { token = "" } = {},
|
|
2116
|
+
hostName = "",
|
|
2105
2117
|
} = get(this.props, "Templates.selectedZaloAccount", {});
|
|
2106
2118
|
this.props.zaloActions.getTemplateInfoById({
|
|
2107
2119
|
username: name,
|
|
2108
2120
|
oa_id: sourceAccountIdentifier,
|
|
2109
2121
|
token: token,
|
|
2122
|
+
host: hostName || this.state.hostName,
|
|
2110
2123
|
id: template?._id,
|
|
2111
2124
|
preview: true,
|
|
2112
2125
|
actionCallback: this.actionCallback,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import get from 'lodash/get';
|
|
1
2
|
import { call, put, takeLatest, take, cancel, select } from 'redux-saga/effects';
|
|
2
3
|
import { LOCATION_CHANGE } from 'react-router-redux';
|
|
3
4
|
// import { schema, normalize } from 'normalizr';
|
|
@@ -176,7 +177,7 @@ export function* getSenderDetails({
|
|
|
176
177
|
if (!apiResponse?.errors?.length) {
|
|
177
178
|
yield put({
|
|
178
179
|
type: types.GET_SENDER_DETAILS_SUCCESS,
|
|
179
|
-
payload: apiResponse
|
|
180
|
+
payload: get(apiResponse, `entity.${channel}[0].domainProperties.hostName`, ''),
|
|
180
181
|
});
|
|
181
182
|
} else {
|
|
182
183
|
yield put({
|
|
@@ -87,380 +87,53 @@ exports[`Test Templates container Should render illustration when no templates a
|
|
|
87
87
|
`;
|
|
88
88
|
|
|
89
89
|
exports[`Test Templates container Should render temlates when Zalo templates are passed in full mode 1`] = `
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
data={
|
|
136
|
-
Array [
|
|
137
|
-
Object {
|
|
138
|
-
"key": "enable",
|
|
139
|
-
"label": <FormattedMessage
|
|
140
|
-
defaultMessage="Enable"
|
|
141
|
-
id="creatives.containersV2.zalo.ENABLE_STATUS"
|
|
142
|
-
values={Object {}}
|
|
143
|
-
/>,
|
|
144
|
-
"value": "ENABLE",
|
|
145
|
-
},
|
|
146
|
-
Object {
|
|
147
|
-
"key": "reject",
|
|
148
|
-
"label": <FormattedMessage
|
|
149
|
-
defaultMessage="Reject"
|
|
150
|
-
id="creatives.containersV2.zalo.REJECT_STATUS"
|
|
151
|
-
values={Object {}}
|
|
152
|
-
/>,
|
|
153
|
-
"value": "REJECT",
|
|
154
|
-
},
|
|
155
|
-
Object {
|
|
156
|
-
"key": "disable",
|
|
157
|
-
"label": <FormattedMessage
|
|
158
|
-
defaultMessage="Disable"
|
|
159
|
-
id="creatives.containersV2.zalo.DISABLE_STATUS"
|
|
160
|
-
values={Object {}}
|
|
161
|
-
/>,
|
|
162
|
-
"value": "DISABLE",
|
|
163
|
-
},
|
|
164
|
-
Object {
|
|
165
|
-
"key": "reviewPending",
|
|
166
|
-
"label": <FormattedMessage
|
|
167
|
-
defaultMessage="Review Pending"
|
|
168
|
-
id="creatives.containersV2.zalo.PENDING_REVIEW_STATUS"
|
|
169
|
-
values={Object {}}
|
|
170
|
-
/>,
|
|
171
|
-
"value": "PENDING_REVIEW",
|
|
172
|
-
},
|
|
173
|
-
]
|
|
174
|
-
}
|
|
175
|
-
dropdownMaxHeight="320px"
|
|
176
|
-
dropdownWidth="228px"
|
|
177
|
-
onSelect={[Function]}
|
|
178
|
-
placeholder="Status"
|
|
179
|
-
placement="bottomLeft"
|
|
180
|
-
selectedValue=""
|
|
181
|
-
width="90px"
|
|
182
|
-
/>
|
|
183
|
-
</div>
|
|
184
|
-
<Component />
|
|
185
|
-
<Component />
|
|
186
|
-
<div
|
|
187
|
-
style={
|
|
188
|
-
Object {
|
|
189
|
-
"alignItems": "center",
|
|
190
|
-
"display": "flex",
|
|
191
|
-
"justifyContent": "space-between",
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
/>
|
|
195
|
-
</div>
|
|
196
|
-
<CapRow
|
|
197
|
-
align="middle"
|
|
198
|
-
className="selected-whatsapp-filters"
|
|
199
|
-
type="flex"
|
|
200
|
-
/>
|
|
201
|
-
<CapSpin
|
|
202
|
-
spinning={false}
|
|
203
|
-
style={
|
|
204
|
-
Object {
|
|
205
|
-
"width": "100%",
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
tip="Getting all templates..."
|
|
209
|
-
>
|
|
210
|
-
<div>
|
|
211
|
-
<div
|
|
212
|
-
className="pagination-container"
|
|
213
|
-
>
|
|
214
|
-
<CapCustomCardList
|
|
215
|
-
cardList={
|
|
216
|
-
Array [
|
|
217
|
-
Object {
|
|
218
|
-
"content": <CapLabel
|
|
219
|
-
className="zalo-listing-content desc"
|
|
220
|
-
type="label19"
|
|
221
|
-
>
|
|
222
|
-
Test1
|
|
223
|
-
</CapLabel>,
|
|
224
|
-
"extra": Array [
|
|
225
|
-
<CapTooltip
|
|
226
|
-
title={
|
|
227
|
-
<div
|
|
228
|
-
className="zalo-view-tooltip"
|
|
229
|
-
>
|
|
230
|
-
Open preview in new tab
|
|
231
|
-
</div>
|
|
232
|
-
}
|
|
233
|
-
>
|
|
234
|
-
<CapIcon
|
|
235
|
-
className="view-zalo"
|
|
236
|
-
onClick={[Function]}
|
|
237
|
-
style={
|
|
238
|
-
Object {
|
|
239
|
-
"marginRight": "16px",
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
type="eye"
|
|
243
|
-
/>
|
|
244
|
-
</CapTooltip>,
|
|
245
|
-
<CapDropdown
|
|
246
|
-
overlay={
|
|
247
|
-
<CapMenu>
|
|
248
|
-
<withItemHOC
|
|
249
|
-
className="duplicate-zalo"
|
|
250
|
-
onClick={[Function]}
|
|
251
|
-
>
|
|
252
|
-
<FormattedMessage
|
|
253
|
-
defaultMessage="Duplicate"
|
|
254
|
-
id="creatives.containersV2.Templates.duplicateButton"
|
|
255
|
-
values={Object {}}
|
|
256
|
-
/>
|
|
257
|
-
</withItemHOC>
|
|
258
|
-
<withItemHOC
|
|
259
|
-
className="delete-zalo"
|
|
260
|
-
onClick={[Function]}
|
|
261
|
-
>
|
|
262
|
-
<FormattedMessage
|
|
263
|
-
defaultMessage="Delete"
|
|
264
|
-
id="creatives.containersV2.Templates.deleteButton"
|
|
265
|
-
values={Object {}}
|
|
266
|
-
/>
|
|
267
|
-
</withItemHOC>
|
|
268
|
-
</CapMenu>
|
|
269
|
-
}
|
|
270
|
-
>
|
|
271
|
-
<React.Fragment />
|
|
272
|
-
</CapDropdown>,
|
|
273
|
-
],
|
|
274
|
-
"hoverOption": <CapButton
|
|
275
|
-
className="edit-zalo"
|
|
276
|
-
isAddBtn={false}
|
|
277
|
-
onClick={[Function]}
|
|
278
|
-
type="primary"
|
|
279
|
-
>
|
|
280
|
-
Overview
|
|
281
|
-
</CapButton>,
|
|
282
|
-
"key": "ZALO-card-Test1",
|
|
283
|
-
"title": <CapRow>
|
|
284
|
-
<CapLabel
|
|
285
|
-
className="zalo-template-name"
|
|
286
|
-
type="label1"
|
|
287
|
-
>
|
|
288
|
-
|
|
289
|
-
</CapLabel>
|
|
290
|
-
<CapRow
|
|
291
|
-
align="middle"
|
|
292
|
-
className="zalo-status-container zalo-status-color"
|
|
293
|
-
type="flex"
|
|
294
|
-
>
|
|
295
|
-
<CapStatus
|
|
296
|
-
color=""
|
|
297
|
-
height="0.571rem"
|
|
298
|
-
labelType="label3"
|
|
299
|
-
text=""
|
|
300
|
-
type="pending"
|
|
301
|
-
width="0.571rem"
|
|
302
|
-
/>
|
|
303
|
-
</CapRow>
|
|
304
|
-
</CapRow>,
|
|
305
|
-
},
|
|
306
|
-
Object {
|
|
307
|
-
"content": <CapLabel
|
|
308
|
-
className="zalo-listing-content desc"
|
|
309
|
-
type="label19"
|
|
310
|
-
>
|
|
311
|
-
Test2
|
|
312
|
-
</CapLabel>,
|
|
313
|
-
"extra": Array [
|
|
314
|
-
<CapTooltip
|
|
315
|
-
title={
|
|
316
|
-
<div
|
|
317
|
-
className="zalo-view-tooltip"
|
|
318
|
-
>
|
|
319
|
-
Open preview in new tab
|
|
320
|
-
</div>
|
|
321
|
-
}
|
|
322
|
-
>
|
|
323
|
-
<CapIcon
|
|
324
|
-
className="view-zalo"
|
|
325
|
-
onClick={[Function]}
|
|
326
|
-
style={
|
|
327
|
-
Object {
|
|
328
|
-
"marginRight": "16px",
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
type="eye"
|
|
332
|
-
/>
|
|
333
|
-
</CapTooltip>,
|
|
334
|
-
<CapDropdown
|
|
335
|
-
overlay={
|
|
336
|
-
<CapMenu>
|
|
337
|
-
<withItemHOC
|
|
338
|
-
className="duplicate-zalo"
|
|
339
|
-
onClick={[Function]}
|
|
340
|
-
>
|
|
341
|
-
<FormattedMessage
|
|
342
|
-
defaultMessage="Duplicate"
|
|
343
|
-
id="creatives.containersV2.Templates.duplicateButton"
|
|
344
|
-
values={Object {}}
|
|
345
|
-
/>
|
|
346
|
-
</withItemHOC>
|
|
347
|
-
<withItemHOC
|
|
348
|
-
className="delete-zalo"
|
|
349
|
-
onClick={[Function]}
|
|
350
|
-
>
|
|
351
|
-
<FormattedMessage
|
|
352
|
-
defaultMessage="Delete"
|
|
353
|
-
id="creatives.containersV2.Templates.deleteButton"
|
|
354
|
-
values={Object {}}
|
|
355
|
-
/>
|
|
356
|
-
</withItemHOC>
|
|
357
|
-
</CapMenu>
|
|
358
|
-
}
|
|
359
|
-
>
|
|
360
|
-
<React.Fragment />
|
|
361
|
-
</CapDropdown>,
|
|
362
|
-
],
|
|
363
|
-
"hoverOption": <CapButton
|
|
364
|
-
className="edit-zalo"
|
|
365
|
-
isAddBtn={false}
|
|
366
|
-
onClick={[Function]}
|
|
367
|
-
type="primary"
|
|
368
|
-
>
|
|
369
|
-
Overview
|
|
370
|
-
</CapButton>,
|
|
371
|
-
"key": "ZALO-card-Test2",
|
|
372
|
-
"title": <CapRow>
|
|
373
|
-
<CapLabel
|
|
374
|
-
className="zalo-template-name"
|
|
375
|
-
type="label1"
|
|
376
|
-
>
|
|
377
|
-
|
|
378
|
-
</CapLabel>
|
|
379
|
-
<CapRow
|
|
380
|
-
align="middle"
|
|
381
|
-
className="zalo-status-container zalo-status-color"
|
|
382
|
-
type="flex"
|
|
383
|
-
>
|
|
384
|
-
<CapStatus
|
|
385
|
-
color=""
|
|
386
|
-
height="0.571rem"
|
|
387
|
-
labelType="label3"
|
|
388
|
-
text=""
|
|
389
|
-
type="pending"
|
|
390
|
-
width="0.571rem"
|
|
391
|
-
/>
|
|
392
|
-
</CapRow>
|
|
393
|
-
</CapRow>,
|
|
394
|
-
},
|
|
395
|
-
]
|
|
396
|
-
}
|
|
397
|
-
fbType="list"
|
|
398
|
-
key="ZALO-card-list"
|
|
399
|
-
style={
|
|
400
|
-
Object {
|
|
401
|
-
"marginLeft": "16px",
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
type="ZALO"
|
|
405
|
-
/>
|
|
406
|
-
</div>
|
|
407
|
-
<div
|
|
408
|
-
style={
|
|
409
|
-
Object {
|
|
410
|
-
"height": "calc(100vh - 325px)",
|
|
411
|
-
"overflow": "auto",
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
/>
|
|
415
|
-
</div>
|
|
416
|
-
</CapSpin>
|
|
417
|
-
</div>
|
|
418
|
-
</Pagination>
|
|
419
|
-
</CapRow>
|
|
420
|
-
<CapRow />
|
|
421
|
-
<CapRow>
|
|
422
|
-
<CapSlideBox
|
|
423
|
-
closeIconPosition="right"
|
|
424
|
-
closeIconSize="m"
|
|
425
|
-
closeIconType="close"
|
|
426
|
-
content={
|
|
427
|
-
<CardGrid
|
|
428
|
-
className=""
|
|
429
|
-
colNumber={2}
|
|
430
|
-
gutterSize={16}
|
|
431
|
-
isLoading={false}
|
|
432
|
-
listItem={Array []}
|
|
433
|
-
onHoverItem={[Function]}
|
|
434
|
-
onItemClick={[Function]}
|
|
435
|
-
/>
|
|
436
|
-
}
|
|
437
|
-
handleClose={[Function]}
|
|
438
|
-
header={
|
|
439
|
-
<h3>
|
|
440
|
-
Select layout
|
|
441
|
-
</h3>
|
|
442
|
-
}
|
|
443
|
-
loadingText="Loading EDM Templates"
|
|
444
|
-
position="right"
|
|
445
|
-
show={false}
|
|
446
|
-
size="size-r"
|
|
447
|
-
width={60}
|
|
448
|
-
/>
|
|
449
|
-
<InjectIntl(Wrapper)
|
|
450
|
-
centered={true}
|
|
451
|
-
className="delete-template-confirm"
|
|
452
|
-
closeText="Cancel"
|
|
453
|
-
okText="Yes, delete"
|
|
454
|
-
onCancel={[Function]}
|
|
455
|
-
onOk={[Function]}
|
|
456
|
-
title="Confirm delete template"
|
|
457
|
-
visible={false}
|
|
458
|
-
>
|
|
459
|
-
Are you sure you wish to delete this template?
|
|
460
|
-
</InjectIntl(Wrapper)>
|
|
461
|
-
</CapRow>
|
|
90
|
+
<CapSpin
|
|
91
|
+
spinning={false}
|
|
92
|
+
>
|
|
93
|
+
<div
|
|
94
|
+
style={
|
|
95
|
+
Object {
|
|
96
|
+
"overflowX": "auto",
|
|
97
|
+
"paddingBottom": "1.142rem",
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
>
|
|
101
|
+
<CapHeader
|
|
102
|
+
className="select-account-header"
|
|
103
|
+
description="Choose the account to send content"
|
|
104
|
+
descriptionClass=""
|
|
105
|
+
inline={false}
|
|
106
|
+
size="regular"
|
|
107
|
+
title="Zalo account"
|
|
108
|
+
titleClass=""
|
|
109
|
+
/>
|
|
110
|
+
<CapRadioCard
|
|
111
|
+
cardHeight="48px"
|
|
112
|
+
cardWidth="276px"
|
|
113
|
+
className="select-account"
|
|
114
|
+
defaultValue=""
|
|
115
|
+
onChange={[Function]}
|
|
116
|
+
panes={
|
|
117
|
+
Array [
|
|
118
|
+
Object {
|
|
119
|
+
"icon": <CapIconAvatar
|
|
120
|
+
backgroundProps={Object {}}
|
|
121
|
+
height="2rem"
|
|
122
|
+
labelProps={Object {}}
|
|
123
|
+
text="c"
|
|
124
|
+
width="auto"
|
|
125
|
+
/>,
|
|
126
|
+
"key": "fa66f53ca2bb4b93b02dfc5bd265e2fd",
|
|
127
|
+
"title": "capillary_zns",
|
|
128
|
+
"value": "capillary_zns",
|
|
129
|
+
},
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
selected=""
|
|
133
|
+
size="small"
|
|
134
|
+
/>
|
|
462
135
|
</div>
|
|
463
|
-
</
|
|
136
|
+
</CapSpin>
|
|
464
137
|
`;
|
|
465
138
|
|
|
466
139
|
exports[`Test Templates container Should render temlates when whatsapp templates are passed 1`] = `
|
|
@@ -998,161 +671,53 @@ exports[`Test Templates container Should render temlates when whatsapp templates
|
|
|
998
671
|
`;
|
|
999
672
|
|
|
1000
673
|
exports[`Test Templates container Should render temlates when zalo templates are passed 1`] = `
|
|
1001
|
-
<
|
|
674
|
+
<CapSpin
|
|
675
|
+
spinning={false}
|
|
676
|
+
>
|
|
1002
677
|
<div
|
|
1003
|
-
|
|
678
|
+
style={
|
|
679
|
+
Object {
|
|
680
|
+
"overflowX": "auto",
|
|
681
|
+
"paddingBottom": "1.142rem",
|
|
682
|
+
}
|
|
683
|
+
}
|
|
1004
684
|
>
|
|
1005
|
-
<
|
|
1006
|
-
|
|
1007
|
-
|
|
685
|
+
<CapHeader
|
|
686
|
+
className="select-account-header"
|
|
687
|
+
description="Choose the account to send content"
|
|
688
|
+
descriptionClass=""
|
|
689
|
+
inline={false}
|
|
690
|
+
size="regular"
|
|
691
|
+
title="Zalo account"
|
|
692
|
+
titleClass=""
|
|
693
|
+
/>
|
|
694
|
+
<CapRadioCard
|
|
695
|
+
cardHeight="48px"
|
|
696
|
+
cardWidth="276px"
|
|
697
|
+
className="select-account"
|
|
698
|
+
defaultValue=""
|
|
1008
699
|
onChange={[Function]}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
700
|
+
panes={
|
|
701
|
+
Array [
|
|
702
|
+
Object {
|
|
703
|
+
"icon": <CapIconAvatar
|
|
704
|
+
backgroundProps={Object {}}
|
|
705
|
+
height="2rem"
|
|
706
|
+
labelProps={Object {}}
|
|
707
|
+
text="c"
|
|
708
|
+
width="auto"
|
|
709
|
+
/>,
|
|
710
|
+
"key": "fa66f53ca2bb4b93b02dfc5bd265e2fd",
|
|
711
|
+
"title": "capillary_zns",
|
|
712
|
+
"value": "capillary_zns",
|
|
713
|
+
},
|
|
714
|
+
]
|
|
1013
715
|
}
|
|
1014
|
-
|
|
716
|
+
selected=""
|
|
717
|
+
size="small"
|
|
1015
718
|
/>
|
|
1016
|
-
<CapRow>
|
|
1017
|
-
<Pagination
|
|
1018
|
-
onPageChange={[Function]}
|
|
1019
|
-
paginationContainer="pagination-container"
|
|
1020
|
-
paginationSelector="pagination-container"
|
|
1021
|
-
templateInProgress={false}
|
|
1022
|
-
>
|
|
1023
|
-
<div>
|
|
1024
|
-
<div
|
|
1025
|
-
className="action-container"
|
|
1026
|
-
>
|
|
1027
|
-
<_class
|
|
1028
|
-
className="search-text"
|
|
1029
|
-
disabled={false}
|
|
1030
|
-
labelPosition="top"
|
|
1031
|
-
onChange={[Function]}
|
|
1032
|
-
onClear={[Function]}
|
|
1033
|
-
onScroll={[Function]}
|
|
1034
|
-
placeholder="Search"
|
|
1035
|
-
style={
|
|
1036
|
-
Object {
|
|
1037
|
-
"width": "210px",
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
value=""
|
|
1041
|
-
/>
|
|
1042
|
-
<div
|
|
1043
|
-
className="zalo-filters"
|
|
1044
|
-
/>
|
|
1045
|
-
<Component />
|
|
1046
|
-
<Component />
|
|
1047
|
-
<div
|
|
1048
|
-
style={
|
|
1049
|
-
Object {
|
|
1050
|
-
"alignItems": "center",
|
|
1051
|
-
"display": "flex",
|
|
1052
|
-
"justifyContent": "space-between",
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
/>
|
|
1056
|
-
</div>
|
|
1057
|
-
<CapRow
|
|
1058
|
-
align="middle"
|
|
1059
|
-
className="selected-whatsapp-filters"
|
|
1060
|
-
type="flex"
|
|
1061
|
-
/>
|
|
1062
|
-
<CapSpin
|
|
1063
|
-
spinning={false}
|
|
1064
|
-
style={
|
|
1065
|
-
Object {
|
|
1066
|
-
"width": "100%",
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
tip="Getting all templates..."
|
|
1070
|
-
>
|
|
1071
|
-
<div>
|
|
1072
|
-
<div
|
|
1073
|
-
style={
|
|
1074
|
-
Object {
|
|
1075
|
-
"height": "calc(100vh - 325px)",
|
|
1076
|
-
"overflow": "auto",
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
>
|
|
1080
|
-
<CapHeader
|
|
1081
|
-
description={
|
|
1082
|
-
<CapLabel
|
|
1083
|
-
style={
|
|
1084
|
-
Object {
|
|
1085
|
-
"textAlign": "center",
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
type="label1"
|
|
1089
|
-
>
|
|
1090
|
-
Please try searching with another term or apply different filter
|
|
1091
|
-
</CapLabel>
|
|
1092
|
-
}
|
|
1093
|
-
descriptionClass=""
|
|
1094
|
-
inline={false}
|
|
1095
|
-
size="large"
|
|
1096
|
-
title={
|
|
1097
|
-
<CapHeading
|
|
1098
|
-
className="channel-specific-illustration-text"
|
|
1099
|
-
type="h3"
|
|
1100
|
-
>
|
|
1101
|
-
Sorry, we couldn’t find any matches
|
|
1102
|
-
</CapHeading>
|
|
1103
|
-
}
|
|
1104
|
-
titleClass=""
|
|
1105
|
-
/>
|
|
1106
|
-
</div>
|
|
1107
|
-
</div>
|
|
1108
|
-
</CapSpin>
|
|
1109
|
-
</div>
|
|
1110
|
-
</Pagination>
|
|
1111
|
-
</CapRow>
|
|
1112
|
-
<CapRow />
|
|
1113
|
-
<CapRow>
|
|
1114
|
-
<CapSlideBox
|
|
1115
|
-
closeIconPosition="right"
|
|
1116
|
-
closeIconSize="m"
|
|
1117
|
-
closeIconType="close"
|
|
1118
|
-
content={
|
|
1119
|
-
<CardGrid
|
|
1120
|
-
className=""
|
|
1121
|
-
colNumber={2}
|
|
1122
|
-
gutterSize={16}
|
|
1123
|
-
isLoading={false}
|
|
1124
|
-
listItem={Array []}
|
|
1125
|
-
onHoverItem={[Function]}
|
|
1126
|
-
onItemClick={[Function]}
|
|
1127
|
-
/>
|
|
1128
|
-
}
|
|
1129
|
-
handleClose={[Function]}
|
|
1130
|
-
header={
|
|
1131
|
-
<h3>
|
|
1132
|
-
Select layout
|
|
1133
|
-
</h3>
|
|
1134
|
-
}
|
|
1135
|
-
loadingText="Loading EDM Templates"
|
|
1136
|
-
position="right"
|
|
1137
|
-
show={false}
|
|
1138
|
-
size="size-r"
|
|
1139
|
-
width={60}
|
|
1140
|
-
/>
|
|
1141
|
-
<InjectIntl(Wrapper)
|
|
1142
|
-
centered={true}
|
|
1143
|
-
className="delete-template-confirm"
|
|
1144
|
-
closeText="Cancel"
|
|
1145
|
-
okText="Yes, delete"
|
|
1146
|
-
onCancel={[Function]}
|
|
1147
|
-
onOk={[Function]}
|
|
1148
|
-
title="Confirm delete template"
|
|
1149
|
-
visible={false}
|
|
1150
|
-
>
|
|
1151
|
-
Are you sure you wish to delete this template?
|
|
1152
|
-
</InjectIntl(Wrapper)>
|
|
1153
|
-
</CapRow>
|
|
1154
719
|
</div>
|
|
1155
|
-
</
|
|
720
|
+
</CapSpin>
|
|
1156
721
|
`;
|
|
1157
722
|
|
|
1158
723
|
exports[`Test Templates container Test max templates exceeded 1`] = `
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { expectSaga } from 'redux-saga-test-plan';
|
|
2
|
-
import { take, call, takeLatest, takeEvery } from 'redux-saga/effects';
|
|
2
|
+
import { take, call, takeLatest, takeEvery, put } from 'redux-saga/effects';
|
|
3
3
|
import * as matchers from 'redux-saga-test-plan/matchers';
|
|
4
4
|
import * as api from '../../../services/api';
|
|
5
5
|
import * as types from '../constants';
|
|
@@ -10,9 +10,12 @@ import {
|
|
|
10
10
|
getAllTemplates,
|
|
11
11
|
watchGetCdnTransformationConfig,
|
|
12
12
|
watchGetAllTemplates,
|
|
13
|
+
getSenderDetails,
|
|
13
14
|
} from '../sagas';
|
|
14
15
|
|
|
15
16
|
import * as mockData from './mockData';
|
|
17
|
+
import { ZALO } from '../../CreativesContainer/constants';
|
|
18
|
+
import { VIET_GUYS } from '../../Zalo/constants';
|
|
16
19
|
|
|
17
20
|
describe('getCdnTransformationConfig saga', () => {
|
|
18
21
|
it("handle valid response from api", () => {
|
|
@@ -134,3 +137,53 @@ describe('watchForTemplates saga', () => {
|
|
|
134
137
|
);
|
|
135
138
|
});
|
|
136
139
|
});
|
|
140
|
+
|
|
141
|
+
describe('getSenderDetails Saga', () => {
|
|
142
|
+
const channel = 'someChannel';
|
|
143
|
+
const orgUnitId = 'someOrgUnitId';
|
|
144
|
+
const action = { channel, orgUnitId };
|
|
145
|
+
|
|
146
|
+
it('should handle apiResponse with hostName', () => {
|
|
147
|
+
const apiResponse = {
|
|
148
|
+
entity: {
|
|
149
|
+
[channel]: [
|
|
150
|
+
{
|
|
151
|
+
domainProperties: {
|
|
152
|
+
hostName: 'example.com',
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const generator = getSenderDetails(action);
|
|
160
|
+
expect(generator.next().value).toEqual(call(api.getSenderDetails, channel, orgUnitId));
|
|
161
|
+
expect(generator.next(apiResponse).value).toEqual(
|
|
162
|
+
put({
|
|
163
|
+
type: types.GET_SENDER_DETAILS_SUCCESS,
|
|
164
|
+
payload: 'example.com',
|
|
165
|
+
})
|
|
166
|
+
);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('should handle apiResponse without hostName', () => {
|
|
170
|
+
const apiResponse = {
|
|
171
|
+
entity: {
|
|
172
|
+
[channel]: [
|
|
173
|
+
{
|
|
174
|
+
domainProperties: {},
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const generator = getSenderDetails(action);
|
|
181
|
+
expect(generator.next().value).toEqual(call(api.getSenderDetails, channel, orgUnitId));
|
|
182
|
+
expect(generator.next(apiResponse).value).toEqual(
|
|
183
|
+
put({
|
|
184
|
+
type: types.GET_SENDER_DETAILS_SUCCESS,
|
|
185
|
+
payload: '',
|
|
186
|
+
})
|
|
187
|
+
);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
@@ -56,7 +56,7 @@ export const Zalo = (props) => {
|
|
|
56
56
|
isFullMode,
|
|
57
57
|
templateData = {},
|
|
58
58
|
editData = {},
|
|
59
|
-
accountData: { selectedZaloAccount = {} } = {},
|
|
59
|
+
accountData: { selectedZaloAccount = {}, senderDetails = {} } = {},
|
|
60
60
|
globalActions,
|
|
61
61
|
location,
|
|
62
62
|
getDefaultTags,
|
|
@@ -66,6 +66,7 @@ export const Zalo = (props) => {
|
|
|
66
66
|
getFormData,
|
|
67
67
|
selectedOfferDetails,
|
|
68
68
|
} = props || {};
|
|
69
|
+
const {hostName = ''} = senderDetails;
|
|
69
70
|
const { formatMessage } = intl;
|
|
70
71
|
const [oa_id, setOaId] = useState('');
|
|
71
72
|
const [token, setToken] = useState('');
|
|
@@ -121,11 +122,12 @@ export const Zalo = (props) => {
|
|
|
121
122
|
|
|
122
123
|
//gets template details
|
|
123
124
|
useEffect(() => {
|
|
124
|
-
if (zaloTempId && oa_id && token && username) {
|
|
125
|
+
if (zaloTempId && oa_id && token && username && hostName) {
|
|
125
126
|
actions.getTemplateInfoById({
|
|
126
127
|
username,
|
|
127
128
|
oa_id,
|
|
128
129
|
token,
|
|
130
|
+
host: hostName,
|
|
129
131
|
id: zaloTempId,
|
|
130
132
|
actionCallback,
|
|
131
133
|
});
|
|
@@ -134,10 +136,10 @@ export const Zalo = (props) => {
|
|
|
134
136
|
return () => {
|
|
135
137
|
actions.resetTemplateInfoData();
|
|
136
138
|
};
|
|
137
|
-
}, [zaloTempId, oa_id, token, username]);
|
|
139
|
+
}, [zaloTempId, oa_id, token, username, hostName]);
|
|
138
140
|
|
|
139
141
|
const handleSetValues = (paramsData = []) =>
|
|
140
|
-
paramsData
|
|
142
|
+
paramsData?.map((paramData) => {
|
|
141
143
|
for (const key in varMapped) {
|
|
142
144
|
if (paramData?.name === key) {
|
|
143
145
|
paramData.value = varMapped[key];
|
|
@@ -339,7 +341,7 @@ export const Zalo = (props) => {
|
|
|
339
341
|
|
|
340
342
|
const isEditDoneDisabled = () => {
|
|
341
343
|
let disableCheck = false;
|
|
342
|
-
templateListParams
|
|
344
|
+
templateListParams?.forEach((listParams) => {
|
|
343
345
|
const { error, value } = listParams;
|
|
344
346
|
const errorMessage = !error
|
|
345
347
|
? handleErrorValidation(value, listParams)
|
|
@@ -352,10 +354,11 @@ export const Zalo = (props) => {
|
|
|
352
354
|
};
|
|
353
355
|
const createPayload = () => {
|
|
354
356
|
const varMap = {};
|
|
355
|
-
templateListParams
|
|
356
|
-
const { name, value } = listParam;
|
|
357
|
+
templateListParams?.forEach((listParam) => {
|
|
358
|
+
const { name = '', value = '' } = listParam;
|
|
357
359
|
varMap[name] = value;
|
|
358
|
-
}
|
|
360
|
+
}
|
|
361
|
+
);
|
|
359
362
|
const payload = {
|
|
360
363
|
channel: ZALO,
|
|
361
364
|
accountId: oa_id,
|
|
@@ -11462,6 +11462,9 @@ export const accountData = {
|
|
|
11462
11462
|
modifiedDate: '2023-10-16T00:00:00+05:30',
|
|
11463
11463
|
},
|
|
11464
11464
|
},
|
|
11465
|
+
senderDetails: {
|
|
11466
|
+
hostName: 'vietguyszalotrans',
|
|
11467
|
+
},
|
|
11465
11468
|
};
|
|
11466
11469
|
|
|
11467
11470
|
export const templateData = {
|
|
@@ -11479,3 +11482,46 @@ export const templateConfigs = {
|
|
|
11479
11482
|
ma_so1: '4',
|
|
11480
11483
|
},
|
|
11481
11484
|
};
|
|
11485
|
+
|
|
11486
|
+
export const mockGapItTemplateData = [
|
|
11487
|
+
{
|
|
11488
|
+
_id: '354701',
|
|
11489
|
+
versions: {
|
|
11490
|
+
base: {
|
|
11491
|
+
content: {
|
|
11492
|
+
zalo: {
|
|
11493
|
+
templateName: 'Test',
|
|
11494
|
+
listParams: [
|
|
11495
|
+
{
|
|
11496
|
+
name: "Name",
|
|
11497
|
+
type: "STRING",
|
|
11498
|
+
require: true,
|
|
11499
|
+
maxLength: 80,
|
|
11500
|
+
minLength: 0,
|
|
11501
|
+
acceptNull: false,
|
|
11502
|
+
},
|
|
11503
|
+
{
|
|
11504
|
+
name: "So_dien_thoai",
|
|
11505
|
+
type: "STRING",
|
|
11506
|
+
require: true,
|
|
11507
|
+
maxLength: 30,
|
|
11508
|
+
minLength: 0,
|
|
11509
|
+
acceptNull: false,
|
|
11510
|
+
},
|
|
11511
|
+
{
|
|
11512
|
+
name: "so_du",
|
|
11513
|
+
type: "STRING",
|
|
11514
|
+
require: true,
|
|
11515
|
+
maxLength: 30,
|
|
11516
|
+
minLength: 0,
|
|
11517
|
+
acceptNull: false,
|
|
11518
|
+
},
|
|
11519
|
+
],
|
|
11520
|
+
previewUrl: 'https://account.zalo.cloud/znspreview/h84m64E6ST_owPQVFzTilg==',
|
|
11521
|
+
status: 'ENABLE',
|
|
11522
|
+
},
|
|
11523
|
+
},
|
|
11524
|
+
},
|
|
11525
|
+
},
|
|
11526
|
+
},
|
|
11527
|
+
];
|
|
@@ -5,7 +5,7 @@ describe("makeSelectZalo", () => {
|
|
|
5
5
|
it("returns the expected object with default values when substate is empty", () => {
|
|
6
6
|
// Arrange
|
|
7
7
|
const state = fromJS({ zalo: {} });
|
|
8
|
-
const expected = {}
|
|
8
|
+
const expected = {};
|
|
9
9
|
const selector = makeSelectZalo();
|
|
10
10
|
|
|
11
11
|
// Act
|
|
@@ -17,7 +17,7 @@ describe("makeSelectZalo", () => {
|
|
|
17
17
|
it("returns the expected object with default values when substate is empty for makeSelectAccount", () => {
|
|
18
18
|
// Arrange
|
|
19
19
|
const state = fromJS({ templates: {} });
|
|
20
|
-
const expected = {}
|
|
20
|
+
const expected = {};
|
|
21
21
|
const selector = makeSelectAccount();
|
|
22
22
|
|
|
23
23
|
// Act
|
|
@@ -25,4 +25,4 @@ describe("makeSelectZalo", () => {
|
|
|
25
25
|
// Assert
|
|
26
26
|
expect(result).toEqual(expected);
|
|
27
27
|
});
|
|
28
|
-
});
|
|
28
|
+
});
|