@capillarytech/creatives-library 7.17.66-alpha.0 → 7.17.66-alpha.2
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
CHANGED
package/utils/common.js
CHANGED
|
@@ -166,10 +166,12 @@ export function getTreeStructuredTags({tagsList, userLocale = 'en', offerDetails
|
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
let combinedTags = result;
|
|
169
|
-
if (offerDetails.length
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
if (offerDetails.length) {
|
|
170
|
+
if (offerDetails?.[0].type === 'BADGES') {
|
|
171
|
+
combinedTags = transformBadgeTags(offerDetails, result);
|
|
172
|
+
} else {
|
|
173
|
+
combinedTags = transformCouponTags(offerDetails, result);
|
|
174
|
+
}
|
|
173
175
|
}
|
|
174
176
|
return getTreeStructureData(combinedTags);
|
|
175
177
|
}
|
|
@@ -195,7 +197,7 @@ function transformCouponTags(offerDetails, allTags) {
|
|
|
195
197
|
return {
|
|
196
198
|
...obj,
|
|
197
199
|
...tempObj,
|
|
198
|
-
|
|
200
|
+
incentiveSeriesId: id,
|
|
199
201
|
};
|
|
200
202
|
};
|
|
201
203
|
offerDetails.forEach((offer) => {
|
|
@@ -218,7 +220,7 @@ function transformCouponTags(offerDetails, allTags) {
|
|
|
218
220
|
'tag-header': true,
|
|
219
221
|
'name': couponNameFinal || couponId,
|
|
220
222
|
'desc': couponNameFinal || couponId,
|
|
221
|
-
'
|
|
223
|
+
'incentiveSeriesId': couponId,
|
|
222
224
|
'subtags': couponSubTags,
|
|
223
225
|
'resolved': true,
|
|
224
226
|
'couponTags': true,
|
|
@@ -247,10 +249,10 @@ export function transformBadgeTags(badgeDetails, allTags) {
|
|
|
247
249
|
};
|
|
248
250
|
badgeDetails.forEach((offer) => {
|
|
249
251
|
const { badgeId, badgeName } = offer;
|
|
250
|
-
const
|
|
252
|
+
const badgeSubTags = {};
|
|
251
253
|
badgeTagsKeys.forEach((badgeTagKey) => {
|
|
252
254
|
const badgeSubTagsObj = withBadgeId(allTags?.Badge?.subtags[badgeTagKey], badgeId);
|
|
253
|
-
|
|
255
|
+
badgeSubTags[badgeTagKey] = badgeSubTagsObj;
|
|
254
256
|
});
|
|
255
257
|
const key = badgeName || badgeId;
|
|
256
258
|
badgeTags[key] = {
|
|
@@ -258,13 +260,14 @@ export function transformBadgeTags(badgeDetails, allTags) {
|
|
|
258
260
|
'name': badgeName,
|
|
259
261
|
'desc': badgeName,
|
|
260
262
|
'incentiveSeriesId': badgeId,
|
|
261
|
-
'subtags':
|
|
263
|
+
'subtags': badgeSubTags,
|
|
262
264
|
'resolved': true,
|
|
263
|
-
'
|
|
265
|
+
'couponTags': true,
|
|
264
266
|
};
|
|
265
267
|
});
|
|
266
268
|
// eslint-disable-next-line no-param-reassign
|
|
267
269
|
allTags.Badge.subtags = badgeTags;
|
|
270
|
+
return allTags;
|
|
268
271
|
}
|
|
269
272
|
|
|
270
273
|
function populateTagForChildren(targetTag, tagsObject, tagValue) {
|
|
@@ -102,6 +102,265 @@ export const tagsList = [
|
|
|
102
102
|
updatedAt: "2018-01-22T11:43:05.611Z",
|
|
103
103
|
},
|
|
104
104
|
];
|
|
105
|
+
|
|
106
|
+
export const badgesTags = [
|
|
107
|
+
{
|
|
108
|
+
_id: "655b080695c9df613dbbed4d",
|
|
109
|
+
type: "TAG",
|
|
110
|
+
definition: {
|
|
111
|
+
"label": {
|
|
112
|
+
"en": "Badge",
|
|
113
|
+
"ja-JP": "バッジ",
|
|
114
|
+
},
|
|
115
|
+
"value": "Badge",
|
|
116
|
+
"subtags": [
|
|
117
|
+
"Badge_expiry_date",
|
|
118
|
+
"Days_until_expiry",
|
|
119
|
+
],
|
|
120
|
+
"tag-header": true,
|
|
121
|
+
"supportedModules": [
|
|
122
|
+
{
|
|
123
|
+
context: "outbound",
|
|
124
|
+
layout: "sms",
|
|
125
|
+
mandatory: false,
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
context: "outbound",
|
|
129
|
+
layout: "email",
|
|
130
|
+
mandatory: false,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
context: "outbound",
|
|
134
|
+
layout: "mobilepush",
|
|
135
|
+
mandatory: false,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
context: "outbound",
|
|
139
|
+
layout: "line",
|
|
140
|
+
mandatory: false,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
context: "outbound",
|
|
144
|
+
layout: "wechat",
|
|
145
|
+
mandatory: false,
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
context: "default",
|
|
149
|
+
layout: "wechat",
|
|
150
|
+
mandatory: false,
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
context: "journey",
|
|
154
|
+
layout: "sms",
|
|
155
|
+
mandatory: false,
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
context: "journey",
|
|
159
|
+
layout: "email",
|
|
160
|
+
mandatory: false,
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
context: "journey",
|
|
164
|
+
layout: "mobilepush",
|
|
165
|
+
mandatory: false,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
context: "loyalty",
|
|
169
|
+
layout: "sms",
|
|
170
|
+
mandatory: false,
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
context: "loyalty",
|
|
174
|
+
layout: "email",
|
|
175
|
+
mandatory: false,
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
context: "loyalty",
|
|
179
|
+
layout: "mobilepush",
|
|
180
|
+
mandatory: false,
|
|
181
|
+
},
|
|
182
|
+
],
|
|
183
|
+
},
|
|
184
|
+
scope: {
|
|
185
|
+
verticals: [],
|
|
186
|
+
orgId: -1,
|
|
187
|
+
tag: "STANDARD",
|
|
188
|
+
},
|
|
189
|
+
isActive: true,
|
|
190
|
+
createdBy: 15000449,
|
|
191
|
+
updatedBy: 15000449,
|
|
192
|
+
createdAt: "2022-06-24T10:28:45.738Z",
|
|
193
|
+
updatedAt: "2022-06-24T10:28:45.738Z",
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
_id: "655b617e48bc1275ad0c717c",
|
|
197
|
+
type: "TAG",
|
|
198
|
+
definition: {
|
|
199
|
+
"label": {
|
|
200
|
+
"en": "Days Until Expiry",
|
|
201
|
+
"ja-JP": "有効期限までの日数",
|
|
202
|
+
},
|
|
203
|
+
"value": "Days_until_expiry",
|
|
204
|
+
"subtags": [],
|
|
205
|
+
"tag-header": false,
|
|
206
|
+
"supportedModules": [
|
|
207
|
+
{
|
|
208
|
+
context: "outbound",
|
|
209
|
+
layout: "sms",
|
|
210
|
+
mandatory: false,
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
context: "outbound",
|
|
214
|
+
layout: "email",
|
|
215
|
+
mandatory: false,
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
context: "outbound",
|
|
219
|
+
layout: "mobilepush",
|
|
220
|
+
mandatory: false,
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
context: "outbound",
|
|
224
|
+
layout: "line",
|
|
225
|
+
mandatory: false,
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
context: "outbound",
|
|
229
|
+
layout: "wechat",
|
|
230
|
+
mandatory: false,
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
context: "default",
|
|
234
|
+
layout: "wechat",
|
|
235
|
+
mandatory: false,
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
context: "journey",
|
|
239
|
+
layout: "sms",
|
|
240
|
+
mandatory: false,
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
context: "journey",
|
|
244
|
+
layout: "email",
|
|
245
|
+
mandatory: false,
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
context: "journey",
|
|
249
|
+
layout: "mobilepush",
|
|
250
|
+
mandatory: false,
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
context: "loyalty",
|
|
254
|
+
layout: "sms",
|
|
255
|
+
mandatory: false,
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
context: "loyalty",
|
|
259
|
+
layout: "email",
|
|
260
|
+
mandatory: false,
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
context: "loyalty",
|
|
264
|
+
layout: "mobilepush",
|
|
265
|
+
mandatory: false,
|
|
266
|
+
},
|
|
267
|
+
],
|
|
268
|
+
},
|
|
269
|
+
scope: {
|
|
270
|
+
verticals: [],
|
|
271
|
+
orgId: -1,
|
|
272
|
+
tag: "STANDARD",
|
|
273
|
+
},
|
|
274
|
+
isActive: true,
|
|
275
|
+
},
|
|
276
|
+
];
|
|
277
|
+
export const OfferTag = [{
|
|
278
|
+
_id: "5aaa0cec7472bc0eab75f55b",
|
|
279
|
+
type: "TAG",
|
|
280
|
+
definition: {
|
|
281
|
+
"supportedModules": [
|
|
282
|
+
{
|
|
283
|
+
context: "journey",
|
|
284
|
+
layout: "sms",
|
|
285
|
+
mandatory: false,
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
context: "journey",
|
|
289
|
+
layout: "email",
|
|
290
|
+
mandatory: false,
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
context: "journey",
|
|
294
|
+
layout: "mobilepush",
|
|
295
|
+
mandatory: false,
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
context: "default",
|
|
299
|
+
layout: "sms",
|
|
300
|
+
mandatory: false,
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
context: "outbound",
|
|
304
|
+
layout: "sms",
|
|
305
|
+
mandatory: false,
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
context: "outbound",
|
|
309
|
+
layout: "line",
|
|
310
|
+
mandatory: false,
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
context: "default",
|
|
314
|
+
layout: "line",
|
|
315
|
+
mandatory: false,
|
|
316
|
+
},
|
|
317
|
+
],
|
|
318
|
+
"tag-header": true,
|
|
319
|
+
"subtags": [
|
|
320
|
+
"voucher",
|
|
321
|
+
"valid_till_date",
|
|
322
|
+
"valid_days_from_create",
|
|
323
|
+
],
|
|
324
|
+
"value": "coupon",
|
|
325
|
+
"label": {
|
|
326
|
+
"en": "Coupons",
|
|
327
|
+
"ja-JP": "クーポン",
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
scope: {
|
|
331
|
+
tag: "STANDARD",
|
|
332
|
+
orgId: -1,
|
|
333
|
+
verticals: [],
|
|
334
|
+
},
|
|
335
|
+
isActive: true,
|
|
336
|
+
createdBy: 15000449,
|
|
337
|
+
updatedBy: 15000449,
|
|
338
|
+
createdAt: "2018-03-15T06:04:28.484Z",
|
|
339
|
+
updatedAt: "2018-03-15T06:04:28.484Z",
|
|
340
|
+
},
|
|
341
|
+
];
|
|
342
|
+
export const offerOutput = [{"children": [{"disabled": undefined, "title": "mac", "value": "{{undefined}}"}], "disabled": false, "selectable": false, "title": "Coupons", "value": "{{coupon}}"}];
|
|
343
|
+
export const badgesOutput = [{
|
|
344
|
+
children: [
|
|
345
|
+
{
|
|
346
|
+
children: [
|
|
347
|
+
{
|
|
348
|
+
disabled: false,
|
|
349
|
+
title: "Days Until Expiry",
|
|
350
|
+
value: "{{Days_until_expiry}}",
|
|
351
|
+
},
|
|
352
|
+
],
|
|
353
|
+
disabled: undefined,
|
|
354
|
+
selectable: false,
|
|
355
|
+
title: "moye_moye",
|
|
356
|
+
value: "{{undefined}}",
|
|
357
|
+
},
|
|
358
|
+
],
|
|
359
|
+
disabled: false,
|
|
360
|
+
selectable: false,
|
|
361
|
+
title: "Badge",
|
|
362
|
+
value: "{{Badge}}",
|
|
363
|
+
}];
|
|
105
364
|
export const tagsToFilter = ["timeSpan_Start"];
|
|
106
365
|
|
|
107
366
|
export const output1 = [
|
|
@@ -11,12 +11,19 @@ describe("getTreeStructuredTags test", () => {
|
|
|
11
11
|
it("test for getTreeStructuredTags when tagsList is empty", () => {
|
|
12
12
|
expect(getTreeStructuredTags({tagsList: []})).toEqual([]);
|
|
13
13
|
});
|
|
14
|
+
|
|
15
|
+
it("test for getTreeStructuredTags when incentive attached is BADGES", () => {
|
|
16
|
+
expect(getTreeStructuredTags({tagsList: mockdata.badgesTags, offerDetails: [{badgeId: '12', badgeName: 'moye_moye', type: "BADGES"}]})).toEqual(mockdata.badgesOutput);
|
|
17
|
+
});
|
|
14
18
|
it("test for filterTags", () => {
|
|
15
19
|
expect(filterTags(mockdata.tagsToFilter, mockdata.tagsList)).toEqual([mockdata.tagsList[1]]);
|
|
16
20
|
});
|
|
17
21
|
it("test for filterTags when tagsToFilter and tagsList is empty", () => {
|
|
18
22
|
expect(filterTags([], [])).toEqual([]);
|
|
19
23
|
});
|
|
24
|
+
it("test for getTreeStructuredTags when incentive attached is offer", () => {
|
|
25
|
+
expect(getTreeStructuredTags({tagsList: mockdata.OfferTag, offerDetails: [{id: '12', couponName: 'mac'}]})).toEqual(mockdata.offerOutput);
|
|
26
|
+
});
|
|
20
27
|
});
|
|
21
28
|
|
|
22
29
|
describe("getUserNameById test", () => {
|
|
@@ -223,7 +223,7 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
223
223
|
title={childDisabled ? <CapTooltip title={key === CUSTOMER_BARCODE_TAG ? customerBarcodeDisableText : loyaltyAttrDisableText}>{val.desc || val.name}</CapTooltip> : (val.desc || val.name)}
|
|
224
224
|
tag={val}
|
|
225
225
|
isLeaf
|
|
226
|
-
key={val
|
|
226
|
+
key={val?.incentiveSeriesId ? `${key}(${val?.incentiveSeriesId})` : `${key}`}
|
|
227
227
|
disabled={childDisabled}
|
|
228
228
|
>
|
|
229
229
|
</CapTreeNode>);
|
|
@@ -50,11 +50,14 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
50
50
|
this.setState({loading: true});
|
|
51
51
|
}
|
|
52
52
|
if (!_.isEqual(nextProps.injectedTags, this.props.injectedTags)) {
|
|
53
|
+
|
|
53
54
|
this.setState({loading: false});
|
|
54
55
|
}
|
|
55
56
|
if (!_.isEqual(nextProps.tags, this.props.tags)) {
|
|
57
|
+
|
|
56
58
|
this.setState({loading: false});
|
|
57
59
|
}
|
|
60
|
+
|
|
58
61
|
}
|
|
59
62
|
componentDidUpdate(prevProps) {
|
|
60
63
|
if (this.props.tags !== prevProps.tags || this.props.injectedTags !== prevProps.injectedTags || this.props.selectedOfferDetails !== prevProps.selectedOfferDetails) {
|
|
@@ -87,11 +90,11 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
87
90
|
tags = this.populateTags(props.tags);
|
|
88
91
|
}
|
|
89
92
|
console.log(`selected Badges: ${props.selectedOfferDetails}, ${JSON.stringify(tags)}`);
|
|
90
|
-
if (props.selectedOfferDetails && !_.isEmpty(props.selectedOfferDetails)
|
|
93
|
+
if (props.selectedOfferDetails && !_.isEmpty(props.selectedOfferDetails) ) {
|
|
91
94
|
console.log(`selected offers: ${JSON.stringify(props.selectedOfferDetails)}`);
|
|
92
|
-
if (props
|
|
95
|
+
if ((props?.selectedOfferDetails[0]?.type === 'BADGES') && (tags && tags?.badge) ) {
|
|
93
96
|
transformBadgeTags(props.selectedOfferDetails, tags);
|
|
94
|
-
} else {
|
|
97
|
+
} else if (tags && tags?.coupon) {
|
|
95
98
|
this.transformCouponTags(props.selectedOfferDetails, tags);
|
|
96
99
|
}
|
|
97
100
|
}
|
|
@@ -123,8 +126,8 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
123
126
|
}
|
|
124
127
|
if (!tag['tag-header']) {
|
|
125
128
|
mainTags[tag.value] = {
|
|
126
|
-
name: tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
|
|
127
|
-
desc: tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
|
|
129
|
+
"name": tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
|
|
130
|
+
"desc": tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
|
|
128
131
|
};
|
|
129
132
|
} else if (tag['tag-header'] && mainTags[tag.value]) {
|
|
130
133
|
mainTags[tag.value].subtags = _.concat(mainTags[tag.value].subtags, tag.subtags);
|
|
@@ -133,7 +136,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
133
136
|
'tag-header': true,
|
|
134
137
|
"name": tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
|
|
135
138
|
"desc": tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
|
|
136
|
-
"subtags": tag
|
|
139
|
+
"subtags": tag?.subtags,
|
|
137
140
|
};
|
|
138
141
|
}
|
|
139
142
|
});
|
|
@@ -204,8 +207,8 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
204
207
|
};
|
|
205
208
|
};
|
|
206
209
|
offerDetails.forEach((offer) => {
|
|
207
|
-
const { id, couponName, description,
|
|
208
|
-
const couponId = id ||
|
|
210
|
+
const { id, couponName, description, couponSeriesId } = offer;
|
|
211
|
+
const couponId = id || couponSeriesId;
|
|
209
212
|
const couponSubTags = {};
|
|
210
213
|
couponTagsKeys.forEach((couponTagKey) => {
|
|
211
214
|
const couponSubTagsObj = withCouponId(allTags.coupon.subtags[couponTagKey], couponId);
|