{"version":3,"file":"./modules/RedeemLoyaltyPoints-LoyaltyNotifications.xxxxxxxx.js","mappings":"yJAIe,MAAMA,EACjB,WAAAC,GACIC,KAAKC,mBAELC,OAAOC,OAAOC,eAAeC,UAAU,OAAQC,GAAuBA,EAAOC,OAAOC,KAAKC,0BAA0B,sBAAuBC,MAAOC,IAC7I,MAAMC,EAAuBD,EAAKE,WAClCC,aAAaC,QAAQ,SAAUH,GAE/BI,WAAW,IAAMhB,KAAKC,mBAAoB,OAElD,CAEQ,gBAAAA,GACJ,IAGIgB,EAHAC,EAAQ,KAERC,GAAiB,EAGrB,MAAMC,EAAiBC,YAAYX,U,QAC/BO,EAASK,SAASR,aAAaS,QAAQ,WACvCL,EAAQD,EAAS,EAAyB,QAArB,oBAAqB,eAAEO,eAAsC,QAArB,oBAAqB,eAAEC,iBAEpER,GAAWC,IAASC,QAK9B,QAAmBD,GAAOQ,KAAMC,IAC7BA,GAKLV,EAASA,EAAS,EAAIW,KAAKC,IAAIZ,GAAUA,EACzCU,EAAQG,KAAOH,EAAQG,KAAKC,QAAQ,mBAAoBd,EAAOe,YAC/D9B,OAAOC,OAAO8B,aAAaC,KAAKP,GAChCb,aAAaqB,WAAW,WAPpBhB,GAAQ,IANZiB,cAAchB,IAenB,KACP,E","sources":["webpack:///./modules/RedeemLoyaltyPoints/LoyaltyNotifications.ts"],"sourcesContent":["\r\nimport { fetchSmartPushItem } from '../../PushNotification/URL';\r\nimport { getLoyaltySmartPush } from '../../PushNotification/helpers';\r\n\r\nexport default class LoyaltyNotification {\r\n constructor() {\r\n this.showNotification();\r\n\r\n window.NiveaX.AlpacaListener.subscribe('init', event => (event).detail.form.registerCustomDataHandler('LoyaltyPointsEarned', async (args) => {\r\n const earnedPoints: string = args.customData;\r\n localStorage.setItem('Points', earnedPoints);\r\n\r\n setTimeout(() => this.showNotification(), 1000); //start timer, wait 1s and fetch smartpush \r\n }));\r\n }\r\n\r\n private showNotification() {\r\n let smpId = null,\r\n smpItem: INotificationItem,\r\n error: boolean = false,\r\n points: number;\r\n\r\n const showLoyaltySmp = setInterval(async () => {\r\n points = parseInt(localStorage.getItem('Points'));\r\n smpId = points > 0 ? getLoyaltySmartPush()?.EarnPointsPush : getLoyaltySmartPush()?.RedeemPointsPush;\r\n\r\n if (smpItem || !points || !smpId || error) {\r\n clearInterval(showLoyaltySmp);\r\n return;\r\n }\r\n\r\n await fetchSmartPushItem(smpId).then((smpItem) => {\r\n if (!smpItem) {\r\n error = true;\r\n return\r\n }\r\n\r\n points = points < 0 ? Math.abs(points) : points;\r\n smpItem.Text = smpItem.Text.replace(/{loyaltyPoints}/g, points.toString());\r\n window.NiveaX.notification.push(smpItem);\r\n localStorage.removeItem('Points');\r\n });\r\n }, 1500);\r\n }\r\n}\r\n\r\n"],"names":["LoyaltyNotification","constructor","this","showNotification","window","NiveaX","AlpacaListener","subscribe","event","detail","form","registerCustomDataHandler","async","args","earnedPoints","customData","localStorage","setItem","setTimeout","points","smpId","error","showLoyaltySmp","setInterval","parseInt","getItem","EarnPointsPush","RedeemPointsPush","then","smpItem","Math","abs","Text","replace","toString","notification","push","removeItem","clearInterval"],"sourceRoot":""}