@capillarytech/creatives-library 7.17.66-alpha.6 → 7.17.66-alpha.7
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
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
JP_LOCALE_HIDE_FEATURE,
|
|
17
17
|
ENABLE_CUSTOMER_BARCODE_TAG,
|
|
18
18
|
BADGES_UI_ENABLED,
|
|
19
|
+
BADGES_ENROLL,
|
|
19
20
|
} from '../containers/App/constants';
|
|
20
21
|
import { apiMessageFormatHandler } from './commonUtils';
|
|
21
22
|
|
|
@@ -166,8 +167,8 @@ export function getTreeStructuredTags({tagsList, userLocale = 'en', offerDetails
|
|
|
166
167
|
}
|
|
167
168
|
});
|
|
168
169
|
let combinedTags = result;
|
|
169
|
-
if (offerDetails
|
|
170
|
-
if (offerDetails?.[0]
|
|
170
|
+
if (offerDetails?.length) {
|
|
171
|
+
if (offerDetails?.[0]?.type === BADGES_ENROLL) {
|
|
171
172
|
combinedTags = transformBadgeTags(offerDetails, result);
|
|
172
173
|
} else {
|
|
173
174
|
combinedTags = transformCouponTags(offerDetails, result);
|
|
@@ -231,7 +232,7 @@ function transformCouponTags(offerDetails, allTags) {
|
|
|
231
232
|
return allTags;
|
|
232
233
|
}
|
|
233
234
|
|
|
234
|
-
export function transformBadgeTags(badgeDetails, allTags) {
|
|
235
|
+
export function transformBadgeTags(badgeDetails = [], allTags) {
|
|
235
236
|
const badgeTags = {};
|
|
236
237
|
const badgeTagsKeys = Object.keys(_.get(allTags, 'Badge.subtags', []));
|
|
237
238
|
const withBadgeId = (obj, id) => {
|
|
@@ -248,18 +249,17 @@ export function transformBadgeTags(badgeDetails, allTags) {
|
|
|
248
249
|
};
|
|
249
250
|
};
|
|
250
251
|
badgeDetails.forEach((offer) => {
|
|
251
|
-
const {
|
|
252
|
+
const { badgeMetaId, badgeName } = offer || {};
|
|
252
253
|
const badgeSubTags = {};
|
|
253
254
|
badgeTagsKeys.forEach((badgeTagKey) => {
|
|
254
|
-
const badgeSubTagsObj = withBadgeId(allTags?.Badge?.subtags[badgeTagKey],
|
|
255
|
+
const badgeSubTagsObj = withBadgeId(allTags?.Badge?.subtags?.[badgeTagKey], badgeMetaId);
|
|
255
256
|
badgeSubTags[badgeTagKey] = badgeSubTagsObj;
|
|
256
257
|
});
|
|
257
|
-
|
|
258
|
-
badgeTags[key] = {
|
|
258
|
+
badgeTags[badgeMetaId] = {
|
|
259
259
|
'tag-header': true,
|
|
260
260
|
'name': badgeName,
|
|
261
261
|
'desc': badgeName,
|
|
262
|
-
'incentiveSeriesId':
|
|
262
|
+
'incentiveSeriesId': badgeMetaId,
|
|
263
263
|
'subtags': badgeSubTags,
|
|
264
264
|
'resolved': true,
|
|
265
265
|
'couponTags': true,
|
|
@@ -571,3 +571,42 @@ export const output2 = [
|
|
|
571
571
|
value: "{{optout}}",
|
|
572
572
|
},
|
|
573
573
|
];
|
|
574
|
+
export const offer = [
|
|
575
|
+
{ badgeMetaId: "12", badgeName: "moye_moye", type: "BADGES_ENROLL" },
|
|
576
|
+
];
|
|
577
|
+
export const expectedOffer = [
|
|
578
|
+
{
|
|
579
|
+
children: [
|
|
580
|
+
{
|
|
581
|
+
children: [
|
|
582
|
+
{
|
|
583
|
+
children: [
|
|
584
|
+
{
|
|
585
|
+
disabled: false,
|
|
586
|
+
title: "mm/dd/yyyy",
|
|
587
|
+
value: "{{badges_enroll_expiry_date.FORMAT_1}}",
|
|
588
|
+
},
|
|
589
|
+
],
|
|
590
|
+
disabled: false,
|
|
591
|
+
selectable: false,
|
|
592
|
+
title: "Badge Expiry Date",
|
|
593
|
+
value: "{{Badge_expiry_date}}",
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
disabled: false,
|
|
597
|
+
title: "Days_until_expiry",
|
|
598
|
+
value: "{{badges_enroll_expiring_in_days}}",
|
|
599
|
+
},
|
|
600
|
+
],
|
|
601
|
+
disabled: undefined,
|
|
602
|
+
selectable: false,
|
|
603
|
+
title: "moye_moye",
|
|
604
|
+
value: "{{undefined}}",
|
|
605
|
+
},
|
|
606
|
+
],
|
|
607
|
+
disabled: false,
|
|
608
|
+
selectable: false,
|
|
609
|
+
title: "Badge",
|
|
610
|
+
value: "{{Badge}}",
|
|
611
|
+
},
|
|
612
|
+
];
|
|
@@ -13,7 +13,7 @@ describe("getTreeStructuredTags test", () => {
|
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
it("test for getTreeStructuredTags when incentive attached is BADGES", () => {
|
|
16
|
-
expect(getTreeStructuredTags({tagsList: mockdata.badgesTags, offerDetails:
|
|
16
|
+
expect(getTreeStructuredTags({tagsList: mockdata.badgesTags, offerDetails: mockdata.offer})).toEqual(mockdata.expectedOffer);
|
|
17
17
|
});
|
|
18
18
|
it("test for filterTags", () => {
|
|
19
19
|
expect(filterTags(mockdata.tagsToFilter, mockdata.tagsList)).toEqual([mockdata.tagsList[1]]);
|
|
@@ -79,6 +79,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
79
79
|
generateTags = (props) => {
|
|
80
80
|
let tags = {};
|
|
81
81
|
let injectedTags = {};
|
|
82
|
+
const {selectedOfferDetails } = props;
|
|
82
83
|
if (props.injectedTags && !_.isEmpty(props.injectedTags)) {
|
|
83
84
|
const formattedInjectedTags = handleInjectedData(
|
|
84
85
|
props.injectedTags,
|
|
@@ -89,11 +90,11 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
89
90
|
if (props.tags && props.tags.length > 0) {
|
|
90
91
|
tags = this.populateTags(props.tags);
|
|
91
92
|
}
|
|
92
|
-
if (
|
|
93
|
-
if ((
|
|
94
|
-
transformBadgeTags(
|
|
93
|
+
if (selectedOfferDetails && !_.isEmpty(selectedOfferDetails) ) {
|
|
94
|
+
if ((selectedOfferDetails[0]?.type === BADGES_ENROLL) && (tags && tags?.Badge) ) {
|
|
95
|
+
transformBadgeTags(selectedOfferDetails, tags);
|
|
95
96
|
} else if (tags && tags?.coupon) {
|
|
96
|
-
this.transformCouponTags(
|
|
97
|
+
this.transformCouponTags(selectedOfferDetails, tags);
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
this.setState({tags: _.merge( {}, tags, injectedTags)});
|