@capillarytech/creatives-library 7.17.65 → 7.17.66-alpha.1
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
|
@@ -167,7 +167,11 @@ export function getTreeStructuredTags({tagsList, userLocale = 'en', offerDetails
|
|
|
167
167
|
});
|
|
168
168
|
let combinedTags = result;
|
|
169
169
|
if (offerDetails.length) {
|
|
170
|
-
|
|
170
|
+
if (offerDetails?.[0].type === 'BADGES') {
|
|
171
|
+
combinedTags = transformBadgeTags(offerDetails, result);
|
|
172
|
+
} else {
|
|
173
|
+
combinedTags = transformCouponTags(offerDetails, result);
|
|
174
|
+
}
|
|
171
175
|
}
|
|
172
176
|
return getTreeStructureData(combinedTags);
|
|
173
177
|
}
|
|
@@ -193,7 +197,7 @@ function transformCouponTags(offerDetails, allTags) {
|
|
|
193
197
|
return {
|
|
194
198
|
...obj,
|
|
195
199
|
...tempObj,
|
|
196
|
-
|
|
200
|
+
incentiveSeriesId: id,
|
|
197
201
|
};
|
|
198
202
|
};
|
|
199
203
|
offerDetails.forEach((offer) => {
|
|
@@ -216,7 +220,7 @@ function transformCouponTags(offerDetails, allTags) {
|
|
|
216
220
|
'tag-header': true,
|
|
217
221
|
'name': couponNameFinal || couponId,
|
|
218
222
|
'desc': couponNameFinal || couponId,
|
|
219
|
-
'
|
|
223
|
+
'incentiveSeriesId': couponId,
|
|
220
224
|
'subtags': couponSubTags,
|
|
221
225
|
'resolved': true,
|
|
222
226
|
'couponTags': true,
|
|
@@ -227,6 +231,45 @@ function transformCouponTags(offerDetails, allTags) {
|
|
|
227
231
|
return allTags;
|
|
228
232
|
}
|
|
229
233
|
|
|
234
|
+
export function transformBadgeTags(badgeDetails, allTags) {
|
|
235
|
+
const badgeTags = {};
|
|
236
|
+
const badgeTagsKeys = Object.keys(_.get(allTags, 'Badge.subtags', []));
|
|
237
|
+
const withBadgeId = (obj, id) => {
|
|
238
|
+
const tempObj = {};
|
|
239
|
+
if (obj?.subtags) {
|
|
240
|
+
tempObj.subtags = _.mapValues(obj.subtags, (tag) => ({
|
|
241
|
+
...withBadgeId(tag, id),
|
|
242
|
+
}));
|
|
243
|
+
}
|
|
244
|
+
return {
|
|
245
|
+
...obj,
|
|
246
|
+
...tempObj,
|
|
247
|
+
incentiveSeriesId: id,
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
badgeDetails.forEach((offer) => {
|
|
251
|
+
const { badgeId, badgeName } = offer;
|
|
252
|
+
const badgeSubTags = {};
|
|
253
|
+
badgeTagsKeys.forEach((badgeTagKey) => {
|
|
254
|
+
const badgeSubTagsObj = withBadgeId(allTags?.Badge?.subtags[badgeTagKey], badgeId);
|
|
255
|
+
badgeSubTags[badgeTagKey] = badgeSubTagsObj;
|
|
256
|
+
});
|
|
257
|
+
const key = badgeName || badgeId;
|
|
258
|
+
badgeTags[key] = {
|
|
259
|
+
'tag-header': true,
|
|
260
|
+
'name': badgeName,
|
|
261
|
+
'desc': badgeName,
|
|
262
|
+
'incentiveSeriesId': badgeId,
|
|
263
|
+
'subtags': badgeSubTags,
|
|
264
|
+
'resolved': true,
|
|
265
|
+
'couponTags': true,
|
|
266
|
+
};
|
|
267
|
+
});
|
|
268
|
+
// eslint-disable-next-line no-param-reassign
|
|
269
|
+
allTags.Badge.subtags = badgeTags;
|
|
270
|
+
return allTags;
|
|
271
|
+
}
|
|
272
|
+
|
|
230
273
|
function populateTagForChildren(targetTag, tagsObject, tagValue) {
|
|
231
274
|
const tag = targetTag;
|
|
232
275
|
if (tag && tag['tag-header'] && !tag.resolved) {
|
|
@@ -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", () => {
|
|
@@ -202,9 +202,9 @@ class CapTagList extends React.Component { // eslint-disable-line react/prefer-s
|
|
|
202
202
|
const temp = this.renderTags(val.subtags, '', disabled);
|
|
203
203
|
const tagValue = (
|
|
204
204
|
<CapTreeNode
|
|
205
|
-
title={disabled ? <CapTooltip title={loyaltyAttrDisableText}>{val
|
|
205
|
+
title={disabled ? <CapTooltip title={loyaltyAttrDisableText}>{val?.name}</CapTooltip> : val?.name}
|
|
206
206
|
tag={val}
|
|
207
|
-
key={val
|
|
207
|
+
key={val?.incentiveSeriesId ? `${key}(${val?.incentiveSeriesId})` : `${key}`}
|
|
208
208
|
disabled={disabled}
|
|
209
209
|
>
|
|
210
210
|
{temp}
|
|
@@ -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>);
|
|
@@ -22,7 +22,7 @@ import './_tagList.scss';
|
|
|
22
22
|
import { selectCurrentOrgDetails } from '../Cap/selectors';
|
|
23
23
|
import { injectIntl } from 'react-intl';
|
|
24
24
|
import { scope } from './messages';
|
|
25
|
-
import { handleInjectedData, hasGiftVoucherFeature, hasPromoFeature, hasBadgesFeature } from '../../utils/common';
|
|
25
|
+
import { handleInjectedData, hasGiftVoucherFeature, hasPromoFeature, hasBadgesFeature, transformBadgeTags } from '../../utils/common';
|
|
26
26
|
import { GIFT_VOUCHER_RELATED_TAGS, PROMO_ENGINE_RELATED_TAGS, BADGES_RELATED_TAGS } from '../../containers/App/constants';
|
|
27
27
|
|
|
28
28
|
const TreeNode = Tree.TreeNode;
|
|
@@ -89,8 +89,14 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
89
89
|
if (props.tags && props.tags.length > 0) {
|
|
90
90
|
tags = this.populateTags(props.tags);
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
console.log(`selected Badges: ${props.selectedOfferDetails}, ${JSON.stringify(tags)}`);
|
|
93
|
+
if (props.selectedOfferDetails && !_.isEmpty(props.selectedOfferDetails) ) {
|
|
94
|
+
console.log(`selected offers: ${JSON.stringify(props.selectedOfferDetails)}`);
|
|
95
|
+
if ((props?.selectedOfferDetails[0]?.type === 'BADGES') && (tags && tags?.badge) ) {
|
|
96
|
+
transformBadgeTags(props.selectedOfferDetails, tags);
|
|
97
|
+
} else if (tags && tags?.coupon) {
|
|
98
|
+
this.transformCouponTags(props.selectedOfferDetails, tags);
|
|
99
|
+
}
|
|
94
100
|
}
|
|
95
101
|
this.setState({tags: _.merge( {}, tags, injectedTags)});
|
|
96
102
|
}
|
|
@@ -130,7 +136,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
130
136
|
'tag-header': true,
|
|
131
137
|
"name": tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
|
|
132
138
|
"desc": tag?.label[userLocale] ? tag?.label[userLocale] : tag?.label?.en,
|
|
133
|
-
"subtags": tag
|
|
139
|
+
"subtags": tag?.subtags,
|
|
134
140
|
};
|
|
135
141
|
}
|
|
136
142
|
});
|
|
@@ -197,7 +203,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
197
203
|
return {
|
|
198
204
|
...obj,
|
|
199
205
|
...tempObj,
|
|
200
|
-
|
|
206
|
+
incentiveSeriesId: id,
|
|
201
207
|
};
|
|
202
208
|
};
|
|
203
209
|
offerDetails.forEach((offer) => {
|
|
@@ -214,7 +220,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
214
220
|
'tag-header': true,
|
|
215
221
|
'name': couponNameFinal || couponId,
|
|
216
222
|
'desc': couponNameFinal || couponId,
|
|
217
|
-
'
|
|
223
|
+
'incentiveSeriesId': couponId,
|
|
218
224
|
'subtags': couponSubTags,
|
|
219
225
|
'resolved': true,
|
|
220
226
|
'couponTags': true,
|
|
@@ -306,7 +312,7 @@ TagList.propTypes = {
|
|
|
306
312
|
modalProps: PropTypes.any,
|
|
307
313
|
currentOrgDetails: PropTypes.object,
|
|
308
314
|
channel: PropTypes.string,
|
|
309
|
-
disabled: PropTypes.bool
|
|
315
|
+
disabled: PropTypes.bool,
|
|
310
316
|
};
|
|
311
317
|
|
|
312
318
|
const mapStateToProps = createStructuredSelector({
|