@ikas/loyalty-widget-renderer 1.0.0-alpha.93 → 1.0.0-alpha.94
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/models/loyalty-widget/settings/index.d.ts +1 -0
- package/build/models/loyalty-widget/settings/index.js +1 -1
- package/build/renderer/index.js +1 -1
- package/build/renderer/screens/credit-history-screen/index.js +1 -1
- package/build/renderer/screens/credit-history-screen/style.js +1 -1
- package/build/storefront-widget-script-injector.iife.js +1 -1
- package/build/storefront-widget-script-injector.iife.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { BadgeIconTypeEnum, LoyaltyWidgetLayoutTypeEnum, WidgetIconTypeEnum, Wid
|
|
|
2
2
|
export declare class LoyaltyWidgetSettings {
|
|
3
3
|
position: WidgetPositionEnum;
|
|
4
4
|
type: LoyaltyWidgetLayoutTypeEnum;
|
|
5
|
+
openOnPageLoad: boolean;
|
|
5
6
|
primaryColor: string | null;
|
|
6
7
|
cartBorderRadius: number;
|
|
7
8
|
widgetIconType: WidgetIconTypeEnum;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{makeObservable as o,observable as
|
|
1
|
+
import{makeObservable as o,observable as e}from"mobx";import{WidgetPositionEnum as i,LoyaltyWidgetLayoutTypeEnum as r,WidgetIconTypeEnum as t,BadgeIconTypeEnum as a}from"../types/index.js";var n=function(n){var p;void 0===n&&(n={}),this.position=n.position||i.RIGHT,this.type=n.type||r.DRAWER,this.openOnPageLoad=!0===n.openOnPageLoad,this.primaryColor=n.primaryColor||null,this.cartBorderRadius=null!==(p=n.cartBorderRadius)&&void 0!==p?p:0,this.widgetIconType=n.widgetIconType||t.NORMAL,this.badgeIconLevel=n.badgeIconLevel||a.LEVEL_1,o(this,{position:e,type:e,openOnPageLoad:e,primaryColor:e,cartBorderRadius:e,widgetIconType:e,badgeIconLevel:e})};export{n as LoyaltyWidgetSettings};
|
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 v}from"../models/loyalty-program-spending-method/index.js";import{LoyaltyWidget as m}from"../models/loyalty-widget/index.js";import{WidgetPositionEnum as g,LoyaltyWidgetLayoutTypeEnum as p}from"../models/loyalty-widget/types/index.js";import{WidgetMode as y,LoyaltyWidgetScreenTypeEnum as E,EarningMethodTypeEnum as h,LoyaltyProgramFilterTypeEnum as T,LoyaltyProgramMethodSpendingTypeEnum as R}from"../models/types/index.js";import k 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 I from"./screens/credit-history-screen/index.js";import M from"./screens/credit-spending-methods-screen/index.js";import _ from"./screens/gift-product-selection-screen/index.js";import C from"./screens/loyalty-level-screen/index.js";import O from"./screens/main-screen/index.js";import S from"./utils/i18n.js";import{unflatten as D}from"./utils/object-utils.js";import{Container as A,MiniModeWrapper as L,Panel as P,ScreenWrapper as U}from"./style.js";var j=i(function(i){var j,x,N,W=i.config,$=s(function(){var e=W||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],G=s(!1),B=G[0],F=G[1],V=s(!1),z=V[0],Y=V[1],H=s(!1),J=H[0],q=H[1],K=$.loyaltyWidget.translations,Q=JSON.stringify(r(null==K?void 0:K.custom));a(function(){var e=null==K?void 0:K.language,t=(null==K?void 0:K.custom)?r(K.custom):{};if(e){var n=["tr","en","de","nl","fr"].includes(e)?e:"en";if(S.language!==n&&S.changeLanguage(n),Object.keys(t).length>0){var i=D(t);S.addResourceBundle(n,"translation",i,!0,!0)}}},[null==K?void 0:K.language,Q]),a(function(){var e=W||window.ikasLoyaltyWidgetConfig;(null==e?void 0:e.onViewModelInitialized)&&e.onViewModelInitialized($)},[$,W]);var X=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 $.callbacks?(e=new Set,r=new Set,i=new Set,o=new Set,$.earningMethods.forEach(function(t){var s,a;t.methodType!==h.ORDER_CREATE&&t.methodType!==h.BUY_PRODUCT||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===T.PRODUCT_AND_VARIANT?t.idList.forEach(function(t){t.startsWith("v:")||e.add(t.replace(/^p:/,""))}):t.type===T.CATEGORY?t.idList.forEach(function(e){return r.add(e)}):t.type===T.PRODUCT_BRAND?t.idList.forEach(function(e){return i.add(e)}):t.type===T.PRODUCT_TAG&&t.idList.forEach(function(e){return o.add(e)})})}),$.spendingMethods&&$.spendingMethods.forEach(function(t){var n,s;t.type===R.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===T.PRODUCT_AND_VARIANT?t.idList.forEach(function(t){t.startsWith("v:")||e.add(t.replace(/^p:/,""))}):t.type===T.CATEGORY?t.idList.forEach(function(e){return r.add(e)}):t.type===T.PRODUCT_BRAND?t.idList.forEach(function(e){return i.add(e)}):t.type===T.PRODUCT_TAG&&t.idList.forEach(function(e){return o.add(e)})})}),s=[],e.size>0&&$.callbacks.getProducts&&s.push($.callbacks.getProducts(Array.from(e)).then(function(e){$.products=e})),r.size>0&&$.callbacks.getCategories&&s.push($.callbacks.getCategories(Array.from(r)).then(function(e){return $.categories=e})),i.size>0&&$.callbacks.getBrands&&s.push($.callbacks.getBrands(Array.from(i)).then(function(e){return $.brands=e})),o.size>0&&$.callbacks.getTags&&s.push($.callbacks.getTags(Array.from(o)).then(function(e){return $.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(!$.callbacks)return[3,6];t.label=1;case 1:return t.trys.push([1,4,5,6]),e=[$.callbacks.getLoyaltyWidget(),$.callbacks.listEarningMethods(),$.callbacks.listLoyaltyProgramTier({})],[4,Promise.all(e)];case 2:return n=t.sent(),r=n[0],i=n[1],o=n[2],$.loyaltyWidget=r instanceof m?r:new m(r||{}),$.earningMethods=i.map(function(e){return new u(e)}),$.tiers=o||[],[4,X()];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 F(!0),[7];case 6:return[2]}})})},[]),a(function(){if(window.IkasEvents){var e=function(e){var t,n,r=null===(t=e.data)||void 0===t?void 0:t.customer;(null==r?void 0:r.id)&&(null===(n=$.ikasEventUser)||void 0===n?void 0:n.id)!==r.id&&($.ikasEventUser=r,$.userRefreshTrigger++,$.cartRefreshTrigger++)},t=function(e){var t,n,r,i,o,s=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)?$.cartId=null:$.cartId=s,$.cartRefreshTrigger++},n={CUSTOMER_LOGIN:e,CUSTOMER_VISIT:e,CUSTOMER_LOGOUT:function(){$.ikasEventUser=null,$.user=null,$.pointHistory=[],$.userRefreshTrigger++,$.cartRefreshTrigger++},ADD_TO_CART:function(e){return t(e)},REMOVE_FROM_CART:t,REMOVE_LOYALTY_POINTS:function(){$.cartRefreshTrigger++,$.userRefreshTrigger++},PAGE_VIEW:function(e){var t,n,r=null===(t=e.data)||void 0===t?void 0:t.customer;if(null==r?void 0:r.id){var i=!$.ikasEventUser,o=(null===(n=$.ikasEventUser)||void 0===n?void 0:n.subscriptionStatus)!==r.subscriptionStatus;(i||o)&&($.ikasEventUser=r,$.userRefreshTrigger++,$.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)}}},[$]),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(z)return[2];if(Y(!0),!$.callbacks||!(null===(o=$.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([$.callbacks.getLoyaltyCustomerInfo(),$.callbacks.listLoyaltyProgramPointHistory({})])];case 2:return e=t.sent(),n=e[0],r=e[1],$.user=n?new d(n):null,n||($.ikasEventUser=null),$.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 Y(!1),[2]}})})},[null===(j=$.ikasEventUser)||void 0===j?void 0:j.id,$.userRefreshTrigger]),a(function(){e(void 0,void 0,void 0,function(){var e,n,r;return t(this,function(t){switch(t.label){case 0:if(J)return[2];if(q(!0),!$.callbacks||!(null===(r=$.ikasEventUser)||void 0===r?void 0:r.id))return[3,6];t.label=1;case 1:return t.trys.push([1,4,,5]),[4,$.callbacks.listSpendingMethodsByCartId($.cartId)];case 2:return e=t.sent(),$.spendingMethods=e.map(function(e){return new v(e)}),[4,X()];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[3,7];case 6:$.spendingMethods=[],t.label=7;case 7:return q(!1),[2]}})})},[$.cartId,$.cartRefreshTrigger,null===(x=$.ikasEventUser)||void 0===x?void 0:x.id]);var Z=function(){$.setWidgetMode(y.MINI_MODE),setTimeout(function(){$.resetNavigation()},300)};a(function(){return $.currentWidgetMode===y.WIDGET_MODE?document.body.style.overflow="hidden":document.body.style.overflow="",function(){document.body.style.overflow=""}},[$.currentWidgetMode]);var ee=s(null),te=ee[0],ne=ee[1],re=s(null),ie=re[0],oe=re[1],se=$.navigationStack.length,ae=se>1?$.navigationStack[1]:null,le=se>2?$.navigationStack[2]:null;a(function(){ae&&ne(ae)},[ae]),a(function(){le&&oe(le)},[le]);var ce=$.loyaltyWidget.settings.position||g.RIGHT,de=$.loyaltyWidget.settings.type||p.DRAWER,ue=function(e){switch(e){case E.CREDIT_SPENDING_METHODS_SCREEN:return o.createElement(M,{viewModel:$,onBack:function(){return $.popScreen()},onClose:Z});case E.CREDIT_EARNING_METHODS_SCREEN:return o.createElement(w,{viewModel:$,onBack:function(){return $.popScreen()},onClose:Z});case E.CREDIT_HISTORY_SCREEN:return o.createElement(I,{viewModel:$,onBack:function(){return $.popScreen()},onClose:Z});case E.LOYALTY_LEVEL_SCREEN:return o.createElement(C,{viewModel:$,onBack:function(){return $.popScreen()},onClose:Z});case E.GIFT_PRODUCT_SELECTION_SCREEN:return o.createElement(_,{viewModel:$,onBack:function(){return $.popScreen()},onClose:Z});default:return null}};if(!B)return null;var fe=(null==W?void 0:W.position)||(null===(N=window.ikasLoyaltyWidgetConfig)||void 0===N?void 0:N.position)||"fixed";return o.createElement(l,{i18n:S},o.createElement(A,{$layoutType:de,$widgetPosition:ce,$widgetMode:$.currentWidgetMode,$position:fe,onClick:function(){$.currentWidgetMode===y.WIDGET_MODE&&Z()},className:"ikas-storefront-widget"},o.createElement(L,{$isVisible:$.currentWidgetMode===y.MINI_MODE,$widgetPosition:ce},o.createElement(b,{viewModel:$,isInitialized:B}),o.createElement(k,{viewModel:$})),o.createElement(P,{$layoutType:de,$isOpen:$.currentWidgetMode===y.WIDGET_MODE,$widgetPosition:ce,onClick:function(e){return e.stopPropagation()}},o.createElement(U,{$isActive:$.isMainScreen,$layer:0,$layoutType:de},o.createElement(O,{viewModel:$,onClose:Z,onNavigate:function(e){return $.pushScreen(e)}})),o.createElement(U,{$isActive:!!ae,$layer:1,$layoutType:de},ue(ae||te)),o.createElement(U,{$isActive:!!le,$layer:2,$layoutType:de},ue(le||ie)))))});export{j as default};
|
|
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 d}from"../models/index.js";import{LoyaltyCustomerInfo as c}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 v}from"../models/loyalty-program-spending-method/index.js";import{LoyaltyWidget as m}from"../models/loyalty-widget/index.js";import{WidgetPositionEnum as g,LoyaltyWidgetLayoutTypeEnum as p}from"../models/loyalty-widget/types/index.js";import{WidgetMode as y,LoyaltyWidgetScreenTypeEnum as E,EarningMethodTypeEnum as h,LoyaltyProgramFilterTypeEnum as T,LoyaltyProgramMethodSpendingTypeEnum as R}from"../models/types/index.js";import k 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 I from"./screens/credit-history-screen/index.js";import M from"./screens/credit-spending-methods-screen/index.js";import _ from"./screens/gift-product-selection-screen/index.js";import C from"./screens/loyalty-level-screen/index.js";import O from"./screens/main-screen/index.js";import S from"./utils/i18n.js";import{unflatten as D}from"./utils/object-utils.js";import{Container as P,MiniModeWrapper as L,Panel as A,ScreenWrapper as U}from"./style.js";var j=i(function(i){var j,W,x,N=i.config,$=s(function(){var e=N||window.ikasLoyaltyWidgetConfig;return new d({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],G=s(!1),B=G[0],F=G[1],V=s(!1),z=V[0],Y=V[1],H=s(!1),J=H[0],q=H[1],K=$.loyaltyWidget.translations,Q=JSON.stringify(r(null==K?void 0:K.custom));a(function(){var e=null==K?void 0:K.language,t=(null==K?void 0:K.custom)?r(K.custom):{};if(e){var n=["tr","en","de","nl","fr"].includes(e)?e:"en";if(S.language!==n&&S.changeLanguage(n),Object.keys(t).length>0){var i=D(t);S.addResourceBundle(n,"translation",i,!0,!0)}}},[null==K?void 0:K.language,Q]),a(function(){var e=N||window.ikasLoyaltyWidgetConfig;(null==e?void 0:e.onViewModelInitialized)&&e.onViewModelInitialized($)},[$,N]);var X=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 $.callbacks?(e=new Set,r=new Set,i=new Set,o=new Set,$.earningMethods.forEach(function(t){var s,a;t.methodType!==h.ORDER_CREATE&&t.methodType!==h.BUY_PRODUCT||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===T.PRODUCT_AND_VARIANT?t.idList.forEach(function(t){t.startsWith("v:")||e.add(t.replace(/^p:/,""))}):t.type===T.CATEGORY?t.idList.forEach(function(e){return r.add(e)}):t.type===T.PRODUCT_BRAND?t.idList.forEach(function(e){return i.add(e)}):t.type===T.PRODUCT_TAG&&t.idList.forEach(function(e){return o.add(e)})})}),$.spendingMethods&&$.spendingMethods.forEach(function(t){var n,s;t.type===R.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===T.PRODUCT_AND_VARIANT?t.idList.forEach(function(t){t.startsWith("v:")||e.add(t.replace(/^p:/,""))}):t.type===T.CATEGORY?t.idList.forEach(function(e){return r.add(e)}):t.type===T.PRODUCT_BRAND?t.idList.forEach(function(e){return i.add(e)}):t.type===T.PRODUCT_TAG&&t.idList.forEach(function(e){return o.add(e)})})}),s=[],e.size>0&&$.callbacks.getProducts&&s.push($.callbacks.getProducts(Array.from(e)).then(function(e){$.products=e})),r.size>0&&$.callbacks.getCategories&&s.push($.callbacks.getCategories(Array.from(r)).then(function(e){return $.categories=e})),i.size>0&&$.callbacks.getBrands&&s.push($.callbacks.getBrands(Array.from(i)).then(function(e){return $.brands=e})),o.size>0&&$.callbacks.getTags&&s.push($.callbacks.getTags(Array.from(o)).then(function(e){return $.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(!$.callbacks)return[3,6];t.label=1;case 1:return t.trys.push([1,4,5,6]),e=[$.callbacks.getLoyaltyWidget(),$.callbacks.listEarningMethods(),$.callbacks.listLoyaltyProgramTier({})],[4,Promise.all(e)];case 2:return n=t.sent(),r=n[0],i=n[1],o=n[2],$.loyaltyWidget=r instanceof m?r:new m(r||{}),$.earningMethods=i.map(function(e){return new u(e)}),$.tiers=o||[],[4,X()];case 3:return t.sent(),!$.isPreviewMode&&$.loyaltyWidget.settings.openOnPageLoad&&$.setWidgetMode(y.WIDGET_MODE),[3,6];case 4:return s=t.sent(),console.error("Failed to initialize loyalty data",s),[3,6];case 5:return F(!0),[7];case 6:return[2]}})})},[]),a(function(){if(window.IkasEvents){var e=function(e){var t,n,r=null===(t=e.data)||void 0===t?void 0:t.customer;(null==r?void 0:r.id)&&(null===(n=$.ikasEventUser)||void 0===n?void 0:n.id)!==r.id&&($.ikasEventUser=r,$.userRefreshTrigger++,$.cartRefreshTrigger++)},t=function(e){var t,n,r,i,o,s=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)?$.cartId=null:$.cartId=s,$.cartRefreshTrigger++},n={CUSTOMER_LOGIN:e,CUSTOMER_VISIT:e,CUSTOMER_LOGOUT:function(){$.ikasEventUser=null,$.user=null,$.pointHistory=[],$.userRefreshTrigger++,$.cartRefreshTrigger++},ADD_TO_CART:function(e){return t(e)},REMOVE_FROM_CART:t,REMOVE_LOYALTY_POINTS:function(){$.cartRefreshTrigger++,$.userRefreshTrigger++},PAGE_VIEW:function(e){var t,n,r=null===(t=e.data)||void 0===t?void 0:t.customer;if(null==r?void 0:r.id){var i=!$.ikasEventUser,o=(null===(n=$.ikasEventUser)||void 0===n?void 0:n.subscriptionStatus)!==r.subscriptionStatus;(i||o)&&($.ikasEventUser=r,$.userRefreshTrigger++,$.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)}}},[$]),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(z)return[2];if(Y(!0),!$.callbacks||!(null===(o=$.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([$.callbacks.getLoyaltyCustomerInfo(),$.callbacks.listLoyaltyProgramPointHistory({})])];case 2:return e=t.sent(),n=e[0],r=e[1],$.user=n?new c(n):null,n||($.ikasEventUser=null),$.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 Y(!1),[2]}})})},[null===(j=$.ikasEventUser)||void 0===j?void 0:j.id,$.userRefreshTrigger]),a(function(){e(void 0,void 0,void 0,function(){var e,n,r;return t(this,function(t){switch(t.label){case 0:if(J)return[2];if(q(!0),!$.callbacks||!(null===(r=$.ikasEventUser)||void 0===r?void 0:r.id))return[3,6];t.label=1;case 1:return t.trys.push([1,4,,5]),[4,$.callbacks.listSpendingMethodsByCartId($.cartId)];case 2:return e=t.sent(),$.spendingMethods=e.map(function(e){return new v(e)}),[4,X()];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[3,7];case 6:$.spendingMethods=[],t.label=7;case 7:return q(!1),[2]}})})},[$.cartId,$.cartRefreshTrigger,null===(W=$.ikasEventUser)||void 0===W?void 0:W.id]);var Z=function(){$.setWidgetMode(y.MINI_MODE),setTimeout(function(){$.resetNavigation()},300)};a(function(){return $.currentWidgetMode===y.WIDGET_MODE?document.body.style.overflow="hidden":document.body.style.overflow="",function(){document.body.style.overflow=""}},[$.currentWidgetMode]);var ee=s(null),te=ee[0],ne=ee[1],re=s(null),ie=re[0],oe=re[1],se=$.navigationStack.length,ae=se>1?$.navigationStack[1]:null,le=se>2?$.navigationStack[2]:null;a(function(){ae&&ne(ae)},[ae]),a(function(){le&&oe(le)},[le]);var de=$.loyaltyWidget.settings.position||g.RIGHT,ce=$.loyaltyWidget.settings.type||p.DRAWER,ue=function(e){switch(e){case E.CREDIT_SPENDING_METHODS_SCREEN:return o.createElement(M,{viewModel:$,onBack:function(){return $.popScreen()},onClose:Z});case E.CREDIT_EARNING_METHODS_SCREEN:return o.createElement(w,{viewModel:$,onBack:function(){return $.popScreen()},onClose:Z});case E.CREDIT_HISTORY_SCREEN:return o.createElement(I,{viewModel:$,onBack:function(){return $.popScreen()},onClose:Z});case E.LOYALTY_LEVEL_SCREEN:return o.createElement(C,{viewModel:$,onBack:function(){return $.popScreen()},onClose:Z});case E.GIFT_PRODUCT_SELECTION_SCREEN:return o.createElement(_,{viewModel:$,onBack:function(){return $.popScreen()},onClose:Z});default:return null}};if(!B)return null;var fe=(null==N?void 0:N.position)||(null===(x=window.ikasLoyaltyWidgetConfig)||void 0===x?void 0:x.position)||"fixed";return o.createElement(l,{i18n:S},o.createElement(P,{$layoutType:ce,$widgetPosition:de,$widgetMode:$.currentWidgetMode,$position:fe,onClick:function(){$.currentWidgetMode===y.WIDGET_MODE&&Z()},className:"ikas-storefront-widget"},o.createElement(L,{$isVisible:$.currentWidgetMode===y.MINI_MODE,$widgetPosition:de},o.createElement(b,{viewModel:$,isInitialized:B}),o.createElement(k,{viewModel:$})),o.createElement(A,{$layoutType:ce,$isOpen:$.currentWidgetMode===y.WIDGET_MODE,$widgetPosition:de,onClick:function(e){return e.stopPropagation()}},o.createElement(U,{$isActive:$.isMainScreen,$layer:0,$layoutType:ce},o.createElement(O,{viewModel:$,onClose:Z,onNavigate:function(e){return $.pushScreen(e)}})),o.createElement(U,{$isActive:!!ae,$layer:1,$layoutType:ce},ue(ae||te)),o.createElement(U,{$isActive:!!le,$layer:2,$layoutType:ce},ue(le||ie)))))});export{j 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,EarningMethodTypeEnum as i}from"../../../models/types/index.js";import a from"../../components/count-up/index.js";import{getRefundIcon as u,getHistoryEarningMethodLabel as s,getEarningMethodIcon as c}from"../../../utils.js";import{Container as m,Header as d,IconButton as E,Title as y,Content as p,PointsSection as f,PointsTitle as h,PointsValue as g,HistoryList as T,HistoryItem as A,HistoryItemLeft as N,HistoryItemTitle as D,EarningMethodInfo as R,EarningMethodIcon as M,HistoryItemDate as x,ExpirationWarning as v,HistoryItemAmount as U,Divider as L}from"./style.js";var w=[o.EARN,o.REFILL,o.MANUAL_EARN],I=[o.SPEND,o.REFUND,o.MANUAL_DEDUCT],_=e(function(e){var _=e.viewModel,j=e.onBack,F=e.onClose,C=n(),b=C.t,k=C.i18n,P=_.user,H=_.pointHistory,W=_.earningMethods;return t.createElement(m,null,t.createElement(d,null,t.createElement(E,{onClick:j},t.createElement(l,null)),t.createElement(y,null,b("screens.creditHistory")),t.createElement(E,{onClick:F},t.createElement(r,null))),t.createElement(p,null,P&&t.createElement(f,{$borderRadius:_.loyaltyWidget.settings.cartBorderRadius},t.createElement(h,null,b("header.earnedPoints")),t.createElement(g,null,t.createElement(a,{end:P.totalPoint}))),t.createElement(T,null,H.map(function(e,n){var r,l=(r=e.type,w.includes(r)?"positive":I.includes(r)?"negative":"neutral"),a=function(e){if(!e)return null;var t=new Date(e);if(Number.isNaN(t.getTime()))return null;var n=t.getTime()-Date.now();if(n<=0)return b("history.expired");if(n>=864e5)return b("history.expiresInDays",{count:Math.floor(n/864e5)});var r=Math.floor(n/6e4);return n<36e5?b("history.expiresInMinutes",{count:Math.max(1,r)}):b("history.expiresInHoursAndMinutes",{hours:b("history.hours",{count:Math.floor(r/60)}),minutes:b("history.minutes",{count:r%60})})}(e.expireDate),m=function(e){if(e.type===o.MANUAL_EARN||e.type===o.MANUAL_DEDUCT)return null;var t=e.loyaltyProgramEarningMethodId;if(!t)return null;var n=W.find(function(e){return e.id===t});return e.type===o.REFUND?{label:b("history.orderRefund"),icon:u(_.loyaltyWidget.settings.widgetIconType),methodType:i.ORDER_CREATE}:n&&e.type===o.EARN?{label:s(n.methodType),icon:c(n.methodType,_.loyaltyWidget.settings.widgetIconType),methodType:n.methodType}:null}(e);return t.createElement(t.Fragment,{key:e.id},t.createElement(A,null,t.createElement(N,null,t.createElement(D,null,function(){switch(e.type){case o.EARN:return b("history.earnedTitle");case o.SPEND:return b("history.spentTitle");case o.REFUND:return b("history.refundTitle");case o.REFILL:return b("history.refillTitle");case o.MANUAL_EARN:return b("history.manualEarnTitle");case o.MANUAL_DEDUCT:return b("history.manualDeductTitle");default:return b("history.unknownTitle")}}()),m&&t.createElement(t.Fragment,null,t.createElement(R,null,m.icon&&t.createElement(M,null,m.icon),m.label)),t.createElement(x,null,function(e){if(!e)return"";try{return new Intl.DateTimeFormat(k.language,{day:"numeric",month:"long",year:"numeric"}).format(new Date(e))}catch(t){return e}}(e.createdAt),a&&t.createElement(v,null,
|
|
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,EarningMethodTypeEnum as i}from"../../../models/types/index.js";import a from"../../components/count-up/index.js";import{getRefundIcon as u,getHistoryEarningMethodLabel as s,getEarningMethodIcon as c}from"../../../utils.js";import{Container as m,Header as d,IconButton as E,Title as y,Content as p,PointsSection as f,PointsTitle as h,PointsValue as g,HistoryList as T,HistoryItem as A,HistoryItemLeft as N,HistoryItemTitle as D,EarningMethodInfo as R,EarningMethodIcon as M,HistoryItemDate as x,ExpirationWarning as v,HistoryItemAmount as U,Divider as L}from"./style.js";var w=[o.EARN,o.REFILL,o.MANUAL_EARN],I=[o.SPEND,o.REFUND,o.MANUAL_DEDUCT],_=e(function(e){var _=e.viewModel,j=e.onBack,F=e.onClose,C=n(),b=C.t,k=C.i18n,P=_.user,H=_.pointHistory,W=_.earningMethods;return t.createElement(m,null,t.createElement(d,null,t.createElement(E,{onClick:j},t.createElement(l,null)),t.createElement(y,null,b("screens.creditHistory")),t.createElement(E,{onClick:F},t.createElement(r,null))),t.createElement(p,null,P&&t.createElement(f,{$borderRadius:_.loyaltyWidget.settings.cartBorderRadius},t.createElement(h,null,b("header.earnedPoints")),t.createElement(g,null,t.createElement(a,{end:P.totalPoint}))),t.createElement(T,null,H.map(function(e,n){var r,l=(r=e.type,w.includes(r)?"positive":I.includes(r)?"negative":"neutral"),a=function(e){if(!e)return null;var t=new Date(e);if(Number.isNaN(t.getTime()))return null;var n=t.getTime()-Date.now();if(n<=0)return b("history.expired");if(n>=864e5)return b("history.expiresInDays",{count:Math.floor(n/864e5)});var r=Math.floor(n/6e4);return n<36e5?b("history.expiresInMinutes",{count:Math.max(1,r)}):b("history.expiresInHoursAndMinutes",{hours:b("history.hours",{count:Math.floor(r/60)}),minutes:b("history.minutes",{count:r%60})})}(e.expireDate),m=function(e){if(e.type===o.MANUAL_EARN||e.type===o.MANUAL_DEDUCT)return null;var t=e.loyaltyProgramEarningMethodId;if(!t)return null;var n=W.find(function(e){return e.id===t});return e.type===o.REFUND?{label:b("history.orderRefund"),icon:u(_.loyaltyWidget.settings.widgetIconType),methodType:i.ORDER_CREATE}:n&&e.type===o.EARN?{label:s(n.methodType),icon:c(n.methodType,_.loyaltyWidget.settings.widgetIconType),methodType:n.methodType}:null}(e);return t.createElement(t.Fragment,{key:e.id},t.createElement(A,null,t.createElement(N,null,t.createElement(D,null,function(){switch(e.type){case o.EARN:return b("history.earnedTitle");case o.SPEND:return b("history.spentTitle");case o.REFUND:return b("history.refundTitle");case o.REFILL:return b("history.refillTitle");case o.MANUAL_EARN:return b("history.manualEarnTitle");case o.MANUAL_DEDUCT:return b("history.manualDeductTitle");default:return b("history.unknownTitle")}}()),m&&t.createElement(t.Fragment,null,t.createElement(R,null,m.icon&&t.createElement(M,null,m.icon),m.label)),t.createElement(x,null,function(e){if(!e)return"";try{return new Intl.DateTimeFormat(k.language,{day:"numeric",month:"long",year:"numeric"}).format(new Date(e))}catch(t){return e}}(e.createdAt),a&&t.createElement(v,null,a))),t.createElement(U,{$sign:l},"negative"===l?"-":"",e.amount)),n<H.length-1&&t.createElement(L,null))}))))});export{_ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__makeTemplateObject as n}from'./../../../ext/tslib/tslib.es6.mjs.js';import e from"styled-components";import{textMDMedium as i,textSMMedium as o,textXLSemiBold as t,textXSMedium as p,textLGMedium as r}from"../../components/style/typography.js";var d,
|
|
1
|
+
import{__makeTemplateObject as n}from'./../../../ext/tslib/tslib.es6.mjs.js';import e from"styled-components";import{textMDMedium as i,textSMMedium as o,textXLSemiBold as t,textXSMedium as p,textLGMedium as r}from"../../components/style/typography.js";var l,d,a,x,c,f,s,g,b,m,y,u,h,v,w,k,j,z,$=e.div(l||(l=n(["\n display: flex;\n flex-direction: column;\n height: 100%;\n background-color: #ffffff;\n"],["\n display: flex;\n flex-direction: column;\n height: 100%;\n background-color: #ffffff;\n"]))),R=e.div(d||(d=n(["\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 20px;\n border-bottom: 1px solid #eef2f6;\n position: sticky;\n top: 0;\n background-color: #ffffff;\n z-index: 10;\n"],["\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 20px;\n border-bottom: 1px solid #eef2f6;\n position: sticky;\n top: 0;\n background-color: #ffffff;\n z-index: 10;\n"]))),_=e.div(a||(a=n(["\n ","\n color: #121926;\n text-align: center;\n flex: 1;\n"],["\n ","\n color: #121926;\n text-align: center;\n flex: 1;\n"])),i),q=e.button(x||(x=n(["\n background: none;\n border: none;\n cursor: pointer;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #697586;\n\n &:hover {\n opacity: 0.8;\n }\n"],["\n background: none;\n border: none;\n cursor: pointer;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #697586;\n\n &:hover {\n opacity: 0.8;\n }\n"]))),A=e.div(c||(c=n(["\n padding-top: 20px;\n padding-bottom: 20px;\n flex: 1;\n overflow-y: auto;\n"],["\n padding-top: 20px;\n padding-bottom: 20px;\n flex: 1;\n overflow-y: auto;\n"]))),B=e.div(f||(f=n(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 16px;\n border-radius: ",";\n border: 1px solid #eef2f6;\n background: #fff;\n box-shadow:\n 0 7px 2px 0 rgba(0, 0, 0, 0),\n 0 5px 2px 0 rgba(0, 0, 0, 0.01),\n 0 3px 2px 0 rgba(0, 0, 0, 0.02),\n 0 1px 1px 0 rgba(0, 0, 0, 0.03),\n 0 0 1px 0 rgba(0, 0, 0, 0.04);\n margin: 0 16px 24px 16px;\n"],["\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 16px;\n border-radius: ",";\n border: 1px solid #eef2f6;\n background: #fff;\n box-shadow:\n 0 7px 2px 0 rgba(0, 0, 0, 0),\n 0 5px 2px 0 rgba(0, 0, 0, 0.01),\n 0 3px 2px 0 rgba(0, 0, 0, 0.02),\n 0 1px 1px 0 rgba(0, 0, 0, 0.03),\n 0 0 1px 0 rgba(0, 0, 0, 0.04);\n margin: 0 16px 24px 16px;\n"])),function(n){var e=n.$borderRadius;return"".concat(e,"px")}),C=e.div(s||(s=n(["\n ","\n color: #121926;\n"],["\n ","\n color: #121926;\n"])),o),D=e.div(g||(g=n(["\n ","\n color: #121926;\n"],["\n ","\n color: #121926;\n"])),t),E=e.div(b||(b=n(["\n display: flex;\n flex-direction: column;\n padding: 0 16px;\n margin-top: 4px;\n"],["\n display: flex;\n flex-direction: column;\n padding: 0 16px;\n margin-top: 4px;\n"]))),F=e.div(m||(m=n(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 0 12px 0 6px;\n gap: 16px;\n"],["\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 0 12px 0 6px;\n gap: 16px;\n"]))),G=e.div(y||(y=n(["\n display: flex;\n flex-direction: column;\n gap: 4px;\n"],["\n display: flex;\n flex-direction: column;\n gap: 4px;\n"]))),H=e.div(u||(u=n(["\n ","\n color: #121926;\n"],["\n ","\n color: #121926;\n"])),o),I=e.span(h||(h=n(["\n ",";\n display: inline-flex;\n align-items: center;\n gap: 4px;\n color: #697586;\n"],["\n ",";\n display: inline-flex;\n align-items: center;\n gap: 4px;\n color: #697586;\n"])),p),J=e.span(v||(v=n(["\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 12px;\n height: 12px;\n\n svg {\n width: 12px;\n height: 12px;\n }\n"],["\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 12px;\n height: 12px;\n\n svg {\n width: 12px;\n height: 12px;\n }\n"]))),K=e.div(w||(w=n(["\n ","\n color: #697586;\n"],["\n ","\n color: #697586;\n"])),p),L=e.span(k||(k=n(["\n display: block;\n margin-top: 4px;\n color: inherit;\n"],["\n display: block;\n margin-top: 4px;\n color: inherit;\n"]))),M=e.div(j||(j=n(["\n ","\n color: ",";\n"],["\n ","\n color: ",";\n"])),r,function(n){return"negative"===n.$sign?"#697586":"#121926"}),N=e.div(z||(z=n(["\n height: 1px;\n background-color: #eef2f6;\n margin: 16px 0;\n width: 100%;\n"],["\n height: 1px;\n background-color: #eef2f6;\n margin: 16px 0;\n width: 100%;\n"])));export{$ as Container,A as Content,N as Divider,J as EarningMethodIcon,I as EarningMethodInfo,L as ExpirationWarning,R as Header,F as HistoryItem,M as HistoryItemAmount,K as HistoryItemDate,G as HistoryItemLeft,H as HistoryItemTitle,E as HistoryList,q as IconButton,B as PointsSection,C as PointsTitle,D as PointsValue,_ as Title};
|