@ikas/loyalty-widget-renderer 1.0.0-alpha.67 → 1.0.0-alpha.68
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/build/index.d.ts +1 -0
- package/build/index.js +1 -1
- package/build/models/index.d.ts +1 -2
- package/build/models/index.js +1 -1
- package/build/models/loyalty-widget/translations.d.ts +1 -8
- package/build/models/loyalty-widget/translations.js +1 -1
- package/build/renderer/index.js +1 -1
- package/build/renderer/screens/credit-history-screen/index.js +1 -1
- package/build/storefront-widget-script-injector.iife.js +3 -3
- package/build/storefront-widget-script-injector.iife.js.map +1 -1
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./models/loyalty-widget";
|
|
|
2
2
|
export * from "./models/loyalty-widget/types";
|
|
3
3
|
export * from "./models/loyalty-widget/header";
|
|
4
4
|
export * from "./models/loyalty-widget/header/header-background";
|
|
5
|
+
export * from "./models/loyalty-widget/translations";
|
|
5
6
|
export * from "./models/image";
|
|
6
7
|
export * from "./models/button";
|
|
7
8
|
export * from "./models/loyalty-customer-info";
|
package/build/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{LoyaltyWidget}from"./models/loyalty-widget/index.js";export{BadgeIconTypeEnum,HeaderBackgroundTypeEnum,ImageTypeEnum,LoyaltyWidgetLayoutTypeEnum,WidgetIconTypeEnum,WidgetPositionEnum}from"./models/loyalty-widget/types/index.js";export{LoyaltyWidgetHeader}from"./models/loyalty-widget/header/index.js";export{LoyaltyWidgetHeaderBackground}from"./models/loyalty-widget/header/header-background/index.js";export{IMAGE_SIZE,LoyaltyWidgetImage}from"./models/image/index.js";export{LoyaltyWidgetButton}from"./models/button/index.js";export{CampaignTypeEnum,CartLoyaltyLineData,LoyaltyCustomerInfo,LoyaltyProgramTier,LoyaltyProgramTierTranslation,OrderAmountTypeEnum}from"./models/loyalty-customer-info/index.js";export{LoyaltyProgramPointHistory}from"./models/loyalty-program-point-history/index.js";export{LoyaltyProgramDiscountSettings,LoyaltyProgramSpendingMethod}from"./models/loyalty-program-spending-method/index.js";export{LoyaltyProgramEarningMethod,LoyaltyProgramEarningMethodOrderSettings,LoyaltyProgramEarningMethodProductSettings}from"./models/loyalty-program-earning-method/index.js";export{LoyaltyWidgetSettings}from"./models/loyalty-widget/settings/index.js";export{LoyaltyWidgetViewModel}from"./models/index.js";export{EarningMethodTypeEnum,LoyaltyProgramFilterTypeEnum,LoyaltyProgramMethodSpendingTypeEnum,LoyaltyProgramPointEarningTypeEnum,LoyaltyProgramPointHistoryTypeEnum,LoyaltyWidgetScreenTypeEnum,PeriodTypeEnum,WidgetMode}from"./models/types/index.js";export{BadgeLevel1}from"./assets/badgeLevel1.js";export{BadgeLevel2}from"./assets/badgeLevel2.js";export{BadgeLevel3}from"./assets/badgeLevel3.js";export{BadgeLevel4}from"./assets/badgeLevel4.js";export{XClose}from"./assets/icons/x-close.js";export{CheckCircleFill}from"./assets/icons/check-circle-fill.js";export{ChevronLeft}from"./assets/icons/chevron-left.js";export{Check}from"./assets/icons/check.js";export{ArrowRight}from"./assets/icons/arrow-right.js";export{CheckCircle}from"./assets/icons/check-circle.js";export{BubbleChatDone}from"./assets/widget-icons/normal/bubbleChatDone.js";export{CommentAdd01}from"./assets/widget-icons/normal/commentAdd01.js";export{CouponPercent}from"./assets/widget-icons/normal/couponPercent.js";export{DiscountTag02}from"./assets/widget-icons/normal/discountTag02.js";export{Gift}from"./assets/widget-icons/normal/gift.js";export{MoneyAdd01}from"./assets/widget-icons/normal/moneyAdd01.js";export{PackageDelivered}from"./assets/widget-icons/normal/packageDelivered.js";export{SaveMoneyDollar}from"./assets/widget-icons/normal/saveMoneyDollar.js";export{ShoppingBasketAdd02}from"./assets/widget-icons/normal/shoppingBasketAdd02.js";export{UserAdd01}from"./assets/widget-icons/normal/userAdd01.js";export{InformationCircle}from"./assets/widget-icons/normal/informationCircle.js";export{UsersIllustration}from"./assets/widget-icons/illustraions/usersIllustration.js";export{BubbleChatIllustration}from"./assets/widget-icons/illustraions/bubbleChatIllustration.js";export{ApprovedChatIllustration}from"./assets/widget-icons/illustraions/approvedChatIllustration.js";export{TshirtIllustration}from"./assets/widget-icons/illustraions/tshirtIllustration.js";export{Medal}from"./assets/widget-icons/illustraions/medal.js";export{GiftIllustration}from"./assets/widget-icons/illustraions/giftIllustration.js";export{ShippingBox}from"./assets/widget-icons/illustraions/shippingBox.js";export{BigSaleMedal}from"./assets/widget-icons/illustraions/bigSaleMedal.js";export{ShoppingCartIllustration}from"./assets/widget-icons/illustraions/shoppingCartIllustration.js";export{InformationCircleIllustration}from"./assets/widget-icons/illustraions/informationCircleIllustration.js";export{CheckFillIllustration}from"./assets/widget-icons/illustraions/check-fill.js";export{default as LoyaltyWidgetRenderer}from"./renderer/index.js";
|
|
1
|
+
export{LoyaltyWidget}from"./models/loyalty-widget/index.js";export{BadgeIconTypeEnum,HeaderBackgroundTypeEnum,ImageTypeEnum,LoyaltyWidgetLayoutTypeEnum,WidgetIconTypeEnum,WidgetPositionEnum}from"./models/loyalty-widget/types/index.js";export{LoyaltyWidgetHeader}from"./models/loyalty-widget/header/index.js";export{LoyaltyWidgetHeaderBackground}from"./models/loyalty-widget/header/header-background/index.js";export{LoyaltyWidgetTranslations}from"./models/loyalty-widget/translations.js";export{IMAGE_SIZE,LoyaltyWidgetImage}from"./models/image/index.js";export{LoyaltyWidgetButton}from"./models/button/index.js";export{CampaignTypeEnum,CartLoyaltyLineData,LoyaltyCustomerInfo,LoyaltyProgramTier,LoyaltyProgramTierTranslation,OrderAmountTypeEnum}from"./models/loyalty-customer-info/index.js";export{LoyaltyProgramPointHistory}from"./models/loyalty-program-point-history/index.js";export{LoyaltyProgramDiscountSettings,LoyaltyProgramSpendingMethod}from"./models/loyalty-program-spending-method/index.js";export{LoyaltyProgramEarningMethod,LoyaltyProgramEarningMethodOrderSettings,LoyaltyProgramEarningMethodProductSettings}from"./models/loyalty-program-earning-method/index.js";export{LoyaltyWidgetSettings}from"./models/loyalty-widget/settings/index.js";export{LoyaltyWidgetViewModel}from"./models/index.js";export{EarningMethodTypeEnum,LoyaltyProgramFilterTypeEnum,LoyaltyProgramMethodSpendingTypeEnum,LoyaltyProgramPointEarningTypeEnum,LoyaltyProgramPointHistoryTypeEnum,LoyaltyWidgetScreenTypeEnum,PeriodTypeEnum,WidgetMode}from"./models/types/index.js";export{BadgeLevel1}from"./assets/badgeLevel1.js";export{BadgeLevel2}from"./assets/badgeLevel2.js";export{BadgeLevel3}from"./assets/badgeLevel3.js";export{BadgeLevel4}from"./assets/badgeLevel4.js";export{XClose}from"./assets/icons/x-close.js";export{CheckCircleFill}from"./assets/icons/check-circle-fill.js";export{ChevronLeft}from"./assets/icons/chevron-left.js";export{Check}from"./assets/icons/check.js";export{ArrowRight}from"./assets/icons/arrow-right.js";export{CheckCircle}from"./assets/icons/check-circle.js";export{BubbleChatDone}from"./assets/widget-icons/normal/bubbleChatDone.js";export{CommentAdd01}from"./assets/widget-icons/normal/commentAdd01.js";export{CouponPercent}from"./assets/widget-icons/normal/couponPercent.js";export{DiscountTag02}from"./assets/widget-icons/normal/discountTag02.js";export{Gift}from"./assets/widget-icons/normal/gift.js";export{MoneyAdd01}from"./assets/widget-icons/normal/moneyAdd01.js";export{PackageDelivered}from"./assets/widget-icons/normal/packageDelivered.js";export{SaveMoneyDollar}from"./assets/widget-icons/normal/saveMoneyDollar.js";export{ShoppingBasketAdd02}from"./assets/widget-icons/normal/shoppingBasketAdd02.js";export{UserAdd01}from"./assets/widget-icons/normal/userAdd01.js";export{InformationCircle}from"./assets/widget-icons/normal/informationCircle.js";export{UsersIllustration}from"./assets/widget-icons/illustraions/usersIllustration.js";export{BubbleChatIllustration}from"./assets/widget-icons/illustraions/bubbleChatIllustration.js";export{ApprovedChatIllustration}from"./assets/widget-icons/illustraions/approvedChatIllustration.js";export{TshirtIllustration}from"./assets/widget-icons/illustraions/tshirtIllustration.js";export{Medal}from"./assets/widget-icons/illustraions/medal.js";export{GiftIllustration}from"./assets/widget-icons/illustraions/giftIllustration.js";export{ShippingBox}from"./assets/widget-icons/illustraions/shippingBox.js";export{BigSaleMedal}from"./assets/widget-icons/illustraions/bigSaleMedal.js";export{ShoppingCartIllustration}from"./assets/widget-icons/illustraions/shoppingCartIllustration.js";export{InformationCircleIllustration}from"./assets/widget-icons/illustraions/informationCircleIllustration.js";export{CheckFillIllustration}from"./assets/widget-icons/illustraions/check-fill.js";export{default as LoyaltyWidgetRenderer}from"./renderer/index.js";
|
package/build/models/index.d.ts
CHANGED
|
@@ -19,7 +19,6 @@ export declare class LoyaltyWidgetViewModel {
|
|
|
19
19
|
merchantId: string;
|
|
20
20
|
storeUrl: string;
|
|
21
21
|
currency: string;
|
|
22
|
-
locale: string;
|
|
23
22
|
isPreviewMode: boolean;
|
|
24
23
|
user: LoyaltyCustomerInfo | null;
|
|
25
24
|
categories: Category[] | null;
|
|
@@ -31,7 +30,7 @@ export declare class LoyaltyWidgetViewModel {
|
|
|
31
30
|
tiers: LoyaltyProgramTier[];
|
|
32
31
|
pointHistory: LoyaltyProgramPointHistory[];
|
|
33
32
|
callbacks?: LoyaltyWidgetCallbacks;
|
|
34
|
-
constructor(data: Partial<LoyaltyWidgetViewModel> | undefined, cdnURL: string, merchantId: string, currency: string,
|
|
33
|
+
constructor(data: Partial<LoyaltyWidgetViewModel> | undefined, cdnURL: string, merchantId: string, currency: string, storeURL?: string | null, isPreviewMode?: boolean, callbacks?: LoyaltyWidgetCallbacks);
|
|
35
34
|
get shouldShowSpendingMethods(): boolean;
|
|
36
35
|
setWidgetMode(mode: WidgetMode): void;
|
|
37
36
|
closeMiniModeDescription(): void;
|
package/build/models/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from'./../ext/tslib/tslib.es6.mjs.js';import{makeObservable as t,observable as i,action as s,computed as r}from"mobx";import{LoyaltyCustomerInfo as o}from"./loyalty-customer-info/index.js";import{LoyaltyProgramEarningMethod as n}from"./loyalty-program-earning-method/index.js";import{LoyaltyProgramSpendingMethod as d}from"./loyalty-program-spending-method/index.js";import{LoyaltyWidget as c}from"./loyalty-widget/index.js";import{WidgetMode as a,LoyaltyWidgetScreenTypeEnum as h}from"./types/index.js";var l=function(){function l(l,g,u,p,M,m,y
|
|
1
|
+
import{__assign as e}from'./../ext/tslib/tslib.es6.mjs.js';import{makeObservable as t,observable as i,action as s,computed as r}from"mobx";import{LoyaltyCustomerInfo as o}from"./loyalty-customer-info/index.js";import{LoyaltyProgramEarningMethod as n}from"./loyalty-program-earning-method/index.js";import{LoyaltyProgramSpendingMethod as d}from"./loyalty-program-spending-method/index.js";import{LoyaltyWidget as c}from"./loyalty-widget/index.js";import{WidgetMode as a,LoyaltyWidgetScreenTypeEnum as h}from"./types/index.js";var l=function(){function l(l,g,u,p,M,m,y){void 0===l&&(l={}),this.userRefreshTrigger=0,this.cartRefreshTrigger=0,this.selectedScreen=l.selectedScreen||h.MAIN_SCREEN,this.currentWidgetMode=m?a.WIDGET_MODE:a.MINI_MODE,this.isMiniModeDescriptionClosed=l.isMiniModeDescriptionClosed||!1,this.isLoading=l.isLoading||!1,this.isActionLoading=l.isActionLoading||!1,this.loyaltyWidget=new c(l.loyaltyWidget),this.cdnURL=g,this.merchantId=u,this.storeUrl=M||l.storeUrl||"",this.currency=p,this.isPreviewMode=m||!1,this.cartId=l.cartId||null,this.cartId=l.cartId||null,this.ikasEventUser=l.ikasEventUser||null,this.user=l.user?new o(l.user):null,this.earningMethods=l.earningMethods?l.earningMethods.map(function(e){return new n(e)}):[],this.spendingMethods=l.spendingMethods?l.spendingMethods.map(function(e){return new d(e)}):[],this.tiers=l.tiers?l.tiers:[],this.categories=l.categories?l.categories:[],this.products=l.products?l.products:[],this.brands=l.brands?l.brands:[],this.tags=l.tags?l.tags:[],this.pointHistory=l.pointHistory?l.pointHistory:[],this.callbacks=y||void 0,t(this,e(e({cartId:i},m?{}:{loyaltyWidget:i}),{isLoading:i,isActionLoading:i,cdnURL:i,merchantId:i,storeUrl:i,currency:i,setWidgetMode:s.bound,closeMiniModeDescription:s.bound,formatCurrency:s.bound,selectedScreen:i,currentWidgetMode:i,isMiniModeDescriptionClosed:i,user:i,earningMethods:i,spendingMethods:i,tiers:i,categories:i,products:i,brands:i,tags:i,pointHistory:i,ikasEventUser:i,userRefreshTrigger:i,cartRefreshTrigger:i,shouldShowSpendingMethods:r}))}return Object.defineProperty(l.prototype,"shouldShowSpendingMethods",{get:function(){return!!this.user&&(!(this.user.totalPoint<=0)&&0!==this.spendingMethods.length)},enumerable:!1,configurable:!0}),l.prototype.setWidgetMode=function(e){this.currentWidgetMode=e,e!==a.WIDGET_MODE||this.isPreviewMode||(this.isMiniModeDescriptionClosed=!0)},l.prototype.closeMiniModeDescription=function(){this.isMiniModeDescriptionClosed=!0},l.prototype.formatCurrency=function(e){var t;return(null===(t=this.callbacks)||void 0===t?void 0:t.formatCurrency)?this.callbacks.formatCurrency(e):"".concat(e.toFixed(2)," ").concat(this.currency)},l}();export{l as LoyaltyWidgetViewModel};
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
export declare enum LoyaltyLocal {
|
|
2
|
-
TR = "tr",
|
|
3
|
-
EN = "en",
|
|
4
|
-
DE = "de",
|
|
5
|
-
NL = "nl",
|
|
6
|
-
FR = "fr"
|
|
7
|
-
}
|
|
8
1
|
export declare class LoyaltyWidgetTranslations {
|
|
9
|
-
language:
|
|
2
|
+
language: string;
|
|
10
3
|
custom: Record<string, string>;
|
|
11
4
|
constructor(data?: Partial<LoyaltyWidgetTranslations>);
|
|
12
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{makeObservable as t,observable as o}from"mobx";var
|
|
1
|
+
import{makeObservable as t,observable as o}from"mobx";var a=function(a){void 0===a&&(a={}),this.language=a.language||"tr",this.custom=a.custom||{},t(this,{language:o,custom:o})};export{a as LoyaltyWidgetTranslations};
|
package/build/renderer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__spreadArray as n}from'./../ext/tslib/tslib.es6.mjs.js';import{toJS as r}from"mobx";import{observer as i}from"mobx-react";import o,{useState as s,useEffect as a}from"react";import'./../ext/react-i18next/dist/es/context.js';import{I18nextProvider as l}from'./../ext/react-i18next/dist/es/I18nextProvider.js';import{LoyaltyWidgetViewModel as c}from"../models/index.js";import{LoyaltyCustomerInfo as d}from"../models/loyalty-customer-info/index.js";import{LoyaltyProgramEarningMethod as u}from"../models/loyalty-program-earning-method/index.js";import{LoyaltyProgramPointHistory as f}from"../models/loyalty-program-point-history/index.js";import{LoyaltyProgramSpendingMethod as m}from"../models/loyalty-program-spending-method/index.js";import{LoyaltyWidget as v}from"../models/loyalty-widget/index.js";import{WidgetPositionEnum as g,LoyaltyWidgetLayoutTypeEnum as E}from"../models/loyalty-widget/types/index.js";import{WidgetMode as y,LoyaltyWidgetScreenTypeEnum as p,EarningMethodTypeEnum as h,LoyaltyProgramFilterTypeEnum as R,LoyaltyProgramMethodSpendingTypeEnum as T}from"../models/types/index.js";import I from"./components/mini-mode-button/index.js";import b from"./components/mini-mode-description/index.js";import w from"./screens/credit-earning-methods-screen/index.js";import M from"./screens/credit-history-screen/index.js";import k from"./screens/credit-spending-methods-screen/index.js";import _ from"./screens/loyalty-level-screen/index.js";import C from"./screens/main-screen/index.js";import{unflatten as S}from"./utils/object-utils.js";import N from"./utils/i18n.js";import{Container as A,MiniModeWrapper as O,Panel as D,ScreenWrapper as L}from"./style.js";var P=i(function(i){var P,j,x=i.config,U=s(function(){var e=x||window.ikasLoyaltyWidgetConfig;return new c({cartId:(null==e?void 0:e.cartId)||null,ikasEventUser:(null==e?void 0:e.userId)?{id:e.userId}:null},(null==e?void 0:e.cdnURL)||"",(null==e?void 0:e.merchantId)||"",(null==e?void 0:e.currency)||"",(null==e?void 0:e.
|
|
1
|
+
import{__awaiter as e,__generator as t,__spreadArray as n}from'./../ext/tslib/tslib.es6.mjs.js';import{toJS as r}from"mobx";import{observer as i}from"mobx-react";import o,{useState as s,useEffect as a}from"react";import'./../ext/react-i18next/dist/es/context.js';import{I18nextProvider as l}from'./../ext/react-i18next/dist/es/I18nextProvider.js';import{LoyaltyWidgetViewModel as c}from"../models/index.js";import{LoyaltyCustomerInfo as d}from"../models/loyalty-customer-info/index.js";import{LoyaltyProgramEarningMethod as u}from"../models/loyalty-program-earning-method/index.js";import{LoyaltyProgramPointHistory as f}from"../models/loyalty-program-point-history/index.js";import{LoyaltyProgramSpendingMethod as m}from"../models/loyalty-program-spending-method/index.js";import{LoyaltyWidget as v}from"../models/loyalty-widget/index.js";import{WidgetPositionEnum as g,LoyaltyWidgetLayoutTypeEnum as E}from"../models/loyalty-widget/types/index.js";import{WidgetMode as y,LoyaltyWidgetScreenTypeEnum as p,EarningMethodTypeEnum as h,LoyaltyProgramFilterTypeEnum as R,LoyaltyProgramMethodSpendingTypeEnum as T}from"../models/types/index.js";import I from"./components/mini-mode-button/index.js";import b from"./components/mini-mode-description/index.js";import w from"./screens/credit-earning-methods-screen/index.js";import M from"./screens/credit-history-screen/index.js";import k from"./screens/credit-spending-methods-screen/index.js";import _ from"./screens/loyalty-level-screen/index.js";import C from"./screens/main-screen/index.js";import{unflatten as S}from"./utils/object-utils.js";import N from"./utils/i18n.js";import{Container as A,MiniModeWrapper as O,Panel as D,ScreenWrapper as L}from"./style.js";var P=i(function(i){var P,j,x=i.config,U=s(function(){var e=x||window.ikasLoyaltyWidgetConfig;return new c({cartId:(null==e?void 0:e.cartId)||null,ikasEventUser:(null==e?void 0:e.userId)?{id:e.userId}:null},(null==e?void 0:e.cdnURL)||"",(null==e?void 0:e.merchantId)||"",(null==e?void 0:e.currency)||"",(null==e?void 0:e.storeURL)||null,null==e?void 0:e.isPreviewMode,null==e?void 0:e.callbacks)})[0],W=s(!1),$=W[0],G=W[1],B=U.loyaltyWidget.translations,V=JSON.stringify(r(null==B?void 0:B.custom));a(function(){var e=null==B?void 0:B.language,t=(null==B?void 0:B.custom)?r(B.custom):{};if(e){var n=["tr","en","de","nl","fr"].includes(e)?e:"en";if(N.language!==n&&N.changeLanguage(n),Object.keys(t).length>0){var i=S(t);N.addResourceBundle(n,"translation",i,!0,!0)}}},[null==B?void 0:B.language,V]),a(function(){var e=x||window.ikasLoyaltyWidgetConfig;(null==e?void 0:e.onViewModelInitialized)&&e.onViewModelInitialized(U)},[U,x]);var F=function(){return e(void 0,void 0,void 0,function(){var e,r,i,o,s;return t(this,function(t){switch(t.label){case 0:return U.callbacks?(e=new Set,r=new Set,i=new Set,o=new Set,U.earningMethods.forEach(function(t){var s,a;t.methodType===h.ORDER_CREATE&&n(n([],(null===(s=t.orderSettings)||void 0===s?void 0:s.productFilters)||[],!0),(null===(a=t.productSettings)||void 0===a?void 0:a.productFilters)||[],!0).forEach(function(t){t.type===R.PRODUCT_AND_VARIANT?t.idList.forEach(function(t){return e.add(t)}):t.type===R.CATEGORY?t.idList.forEach(function(e){return r.add(e)}):t.type===R.PRODUCT_BRAND?t.idList.forEach(function(e){return i.add(e)}):t.type===R.PRODUCT_TAG&&t.idList.forEach(function(e){return o.add(e)})})}),U.spendingMethods&&U.spendingMethods.forEach(function(t){var n,s;t.type===T.FREE_PRODUCT&&(null===(n=t.discountSettings)||void 0===n?void 0:n.freeProductId)&&e.add(t.discountSettings.freeProductId),null===(s=t.productFilters)||void 0===s||s.forEach(function(t){t.type===R.PRODUCT_AND_VARIANT?t.idList.forEach(function(t){return e.add(t)}):t.type===R.CATEGORY?t.idList.forEach(function(e){return r.add(e)}):t.type===R.PRODUCT_BRAND?t.idList.forEach(function(e){return i.add(e)}):t.type===R.PRODUCT_TAG&&t.idList.forEach(function(e){return o.add(e)})})}),s=[],e.size>0&&U.callbacks.getProducts&&s.push(U.callbacks.getProducts(Array.from(e)).then(function(e){return U.products=e})),r.size>0&&U.callbacks.getCategories&&s.push(U.callbacks.getCategories(Array.from(r)).then(function(e){return U.categories=e})),i.size>0&&U.callbacks.getBrands&&s.push(U.callbacks.getBrands(Array.from(i)).then(function(e){return U.brands=e})),o.size>0&&U.callbacks.getTags&&s.push(U.callbacks.getTags(Array.from(o)).then(function(e){return U.tags=e})),[4,Promise.all(s)]):[2];case 1:return t.sent(),[2]}})})};a(function(){e(void 0,void 0,void 0,function(){var e,n,r,i,o,s;return t(this,function(t){switch(t.label){case 0:if(!U.callbacks)return[3,6];t.label=1;case 1:return t.trys.push([1,4,5,6]),e=[U.callbacks.getLoyaltyWidget(),U.callbacks.listEarningMethods(),U.callbacks.listLoyaltyProgramTier({})],[4,Promise.all(e)];case 2:return n=t.sent(),r=n[0],i=n[1],o=n[2],U.loyaltyWidget=r instanceof v?r:new v(r||{}),U.earningMethods=i.map(function(e){return new u(e)}),U.tiers=o||[],[4,F()];case 3:return t.sent(),[3,6];case 4:return s=t.sent(),console.error("Failed to initialize loyalty data",s),[3,6];case 5:return G(!0),[7];case 6:return[2]}})})},[]),a(function(){if(window.IkasEvents){var e=function(e){var t,n=null===(t=e.data)||void 0===t?void 0:t.customer;n&&(U.ikasEventUser=n),U.userRefreshTrigger++,U.cartRefreshTrigger++},t=function(e){var t,n,r,i,o,s=U.cartId,a=null===(n=null===(t=e.data)||void 0===t?void 0:t.cart)||void 0===n?void 0:n.id;0===(null===(o=null===(i=null===(r=e.data)||void 0===r?void 0:r.cart)||void 0===i?void 0:i.orderLineItems)||void 0===o?void 0:o.length)?U.cartId=null:U.cartId=a,s!==U.cartId&&U.cartRefreshTrigger++},n={CUSTOMER_LOGIN:e,CUSTOMER_VISIT:e,CUSTOMER_LOGOUT:function(){U.userRefreshTrigger++,U.cartRefreshTrigger++},ADD_TO_CART:t,REMOVE_FROM_CART:t,REMOVE_LOYALTY_POINTS:function(e){U.cartRefreshTrigger++,U.userRefreshTrigger++},PAGE_VIEW:function(e){var t,n,r=null===(t=e.data)||void 0===t?void 0:t.customer;if(r){var i=!U.ikasEventUser,o=(null===(n=U.ikasEventUser)||void 0===n?void 0:n.subscriptionStatus)!==r.subscriptionStatus;(i||o)&&(U.ikasEventUser=r,U.userRefreshTrigger++,U.cartRefreshTrigger++)}}},r="ikas-loyalty-widget-subscriber";try{window.IkasEvents.subscribe({id:r,callback:function(e){var t=n[e.type];t&&t(e)}})}catch(e){console.error("Failed to subscribe to IkasEvents",e)}return function(){var e;(null===(e=window.IkasEvents)||void 0===e?void 0:e.unsubscribe)&&window.IkasEvents.unsubscribe(r)}}},[U]),a(function(){e(void 0,void 0,void 0,function(){var e,n,r,i,o;return t(this,function(t){switch(t.label){case 0:if(!U.callbacks||!(null===(o=U.ikasEventUser)||void 0===o?void 0:o.id))return[3,4];t.label=1;case 1:return t.trys.push([1,3,,4]),[4,Promise.all([U.callbacks.getLoyaltyCustomerInfo(),U.callbacks.listLoyaltyProgramPointHistory({})])];case 2:return e=t.sent(),n=e[0],r=e[1],U.user=n?new d(n):null,n||(U.ikasEventUser=null),U.pointHistory=r?r.map(function(e){return new f(e)}):[],[3,4];case 3:return i=t.sent(),console.error("Failed to fetch user data",i),[3,4];case 4:return[2]}})})},[null===(P=U.ikasEventUser)||void 0===P?void 0:P.id,U.userRefreshTrigger]),a(function(){e(void 0,void 0,void 0,function(){var e,n;return t(this,function(t){switch(t.label){case 0:if(!U.callbacks)return[3,5];t.label=1;case 1:return t.trys.push([1,4,,5]),[4,U.callbacks.listSpendingMethodsByCartId(U.cartId)];case 2:return e=t.sent(),U.spendingMethods=e.map(function(e){return new m(e)}),[4,F()];case 3:return t.sent(),[3,5];case 4:return n=t.sent(),console.error("Failed to fetch cart data",n),[3,5];case 5:return[2]}})})},[U.cartId,U.cartRefreshTrigger]);var z=function(e){U.selectedScreen=e},Y=function(){U.setWidgetMode(y.MINI_MODE),setTimeout(function(){U.selectedScreen=p.MAIN_SCREEN},300)};a(function(){return U.currentWidgetMode===y.WIDGET_MODE?document.body.style.overflow="hidden":document.body.style.overflow="",function(){document.body.style.overflow=""}},[U.currentWidgetMode]);var H=U.selectedScreen===p.MAIN_SCREEN,J=s(null),q=J[0],K=J[1];a(function(){U.selectedScreen!==p.MAIN_SCREEN&&K(U.selectedScreen)},[U.selectedScreen]);var Q=H?q:U.selectedScreen,X=U.loyaltyWidget.settings.position||g.RIGHT,Z=U.loyaltyWidget.settings.type||E.DRAWER;if(!$)return null;var ee=(null==x?void 0:x.position)||(null===(j=window.ikasLoyaltyWidgetConfig)||void 0===j?void 0:j.position)||"fixed";return o.createElement(l,{i18n:N},o.createElement(A,{$layoutType:Z,$widgetPosition:X,$widgetMode:U.currentWidgetMode,$position:ee,onClick:function(){U.currentWidgetMode===y.WIDGET_MODE&&Y()},className:"ikas-storefront-widget"},o.createElement(O,{$isVisible:U.currentWidgetMode===y.MINI_MODE,$widgetPosition:X},o.createElement(b,{viewModel:U}),o.createElement(I,{viewModel:U})),o.createElement(D,{$layoutType:Z,$isOpen:U.currentWidgetMode===y.WIDGET_MODE,$widgetPosition:X,onClick:function(e){return e.stopPropagation()}},o.createElement(L,{$isActive:H,$isMain:!0,$layoutType:Z},o.createElement(C,{viewModel:U,onClose:Y,onNavigate:z})),o.createElement(L,{$isActive:!H,$isMain:!1,$layoutType:Z},function(){switch(Q){case p.CREDIT_SPENDING_METHODS_SCREEN:return o.createElement(k,{viewModel:U,onBack:function(){return z(p.MAIN_SCREEN)},onClose:Y});case p.CREDIT_EARNING_METHODS_SCREEN:return o.createElement(w,{viewModel:U,onBack:function(){return z(p.MAIN_SCREEN)},onClose:Y});case p.CREDIT_HISTORY_SCREEN:return o.createElement(M,{viewModel:U,onBack:function(){return z(p.MAIN_SCREEN)},onClose:Y});case p.LOYALTY_LEVEL_SCREEN:return o.createElement(_,{viewModel:U,onBack:function(){return z(p.MAIN_SCREEN)},onClose:Y});default:return null}}()))))});export{P as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{observer as e}from"mobx-react";import t from"react";import'./../../../ext/react-i18next/dist/es/context.js';import{useTranslation as n}from'./../../../ext/react-i18next/dist/es/useTranslation.js';import{XClose as r}from"../../../assets/icons/x-close.js";import{ChevronLeft as l}from"../../../assets/icons/chevron-left.js";import{LoyaltyProgramPointHistoryTypeEnum as o}from"../../../models/types/index.js";import a from"../../components/count-up/index.js";import{Container as m,Header as c,IconButton as i,Title as s,Content as u,PointsSection as d,PointsTitle as E,PointsValue as p,HistoryList as f,HistoryItem as y,HistoryItemLeft as x,HistoryItemTitle as
|
|
1
|
+
import{observer as e}from"mobx-react";import t from"react";import'./../../../ext/react-i18next/dist/es/context.js';import{useTranslation as n}from'./../../../ext/react-i18next/dist/es/useTranslation.js';import{XClose as r}from"../../../assets/icons/x-close.js";import{ChevronLeft as l}from"../../../assets/icons/chevron-left.js";import{LoyaltyProgramPointHistoryTypeEnum as o}from"../../../models/types/index.js";import a from"../../components/count-up/index.js";import{Container as m,Header as c,IconButton as i,Title as s,Content as u,PointsSection as d,PointsTitle as E,PointsValue as p,HistoryList as f,HistoryItem as y,HistoryItemLeft as x,HistoryItemTitle as g,HistoryItemDate as h,HistoryItemAmount as j,Divider as v}from"./style.js";var k=e(function(e){var k=e.viewModel,T=e.onBack,w=e.onClose,C=n(),R=C.t,b=C.i18n,A=k.user,B=k.pointHistory;return t.createElement(m,null,t.createElement(c,null,t.createElement(i,{onClick:T},t.createElement(l,null)),t.createElement(s,null,R("screens.creditHistory")),t.createElement(i,{onClick:w},t.createElement(r,null))),t.createElement(u,null,A&&t.createElement(d,{$borderRadius:k.loyaltyWidget.settings.cartBorderRadius},t.createElement(E,null,R("header.earnedPoints")),t.createElement(p,null,t.createElement(a,{end:A.totalPoint}))),t.createElement(f,null,B.map(function(e,n){var r=e.type===o.EARN;return t.createElement(t.Fragment,{key:e.id},t.createElement(y,null,t.createElement(x,null,t.createElement(g,null,R(r?"history.earnedTitle":"history.spentTitle")),t.createElement(h,null,function(e){if(!e)return"";try{return new Intl.DateTimeFormat(b.language,{day:"numeric",month:"long",year:"numeric"}).format(new Date(e))}catch(t){return e}}(e.createdAt))),t.createElement(j,{$isEarn:r},r?"":"-",e.amount)),n<B.length-1&&t.createElement(v,null))}))))});export{k as default};
|