@ikas/storefront 4.0.0-beta.8 → 4.0.0
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/components/checkout/model.js +1 -1
- package/build/components/google-captcha/index.js +1 -1
- package/build/components/page/index.js +1 -1
- package/build/components/page-editor/model.d.ts +1 -0
- package/build/components/page-editor/model.js +1 -1
- package/build/models/data/product/filter/index.d.ts +1 -2
- package/build/models/data/product/filter/index.js +1 -1
- package/build/models/ui/brand-list/index.d.ts +1 -1
- package/build/models/ui/category-list/index.d.ts +1 -1
- package/build/models/ui/product-list/index.js +1 -1
- package/build/page-data-init/index.js +1 -1
- package/build/store/category/index.js +1 -1
- package/build/store/customer/index.d.ts +2 -2
- package/build/store/customer/index.js +1 -1
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from"lodash/cloneDeep";import r from"lodash/sortBy";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasTransactionStatus as o,IkasPaymentMethodType as a,IkasPaymentGatewayType as c,IkasCartCampaignOfferStatus as d,IkasCampaignOfferTargetPageType as u,IkasOrderShippingMethod as l}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import{IkasCheckout as h}from"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import{IkasCustomerAddress as p}from"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import{IkasMerchantSettings as m}from"../../models/data/merchant-settings/index.js";import{IkasOrderAddress as f}from"../../models/data/order/address/index.js";import{IkasOrderCustomer as g}from"../../models/data/order/customer/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as v}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import y from"./components/credit-card-form/model.js";import S from"../../store/customer/api.js";import k from"../../store/checkout/index.js";import b from"../../store/cart/api.js";import C from"./modelMasterPass.js";import I from"../../store/product/index.js";import{IkasBaseStore as P}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as A}from"@ikas/storefront-config";import{Analytics as w}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as N,CheckStocksLineInput as O}from"@ikas/storefront-api";var j,R,E=/^\d+$/,T="undefined"==typeof localStorage,x=function(){function E(l,m,E,x,L,M,_,V,U,K){var F=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=j.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.policyModalTitle="",this.policyModalText="",this.error=null,this.showTestModal=!1,this.init=function(){return t(F,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,P.getInstance().customerStore.waitUntilInitialized()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getCampaignOffer()];case 2:return t.sent(),[4,this.initStep()];case 3:return t.sent(),[2]}}))}))},this.initStep=function(){return t(F,void 0,void 0,(function(){var t,i,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:if(A.getIsEditor())return this.step=j.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===j.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(j.INFO)];if(this.step!==j.PAYMENT||this.canProceedToPayment){if(this.step===j.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(j.INFO)];if(![j.INFO,j.SUCCESS,j.SHIPPING,j.PAYMENT].includes(this.step))return[2,this.changeStep(j.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep(j.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:R.PAYMENT_ERROR,data:n||null}),this.step!==j.INFO?[3,4]:[4,this.getShippingCountries()];case 1:return e.sent(),this.checkShippingCountries(),[4,this.getStockLocations()];case 2:return e.sent(),[4,this.getAvailableStockLocations()];case 3:e.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),e.label=4;case 4:return this.step!==j.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=j.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==j.SHIPPING||(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)?this.step!==j.PAYMENT&&this.step!==j.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:R.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 5:return e.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,7];case 6:e.sent(),e.label=7;case 7:if(!this.paymentGateways.length)return this.error={type:R.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return this.step===j.SUCCESS?[3,12]:this.checkout.isComplete?[2,this.changeStep(j.SUCCESS)]:[3,9];case 9:return[4,this.initialStockCheck()];case 10:e.sent(),e.label=11;case 11:return[3,14];case 12:return[4,this.getSuccessTransaction()];case 13:e.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===r}))),e.label=14;case 14:return this.isCheckoutLoaded=!0,w.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return t(F,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,S.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return t=e.sent(),this.successTransaction=t.isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?t.data[0]:void 0,[2]}}))}))},this.saveCart=function(){return t(F,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return t=new N(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return this.step!==j.INFO&&this.step!==j.SHIPPING||this.isDigitalOnly||(t.billingAddress=null),this.isDigitalOnly&&(t.shippingAddress=null),[4,b.saveCart({input:t})];case 3:if((null==(i=e.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:R.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:R.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(F,void 0,void 0,(function(){var t,s,n=this;return e(this,(function(e){return t=i,(s=this.stockLocations.find((function(t){return t.id===n.checkout.stockLocationId})))&&t.shippingAddress&&s.address&&(t.shippingAddress.country=s.address.country,t.shippingAddress.city=s.address.city,t.shippingAddress.state=s.address.state,t.shippingAddress.district=s.address.district,t.shippingAddress.postalCode=s.address.postalCode,t.shippingAddress.addressLine1=s.address.address||"",t.shippingAddress.addressLine2=null),[2,t]}))}))},this.checkStocks=function(){return t(F,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,l,h;return e(this,(function(e){switch(e.label){case 0:return t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,k.checkStocks({lines:t.map((function(t){return new O(t)})),stockLocationIdList:(null===(u=A.getStockLocationIds())||void 0===u?void 0:u.length)?A.getStockLocationIds():null})];case 1:if(!(i=e.sent()).isSuccess)throw{type:R.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(h=null===(l=i.data)||void 0===l?void 0:l.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=o.checkout.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push({item:e,stockCount:t.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:R.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return t(F,void 0,void 0,(function(){return e(this,(function(t){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return t(F,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,P.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(F,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,k.getAvailableShippingCountries({salesChannelId:A.getSalesChannelId()})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(F,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return A.getPickupStockLocationIds()?[4,k.listStockLocation({id:{in:A.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:R.API_ERROR,data:t.firstErrorMessage},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(F,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return A.getPickupStockLocationIds()?(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,k.getAvailableStockLocations({lines:t.map((function(t){return new O(t)})),stockLocationIdList:A.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:R.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=F.shippingCountryIds)||void 0===t?void 0:t.length)||(F.error={type:R.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(F.checkout.stockLocationId=null),F.deliveryMethod=t,F.isErrorsVisible=!1},this.initialStockCheck=function(){return t(F,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:R.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(F,void 0,void 0,(function(){var t,i,s,n,o,a,c,d,u,l=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=A.getPaymentGateways().map((function(t){return t.id})),[4,k.listPaymentGateway({id:t?void 0:{in:i},locale:A.getCurrentLocale()})];case 1:return(s=e.sent()).isSuccess&&(null===(d=s.data)||void 0===d?void 0:d.length)?(n=s.data,this.step===j.PAYMENT&&(n=n.filter((function(t){var e;return!(null===(e=t.supportedCurrencies)||void 0===e?void 0:e.length)||t.supportedCurrencies.includes(l.checkout.currencyCode)})),(o=null===(u=this.checkout.shippingAddress)||void 0===u?void 0:u.country)&&o.iso2&&(n=n.filter((function(t){var e;return!(null===(e=t.availableCountries)||void 0===e?void 0:e.length)||t.availableCountries.includes(o.iso2||"")})))),a=[],r(A.getPaymentGateways(),"order").forEach((function(t){var e=null==n?void 0:n.find((function(e){return e.id===t.id}));e&&a.push(e)})),this.paymentGateways=t?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),this.step===j.PAYMENT&&(c=n.find((function(t){return!!t.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,this.mpVM.checkMasterPass({checkout:this.checkout,store:P.getInstance()})),[2]):(this.error={type:R.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(F,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,k.retrieveInstallmentInfo(i)];case 1:return t=e.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;F.store.customerStore.customer?(null===(t=F.store.customerStore.customer.addresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=F.checkoutSettings})),F.checkout.customer=new g(F.store.customerStore.customer)):F.checkout.customer=new g(F.checkout.customer||{})},this.createShippingAddress=function(){if(!F.isDigitalOnly)if(F.checkout.shippingAddress)F.checkout.shippingAddress=new f(n(F.checkout.shippingAddress)||{}),F.checkout.shippingAddress.checkoutSettings=F.checkoutSettings;else if(F.store.customerStore.customer){var t=F.store.customerStore.customer.addresses;F.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else F.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(F.useDifferentAddress=!!localStorage.getItem("sAddr"),F.checkout.billingAddress)F.checkout.billingAddress=new f(n(F.checkout.billingAddress)||{}),F.checkout.billingAddress.checkoutSettings=F.checkoutSettings;else if(F.store.customerStore.customer){var t=F.store.customerStore.customer.addresses;F.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else F.onSelectedBillingAddressIdChange("-1"),F.useDifferentAddress||!F.checkout.shippingAddress||F.isInStoreDelivery||(F.checkout.billingAddress=new f(n(F.checkout.shippingAddress)),F.checkout.billingAddress.checkoutSettings=F.checkoutSettings)},this.onShippingMethodChange=function(i){return t(F,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=e.sent())&&(this.checkout=new h(t)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(F,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(F,void 0,void 0,(function(){var t,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,b.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=e.sent()).isSuccess&&t.data&&(s=t.data,n=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.step===j.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),s&&(r=this.checkout,this.checkout=new h(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway})))),[3,3];case 2:return e.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e,i;if(F.selectedShippingAddressId=t,"-1"===t)F.checkout.shippingAddress=new f;else{var s=null===(i=null===(e=F.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(F.checkout.shippingAddress=new f(s))}F.checkout.shippingAddress&&(F.checkout.shippingAddress.checkoutSettings=F.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e,i;if(F.selectedBillingAddressId=t,"-1"===t)F.checkout.billingAddress=new f;else{var s=null===(i=null===(e=F.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(F.checkout.billingAddress=new f(s))}F.checkout.billingAddress&&(F.checkout.billingAddress.checkoutSettings=F.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){F.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(F.cardData&&(!(t.length>F.cardData.cardNumber.length)||G(t))){var e=(F.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!F.installmentInfo?F.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:F.checkout.selectedPaymentGateway.id,price:F.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(F.cardData.installmentCount=1,F.installmentInfo=void 0),F.cardData.cardNumber=D(i,4).join(" "))}},this.onCardHolderNameChange=function(t){F.cardData&&(F.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(F.cardData&&(!(t.length>F.cardData.expirationDate.length)||G(t))){if(0===(null===(e=F.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.replace(".","/").split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(F.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(F.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(F.cardData.expirationDate=D(a,2).join(" / "))}},this.onCvcChange=function(t){F.cardData&&(t.length>F.cardData.cvv.length&&!G(t)||t.length>4||(F.cardData.cvv=t))},this.saveAddress=function(s){return t(F,void 0,void 0,(function(){var t,r,o,a,c,d,u=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(c=this.store.customerStore.customer.addresses)||void 0===c?void 0:c.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(r=new p(i(i({},t),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(o=n(this.store.customerStore.customer)).addresses||(o.addresses=[]),o.addresses.push(r),[4,this.store.customerStore.saveCustomer(o)])):[3,2];case 1:e.sent(),null===(d=this.store.customerStore.customer.addresses)||void 0===d||d.forEach((function(t){return t.checkoutSettings=u.checkoutSettings})),"shipping"===s?(this.checkout.shippingAddress.id=r.id,this.selectedShippingAddressId=r.id||"-1"):(this.checkout.billingAddress.id=r.id,this.selectedBillingAddressId=r.id||"-1"),e.label=2;case 2:return[3,4];case 3:return a=e.sent(),console.error(a),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){F.router.push("/cart")},this.onBackToShoppingClick=function(){F.router.push("/")},this.onProceedToShippingClick=function(){return t(F,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:e.sent(),e.label=3;case 3:return[4,this.checkStocks()];case 4:return e.sent(),[4,this.saveCart()];case 5:return e.sent(),"address"===this.deliveryMethod?this.changeStep(j.SHIPPING):this.changeStep(j.PAYMENT),[3,7];case 6:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:R.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return t(F,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.changeStep(j.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:R.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(F,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.error=void 0,this.changeStep(j.PAYMENT),[3,5];case 4:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:R.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(F,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!this.canPerformPayment)return this.isErrorsVisible=!0,[2];if(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isKlarna)return this.setIsKlarnaPaymentCompleted(!0),[2];e.label=1;case 1:return e.trys.push([1,7,,8]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),"address"!==this.deliveryMethod?[3,4]:[4,this.saveAddress("billing")];case 3:e.sent(),e.label=4;case 4:return[4,this.saveCart()];case 5:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 6:return e.sent(),[3,8];case 7:return void 0!==typeof(i=e.sent()).type?this.error=i:this.error={type:R.UNKNOWN},this.isStepLoading=!1,[3,8];case 8:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return t(F,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return this.isErrorsVisible=!0,[2];if(this.isKlarna)return this.setIsKlarnaPaymentCompleted(!0),[2];e.label=1;case 1:return e.trys.push([1,5,,6]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 4:return e.sent(),[3,6];case 5:return(i=e.sent()).type?this.error=i:this.error={type:R.UNKNOWN},this.isStepLoading=!1,[3,6];case 6:return[2]}}))}))},this.createSaleTransaction=function(){return t(F,void 0,void 0,(function(){var t,i,s,n,r,d,u,l,h,p,m,f,g,v,y;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=n),void 0===(null===(h=this.cardData)||void 0===h?void 0:h.installmentCount)?[2]:[4,k.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name},paymentGatewayId:null===(m=this.mpVM.selectedCard)||void 0===m?void 0:m.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(f=this.cardData)||void 0===f?void 0:f.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,k.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===a.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===c.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=e.sent(),e.label=4;case 4:return r=null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.transactionStatus,d=r&&[o.SUCCESS,o.AUTHORIZED].includes(r),u=r===o.PENDING,d?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.sent(),[3,8];case 7:if(!u||!(null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.returnSlug))throw{data:s.firstErrorMessage,type:R.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,e.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(F,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep(j.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){F.changeStep(j.INFO)},this.onBackToShippingClick=function(){F.changeStep(j.SHIPPING)},this.setCustomerConsentGranted=function(t){F.checkout.customer&&(F.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){F.useDifferentAddress=t,F.useDifferentAddress?(localStorage.setItem("sAddr","1"),F.checkout.billingAddress=F.checkout.billingAddress||new f):(localStorage.removeItem("sAddr"),F.checkout.billingAddress=F.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){F.shouldSaveAddress=t},this.setAddressTitle=function(t){F.addressTitle=t},this.setPaymentGateway=function(i){return t(F,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return this.paymentGateways.length?"STRIPE"!==(t=this.paymentGateways[i]).code||!(null===(n=t.settings)||void 0===n?void 0:n.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))||this.stripeResponse?[3,2]:[4,k.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})]:[2];case 1:(s=e.sent()).isSuccess&&s.data&&(this.stripeResponse=s.data),e.label=2;case 2:return"KLARNA"!==t.code||this.klarnaResponse?[3,4]:[4,k.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})];case 3:(s=e.sent()).isSuccess&&s.data&&(this.klarnaResponse=s.data),e.label=4;case 4:return this.checkout.selectedPaymentGateway=t,this.step!==j.SUCCESS&&(t.paymentMethodType===a.CREDIT_CARD&&t.type===c.INTERNAL&&(this.cardData=new y),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){F.cardData&&(F.cardData.installmentCount=t)},this.changeStep=function(i){return t(F,void 0,void 0,(function(){return e(this,(function(t){return T||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(F,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){F.isContactModalVisible=t},this.getCampaignOfferProducts=function(i){return t(F,void 0,void 0,(function(){var t,s,n,r;return e(this,(function(o){switch(o.label){case 0:if(!this.checkout.campaignOffers||!this.checkout.campaignOffers.length)return[3,4];if(t=this.checkout.campaignOffers.filter((function(t){var e;return t.status===d.WAITING_FOR_ACTION&&(null===(e=t.campaignOffer)||void 0===e?void 0:e.targetPageTypes.some((function(t){return t===i})))})),!t.length)return[3,4];s=function(i){var s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return(s=t[i]).campaignOffer&&(n=s.campaignOffer.offers.find((function(t){return t.id===s.campaignOfferProductId})))?[4,I.searchProducts({input:{productIdList:[n.productId]}})]:[3,2];case 1:if((r=e.sent()).isSuccess&&r.data&&r.data.data&&r.data.data.length&&(o=r.data.data[0],a=[],n.excludedVariantIdList&&n.excludedVariantIdList.length?o.variants.map((function(t){var e;t.hasStock&&!(null===(e=n.excludedVariantIdList)||void 0===e?void 0:e.some((function(e){return e===t.id})))&&a.push(t)})):a.push.apply(a,o.variants.filter((function(t){return t.hasStock}))),a.length))return[2,{value:{product:new v(o),variants:a,campaignOffer:s,offer:n}}];e.label=2;case 2:return[2]}}))},n=0,o.label=1;case 1:return n<t.length?[5,s(n)]:[3,4];case 2:if("object"==typeof(r=o.sent()))return[2,r.value];o.label=3;case 3:return n++,[3,1];case 4:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return t(F,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getCampaignOfferProducts(u.CHECKOUT)];case 1:return t.checkoutCampaignOffer=e.sent(),i=this,[4,this.getCampaignOfferProducts(u.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=e.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return t(F,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isCheckoutLoaded=!1,[4,b.updateCartCampaignOffer({input:i})];case 1:return(t=e.sent())&&t.isSuccess&&t.data?(this.checkout=new h(t.data),[4,this.init()]):[3,3];case 2:e.sent(),e.label=3;case 3:return this.isCheckoutLoaded=!0,[2]}}))}))},this.checkout=l,this.checkoutSettings=m,this.router=E,this.returnPolicy=x,this.privacyPolicy=L,this.termsOfService=M,this.imprint=_,this.shippingPolicy=V,this.t=U,this.customizationProps=K,this.mpVM=new C,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.init(),s(this)}return Object.defineProperty(E.prototype,"merchantSettings",{get:function(){return new m(A.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"selectedInstallmentIndex",{get:function(){var t,e,i=this;return(null===(e=null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices)||void 0===e?void 0:e.findIndex((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(e=null===(t=P.getInstance().customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"installmentPrice",{get:function(){var t,e,i,s=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(i=null===(e=this.installmentInfo.installmentPrices)||void 0===e?void 0:e.find((function(t){var e;return t.installmentCount===(null===(e=s.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"finalPrice",{get:function(){return this.step===j.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===R.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"canProceedToShipping",{get:function(){var t,e,i;return(this.isDigitalOnly?null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid:null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.isValid)&&this.checkout.hasValidCustomerEmail&&(null===(i=this.error)||void 0===i?void 0:i.type)!==R.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"canProceedToInStoreDelivery",{get:function(){var t,e,i;return!!((null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.firstName)&&(null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"klarnaPaymentGateway",{get:function(){var t=this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}));if(-1!==t)return this.paymentGateways[t]},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"isCustomFlowStripe",{get:function(){var t,e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"isKlarna",{get:function(){var t=this.checkout.selectedPaymentGateway;return t&&"KLARNA"===t.code},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"store",{get:function(){return P.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid),r=!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===a.CREDIT_CARD&&i.type===c.INTERNAL?!!this.isCustomFlowStripe||(!!this.isKlarna||(null===(e=this.cardData)||void 0===e?void 0:e.isValid)):!!i);return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(E.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===l.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),E}();function D(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function G(t){return t&&E.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(j||(j={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(R||(R={}));export{j as CheckoutStep,R as ErrorType,x as default};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as s}from"mobx";import n from"lodash/cloneDeep";import r from"lodash/sortBy";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasTransactionStatus as o,IkasPaymentMethodType as a,IkasPaymentGatewayType as c,IkasCartCampaignOfferStatus as d,IkasCampaignOfferTargetPageType as u,IkasOrderShippingMethod as l}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import{IkasCheckout as h}from"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import{IkasCustomerAddress as p}from"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import{IkasMerchantSettings as m}from"../../models/data/merchant-settings/index.js";import{IkasOrderAddress as f}from"../../models/data/order/address/index.js";import{IkasOrderCustomer as g}from"../../models/data/order/customer/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import{IkasProduct as v}from"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import y from"./components/credit-card-form/model.js";import S from"../../store/customer/api.js";import k from"../../store/checkout/index.js";import b from"../../store/cart/api.js";import C from"./modelMasterPass.js";import I from"../../store/product/index.js";import{IkasBaseStore as P}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{IkasStorefrontConfig as A}from"@ikas/storefront-config";import{Analytics as w}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as N,CheckStocksLineInput as O}from"@ikas/storefront-api";var j,E,R=/^\d+$/,T="undefined"==typeof localStorage,x=function(){function R(l,m,R,x,L,M,_,V,U,K){var F=this;this.storefront=null,this.isCheckoutLoaded=!1,this.isErrorsVisible=!1,this.isStepLoading=!1,this.isTermsAndConditionsChecked=!1,this.isChangingShippingMethod=!1,this.isContactModalVisible=!1,this.step=j.INFO,this.customizationProps=null,this.cardData=null,this.paymentGateways=[],this.installmentInfo=null,this.useDifferentAddress=!1,this.shouldSaveAddress=!0,this.addressTitle="",this.shippingCountryIds=null,this.selectedShippingAddressId="-1",this.selectedBillingAddressId="-1",this.stockLocations=[],this.availableStockLocations=[],this.deliveryMethod="address",this.stripeResponse=null,this.klarnaResponse=null,this.isKlarnaPaymentCompleted=!1,this.policyModalTitle="",this.policyModalText="",this.error=null,this.showTestModal=!1,this.init=function(){return t(F,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,P.getInstance().customerStore.waitUntilInitialized()];case 1:return t.sent(),this.createCustomer(),this.createShippingAddress(),this.createBillingAddress(),[4,this.getCampaignOffer()];case 2:return t.sent(),[4,this.initStep()];case 3:return t.sent(),[2]}}))}))},this.initStep=function(){return t(F,void 0,void 0,(function(){var t,i,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:if(A.getIsEditor())return this.step=j.INFO,this.isCheckoutLoaded=!0,[2];if(t=new URLSearchParams(window.location.search),i=t.get("step"),s=t.get("failed"),n=t.get("error"),i){if(this.step=i,this.step===j.SHIPPING&&!this.canProceedToShipping)return[2,this.changeStep(j.INFO)];if(this.step!==j.PAYMENT||this.canProceedToPayment){if(this.step===j.SUCCESS&&!this.canProceedToPayment)return[2,this.changeStep(j.INFO)];if(![j.INFO,j.SUCCESS,j.SHIPPING,j.PAYMENT].includes(this.step))return[2,this.changeStep(j.INFO)]}else{if(!this.isInStoreDelivery)return[2,this.changeStep(j.INFO)];this.deliveryMethod="in-store"}}return s&&(this.error={type:E.PAYMENT_ERROR,data:n||null}),this.step!==j.INFO?[3,4]:[4,this.getShippingCountries()];case 1:return e.sent(),this.checkShippingCountries(),[4,this.getStockLocations()];case 2:return e.sent(),[4,this.getAvailableStockLocations()];case 3:e.sent(),this.isInStoreDelivery&&(this.deliveryMethod="in-store"),e.label=4;case 4:return this.step!==j.SHIPPING||1!==(null===(o=this.checkout.availableShippingMethods)||void 0===o?void 0:o.length)||this.checkoutSettings.isGiftPackageEnabled||(this.step=j.PAYMENT,this.router.replace("/checkout?id=".concat(this.checkout.id,"&step=").concat(this.step),void 0,{shallow:!0})),this.step!==j.SHIPPING||(null===(a=this.checkout.availableShippingMethods)||void 0===a?void 0:a.length)?this.step!==j.PAYMENT&&this.step!==j.SUCCESS?[3,8]:[4,this.listPaymentGateways()]:(this.error={type:E.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2]);case 5:return e.sent(),this.isInStoreDelivery?(this.deliveryMethod="in-store",[4,this.getStockLocations()]):[3,7];case 6:e.sent(),e.label=7;case 7:if(!this.paymentGateways.length)return this.error={type:E.NO_SHIPPING_ERROR},this.isCheckoutLoaded=!0,[2];e.label=8;case 8:return this.step===j.SUCCESS?[3,12]:this.checkout.isComplete?[2,this.changeStep(j.SUCCESS)]:[3,9];case 9:return[4,this.initialStockCheck()];case 10:e.sent(),e.label=11;case 11:return[3,14];case 12:return[4,this.getSuccessTransaction()];case 13:e.sent(),this.successTransaction&&(r=this.successTransaction.paymentGatewayId,this.checkout.selectedPaymentGateway=this.paymentGateways.find((function(t){return t.id===r}))),e.label=14;case 14:return this.isCheckoutLoaded=!0,w.checkoutStep(this.checkout,this.step),[2]}}))}))},this.getSuccessTransaction=function(){return t(F,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,S.listOrderTransactions({orderId:{eq:this.checkout.id}})];case 1:return t=e.sent(),this.successTransaction=t.isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?t.data[0]:void 0,[2]}}))}))},this.saveCart=function(){return t(F,void 0,void 0,(function(){var t,i,s,n;return e(this,(function(e){switch(e.label){case 0:return t=new N(this.checkout),"in-store"!==this.deliveryMethod?[3,2]:[4,this.inStockDeliveryInputData(t)];case 1:t=e.sent(),e.label=2;case 2:return this.step!==j.INFO&&this.step!==j.SHIPPING||this.isDigitalOnly||(t.billingAddress=null),this.isDigitalOnly&&(t.shippingAddress=null),[4,b.saveCart({input:t})];case 3:if((null==(i=e.sent())?void 0:i.graphQLErrors)&&i.graphQLErrors.length)throw s=i.graphQLErrors[0],"CUSTOMER_LOGIN_REQUIRED"===(null===(n=s.extensions)||void 0===n?void 0:n.code)?{type:E.CUSTOMER_LOGIN_REQUIRED_ERROR}:{type:E.API_ERROR,data:i.firstErrorMessage};return[2,i.data]}}))}))},this.inStockDeliveryInputData=function(i){return t(F,void 0,void 0,(function(){var t,s,n=this;return e(this,(function(e){return t=i,(s=this.stockLocations.find((function(t){return t.id===n.checkout.stockLocationId})))&&t.shippingAddress&&s.address&&(t.shippingAddress.country=s.address.country,t.shippingAddress.city=s.address.city,t.shippingAddress.state=s.address.state,t.shippingAddress.district=s.address.district,t.shippingAddress.postalCode=s.address.postalCode,t.shippingAddress.addressLine1=s.address.address||"",t.shippingAddress.addressLine2=null),[2,t]}))}))},this.checkStocks=function(){return t(F,void 0,void 0,(function(){var t,i,s,n,r,o,a,c,d,u,l,h;return e(this,(function(e){switch(e.label){case 0:return t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,k.checkStocks({lines:t.map((function(t){return new O(t)})),stockLocationIdList:(null===(u=A.getStockLocationIds())||void 0===u?void 0:u.length)?A.getStockLocationIds():null})];case 1:if(!(i=e.sent()).isSuccess)throw{type:E.API_ERROR,data:i.firstErrorMessage};if(null==(s=null===(h=null===(l=i.data)||void 0===l?void 0:l.lines)||void 0===h?void 0:h.filter((function(t){return!t.isAvailable})))?void 0:s.length){for(n=[],r=function(t){var e=o.checkout.items.find((function(e){return e.variant.id===t.variantId}));e&&n.push({item:e,stockCount:t.stockCount})},o=this,a=0,c=s;a<c.length;a++)d=c[a],r(d);throw{type:E.STOCK_ERROR,data:n}}return[2]}}))}))},this.setIsKlarnaPaymentCompleted=function(i){return t(F,void 0,void 0,(function(){return e(this,(function(t){return this.isKlarnaPaymentCompleted=i,[2]}))}))},this.removeUnavailableItems=function(i){return t(F,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:t=0,s=i,e.label=1;case 1:return t<s.length?(n=s[t],[4,P.getInstance().cartStore.changeItemQuantity(n.item,n.stockCount)]):[3,4];case 2:e.sent(),e.label=3;case 3:return t++,[3,1];case 4:return[2]}}))}))},this.getShippingCountries=function(){return t(F,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,k.getAvailableShippingCountries({salesChannelId:A.getSalesChannelId()})];case 1:return t=e.sent(),this.shippingCountryIds=t.data,[2]}}))}))},this.getStockLocations=function(){return t(F,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return A.getPickupStockLocationIds()?[4,k.listStockLocation({id:{in:A.getPickupStockLocationIds()}})]:[3,2];case 1:if(!(t=e.sent()).isSuccess||!(null===(i=t.data)||void 0===i?void 0:i.length))return this.error={type:E.API_ERROR,data:t.firstErrorMessage},[2];this.stockLocations=t.data,e.label=2;case 2:return[2]}}))}))},this.getAvailableStockLocations=function(){return t(F,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return A.getPickupStockLocationIds()?(t=this.checkout.items.map((function(t){return{quantity:t.quantity,variantId:t.variant.id,productId:t.variant.productId}})),[4,k.getAvailableStockLocations({lines:t.map((function(t){return new O(t)})),stockLocationIdList:A.getPickupStockLocationIds()})]):[3,2];case 1:if(!(i=e.sent()).isSuccess)return this.error={type:E.API_ERROR},[2];this.availableStockLocations=i.data||[],e.label=2;case 2:return[2]}}))}))},this.checkShippingCountries=function(){var t;(null===(t=F.shippingCountryIds)||void 0===t?void 0:t.length)||(F.error={type:E.NO_SHIPPING_ERROR})},this.onDeliveryMethodChange=function(t){"address"===t&&(F.checkout.stockLocationId=null),F.deliveryMethod=t,F.isErrorsVisible=!1},this.initialStockCheck=function(){return t(F,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,this.checkStocks()];case 1:return e.sent(),[3,3];case 2:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:E.UNKNOWN}),[3,3];case 3:return[2]}}))}))},this.listPaymentGateways=function(){return t(F,void 0,void 0,(function(){var t,i,s,n,o,a,c,d,u,l,h=this;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,i=A.getPaymentGateways().map((function(t){return t.id})),[4,k.listPaymentGateway({id:t?void 0:{in:i},locale:A.getCurrentLocale()})];case 1:return(s=e.sent()).isSuccess&&(null===(u=s.data)||void 0===u?void 0:u.length)?(n=s.data,this.step===j.PAYMENT&&(n=n.filter((function(t){var e;return!(null===(e=t.supportedCurrencies)||void 0===e?void 0:e.length)||t.supportedCurrencies.includes(h.checkout.currencyCode)})),(o=null===(l=this.checkout.shippingAddress)||void 0===l?void 0:l.country)&&o.iso2&&(n=n.filter((function(t){var e;return!(null===(e=t.availableCountries)||void 0===e?void 0:e.length)||t.availableCountries.includes(o.iso2||"")})))),a=[],r(A.getPaymentGateways(),"order").forEach((function(t){var e=null==n?void 0:n.find((function(e){return e.id===t.id}));e&&a.push(e)})),this.paymentGateways=t?n:a,this.checkout.selectedPaymentGateway||this.setPaymentGateway(0),this.step===j.PAYMENT&&(c=n.find((function(t){return!!t.masterPassClientId})))&&(this.checkout.masterPassPaymentGateway=c,(d=document.createElement("script")).id="ikasMasterPass",d.src="https://cdn.myikas.com/sf/scripts/mfs-client-nojquery.min.js",d.onload=function(){h.mpVM.checkMasterPass({checkout:h.checkout,store:P.getInstance()})},document.head.appendChild(d)),[2]):(this.error={type:E.API_ERROR,data:s.firstErrorMessage},[2])}}))}))},this.retrieveInstallmentInfo=function(i){return t(F,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return[4,k.retrieveInstallmentInfo(i)];case 1:return t=e.sent(),s=t.data,null===(n=null==s?void 0:s.installmentPrices)||void 0===n||n.sort((function(t,e){return(t.installmentCount||-1)>(e.installmentCount||-1)?1:-1})),this.installmentInfo=s,[2]}}))}))},this.createCustomer=function(){var t;F.store.customerStore.customer?(null===(t=F.store.customerStore.customer.addresses)||void 0===t||t.forEach((function(t){return t.checkoutSettings=F.checkoutSettings})),F.checkout.customer=new g(F.store.customerStore.customer)):F.checkout.customer=new g(F.checkout.customer||{})},this.createShippingAddress=function(){if(!F.isDigitalOnly)if(F.checkout.shippingAddress)F.checkout.shippingAddress=new f(n(F.checkout.shippingAddress)||{}),F.checkout.shippingAddress.checkoutSettings=F.checkoutSettings;else if(F.store.customerStore.customer){var t=F.store.customerStore.customer.addresses;F.onSelectedShippingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else F.onSelectedShippingAddressIdChange("-1")},this.createBillingAddress=function(){if("undefined"!=typeof localStorage)if(F.useDifferentAddress=!!localStorage.getItem("sAddr"),F.checkout.billingAddress)F.checkout.billingAddress=new f(n(F.checkout.billingAddress)||{}),F.checkout.billingAddress.checkoutSettings=F.checkoutSettings;else if(F.store.customerStore.customer){var t=F.store.customerStore.customer.addresses;F.onSelectedBillingAddressIdChange((null==t?void 0:t.length)?t[0].id:"-1")}else F.onSelectedBillingAddressIdChange("-1"),F.useDifferentAddress||!F.checkout.shippingAddress||F.isInStoreDelivery||(F.checkout.billingAddress=new f(n(F.checkout.shippingAddress)),F.checkout.billingAddress.checkoutSettings=F.checkoutSettings)},this.onShippingMethodChange=function(i){return t(F,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isChangingShippingMethod?[2]:(this.isChangingShippingMethod=!0,this.checkout.shippingSettingsId=i.shippingSettingsId,this.checkout.shippingZoneRateId=i.shippingZoneRateId,[4,this.saveCart()]);case 1:return(t=e.sent())&&(this.checkout=new h(t)),this.checkout.shippingAddress&&(this.checkout.shippingAddress.checkoutSettings=this.checkoutSettings),this.isChangingShippingMethod=!1,[2]}}))}))},this.onStockLocationChange=function(i){return t(F,void 0,void 0,(function(){return e(this,(function(t){return this.checkout.stockLocationId=i.id,[2]}))}))},this.onCouponCodeApply=function(){return t(F,void 0,void 0,(function(){var t,s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,b.saveCartCouponCode({cartId:this.checkout.id,couponCode:this.checkout.couponCode||null})];case 1:return(t=e.sent()).isSuccess&&t.data&&(s=t.data,n=null===(a=null===(o=this.cardData)||void 0===o?void 0:o.cardNumber)||void 0===a?void 0:a.split(" ").join(""),this.step===j.PAYMENT&&(null==n?void 0:n.length)&&n.length>=6&&this.retrieveInstallmentInfo({input:{binNumber:n.slice(0,6),paymentGatewayId:this.checkout.selectedPaymentGateway.id,price:s.totalFinalPrice}}),s&&(r=this.checkout,this.checkout=new h(i(i({},s),{shippingAddress:r.shippingAddress,billingAddress:r.billingAddress,customer:r.customer,selectedPaymentGateway:r.selectedPaymentGateway})))),[3,3];case 2:return e.sent(),[3,3];case 3:return[2]}}))}))},this.onSelectedShippingAddressIdChange=function(t){var e,i;if(F.selectedShippingAddressId=t,"-1"===t)F.checkout.shippingAddress=new f;else{var s=null===(i=null===(e=F.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(F.checkout.shippingAddress=new f(s))}F.checkout.shippingAddress&&(F.checkout.shippingAddress.checkoutSettings=F.checkoutSettings)},this.onSelectedBillingAddressIdChange=function(t){var e,i;if(F.selectedBillingAddressId=t,"-1"===t)F.checkout.billingAddress=new f;else{var s=null===(i=null===(e=F.store.customerStore.customer)||void 0===e?void 0:e.addresses)||void 0===i?void 0:i.find((function(e){return e.id===t}));s&&(F.checkout.billingAddress=new f(s))}F.checkout.billingAddress&&(F.checkout.billingAddress.checkoutSettings=F.checkoutSettings)},this.onTermsAndConditionsCheckedChange=function(t){F.isTermsAndConditionsChecked=t},this.onCardNumberChange=function(t){if(F.cardData&&(!(t.length>F.cardData.cardNumber.length)||G(t))){var e=(F.cardData.cardNumber||"").split(" ").join(""),i=t.split(" ").join("");i.length>16||(e.length<6&&i.length>=6&&!F.installmentInfo?F.retrieveInstallmentInfo({input:{binNumber:i.slice(0,6),paymentGatewayId:F.checkout.selectedPaymentGateway.id,price:F.checkout.totalFinalPrice}}):i.length<6&&e.length>i.length&&(F.cardData.installmentCount=1,F.installmentInfo=void 0),F.cardData.cardNumber=D(i,4).join(" "))}},this.onCardHolderNameChange=function(t){F.cardData&&(F.cardData.cardHolderName=t)},this.onExpirationDateChange=function(t){var e;if(F.cardData&&(!(t.length>F.cardData.expirationDate.length)||G(t))){if(0===(null===(e=F.cardData.expirationDate)||void 0===e?void 0:e.length)){var i=t.replace(".","/").split("/");if(2===i.length){var s=i[0].trim(),n=i[1].trim();if(4===s.length&&2===n.length){var r=parseInt(s.slice(2)),o=parseInt(n);if(!isNaN(r)&&!isNaN(o))return void(F.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}if(2===s.length&&4===n.length){o=parseInt(s),r=parseInt(n.slice(2));if(!isNaN(r)&&!isNaN(o))return void(F.cardData.expirationDate="".concat(o<10?"0"+o:o," / ").concat(r<10?"0"+r:r))}}}var a=t.split(" / ").join("");a.length>4||(F.cardData.expirationDate=D(a,2).join(" / "))}},this.onCvcChange=function(t){F.cardData&&(t.length>F.cardData.cvv.length&&!G(t)||t.length>4||(F.cardData.cvv=t))},this.saveAddress=function(s){return t(F,void 0,void 0,(function(){var t,r,o,a,c,d,u=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.shouldSaveAddress&&this.store.customerStore.customer?(t="shipping"===s?this.checkout.shippingAddress:this.checkout.billingAddress,(null===(c=this.store.customerStore.customer.addresses)||void 0===c?void 0:c.find((function(e){return e.id===(null==t?void 0:t.id)})))?[2]:(r=new p(i(i({},t),{title:this.addressTitle||this.t("checkout-page:newAddress")})),(o=n(this.store.customerStore.customer)).addresses||(o.addresses=[]),o.addresses.push(r),[4,this.store.customerStore.saveCustomer(o)])):[3,2];case 1:e.sent(),null===(d=this.store.customerStore.customer.addresses)||void 0===d||d.forEach((function(t){return t.checkoutSettings=u.checkoutSettings})),"shipping"===s?(this.checkout.shippingAddress.id=r.id,this.selectedShippingAddressId=r.id||"-1"):(this.checkout.billingAddress.id=r.id,this.selectedBillingAddressId=r.id||"-1"),e.label=2;case 2:return[3,4];case 3:return a=e.sent(),console.error(a),[3,4];case 4:return[2]}}))}))},this.onGoToCartClick=function(){F.router.push("/cart")},this.onBackToShoppingClick=function(){F.router.push("/")},this.onProceedToShippingClick=function(){return t(F,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if("address"===this.deliveryMethod){if(!this.canProceedToShipping)return this.isErrorsVisible=!0,[2]}else if(!this.canProceedToInStoreDelivery)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,6,,7]),this.isStepLoading=!0,"address"!==this.deliveryMethod?[3,3]:[4,this.saveAddress("shipping")];case 2:e.sent(),e.label=3;case 3:return[4,this.checkStocks()];case 4:return e.sent(),[4,this.saveCart()];case 5:return e.sent(),"address"===this.deliveryMethod?this.changeStep(j.SHIPPING):this.changeStep(j.PAYMENT),[3,7];case 6:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:E.UNKNOWN}),this.isStepLoading=!1,[3,7];case 7:return[2]}}))}))},this.onProceedToDigitalOnlyPaymentClick=function(){return t(F,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.changeStep(j.PAYMENT),[3,5];case 4:return(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:E.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onProceedToPaymentClick=function(){return t(F,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment)return this.isErrorsVisible=!0,[2];this.isErrorsVisible=!1,e.label=1;case 1:return e.trys.push([1,4,,5]),this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.error=void 0,this.changeStep(j.PAYMENT),[3,5];case 4:return void 0!==typeof(t=e.sent()).type?this.error=t:(console.log(t),this.error={type:E.UNKNOWN}),this.isStepLoading=!1,[3,5];case 5:return[2]}}))}))},this.onCompletePaymentClick=function(){return t(F,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!this.canPerformPayment)return this.isErrorsVisible=!0,[2];if(this.useDifferentAddress||(this.checkout.billingAddress=this.checkout.shippingAddress),this.isKlarna)return this.setIsKlarnaPaymentCompleted(!0),[2];e.label=1;case 1:return e.trys.push([1,7,,8]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),"address"!==this.deliveryMethod?[3,4]:[4,this.saveAddress("billing")];case 3:e.sent(),e.label=4;case 4:return[4,this.saveCart()];case 5:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 6:return e.sent(),[3,8];case 7:return void 0!==typeof(i=e.sent()).type?this.error=i:this.error={type:E.UNKNOWN},this.isStepLoading=!1,[3,8];case 8:return[2]}}))}))},this.onCompleteDigitalOnlyPaymentClick=function(){return t(F,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!this.canProceedToPayment||this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return this.isErrorsVisible=!0,[2];if(this.isKlarna)return this.setIsKlarnaPaymentCompleted(!0),[2];e.label=1;case 1:return e.trys.push([1,5,,6]),this.isErrorsVisible=!1,this.isStepLoading=!0,[4,this.checkStocks()];case 2:return e.sent(),[4,this.saveCart()];case 3:return e.sent(),this.isCustomFlowStripe?((t=document.querySelector("#stripe-form-btn"))&&t.click(),[2]):[4,this.createSaleTransaction()];case 4:return e.sent(),[3,6];case 5:return(i=e.sent()).type?this.error=i:this.error={type:E.UNKNOWN},this.isStepLoading=!1,[3,6];case 6:return[2]}}))}))},this.createSaleTransaction=function(){return t(F,void 0,void 0,(function(){var t,i,s,n,r,d,u,l,h,p,m,f,g,v,y;return e(this,(function(e){switch(e.label){case 0:return(i=this.mpVM.selectedCard)&&(null===(l=this.mpVM.selectedCard)||void 0===l?void 0:l.Name)?((n=this.mpVM.phoneNumber({store:this.store,checkout:this.checkout}))&&(t=n),void 0===(null===(h=this.cardData)||void 0===h?void 0:h.installmentCount)?[2]:[4,k.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:{phoneNumber:t,savedCardName:null===(p=this.mpVM.selectedCard)||void 0===p?void 0:p.Name},paymentGatewayId:null===(m=this.mpVM.selectedCard)||void 0===m?void 0:m.paymentGatewayId,paymentMethodDetail:{cardNumber:this.mpVM.selectedCard.Value1,cardHolderName:this.mpVM.selectedCard.Name,cvv:this.mpVM.selectedCard.Value2,expiredMonth:11,expiredYear:11,installmentCount:this.cardData.installmentCount,threeDSecure:!!(null===(f=this.cardData)||void 0===f?void 0:f.threeDSecure)}}})]):[3,2];case 1:return s=e.sent(),[3,4];case 2:return this.checkout.selectedPaymentGateway?[4,k.createSaleTransactionWithCart({input:{cartId:this.checkout.id,masterPassDetail:i&&t?{phoneNumber:t,savedCardName:null===(g=this.mpVM.selectedCard)||void 0===g?void 0:g.Name}:void 0,paymentGatewayId:this.checkout.selectedPaymentGateway.id,paymentMethodDetail:i?void 0:this.checkout.selectedPaymentGateway.paymentMethodType===a.CREDIT_CARD&&this.checkout.selectedPaymentGateway.type===c.INTERNAL&&this.cardData?this.cardData.toInput():void 0}})]:[2];case 3:s=e.sent(),e.label=4;case 4:return r=null===(v=null==s?void 0:s.data)||void 0===v?void 0:v.transactionStatus,d=r&&[o.SUCCESS,o.AUTHORIZED].includes(r),u=r===o.PENDING,d?[4,this.getSuccessTransaction()]:[3,7];case 5:return e.sent(),[4,this.onCheckoutTransactionSuccess()];case 6:return e.sent(),[3,8];case 7:if(!u||!(null===(y=null==s?void 0:s.data)||void 0===y?void 0:y.returnSlug))throw{data:s.firstErrorMessage,type:E.UNKNOWN};window.location.href=process.env.NEXT_PUBLIC_BASE_URL+s.data.returnSlug,e.label=8;case 8:return[2]}}))}))},this.onCheckoutTransactionSuccess=function(){return t(F,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return localStorage.removeItem("sAddr"),(null===(t=this.checkout.customer)||void 0===t?void 0:t.notificationsAccepted)?[4,this.store.customerStore.createEmailSubscription((null===(i=this.checkout.customer)||void 0===i?void 0:i.email)||"")]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.changeStep(j.SUCCESS),[2]}}))}))},this.onBackToInfoClick=function(){F.changeStep(j.INFO)},this.onBackToShippingClick=function(){F.changeStep(j.SHIPPING)},this.setCustomerConsentGranted=function(t){F.checkout.customer&&(F.checkout.customer.notificationsAccepted=t)},this.setUseDifferentAddress=function(t){F.useDifferentAddress=t,F.useDifferentAddress?(localStorage.setItem("sAddr","1"),F.checkout.billingAddress=F.checkout.billingAddress||new f):(localStorage.removeItem("sAddr"),F.checkout.billingAddress=F.checkout.shippingAddress)},this.setShouldSaveAddress=function(t){F.shouldSaveAddress=t},this.setAddressTitle=function(t){F.addressTitle=t},this.setPaymentGateway=function(i){return t(F,void 0,void 0,(function(){var t,s,n;return e(this,(function(e){switch(e.label){case 0:return this.paymentGateways.length?"STRIPE"!==(t=this.paymentGateways[i]).code||!(null===(n=t.settings)||void 0===n?void 0:n.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))||this.stripeResponse?[3,2]:[4,k.createStripePaymentIntent({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})]:[2];case 1:(s=e.sent()).isSuccess&&s.data&&(this.stripeResponse=s.data),e.label=2;case 2:return"KLARNA"!==t.code||this.klarnaResponse?[3,4]:[4,k.createKlarnaClientToken({input:{cartId:this.checkout.id,paymentGatewayId:t.id||""}})];case 3:(s=e.sent()).isSuccess&&s.data&&(this.klarnaResponse=s.data),e.label=4;case 4:return this.checkout.selectedPaymentGateway=t,this.step!==j.SUCCESS&&(t.paymentMethodType===a.CREDIT_CARD&&t.type===c.INTERNAL&&(this.cardData=new y),this.installmentInfo=void 0),[2]}}))}))},this.setInstallmentCount=function(t){F.cardData&&(F.cardData.installmentCount=t)},this.changeStep=function(i){return t(F,void 0,void 0,(function(){return e(this,(function(t){return T||window.location.replace("".concat(window.location.pathname,"?id=").concat(this.checkout.id,"&step=").concat(i)),[2]}))}))},this.logout=function(){return t(F,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:this.checkout.customer=null,this.store.customerStore.logout(),t.label=1;case 1:return t.trys.push([1,3,,4]),[4,this.saveCart()];case 2:case 3:return t.sent(),[3,4];case 4:return this.createCustomer(),[2]}}))}))},this.setContactModalVisible=function(t){F.isContactModalVisible=t},this.getCampaignOfferProducts=function(i){return t(F,void 0,void 0,(function(){var t,s,n,r;return e(this,(function(o){switch(o.label){case 0:if(!this.checkout.campaignOffers||!this.checkout.campaignOffers.length)return[3,4];if(t=this.checkout.campaignOffers.filter((function(t){var e;return t.status===d.WAITING_FOR_ACTION&&(null===(e=t.campaignOffer)||void 0===e?void 0:e.targetPageTypes.some((function(t){return t===i})))})),!t.length)return[3,4];s=function(i){var s,n,r,o,a;return e(this,(function(e){switch(e.label){case 0:return(s=t[i]).campaignOffer&&(n=s.campaignOffer.offers.find((function(t){return t.id===s.campaignOfferProductId})))?[4,I.searchProducts({input:{productIdList:[n.productId]}})]:[3,2];case 1:if((r=e.sent()).isSuccess&&r.data&&r.data.data&&r.data.data.length&&(o=r.data.data[0],a=[],n.excludedVariantIdList&&n.excludedVariantIdList.length?o.variants.map((function(t){var e;t.hasStock&&!(null===(e=n.excludedVariantIdList)||void 0===e?void 0:e.some((function(e){return e===t.id})))&&a.push(t)})):a.push.apply(a,o.variants.filter((function(t){return t.hasStock}))),a.length))return[2,{value:{product:new v(o),variants:a,campaignOffer:s,offer:n}}];e.label=2;case 2:return[2]}}))},n=0,o.label=1;case 1:return n<t.length?[5,s(n)]:[3,4];case 2:if("object"==typeof(r=o.sent()))return[2,r.value];o.label=3;case 3:return n++,[3,1];case 4:return[2,void 0]}}))}))},this.getCampaignOffer=function(){return t(F,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return t=this,[4,this.getCampaignOfferProducts(u.CHECKOUT)];case 1:return t.checkoutCampaignOffer=e.sent(),i=this,[4,this.getCampaignOfferProducts(u.POST_CHECKOUT)];case 2:return i.postCheckoutCampaignOffer=e.sent(),[2]}}))}))},this.updateCartCampaignOffer=function(i){return t(F,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.isCheckoutLoaded=!1,[4,b.updateCartCampaignOffer({input:i})];case 1:return(t=e.sent())&&t.isSuccess&&t.data?(this.checkout=new h(t.data),[4,this.init()]):[3,3];case 2:e.sent(),e.label=3;case 3:return this.isCheckoutLoaded=!0,[2]}}))}))},this.checkout=l,this.checkoutSettings=m,this.router=R,this.returnPolicy=x,this.privacyPolicy=L,this.termsOfService=M,this.imprint=_,this.shippingPolicy=V,this.t=U,this.customizationProps=K,this.mpVM=new C,this.isTermsAndConditionsChecked=this.checkoutSettings.isTermsAndConditionsDefaultChecked||!1,this.init(),s(this)}return Object.defineProperty(R.prototype,"merchantSettings",{get:function(){return new m(A.getMerchantSettings())},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"selectedPaymentGatewayIndex",{get:function(){var t=this;return this.paymentGateways.findIndex((function(e){var i;return e.id===(null===(i=t.checkout.selectedPaymentGateway)||void 0===i?void 0:i.id)}))},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"selectedInstallmentIndex",{get:function(){var t,e,i=this;return(null===(e=null===(t=this.installmentInfo)||void 0===t?void 0:t.installmentPrices)||void 0===e?void 0:e.findIndex((function(t){var e;return t.installmentCount===(null===(e=i.cardData)||void 0===e?void 0:e.installmentCount)})))||0},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"checkoutUrl",{get:function(){return"/checkout?id=".concat(this.checkout.id,"&step=info")},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"customerAddressOptions",{get:function(){var t,e,i={label:this.t("checkout-page:newAddress"),value:"-1"},s=(null===(e=null===(t=P.getInstance().customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.map((function(t){return{label:t.title+" - "+t.addressText,value:t.id}})))||[];return[i].concat(s)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"installmentPrice",{get:function(){var t,e,i,s=this;if(this.installmentInfo&&(null===(t=this.cardData)||void 0===t?void 0:t.installmentCount))return null===(i=null===(e=this.installmentInfo.installmentPrices)||void 0===e?void 0:e.find((function(t){var e;return t.installmentCount===(null===(e=s.cardData)||void 0===e?void 0:e.installmentCount)})))||void 0===i?void 0:i.totalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"installmentExtraPrice",{get:function(){if(this.installmentPrice&&this.checkout.totalFinalPrice)return this.installmentPrice-this.checkout.totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"finalPrice",{get:function(){return this.step===j.SUCCESS?this.checkout.totalFinalPrice:this.installmentPrice||this.checkout.$totalFinalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"hasStockError",{get:function(){var t;return(null===(t=this.error)||void 0===t?void 0:t.type)===E.STOCK_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isPaymentGatewayHasMasterPass",{get:function(){return-1!==this.selectedPaymentGatewayIndex&&(!!this.paymentGateways.length&&!!this.paymentGateways[this.selectedPaymentGatewayIndex].masterPassClientId)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"canProceedToShipping",{get:function(){var t,e,i;return(this.isDigitalOnly?null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid:null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.isValid)&&this.checkout.hasValidCustomerEmail&&(null===(i=this.error)||void 0===i?void 0:i.type)!==E.NO_SHIPPING_ERROR},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"canProceedToInStoreDelivery",{get:function(){var t,e,i;return!!((null===(t=this.checkout.shippingAddress)||void 0===t?void 0:t.firstName)&&(null===(e=this.checkout.shippingAddress)||void 0===e?void 0:e.lastName)&&(null===(i=this.checkout.customer)||void 0===i?void 0:i.email)&&this.checkout.stockLocationId)},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"canProceedToPayment",{get:function(){return this.canProceedToShipping},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isInStoreDelivery",{get:function(){return!!this.checkout.stockLocationId},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"klarnaPaymentGateway",{get:function(){var t=this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}));if(-1!==t)return this.paymentGateways[t]},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"klarnaPaymentGatewayIndex",{get:function(){return this.paymentGateways.findIndex((function(t){return"KLARNA"===t.code}))},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isCustomFlowStripe",{get:function(){var t,e=this.checkout.selectedPaymentGateway;return e&&"STRIPE"===e.code&&(null===(t=e.settings)||void 0===t?void 0:t.find((function(t){return"allow_custom_flow"===t.label&&"true"===t.value})))},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isKlarna",{get:function(){var t=this.checkout.selectedPaymentGateway;return t&&"KLARNA"===t.code},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"store",{get:function(){return P.getInstance()},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"canPerformPayment",{get:function(){var t,e;if(this.checkoutSettings.showTermsAndConditionsCheckbox&&!this.isTermsAndConditionsChecked)return!1;var i=this.checkout.selectedPaymentGateway,s=!!("in-store"===this.deliveryMethod)||!!this.canProceedToShipping,n=!!(null===(t=this.checkout.billingAddress)||void 0===t?void 0:t.isValid),r=!!this.mpVM.selectedCard||((null==i?void 0:i.paymentMethodType)===a.CREDIT_CARD&&i.type===c.INTERNAL?!!this.isCustomFlowStripe||(!!this.isKlarna||(null===(e=this.cardData)||void 0===e?void 0:e.isValid)):!!i);return s&&n&&r},enumerable:!1,configurable:!0}),Object.defineProperty(R.prototype,"isDigitalOnly",{get:function(){return this.checkout.shippingMethod===l.DIGITAL_DELIVERY},enumerable:!1,configurable:!0}),R}();function D(t,e){return t.match(new RegExp(".{1,"+e+"}","g"))||[]}function G(t){return t&&R.test(t.charAt(t.length-1))}!function(t){t.INFO="info",t.SHIPPING="shipping",t.PAYMENT="payment",t.SUCCESS="success"}(j||(j={})),function(t){t[t.UNKNOWN=0]="UNKNOWN",t[t.API_ERROR=1]="API_ERROR",t[t.STOCK_ERROR=2]="STOCK_ERROR",t[t.PAYMENT_ERROR=3]="PAYMENT_ERROR",t[t.NO_SHIPPING_ERROR=4]="NO_SHIPPING_ERROR",t[t.CUSTOMER_LOGIN_REQUIRED_ERROR=5]="CUSTOMER_LOGIN_REQUIRED_ERROR"}(E||(E={}));export{j as CheckoutStep,E as ErrorType,x as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.js';import*as a from"react";import{observer as r}from"mobx-react-lite";import{IkasBaseStore as c}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";var o=r((function(r){return a.useEffect((function(){window.captchaOnLoad=function(e){c.getInstance().customerStore.setCaptchaToken(e)}}),[]),a.useEffect((function(){try{var a=document.createElement("script");a.src="https://www.google.com/recaptcha/api.js?render=6LcBVyAhAAAAAPqU6pwhCXm26KgqYAdLrwYAVjZ2",a.className="googleRecaptchaScript",document.body.appendChild(a);var r=document.getElementsByClassName("grecaptcha-badge");e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){var t=setInterval((function(){if(r&&r.length>1){clearInterval(t);for(var a=0;a<r.length;a++){var c=r[a].getAttribute("style");c&&(c=c.concat("opacity: 0; visibility: hidden !important;")),r[a].setAttribute("style","".concat(c))}e(null)}else r=document.getElementsByClassName("grecaptcha-badge")}),100)}))];case 1:return[2,e.sent()]}}))}))}catch(e){console.log("Captcha Error",e)}}),[]),a.useEffect((function(){return function(){var e,t;try{var a=document.getElementsByClassName("grecaptcha-badge");if(a&&a.length)for(var r=0;r<a.length;r++)null===(e=a[r].parentNode)||void 0===e||e.removeChild(a[r]);var c=document.getElementsByClassName("googleRecaptchaScript");if(c&&c.length)for(r=0;r<c.length;r++)null===(t=c[r].parentNode)||void 0===t||t.removeChild(c[r])}catch(e){console.log("Captcha Remove Error",e)}}}),[]),a.createElement("div",{id:"recaptcha",className:"g-recaptcha","data-sitekey":"6LcBVyAhAAAAAPqU6pwhCXm26KgqYAdLrwYAVjZ2","data-callback":"captchaOnLoad","data-size":"invisible"})}));export{o as GoogleCaptcha};
|
|
1
|
+
import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.js';import*as a from"react";import{observer as r}from"mobx-react-lite";import{IkasBaseStore as c}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";var o=r((function(r){return a.useEffect((function(){window.captchaOnLoad=function(e){c.getInstance().customerStore.setCaptchaToken(e)}}),[]),a.useEffect((function(){try{var a=document.createElement("script");a.src="https://www.google.com/recaptcha/api.js?render=6LcBVyAhAAAAAPqU6pwhCXm26KgqYAdLrwYAVjZ2",a.className="googleRecaptchaScript",a.async=!0,document.body.appendChild(a);var r=document.getElementsByClassName("grecaptcha-badge");e(void 0,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,new Promise((function(e){var t=setInterval((function(){if(r&&r.length>1){clearInterval(t);for(var a=0;a<r.length;a++){var c=r[a].getAttribute("style");c&&(c=c.concat("opacity: 0; visibility: hidden !important;")),r[a].setAttribute("style","".concat(c))}e(null)}else r=document.getElementsByClassName("grecaptcha-badge")}),100)}))];case 1:return[2,e.sent()]}}))}))}catch(e){console.log("Captcha Error",e)}}),[]),a.useEffect((function(){return function(){var e,t;try{var a=document.getElementsByClassName("grecaptcha-badge");if(a&&a.length)for(var r=0;r<a.length;r++)null===(e=a[r].parentNode)||void 0===e||e.removeChild(a[r]);var c=document.getElementsByClassName("googleRecaptchaScript");if(c&&c.length)for(r=0;r<c.length;r++)null===(t=c[r].parentNode)||void 0===t||t.removeChild(c[r])}catch(e){console.log("Captcha Remove Error",e)}}}),[]),a.createElement("div",{id:"recaptcha",className:"g-recaptcha","data-sitekey":"6LcBVyAhAAAAAPqU6pwhCXm26KgqYAdLrwYAVjZ2","data-callback":"captchaOnLoad","data-size":"invisible"})}));export{o as GoogleCaptcha};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as t,__generator as o}from'./../../ext/tslib/tslib.es6.js';import*as i from"react";import{observer as r}from"mobx-react-lite";import{useRouter as a}from"next/router.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"mobx";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as s}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{IkasStorefrontConfig as d}from"@ikas/storefront-config";import{Analytics as
|
|
1
|
+
import{__assign as e,__awaiter as t,__generator as o}from'./../../ext/tslib/tslib.es6.js';import*as i from"react";import{observer as r}from"mobx-react-lite";import{useRouter as a}from"next/router.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"mobx";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as s}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{IkasStorefrontConfig as d}from"@ikas/storefront-config";import{Analytics as n}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasPageHead as m}from"./head.js";import{ThemeComponent as l}from"./ThemeComponent.js";import{IkasBaseStore as p}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import{initIkasEvents as c}from"../../analytics/events.js";import{IkasPageDataInit as u}from"../../page-data-init/index.js";import{setAPIClientConfig as f}from"@ikas/storefront-api";var j=r((function(r){var l=r.propValues,j=r.themeJsonComponents,g=r.pageType,v=r.pageTitle,y=r.pageDescription,h=r.pageSpecificData,b=r.canonicals,w=r.disableIndex,S=r.settings,C=r.merchantSettings,I=r.configJson,P=r.reInitOnBrowser,k=r.addOgpMetas,D=r.components,E=r.productReviewSummary,T=a();d.init(e(e({},I),{currentPageComponents:D,loginRequiredCallback:function(){T.push("/account/login")}})),p.getInstance().router=T,f();var V=p.getInstance();V.router=T,V.currentPageType=g;var R=i.useState(!1),O=R[0],M=R[1],F=i.useMemo((function(){return u.setPageSpecificData(h,g,O),u.initPagePropValues(l,j,S,O)}),[O,l,g,S,h,j]);i.useEffect((function(){P&&M("undefined"!=typeof window),V.cartStore.getCart(),V.checkLocalization(),c()}),[]),i.useEffect((function(){var e=function(){V.customerStore.routeChangeInit()};return T.events.on("routeChangeStart",e),function(){T.events.off("routeChangeStart",e)}}),[]),i.useEffect((function(){!function(e,i){var r,a;t(this,void 0,void 0,(function(){var t,d,m,l,c;return o(this,(function(o){switch(o.label){case 0:t=p.getInstance(),n.pageView(e),o.label=1;case 1:return o.trys.push([1,4,,5]),e===s.PRODUCT&&(d=i,n.productView(d),t.customerStore.onProductView(d.id,d.selectedVariant.id)),e===s.CATEGORY&&(l=null===(r=(m=i).categoryPathItems)||void 0===r?void 0:r.map((function(e){return e.name})).join(" > "),l=m.categoryPathItems&&(null===(a=m.categoryPathItems)||void 0===a?void 0:a.length)>0?l+" > "+m.name:m.name,n.viewCategory(l,m)),e!==s.CART?[3,3]:[4,t.cartStore.waitUntilInitialized()];case 2:o.sent(),n.viewCart(t.cartStore.cart),o.label=3;case 3:return[3,5];case 4:return c=o.sent(),console.error(c),[3,5];case 5:return[2]}}))}))}(g,u.pageSpecificData)}),[g,h]);var H=i.useMemo((function(){var e=F.find((function(e){return e.component.isHeader})),t=F.find((function(e){return e.component.isFooter})),o=F.filter((function(e){return!e.component.isHeader&&!e.component.isFooter}))||[];return i.createElement("div",{style:{position:"relative",minHeight:"100vh",display:"flex",flexDirection:"column",justifyContent:"space-between"}},i.createElement("div",null,e&&x(e,S,-1),o.map((function(e,t){return x(e,S,t)}))),t&&x(t,S,-1))}),[F,S]);return i.createElement(i.Fragment,null,i.createElement(m,{pageType:g,pageTitle:v,pageDescription:y,pageSpecificData:u.pageSpecificData,canonicals:b,disableIndex:w,merchantSettings:C,addOgpMetas:k,productReviewSummary:E}),H)})),x=function(e,t,o){return i.createElement(l,{key:e.pageComponent.id,index:o,pageComponentPropValue:e,settings:t})};export{j as IkasPage,x as renderComponent};
|
|
@@ -35,6 +35,7 @@ export default class IkasPageEditorViewModel {
|
|
|
35
35
|
setComponentRef: (element: React.ElementType, component: IkasThemeJsonPageComponent) => void;
|
|
36
36
|
isScrolledIntoView: (el: HTMLElement) => boolean;
|
|
37
37
|
handleUpdateFrameData: (data: any) => Promise<void>;
|
|
38
|
+
setCustomerSettings: () => Promise<void>;
|
|
38
39
|
handleUpdateThemeJson: (data: any) => Promise<void>;
|
|
39
40
|
handleUpdatePropValue: (data: any) => Promise<void>;
|
|
40
41
|
handleUpdatePageParams: (data: any) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import{IkasBlogMetaDataTargetType as o}from"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import{reaction as n,makeAutoObservable as a,runInAction as s}from"mobx";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as r}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import{IkasHTMLMetaDataTargetType as d}from"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import{IkasThemeJson as p}from"../../models/data/theme-json/index.js";import{IkasStorefront as l}from"../../models/data/storefront/index.js";import{IkasThemeJsonComponent as c}from"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import{IkasThemeJsonPageComponent as m}from"../../models/data/theme-json/page/component/index.js";import{IkasThemeJsonSettings as u}from"../../models/data/theme-json/settings/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{IkasPageDataProvider as g}from"@ikas/storefront-providers";import{IkasPageDataInit as h}from"../../page-data-init/index.js";import"../../analytics/analytics.js";import"../../analytics/head/index.js";import"../page/index.js";import"../page/head.js";import"react";import"next/image.js";import"@ikas/storefront-model-functions";import"../link/index.js";import"./loader/style.module.scss.js";import"../google-captcha/index.js";import"../../pages/home.js";import"../../pages/_slug_/index.js";import"../../pages/pages/_slug_.js";import"../../pages/checkout.js";import"../../pages/account/index.js";import"../../pages/account/addresses.js";import"../../pages/account/orders/index.js";import"../../pages/account/orders/_id_.js";import"../../pages/account/login.js";import"../../pages/account/register.js";import"../../pages/account/forgot-password.js";import"../../pages/account/recover-password.js";import"../../pages/cart.js";import"../../pages/editor.js";import"../../pages/account/favorite-products.js";import"../../pages/search.js";import"next/error.js";import"../../pages/blog/index.js";import"../../pages/blog/_slug_.js";import"../../pages/raffle/_slug_.js";import"../../pages/raffle/index.js";import"../../pages/account/raffles.js";import{IkasBaseStore as f}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import"lodash/get";import E from"../../store/html-meta-data/index.js";import v from"../../store/blog/index.js";import P from"../../store/raffle/index.js";import O from"../../store/product/index.js";import{setAPIClientConfig as T}from"@ikas/storefront-api";var _,C=function(){function C(n){var O=this;this.theme=null,this.page=null,this.selectedPageComponentId=null,this.hoveredPageComponentId=null,this.componentRefs={},this.isLoading=!1,this.updateId="",this.locale="en",this.pageParams={},this.apiKey=null,this.pageDataProvider=null,this.initializedPropValues=[],this.startMessaging=function(){window.addEventListener("message",O.onMessage,!1),O.sendMessage(_.FRAME_DID_LOAD,"4.0.0"),O.createLoadingListener()},this.onMessage=function(i){return e(O,void 0,void 0,(function(){var e,o;return t(this,(function(t){switch(t.label){case 0:switch(e=i.data.type,o=i.data.data,e){case _.UPDATE_FRAME_DATA:return[3,1];case _.UPDATE_THEME_JSON:return[3,3];case _.UPDATE_PROP_VALUE:return[3,5];case _.UPDATE_PAGE_PARAMS:return[3,7];case _.UPDATE_PAGE_COMPONENT_ORDER:return[3,9];case _.ADD_COMPONENT:return[3,11];case _.DELETE_COMPONENT:return[3,12];case _.UPDATE_COMPONENT:return[3,13];case _.ADD_PAGE_COMPONENT:return[3,14];case _.DELETE_PAGE_COMPONENT:return[3,16];case _.SET_SELECTED_COMPONENT:return[3,17];case _.SET_HOVERED_COMPONENT:return[3,18];case _.SCROLL_TO_COMPONENT:return[3,19];case _.EDITOR_RELOAD:return[3,20];case _.UPDATE_THEME_SETTINGS:return[3,21]}return[3,22];case 1:return[4,this.handleUpdateFrameData(o)];case 2:case 4:case 6:case 8:case 10:case 15:return t.sent(),[3,23];case 3:return[4,this.handleUpdateThemeJson(o)];case 5:return[4,this.handleUpdatePropValue(o)];case 7:return[4,this.handleUpdatePageParams(o)];case 9:return[4,this.handleUpdatePageComponentOrder(o)];case 11:return this.handleAddNewComponent(o),[3,23];case 12:return this.handleDeleteComponent(o),[3,23];case 13:return this.handleUpdateComponent(o),[3,23];case 14:return[4,this.handleAddNewPageComponent(o)];case 16:return this.handleDeletePageComponent(o),[3,23];case 17:return this.handleSetSelectedComponent(o),[3,23];case 18:return this.handleSetHoveredComponent(o),[3,23];case 19:return this.handleScrollToComponent(o),[3,23];case 20:return this.handleEditorReload(),[3,23];case 21:return this.updateThemeSettings(o),[3,23];case 22:return[3,23];case 23:return[2]}}))}))},this.onClick=function(e){O.sendMessage(_.COMPONENT_CLICK,{componentId:e})},this.onMouseOver=function(e){O.sendMessage(_.COMPONENT_MOUSE_OVER,{componentId:e})},this.onMouseLeave=function(e){O.sendMessage(_.COMPONENT_MOUSE_LEAVE,{componentId:e})},this.onPageChange=function(i){return e(O,void 0,void 0,(function(){var e,n,a,p,l,c,m,u,g,h,O,T,C,D=this;return t(this,(function(t){switch(t.label){case 0:return e=i.slice(1),n=e.split("?"),e=n[0],a=n[1],this.pageParams={},i.startsWith("/account/orders/")?p=r.ORDER_DETAIL:i.startsWith("/account/orders")?p=r.ORDERS:i.startsWith("/account/addresses")?p=r.ADDRESSES:i.startsWith("/account/favorite-products")?p=r.FAVORITE_PRODUCTS:i.startsWith("/account/forgot-password")?p=r.FORGOT_PASSWORD:i.startsWith("/account/login")?p=r.LOGIN:i.startsWith("/account/raffles")?p=r.RAFFLE_ACCOUNT:i.startsWith("/account/recover-password")?p=r.RECOVER_PASSWORD:i.startsWith("/account/register")?p=r.REGISTER:i.startsWith("/account")?p=r.ACCOUNT:i.startsWith("/blog/")?p=r.BLOG:i.startsWith("/blog")?p=r.BLOG_INDEX:i.startsWith("/pages")?(p=r.CUSTOM,this.pageParams={slug:e.split("/")[1]}):p=i.startsWith("/raffle/")?r.RAFFLE_DETAIL:i.startsWith("/raffle")?r.RAFFLE:i.startsWith("/404")?r.NOT_FOUND:i.startsWith("/cart")?r.CART:i.startsWith("/checkout")?r.CHECKOUT:"/"===i?r.INDEX:i.startsWith("/search")?r.SEARCH:r.PRODUCT,p!==r.PRODUCT?[3,6]:[4,E.listHTMLMetaData({slug:{eq:e}})];case 1:return(c=t.sent()).isSuccess&&(null===(g=c.data)||void 0===g?void 0:g.length)?(m=c.data[0]).targetType!==d.PRODUCT?[3,3]:[4,this.getVariantIdFromParams(m.targetId,a)]:[3,5];case 2:return l=t.sent(),this.pageParams={productId:m.targetId,variantId:l,slug:e},[3,4];case 3:if(m.targetType===d.CATEGORY)p=r.CATEGORY,this.pageParams={categoryId:m.targetId,slug:e};else{if(m.targetType!==d.BRAND)return[2];p=r.BRAND,this.pageParams={brandId:m.targetId,slug:e}}t.label=4;case 4:return[3,6];case 5:return[2];case 6:return p!==r.BLOG?[3,8]:[4,v.listBlogMetaData({slug:{eq:e}})];case 7:if(!(c=t.sent()).isSuccess||!(null===(O=null===(h=c.data)||void 0===h?void 0:h.data)||void 0===O?void 0:O.length))return[2];if((m=c.data.data[0]).targetType===o.BLOG)this.pageParams={blogId:m.targetId,slug:e};else{if(m.targetType!==o.BLOG_CATEGORY)return[2];p=r.BLOG_CATEGORY,this.pageParams={blogCategoryId:m.targetId,slug:e}}t.label=8;case 8:return p!==r.RAFFLE_DETAIL?[3,10]:[4,P.listRaffleMetaData({slug:{eq:e}})];case 9:if(!(c=t.sent()).isSuccess||!(null===(T=c.data)||void 0===T?void 0:T.length))return[2];m=c.data[0],this.pageParams={raffleId:m.targetId,slug:e},t.label=10;case 10:return this.isLoading=!0,[4,this.getPagePropValues(this.theme,p,this.pageParams)];case 11:return u=t.sent(),s((function(){var e,t;f.getInstance().currentPageType=p,D.pageDataProvider=u,p===r.CUSTOM?D.page=null===(e=D.theme)||void 0===e?void 0:e.pages.find((function(e){return e.type===p&&e.slug===D.pageParams.slug})):D.page=null===(t=D.theme)||void 0===t?void 0:t.pages.find((function(e){return e.type===p})),requestAnimationFrame((function(){document.body.scrollTop=0,document.scrollingElement&&(document.scrollingElement.scrollTop=0)}))})),this.sendMessage(_.EDITOR_PAGE_CHANGE,{pageType:p,pageParams:this.pageParams,pageSpecificData:(null===(C=this.pageDataProvider)||void 0===C?void 0:C.pageSpecificData)||null}),this.isLoading=!1,[2]}}))}))},this.onLoadingChange=function(){O.sendMessage(_.EDITOR_LOADING_CHANGE,{isLoading:O.isLoading})},this.sendMessage=function(e,t){window.parent.postMessage({type:e,data:JSON.parse(JSON.stringify(t))},"*")},this.getPagePropValues=function(i,o,n){return e(O,void 0,void 0,(function(){var e,a,s;return t(this,(function(t){switch(t.label){case 0:return e=new g(i,n,o),(n.blogId||n.blogCategoryId)&&(e.possiblePageTypes=[r.BLOG,r.BLOG_CATEGORY]),n.raffleId&&(e.possiblePageTypes=[r.RAFFLE_DETAIL]),[4,e.getPageData()];case 1:return t.sent(),e.pageSpecificData?(h.setPageSpecificData(e.pageSpecificData,o,!0),o===r.PRODUCT&&h.pageSpecificData&&(a=h.pageSpecificData,(s=a.variants.find((function(e){return e.id===n.variantId})))&&(a.selectedVariantValues=s.variantValues))):h.pageSpecificData=void 0,this.initializedPropValues=h.initPagePropValues(e.$pageComponentPropValues,i.components,i.settings,!1),[2,e]}}))}))},this.setComponentRef=function(e,t){O.componentRefs[t.id]=e},this.isScrolledIntoView=function(e){var t=e.getBoundingClientRect(),i=t.top,o=t.bottom;return i<window.innerHeight&&o>=0&&o<window.innerHeight&&i>0},this.handleUpdateFrameData=function(o){return e(O,void 0,void 0,(function(){var e,n,a,s,r,d,c=this;return t(this,(function(t){switch(t.label){case 0:return this.theme=new p(o.theme),this.page=null===(r=this.theme)||void 0===r?void 0:r.pages.find((function(e){return e.id===o.selectedPage.id})),this.pageParams=o.pageParams,this.apiKey=o.apiKey,this.locale=o.locale||"en",this.translations=o.translations||void 0,this.page?((e=o.storefront?new l(o.storefront):null)&&(n=e.routings.find((function(e){return e.locale===c.locale})),i.init({storefrontId:e.id,storefrontRoutingId:null==n?void 0:n.id,storefrontThemeId:e.mainStorefrontThemeId||void 0,salesChannelId:e.salesChannelId||void 0,priceListId:(null==n?void 0:n.priceListId)||void 0,routings:e.routings,stockPreference:null===(d=this.theme)||void 0===d?void 0:d.settings.stockPreference,translations:this.translations||{},isEditor:!0,apiKey:o.apiKey,apiUrl:o.apiUrl,adminApiUrl:o.adminApiUrl,cdnUrl:o.cdnUrl,merchantSettings:o.merchantSettings}),T()),a=Date.now()+"",this.updateId=a,this.isLoading=!0,[4,this.getPagePropValues(this.theme,this.page.type,this.pageParams||{})]):[2];case 1:return s=t.sent(),this.updateId===a&&(this.pageDataProvider=s,this.isLoading=!1),[2]}}))}))},this.handleUpdateThemeJson=function(i){return e(O,void 0,void 0,(function(){return t(this,(function(e){return this.theme=new p(i.theme),[2]}))}))},this.handleUpdatePropValue=function(i){return e(O,void 0,void 0,(function(){var e,o,n,a,s,r,d,p=this;return t(this,(function(t){switch(t.label){case 0:return e=i.propName,o=i.value,(n=null===(d=null===(r=this.selectedComponent)||void 0===r?void 0:r.props)||void 0===d?void 0:d.find((function(t){return t.name===e})))&&this.selectedPageComponent?(a=this.initializedPropValues.find((function(e){return e.pageComponent.id===p.selectedPageComponentId})),this.pageDataProvider&&a?(this.selectedPageComponent.propValues[e]=o,[4,this.pageDataProvider.getPageComponentPropValue(this.selectedPageComponent,n)]):[2]):[2];case 1:return(s=t.sent())&&JSON.stringify(s).includes("href")?[4,this.pageDataProvider.setLinkSlugs()]:[3,3];case 2:t.sent(),t.label=3;case 3:return a.propValues[e]=h.initPropValue(n,s,this.theme.settings,!0),[2]}}))}))},this.handleUpdatePageParams=function(i){return e(O,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageParams=i.pageParams,this.isLoading=!0,[4,this.getPagePropValues(this.theme,this.page.type,this.pageParams||{})];case 1:return e=t.sent(),this.pageDataProvider=e,this.isLoading=!1,[2]}}))}))},this.handleUpdatePageComponentOrder=function(i){return e(O,void 0,void 0,(function(){return t(this,(function(e){return this.specification?this.specification.components=i.pageComponents.map((function(e){return new m(e)})):this.page.components=i.pageComponents.map((function(e){return new m(e)})),[2]}))}))},this.handleAddNewComponent=function(e){var t,i=new c(e.component);null===(t=O.theme)||void 0===t||t.components.push(i)},this.handleDeleteComponent=function(e){var t,i;(null===(t=O.theme)||void 0===t?void 0:t.components)&&(O.theme.components=O.theme.components.filter((function(t){return t.id!==e.componentId})));var o=O.pageComponents.filter((function(t){return t.componentId!==e.componentId}))||[];O.specification&&O.specification.components&&(O.specification.components=o),!O.specification&&(null===(i=O.page)||void 0===i?void 0:i.components)&&(O.page.components=o)},this.handleUpdateComponent=function(e){var t=O.theme.components.findIndex((function(t){return t.id===e.component.id}));-1!==t&&(O.theme.components[t]=new c(e.component))},this.handleAddNewPageComponent=function(i){return e(O,void 0,void 0,(function(){var e,o,n;return t(this,(function(t){switch(t.label){case 0:return e=new m(i.pageComponent),this.pageComponents.some((function(t){return t.id===e.id}))?[2]:[4,this.pageDataProvider.getPageComponentPropValues(e)];case 1:return o=t.sent(),n=h.initPageComponentPropValue(o,[o.component],this.theme.settings,!0),this.initializedPropValues.push(n),this.pageComponents.push(e),[2]}}))}))},this.handleDeletePageComponent=function(e){O.specification?O.specification.components=O.pageComponents.filter((function(t){return t.id!==e.pageComponentId})):O.page.components=O.pageComponents.filter((function(t){return t.id!==e.pageComponentId}))},this.handleSetSelectedComponent=function(e){O.selectedPageComponentId=e.componentId},this.handleSetHoveredComponent=function(e){O.hoveredPageComponentId=e.componentId},this.handleScrollToComponent=function(e){var t=e.componentId,i=O.componentRefs[t];i&&(O.isScrolledIntoView(i)||window.scrollTo({top:i.offsetTop,behavior:"smooth"}))},this.handleEditorReload=function(){window.location.reload()},this.updateThemeSettings=function(e){var t=e.settings;O.theme&&(O.theme.settings=new u(t))},this.router=n,a(this),this.startMessaging()}return Object.defineProperty(C.prototype,"specification",{get:function(){var e,t,i,o,n,a,s,d=this,p=this.page;return(null==p?void 0:p.type)===r.PRODUCT&&(s=null===(e=p.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.productId)}))),(null==p?void 0:p.type)===r.CATEGORY&&(s=null===(t=p.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.categoryId)}))),(null==p?void 0:p.type)===r.BRAND&&(s=null===(i=p.specifications)||void 0===i?void 0:i.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.brandId)}))),(null==p?void 0:p.type)===r.BLOG&&(s=null===(o=p.specifications)||void 0===o?void 0:o.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.blogId)}))),(null==p?void 0:p.type)===r.BLOG_CATEGORY&&(s=null===(n=p.specifications)||void 0===n?void 0:n.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.blogCategoryId)}))),(null==p?void 0:p.type)===r.RAFFLE_DETAIL&&(s=null===(a=p.specifications)||void 0===a?void 0:a.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.raffleId)}))),s},enumerable:!1,configurable:!0}),Object.defineProperty(C.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(C.prototype,"selectedPageComponent",{get:function(){var e=this;return this.pageComponents.find((function(t){return t.id===e.selectedPageComponentId}))},enumerable:!1,configurable:!0}),Object.defineProperty(C.prototype,"selectedComponent",{get:function(){var e,t=this;return null===(e=this.theme)||void 0===e?void 0:e.components.find((function(e){var i;return e.id===(null===(i=t.selectedPageComponent)||void 0===i?void 0:i.componentId)}))},enumerable:!1,configurable:!0}),C.prototype.createLoadingListener=function(){var e=this;n((function(){return e.isLoading}),(function(){e.onLoadingChange()}))},C.prototype.getVariantIdFromParams=function(o,n){var a,s;return e(this,void 0,void 0,(function(){var e,r,d,p,l,c,m;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=new URLSearchParams("?"+n),[4,O.searchProducts({input:{productIdList:[o],priceListId:i.getPriceListId(),salesChannelId:i.getSalesChannelId()}})];case 1:return(r=t.sent()).isSuccess&&!(null===(s=null===(a=null==r?void 0:r.data)||void 0===a?void 0:a.data)||void 0===s?void 0:s.length)?[2]:(d=r.data.data[0],p=d.variantTypes.map((function(e){return e.variantType.slug})),l=[],p.forEach((function(t,i){var o=d.variantTypes[i],n=e.get(t);if(n){var a=o.variantType.values.find((function(e){return e.slug===n}));a&&l.push(a)}})),(c=d.variants.find((function(e){return e.variantValues.every((function(e){return l.some((function(t){return t.id===e.id}))}))})))?[2,c.id]:[3,3]);case 2:return m=t.sent(),console.error(m),[3,3];case 3:return[2]}}))}))},C}();!function(e){e.FRAME_DID_LOAD="FRAME_DID_LOAD",e.UPDATE_FRAME_DATA="UPDATE_FRAME_DATA",e.UPDATE_THEME_JSON="UPDATE_THEME_JSON",e.UPDATE_PROP_VALUE="UPDATE_PROP_VALUE",e.UPDATE_PAGE_PARAMS="UPDATE_PAGE_PARAMS",e.UPDATE_PAGE_COMPONENT_ORDER="UPDATE_PAGE_COMPONENT_ORDER",e.ADD_COMPONENT="ADD_COMPONENT",e.DELETE_COMPONENT="DELETE_COMPONENT",e.UPDATE_COMPONENT="UPDATE_COMPONENT",e.ADD_PAGE_COMPONENT="ADD_PAGE_COMPONENT",e.DELETE_PAGE_COMPONENT="DELETE_PAGE_COMPONENT",e.COMPONENT_MOUSE_OVER="COMPONENT_MOUSE_OVER",e.COMPONENT_MOUSE_LEAVE="COMPONENT_MOUSE_LEAVE",e.COMPONENT_CLICK="COMPONENT_CLICK",e.SET_SELECTED_COMPONENT="SET_SELECTED_COMPONENT",e.SET_HOVERED_COMPONENT="SET_HOVERED_COMPONENT",e.SCROLL_TO_COMPONENT="SCROLL_TO_COMPONENT",e.UPDATE_THEME_SETTINGS="UPDATE_THEME_SETTINGS",e.EDITOR_PAGE_CHANGE="EDITOR_PAGE_CHANGE",e.EDITOR_LOADING_CHANGE="EDITOR_LOADING_CHANGE",e.EDITOR_RELOAD="EDITOR_RELOAD"}(_||(_={}));export{_ as BridgeMessageType,C as default};
|
|
1
|
+
import{__awaiter as e,__generator as t}from'./../../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as i}from"@ikas/storefront-config";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import{IkasBlogMetaDataTargetType as o}from"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import{reaction as n,makeAutoObservable as a,runInAction as s}from"mobx";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasThemeJsonPageType as r}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import{IkasHTMLMetaDataTargetType as d}from"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import{IkasThemeJson as p}from"../../models/data/theme-json/index.js";import{IkasStorefront as l}from"../../models/data/storefront/index.js";import{IkasThemeJsonComponent as c}from"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import{IkasThemeJsonPageComponent as m}from"../../models/data/theme-json/page/component/index.js";import{IkasThemeJsonSettings as u}from"../../models/data/theme-json/settings/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import{IkasPageDataProvider as g}from"@ikas/storefront-providers";import{IkasPageDataInit as h}from"../../page-data-init/index.js";import"../../analytics/analytics.js";import"../../analytics/head/index.js";import"../page/index.js";import"../page/head.js";import"react";import"next/image.js";import"@ikas/storefront-model-functions";import"../link/index.js";import"./loader/style.module.scss.js";import"../google-captcha/index.js";import"../../pages/home.js";import"../../pages/_slug_/index.js";import"../../pages/pages/_slug_.js";import"../../pages/checkout.js";import"../../pages/account/index.js";import"../../pages/account/addresses.js";import"../../pages/account/orders/index.js";import"../../pages/account/orders/_id_.js";import"../../pages/account/login.js";import"../../pages/account/register.js";import"../../pages/account/forgot-password.js";import"../../pages/account/recover-password.js";import"../../pages/cart.js";import"../../pages/editor.js";import"../../pages/account/favorite-products.js";import"../../pages/search.js";import"next/error.js";import"../../pages/blog/index.js";import"../../pages/blog/_slug_.js";import"../../pages/raffle/_slug_.js";import"../../pages/raffle/index.js";import"../../pages/account/raffles.js";import{IkasBaseStore as f}from"../../store/base.js";import"../../store/customer/index.js";import"../../store/cart/index.js";import"lodash/get";import E from"../../store/html-meta-data/index.js";import v from"../../store/blog/index.js";import P from"../../store/raffle/index.js";import O from"../../store/product/index.js";import{setAPIClientConfig as T,listCustomerSettings as C}from"@ikas/storefront-api";var _,D=function(){function D(n){var O=this;this.theme=null,this.page=null,this.selectedPageComponentId=null,this.hoveredPageComponentId=null,this.componentRefs={},this.isLoading=!1,this.updateId="",this.locale="en",this.pageParams={},this.apiKey=null,this.pageDataProvider=null,this.initializedPropValues=[],this.startMessaging=function(){window.addEventListener("message",O.onMessage,!1),O.sendMessage(_.FRAME_DID_LOAD,"4.0.0"),O.createLoadingListener()},this.onMessage=function(i){return e(O,void 0,void 0,(function(){var e,o;return t(this,(function(t){switch(t.label){case 0:switch(e=i.data.type,o=i.data.data,e){case _.UPDATE_FRAME_DATA:return[3,1];case _.UPDATE_THEME_JSON:return[3,3];case _.UPDATE_PROP_VALUE:return[3,5];case _.UPDATE_PAGE_PARAMS:return[3,7];case _.UPDATE_PAGE_COMPONENT_ORDER:return[3,9];case _.ADD_COMPONENT:return[3,11];case _.DELETE_COMPONENT:return[3,12];case _.UPDATE_COMPONENT:return[3,13];case _.ADD_PAGE_COMPONENT:return[3,14];case _.DELETE_PAGE_COMPONENT:return[3,16];case _.SET_SELECTED_COMPONENT:return[3,17];case _.SET_HOVERED_COMPONENT:return[3,18];case _.SCROLL_TO_COMPONENT:return[3,19];case _.EDITOR_RELOAD:return[3,20];case _.UPDATE_THEME_SETTINGS:return[3,21]}return[3,22];case 1:return[4,this.handleUpdateFrameData(o)];case 2:case 4:case 6:case 8:case 10:case 15:return t.sent(),[3,23];case 3:return[4,this.handleUpdateThemeJson(o)];case 5:return[4,this.handleUpdatePropValue(o)];case 7:return[4,this.handleUpdatePageParams(o)];case 9:return[4,this.handleUpdatePageComponentOrder(o)];case 11:return this.handleAddNewComponent(o),[3,23];case 12:return this.handleDeleteComponent(o),[3,23];case 13:return this.handleUpdateComponent(o),[3,23];case 14:return[4,this.handleAddNewPageComponent(o)];case 16:return this.handleDeletePageComponent(o),[3,23];case 17:return this.handleSetSelectedComponent(o),[3,23];case 18:return this.handleSetHoveredComponent(o),[3,23];case 19:return this.handleScrollToComponent(o),[3,23];case 20:return this.handleEditorReload(),[3,23];case 21:return this.updateThemeSettings(o),[3,23];case 22:return[3,23];case 23:return[2]}}))}))},this.onClick=function(e){O.sendMessage(_.COMPONENT_CLICK,{componentId:e})},this.onMouseOver=function(e){O.sendMessage(_.COMPONENT_MOUSE_OVER,{componentId:e})},this.onMouseLeave=function(e){O.sendMessage(_.COMPONENT_MOUSE_LEAVE,{componentId:e})},this.onPageChange=function(i){return e(O,void 0,void 0,(function(){var e,n,a,p,l,c,m,u,g,h,O,T,C,D=this;return t(this,(function(t){switch(t.label){case 0:return e=i.slice(1),n=e.split("?"),e=n[0],a=n[1],this.pageParams={},i.startsWith("/account/orders/")?p=r.ORDER_DETAIL:i.startsWith("/account/orders")?p=r.ORDERS:i.startsWith("/account/addresses")?p=r.ADDRESSES:i.startsWith("/account/favorite-products")?p=r.FAVORITE_PRODUCTS:i.startsWith("/account/forgot-password")?p=r.FORGOT_PASSWORD:i.startsWith("/account/login")?p=r.LOGIN:i.startsWith("/account/raffles")?p=r.RAFFLE_ACCOUNT:i.startsWith("/account/recover-password")?p=r.RECOVER_PASSWORD:i.startsWith("/account/register")?p=r.REGISTER:i.startsWith("/account")?p=r.ACCOUNT:i.startsWith("/blog/")?p=r.BLOG:i.startsWith("/blog")?p=r.BLOG_INDEX:i.startsWith("/pages")?(p=r.CUSTOM,this.pageParams={slug:e.split("/")[1]}):p=i.startsWith("/raffle/")?r.RAFFLE_DETAIL:i.startsWith("/raffle")?r.RAFFLE:i.startsWith("/404")?r.NOT_FOUND:i.startsWith("/cart")?r.CART:i.startsWith("/checkout")?r.CHECKOUT:"/"===i?r.INDEX:i.startsWith("/search")?r.SEARCH:r.PRODUCT,p!==r.PRODUCT?[3,6]:[4,E.listHTMLMetaData({slug:{eq:e}})];case 1:return(c=t.sent()).isSuccess&&(null===(g=c.data)||void 0===g?void 0:g.length)?(m=c.data[0]).targetType!==d.PRODUCT?[3,3]:[4,this.getVariantIdFromParams(m.targetId,a)]:[3,5];case 2:return l=t.sent(),this.pageParams={productId:m.targetId,variantId:l,slug:e},[3,4];case 3:if(m.targetType===d.CATEGORY)p=r.CATEGORY,this.pageParams={categoryId:m.targetId,slug:e};else{if(m.targetType!==d.BRAND)return[2];p=r.BRAND,this.pageParams={brandId:m.targetId,slug:e}}t.label=4;case 4:return[3,6];case 5:return[2];case 6:return p!==r.BLOG?[3,8]:[4,v.listBlogMetaData({slug:{eq:e}})];case 7:if(!(c=t.sent()).isSuccess||!(null===(O=null===(h=c.data)||void 0===h?void 0:h.data)||void 0===O?void 0:O.length))return[2];if((m=c.data.data[0]).targetType===o.BLOG)this.pageParams={blogId:m.targetId,slug:e};else{if(m.targetType!==o.BLOG_CATEGORY)return[2];p=r.BLOG_CATEGORY,this.pageParams={blogCategoryId:m.targetId,slug:e}}t.label=8;case 8:return p!==r.RAFFLE_DETAIL?[3,10]:[4,P.listRaffleMetaData({slug:{eq:e}})];case 9:if(!(c=t.sent()).isSuccess||!(null===(T=c.data)||void 0===T?void 0:T.length))return[2];m=c.data[0],this.pageParams={raffleId:m.targetId,slug:e},t.label=10;case 10:return this.isLoading=!0,[4,this.getPagePropValues(this.theme,p,this.pageParams)];case 11:return u=t.sent(),s((function(){var e,t;f.getInstance().currentPageType=p,D.pageDataProvider=u,p===r.CUSTOM?D.page=null===(e=D.theme)||void 0===e?void 0:e.pages.find((function(e){return e.type===p&&e.slug===D.pageParams.slug})):D.page=null===(t=D.theme)||void 0===t?void 0:t.pages.find((function(e){return e.type===p})),requestAnimationFrame((function(){document.body.scrollTop=0,document.scrollingElement&&(document.scrollingElement.scrollTop=0)}))})),this.sendMessage(_.EDITOR_PAGE_CHANGE,{pageType:p,pageParams:this.pageParams,pageSpecificData:(null===(C=this.pageDataProvider)||void 0===C?void 0:C.pageSpecificData)||null}),this.isLoading=!1,[2]}}))}))},this.onLoadingChange=function(){O.sendMessage(_.EDITOR_LOADING_CHANGE,{isLoading:O.isLoading})},this.sendMessage=function(e,t){window.parent.postMessage({type:e,data:JSON.parse(JSON.stringify(t))},"*")},this.getPagePropValues=function(i,o,n){return e(O,void 0,void 0,(function(){var e,a,s;return t(this,(function(t){switch(t.label){case 0:return e=new g(i,n,o),(n.blogId||n.blogCategoryId)&&(e.possiblePageTypes=[r.BLOG,r.BLOG_CATEGORY]),n.raffleId&&(e.possiblePageTypes=[r.RAFFLE_DETAIL]),[4,e.getPageData()];case 1:return t.sent(),e.pageSpecificData?(h.setPageSpecificData(e.pageSpecificData,o,!0),o===r.PRODUCT&&h.pageSpecificData&&(a=h.pageSpecificData,(s=a.variants.find((function(e){return e.id===n.variantId})))&&(a.selectedVariantValues=s.variantValues))):h.pageSpecificData=void 0,this.initializedPropValues=h.initPagePropValues(e.$pageComponentPropValues,i.components,i.settings,!1),[2,e]}}))}))},this.setComponentRef=function(e,t){O.componentRefs[t.id]=e},this.isScrolledIntoView=function(e){var t=e.getBoundingClientRect(),i=t.top,o=t.bottom;return i<window.innerHeight&&o>=0&&o<window.innerHeight&&i>0},this.handleUpdateFrameData=function(o){return e(O,void 0,void 0,(function(){var e,n,a,s,r,d,c=this;return t(this,(function(t){switch(t.label){case 0:return this.theme=new p(o.theme),this.page=null===(r=this.theme)||void 0===r?void 0:r.pages.find((function(e){return e.id===o.selectedPage.id})),this.pageParams=o.pageParams,this.apiKey=o.apiKey,this.locale=o.locale||"en",this.translations=o.translations||void 0,this.page?((e=o.storefront?new l(o.storefront):null)&&(n=e.routings.find((function(e){return e.locale===c.locale})),i.init({storefrontId:e.id,storefrontRoutingId:null==n?void 0:n.id,storefrontThemeId:e.mainStorefrontThemeId||void 0,salesChannelId:e.salesChannelId||void 0,priceListId:(null==n?void 0:n.priceListId)||void 0,routings:e.routings,stockPreference:null===(d=this.theme)||void 0===d?void 0:d.settings.stockPreference,translations:this.translations||{},isEditor:!0,apiKey:o.apiKey,apiUrl:o.apiUrl,adminApiUrl:o.adminApiUrl,cdnUrl:o.cdnUrl,merchantSettings:o.merchantSettings}),T(),this.setCustomerSettings()),a=Date.now()+"",this.updateId=a,this.isLoading=!0,[4,this.getPagePropValues(this.theme,this.page.type,this.pageParams||{})]):[2];case 1:return s=t.sent(),this.updateId===a&&(this.pageDataProvider=s,this.isLoading=!1),[2]}}))}))},this.setCustomerSettings=function(){return e(O,void 0,void 0,(function(){var e,o,n;return t(this,(function(t){switch(t.label){case 0:return i.getCustomerSettings()?[3,2]:[4,C({storefrontId:{eq:i.getStorefrontId()}})];case 1:(e=t.sent()).isSuccess&&(null===(n=e.data)||void 0===n?void 0:n.data.length)&&(o=e.data.data[0],i.init({customerSettings:o})),t.label=2;case 2:return[2]}}))}))},this.handleUpdateThemeJson=function(i){return e(O,void 0,void 0,(function(){return t(this,(function(e){return this.theme=new p(i.theme),[2]}))}))},this.handleUpdatePropValue=function(i){return e(O,void 0,void 0,(function(){var e,o,n,a,s,r,d,p=this;return t(this,(function(t){switch(t.label){case 0:return e=i.propName,o=i.value,(n=null===(d=null===(r=this.selectedComponent)||void 0===r?void 0:r.props)||void 0===d?void 0:d.find((function(t){return t.name===e})))&&this.selectedPageComponent?(a=this.initializedPropValues.find((function(e){return e.pageComponent.id===p.selectedPageComponentId})),this.pageDataProvider&&a?(this.selectedPageComponent.propValues[e]=o,[4,this.pageDataProvider.getPageComponentPropValue(this.selectedPageComponent,n)]):[2]):[2];case 1:return(s=t.sent())&&JSON.stringify(s).includes("href")?[4,this.pageDataProvider.setLinkSlugs()]:[3,3];case 2:t.sent(),t.label=3;case 3:return a.propValues[e]=h.initPropValue(n,s,this.theme.settings,!0),[2]}}))}))},this.handleUpdatePageParams=function(i){return e(O,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return this.pageParams=i.pageParams,this.isLoading=!0,[4,this.getPagePropValues(this.theme,this.page.type,this.pageParams||{})];case 1:return e=t.sent(),this.pageDataProvider=e,this.isLoading=!1,[2]}}))}))},this.handleUpdatePageComponentOrder=function(i){return e(O,void 0,void 0,(function(){return t(this,(function(e){return this.specification?this.specification.components=i.pageComponents.map((function(e){return new m(e)})):this.page.components=i.pageComponents.map((function(e){return new m(e)})),[2]}))}))},this.handleAddNewComponent=function(e){var t,i=new c(e.component);null===(t=O.theme)||void 0===t||t.components.push(i)},this.handleDeleteComponent=function(e){var t,i;(null===(t=O.theme)||void 0===t?void 0:t.components)&&(O.theme.components=O.theme.components.filter((function(t){return t.id!==e.componentId})));var o=O.pageComponents.filter((function(t){return t.componentId!==e.componentId}))||[];O.specification&&O.specification.components&&(O.specification.components=o),!O.specification&&(null===(i=O.page)||void 0===i?void 0:i.components)&&(O.page.components=o)},this.handleUpdateComponent=function(e){var t=O.theme.components.findIndex((function(t){return t.id===e.component.id}));-1!==t&&(O.theme.components[t]=new c(e.component))},this.handleAddNewPageComponent=function(i){return e(O,void 0,void 0,(function(){var e,o,n;return t(this,(function(t){switch(t.label){case 0:return e=new m(i.pageComponent),this.pageComponents.some((function(t){return t.id===e.id}))?[2]:[4,this.pageDataProvider.getPageComponentPropValues(e)];case 1:return o=t.sent(),n=h.initPageComponentPropValue(o,[o.component],this.theme.settings,!0),this.initializedPropValues.push(n),i.customIndex?this.pageComponents.splice(i.customIndex,0,e):this.pageComponents.push(e),[2]}}))}))},this.handleDeletePageComponent=function(e){O.specification?O.specification.components=O.pageComponents.filter((function(t){return t.id!==e.pageComponentId})):O.page.components=O.pageComponents.filter((function(t){return t.id!==e.pageComponentId}))},this.handleSetSelectedComponent=function(e){O.selectedPageComponentId=e.componentId},this.handleSetHoveredComponent=function(e){O.hoveredPageComponentId=e.componentId},this.handleScrollToComponent=function(e){var t=e.componentId,i=O.componentRefs[t];i&&(O.isScrolledIntoView(i)||window.scrollTo({top:i.offsetTop,behavior:"smooth"}))},this.handleEditorReload=function(){window.location.reload()},this.updateThemeSettings=function(e){var t=e.settings;O.theme&&(O.theme.settings=new u(t))},this.router=n,a(this),this.startMessaging()}return Object.defineProperty(D.prototype,"specification",{get:function(){var e,t,i,o,n,a,s,d=this,p=this.page;return(null==p?void 0:p.type)===r.PRODUCT&&(s=null===(e=p.specifications)||void 0===e?void 0:e.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.productId)}))),(null==p?void 0:p.type)===r.CATEGORY&&(s=null===(t=p.specifications)||void 0===t?void 0:t.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.categoryId)}))),(null==p?void 0:p.type)===r.BRAND&&(s=null===(i=p.specifications)||void 0===i?void 0:i.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.brandId)}))),(null==p?void 0:p.type)===r.BLOG&&(s=null===(o=p.specifications)||void 0===o?void 0:o.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.blogId)}))),(null==p?void 0:p.type)===r.BLOG_CATEGORY&&(s=null===(n=p.specifications)||void 0===n?void 0:n.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.blogCategoryId)}))),(null==p?void 0:p.type)===r.RAFFLE_DETAIL&&(s=null===(a=p.specifications)||void 0===a?void 0:a.find((function(e){var t;return e.id===(null===(t=d.pageParams)||void 0===t?void 0:t.raffleId)}))),s},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"pageComponents",{get:function(){var e;return this.specification?this.specification.components:(null===(e=this.page)||void 0===e?void 0:e.components)||[]},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"selectedPageComponent",{get:function(){var e=this;return this.pageComponents.find((function(t){return t.id===e.selectedPageComponentId}))},enumerable:!1,configurable:!0}),Object.defineProperty(D.prototype,"selectedComponent",{get:function(){var e,t=this;return null===(e=this.theme)||void 0===e?void 0:e.components.find((function(e){var i;return e.id===(null===(i=t.selectedPageComponent)||void 0===i?void 0:i.componentId)}))},enumerable:!1,configurable:!0}),D.prototype.createLoadingListener=function(){var e=this;n((function(){return e.isLoading}),(function(){e.onLoadingChange()}))},D.prototype.getVariantIdFromParams=function(o,n){var a,s;return e(this,void 0,void 0,(function(){var e,r,d,p,l,c,m;return t(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),e=new URLSearchParams("?"+n),[4,O.searchProducts({input:{productIdList:[o],priceListId:i.getPriceListId(),salesChannelId:i.getSalesChannelId()}})];case 1:return(r=t.sent()).isSuccess&&!(null===(s=null===(a=null==r?void 0:r.data)||void 0===a?void 0:a.data)||void 0===s?void 0:s.length)?[2]:(d=r.data.data[0],p=d.variantTypes.map((function(e){return e.variantType.slug})),l=[],p.forEach((function(t,i){var o=d.variantTypes[i],n=e.get(t);if(n){var a=o.variantType.values.find((function(e){return e.slug===n}));a&&l.push(a)}})),(c=d.variants.find((function(e){return e.variantValues.every((function(e){return l.some((function(t){return t.id===e.id}))}))})))?[2,c.id]:[3,3]);case 2:return m=t.sent(),console.error(m),[3,3];case 3:return[2]}}))}))},D}();!function(e){e.FRAME_DID_LOAD="FRAME_DID_LOAD",e.UPDATE_FRAME_DATA="UPDATE_FRAME_DATA",e.UPDATE_THEME_JSON="UPDATE_THEME_JSON",e.UPDATE_PROP_VALUE="UPDATE_PROP_VALUE",e.UPDATE_PAGE_PARAMS="UPDATE_PAGE_PARAMS",e.UPDATE_PAGE_COMPONENT_ORDER="UPDATE_PAGE_COMPONENT_ORDER",e.ADD_COMPONENT="ADD_COMPONENT",e.DELETE_COMPONENT="DELETE_COMPONENT",e.UPDATE_COMPONENT="UPDATE_COMPONENT",e.ADD_PAGE_COMPONENT="ADD_PAGE_COMPONENT",e.DELETE_PAGE_COMPONENT="DELETE_PAGE_COMPONENT",e.COMPONENT_MOUSE_OVER="COMPONENT_MOUSE_OVER",e.COMPONENT_MOUSE_LEAVE="COMPONENT_MOUSE_LEAVE",e.COMPONENT_CLICK="COMPONENT_CLICK",e.SET_SELECTED_COMPONENT="SET_SELECTED_COMPONENT",e.SET_HOVERED_COMPONENT="SET_HOVERED_COMPONENT",e.SCROLL_TO_COMPONENT="SCROLL_TO_COMPONENT",e.UPDATE_THEME_SETTINGS="UPDATE_THEME_SETTINGS",e.EDITOR_PAGE_CHANGE="EDITOR_PAGE_CHANGE",e.EDITOR_LOADING_CHANGE="EDITOR_LOADING_CHANGE",e.EDITOR_RELOAD="EDITOR_RELOAD"}(_||(_={}));export{_ as BridgeMessageType,D as default};
|
|
@@ -72,9 +72,8 @@ export declare class IkasProductFilterNumberRangeListOption implements IProductF
|
|
|
72
72
|
from: number;
|
|
73
73
|
to: number | undefined | null;
|
|
74
74
|
key: string;
|
|
75
|
-
|
|
75
|
+
isSelected: boolean;
|
|
76
76
|
constructor(data: Partial<IProductFilterNumberRangeListOption>);
|
|
77
|
-
get isSelected(): boolean;
|
|
78
77
|
toJSON(): this & {
|
|
79
78
|
isSelected: boolean;
|
|
80
79
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as t}from'./../../../../ext/tslib/tslib.es6.js';import{IkasImage as e}from"../../image/index.js";import{IkasProductFilterType as i,IkasProductFilterDisplayType as s,IkasProductFilterSortType as o}from"@ikas/storefront-models";export{IkasProductFilterDisplayType,IkasProductFilterSortType,IkasProductFilterType}from"@ikas/storefront-models";import{makeAutoObservable as n}from"mobx";import{IkasProductFilterFunctions as
|
|
1
|
+
import{__assign as t}from'./../../../../ext/tslib/tslib.es6.js';import{IkasImage as e}from"../../image/index.js";import{IkasProductFilterType as i,IkasProductFilterDisplayType as s,IkasProductFilterSortType as o}from"@ikas/storefront-models";export{IkasProductFilterDisplayType,IkasProductFilterSortType,IkasProductFilterType}from"@ikas/storefront-models";import{makeAutoObservable as n}from"mobx";import{IkasProductFilterFunctions as l}from"@ikas/storefront-model-functions";var r=function(){function e(e,o){var r=this;if(this.productList=null,this.onFilterValueClick=function(t){var e;l.onFilterValueClick(r,t),null===(e=r.productList)||void 0===e||e.applyFilters()},this.onNumberRangeClick=function(t){var e;l.onNumberRangeClick(r,t),null===(e=r.productList)||void 0===e||e.applyFilters()},this.onNumberRangeChange=function(t){var e;l.onNumberRangeChange(r,t),null===(e=r.productList)||void 0===e||e.applyFilters()},this.clear=function(){l.clear(r)},this.toInput=function(){return l.toInput(r)},this.applyQueryParam=function(t){l.applyQueryParam(r,t)},this.id=e.id||"",this.key=e.key||"",this.name=e.name||"",this.order=e.order||0,this.type=e.type||i.BRAND,this.displayType=e.displayType||s.BOX,this.isMultiSelect=e.isMultiSelect||!1,this.isFacetFilter=e.isFacetFilter||!1,this.values=e.values?e.values.map((function(t){return new u(t)})):null,this.customValues=e.customValues||null,this.settings=e.settings?new h(e.settings):null,this.displayType===s.NUMBER_RANGE_LIST&&this.customValues&&this.customValues.length&&(this.numberRangeListOptions=this.customValues.map((function(e){return new c(t(t({key:e},d(e)),{isSelected:!1}))}))),this.displayType===s.NUMBER_RANGE&&this.customValues&&this.customValues.length){var a=this.customValues[0];this.numberRangeLimit=d(a)}this.productList=o,n(this)}return Object.defineProperty(e.prototype,"isCustomValueFilter",{get:function(){return l.isCustomValueFilter(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isStockFilter",{get:function(){return l.isStockFilter(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"valueList",{get:function(){return l.getValueList(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"keyList",{get:function(){return l.getKeyList(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"displayedValues",{get:function(){return l.getDisplayedValues(this)},enumerable:!1,configurable:!0}),e.prototype.toJSON=function(){var e=t({},this);return delete e.productList,e},e}(),u=function(t){this.id=t.id||"",this.key=t.key||"",this.name=t.name||"",this.colorCode=t.colorCode||null,this.thumbnailImageId=t.thumbnailImageId||null,this.thumbnailImageId&&(this.thumbnailImage=new e({id:this.thumbnailImageId,isVideo:!1})),this.isSelected=t.isSelected||!1,this.resultCount=void 0!==t.resultCount&&null!==t.resultCount?t.resultCount:null,n(this)},a=function(t){this.id=t.id,this.type=t.type,this.displayType=t.displayType,this.valueList=t.valueList,n(this)},h=function(t){this.useAndFilter=t.useAndFilter||!1,this.showCollapsedOnDesktop=t.showCollapsedOnDesktop||!1,this.showCollapsedOnMobile=t.showCollapsedOnMobile||!1,this.sortType=t.sortType||o.ALPHABETICAL_ASC,this.customSortedValues=t.customSortedValues||null,n(this)},p=function(t){this.from=t.from||0,this.to=t.to||null,n(this)},c=function(){function e(t){this.from=t.from||0,this.to=t.to||null,this.key=t.key||"",this.isSelected=t.isSelected||!1,n(this)}return e.prototype.toJSON=function(){return t(t({},this),{isSelected:this.isSelected})},e}();function d(t){return l.parseRangeStr(t)}export{u as IkasApplicableProductFilterValue,p as IkasFilterRangeValue,r as IkasProductFilter,c as IkasProductFilterNumberRangeListOption,h as IkasProductFilterSettings,a as IkasProductFilterValue,d as parseRangeStr};
|
|
@@ -23,7 +23,7 @@ export declare class IkasBrandList {
|
|
|
23
23
|
get hasNext(): boolean;
|
|
24
24
|
get isLoading(): boolean;
|
|
25
25
|
private getSortParams;
|
|
26
|
-
getInitial
|
|
26
|
+
private getInitial;
|
|
27
27
|
getPrev: () => Promise<void>;
|
|
28
28
|
getNext: () => Promise<void>;
|
|
29
29
|
getPage: (page: number) => Promise<void>;
|
|
@@ -23,7 +23,7 @@ export declare class IkasCategoryList {
|
|
|
23
23
|
get hasNext(): boolean;
|
|
24
24
|
get isLoading(): boolean;
|
|
25
25
|
private getSortParams;
|
|
26
|
-
getInitial
|
|
26
|
+
private getInitial;
|
|
27
27
|
getPrev: () => Promise<void>;
|
|
28
28
|
getNext: () => Promise<void>;
|
|
29
29
|
getPage: (page: number) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as i}from'./../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import s from"lodash/debounce";import"../../data/blog/category/index.js";import"../../data/blog/content/index.js";import"../../data/blog/meta-data/index.js";import"../../data/blog/tag/index.js";import"../../data/blog/index.js";import"../../data/brand/index.js";import{IkasCategoryProductsOrderType as a,IkasThemeJsonPageType as o,IkasThemeJsonStockPreference as n}from"@ikas/storefront-models";import"../../data/campaign-offer/index.js";import"../../data/cart/campaign-offer/index.js";import"../../data/cart/index.js";import"../../data/category/path-item/index.js";import"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/checkout-settings/index.js";import"../../data/city/index.js";import"../../data/country/index.js";import"../../data/customer/address/index.js";import"../../data/customer/attribute/index.js";import"../../data/customer/review/summary/index.js";import"../../data/customer/review/index.js";import"../../data/customer/index.js";import"../../data/district/index.js";import"../../data/favorite-product/index.js";import{IkasFilterCategory as d}from"../../data/filter-category/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/order/address/index.js";import"../../data/order/line-item/variant/value/index.js";import"../../data/order/line-item/variant/index.js";import"../../data/order/line-item/index.js";import"../../data/order/package/index.js";import"../../data/order/index.js";import"../../data/payment-gateway/index.js";import"../../data/product/attribute-value/index.js";import{IkasProductFilter as u,IkasProductFilterValue as c}from"../../data/product/filter/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/variant/price/index.js";import"../../data/product/variant/index.js";import"../../data/variant-type/index.js";import{IkasProduct as l}from"../../data/product/index.js";import"../../data/raffle/index.js";import"../../data/state/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import p from"../../../store/product/index.js";import h from"query-string";import{SortByDirectionEnum as f,SortByTypeEnum as m}from"@ikas/storefront-api";import{IkasStorefrontConfig as g}from"@ikas/storefront-config";import{Analytics as v}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import"../../../components/page/index.js";import"../../../components/page/head.js";import"react";import"next/image.js";import"@ikas/storefront-model-functions";import"../../../components/link/index.js";import"../../../components/page-editor/loader/style.module.scss.js";import"../../../components/google-captcha/index.js";import"../blog-list/index.js";import"../blog-category-list/index.js";import"../brand-list/index.js";import"../category-list/index.js";import"../product-attribute-detail/index.js";import"../product-attribute-list/index.js";import"../customer-review-list/index.js";import"../customer-review-summary-list/index.js";import"../validator/index.js";import"../validator/rules/index.js";import"../validator/form/login.js";import"../validator/form/address.js";import"../validator/form/register.js";import"../validator/form/contact-form.js";import"../validator/form/forgot-password.js";import"../validator/form/recover-password.js";import"../validator/form/account-info.js";import"../validator/form/raffle-form.js";import"../validator/form/customer-review.js";import"../raffle-list/index.js";import"../../../pages/home.js";import"../../../pages/_slug_/index.js";import"../../../pages/pages/_slug_.js";import"../../../pages/checkout.js";import"../../../pages/account/index.js";import"../../../pages/account/addresses.js";import"../../../pages/account/orders/index.js";import"../../../pages/account/orders/_id_.js";import"../../../pages/account/login.js";import"../../../pages/account/register.js";import"../../../pages/account/forgot-password.js";import"../../../pages/account/recover-password.js";import"../../../pages/cart.js";import"../../../pages/editor.js";import"../../../pages/account/favorite-products.js";import"../../../pages/search.js";import"next/error.js";import"../../../pages/blog/index.js";import"../../../pages/blog/_slug_.js";import"../../../pages/raffle/_slug_.js";import"../../../pages/raffle/index.js";import"../../../pages/account/raffles.js";import{IkasBaseStore as _}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import"lodash/get";var y,I,S,b=function(){function S(a,n){var c=this;this.filters=null,this._filterCategories=null,this._infiniteScrollPage=null,this._initialized=!1,this._minPage=null,this._filterBrandId=null,this._filterCategoryId=null,this._relatedProductData=null,this.pageSpecificData=null,this._recommendFor=null,this._isLoading=!1,this._fetchRequestTime=0,this.router=null,this.applyFilters=function(){return t(c,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,this.getInitial()];case 1:return t=e.sent(),[o.CATEGORY,o.BRAND,o.SEARCH].includes(this._pageType)?(t&&this.isBrowser()&&!this.isSearch&&!g.getIsEditor()&&(null===(i=this.router)||void 0===i||i.replace("".concat(location.pathname).concat(this.filterQueryParams?"?"+this.filterQueryParams:""),void 0,{shallow:!0})),[2]):[2]}}))}))},this.getInitial=function(r,s){return t(c,void 0,void 0,(function(){var t,a,o,n,d,u,c,p,h,f,m,g,v;return e(this,(function(e){switch(e.label){case 0:this._isLoading=!0,t=Date.now(),this._fetchRequestTime=t,e.label=1;case 1:return e.trys.push([1,12,13,14]),a=s?this._page:1,o=this._limit,!this.isFilterable||this.filters?[3,3]:[4,this.getFilters()];case 2:e.sent(),e.label=3;case 3:return this.applyQueryParamFilters(r),this.isSearch&&!this.hasAppliedfilter?(this.data=[],this._page=1,this._minPage=1,this._count=0,this._initialized=!0,[2,!0]):(n=void 0,this.isStatic?(a=void 0,o=200,[3,10]):[3,4]);case 4:return this.isDiscounted?(a=1,o=10,[3,10]):[3,5];case 5:return this.isRecommended?(a=1,o=10,[3,10]):[3,6];case 6:return this.isLastViewed?this.isBrowser()?[4,this.waitForCustomerStoreInit()]:[3,9]:[3,10];case 7:return e.sent(),[4,_.getInstance().customerStore.getLastViewedProducts()];case 8:return(d=e.sent())&&d.length&&(n=d.map((function(t){return t.productId}))),[3,10];case 9:return[2];case 10:return[4,this.searchProducts(a||1,o||10,n)];case 11:return(u=e.sent())&&this._fetchRequestTime===t?(c=[],this.isStatic||this.isLastViewed?(p=this.isStatic?this._productListPropValue.productIds:_.getInstance().customerStore._lastViewedProducts,c=(null==p?void 0:p.map((function(t){var e,r,s=null===(r=null===(e=u.data)||void 0===e?void 0:e.data)||void 0===r?void 0:r.find((function(e){return e.id===t.productId})),a=null==s?void 0:s.variants.find((function(e){return e.id===t.variantId}));if((null==a?void 0:a.isActive)||(a=null==s?void 0:s.variants.find((function(t){return t.isActive}))),s&&a)return new l(i(i({},s),{selectedVariantValues:a.variantValues}))})).filter((function(t){return!!t})))||[]):c=(null===(m=null===(f=u.data)||void 0===f?void 0:f.data)||void 0===m?void 0:m.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})))||[],this.applyFacets(null===(g=u.data)||void 0===g?void 0:g.facets),this.data=c,this._count=(null===(v=u.data)||void 0===v?void 0:v.count)||0,this._initialized=!0,this._page=a||1,this._minPage=this.page,s||(this._infiniteScrollPage=null),this.handleListingEvent(),[2,!0]):[2];case 12:return h=e.sent(),console.log(h),[3,14];case 13:return t===this._fetchRequestTime&&(this._isLoading=!1),[7];case 14:return[2]}}))}))},this.getPrev=function(){return t(c,void 0,void 0,(function(){var t,r,s,a,o,n,d;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.searchProducts(t,this.limit)];case 2:return(r=e.sent())?(s=null===(n=null===(o=r.data)||void 0===o?void 0:o.data)||void 0===n?void 0:n.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=(null==s?void 0:s.concat(this.data))||this.data,this._count=(null===(d=r.data)||void 0===d?void 0:d.count)||this._count,this._minPage=t,[3,5]):[2];case 3:return a=e.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(c,void 0,void 0,(function(){var t,r,s,a,o,n;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasNext)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(this.page+1,this.limit)];case 2:return(t=e.sent())?(r=null===(o=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===o?void 0:o.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=this.data.concat(r||[]),this._count=(null===(n=t.data)||void 0===n?void 0:n.count)||this._count,this._page=this.page+1,[3,5]):[2];case 3:return s=e.sent(),console.log(s),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(r){return t(c,void 0,void 0,(function(){var t,s,a,o,n,d;return e(this,(function(e){switch(e.label){case 0:if(this._isLoading||this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(r,this.limit)];case 2:return(t=e.sent())?(s=null===(n=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===n?void 0:n.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=s||[],this._count=(null===(d=t.data)||void 0===d?void 0:d.count)||0,this._page=r,this._minPage=r,[3,5]):[2];case 3:return a=e.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.setVisibleInfiniteScrollPage=function(t){var e;c._infiniteScrollPage!==t&&(c._infiniteScrollPage=t,g.getIsEditor()||null===(e=c.router)||void 0===e||e.replace("".concat(location.pathname).concat(c.filterQueryParams?"?"+c.filterQueryParams:""),void 0,{shallow:!0}))},this.searchDebouncer=s((function(){c.applyFilters()}),500),this.searchAnalyticsDebouncer=s((function(){v.search(c._searchKeyword)}),1e3);var p=a,h=a;if(this.data=a.data?a.data.map((function(t){return new l(t)})):[],this._type=p.type||h._type||p.productListPropValue.productListType||h._productListPropValue.productListType||y.ALL,this._pageType=a.pageType,this._sort=a.sort||a.productListPropValue.initialSort||I.LAST_ADDED,this._limit=a.limit||p.productListPropValue.initialLimit||h._productListPropValue.initialLimit||20,this._page=a.page||1,this._minPage=a.minPage||null,this._count=a.count||0,this._searchKeyword=a.searchKeyword||"",this._productListPropValue=p.productListPropValue||h._productListPropValue,this._filterBrandId=p.filterBrandId||h._filterBrandId||null,this._filterCategoryId=p.filterCategoryId||h._filterCategoryId||null,this._relatedProductData=p.relatedProductData||h._relatedProductData||null,this._recommendFor=p.recommendFor||h._recommendFor,this.filters=a.filters?a.filters.map((function(t){return new u(t,c)})):null,this._filterCategories=a.filterCategories?a.filterCategories.map((function(t){return new d(t)})):null,this.pageSpecificData=p.pageSpecificData||h.pageSpecificData||null,this.router=n,r(this),this.setPageSpecificSort(),this.isBrowser())if(this.restoreInfiniteScrollPage(),location.search&&(this.isFilterable||this._type===y.SEARCH)){var f=this.getQueryParams();this.getInitial(f,this._page>1)}else this._page>1?this.getInitial(void 0,!0):this.isLastViewed?this.getInitial():this.handleListingEvent()}return Object.defineProperty(S.prototype,"sort",{get:function(){return this._sort},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"pageType",{get:function(){return this._pageType},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"minPage",{get:function(){return this._minPage||1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"searchKeyword",{get:function(){return this._searchKeyword},set:function(t){t!==this._searchKeyword&&(this._searchKeyword=t,this.searchDebouncer(),this.searchAnalyticsDebouncer())},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isFilterable",{get:function(){return this._type===y.ALL||this._type===y.CATEGORY},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isFiltered",{get:function(){var t,e;return(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))||!!this._searchKeyword||this._pageType!==o.CATEGORY&&(!!this._filterCategoryId||(null===(e=this._filterCategories)||void 0===e?void 0:e.some((function(t){return t.isSelected}))))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isStatic",{get:function(){return this._type===y.STATIC},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isDiscounted",{get:function(){return this._type===y.DISCOUNTED},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isRecommended",{get:function(){return this._type===y.RECOMMENDED},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isLastViewed",{get:function(){return this._type===y.LAST_VIEWED},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isRelatedProducts",{get:function(){return this._type===y.RELATED_PRODUCTS},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isSearch",{get:function(){return this._type===y.SEARCH},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasPrev",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended||!this._minPage)&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasNext",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended)&&this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"filterQueryParams",{get:function(){var t,e,i,r,s=this,a={};if(null===(t=this.filters)||void 0===t||t.forEach((function(t){t.keyList.length&&(a[t.key]=t.keyList)})),this._searchKeyword&&(a.s=this._searchKeyword),this._infiniteScrollPage&&(a.page=this._infiniteScrollPage),this._pageType!==o.CATEGORY){var n=null===(e=this.filterCategories)||void 0===e?void 0:e.filter((function(t){return t.isSelected}));if(!!(null==n?void 0:n.length))a.c=null==n?void 0:n.map((function(t){return t.slug}));else if(this._filterCategoryId){var d=null===(r=null===(i=this.filterCategories)||void 0===i?void 0:i.find((function(t){return t.id===s._filterCategoryId})))||void 0===r?void 0:r.slug;d&&(a.c=d)}}return h.stringify(a,{arrayFormat:"comma"})},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"filterCategories",{get:function(){var t;return null===(t=this._filterCategories)||void 0===t?void 0:t.filter((function(t){return 0!==t.resultCount}))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasAppliedfilter",{get:function(){var t;return!!this._searchKeyword||(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isFeaturedSortEnabled",{get:function(){var t;return(null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)===a.MANUALLY&&[y.ALL,y.CATEGORY].includes(this._type)},enumerable:!1,configurable:!0}),S.prototype.setPageSpecificSort=function(){var t;if((null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)&&[y.ALL].includes(this._type))switch(this.pageSpecificData.orderType){case a.HIGHEST_DISCOUNT_RATIO:this._sort=I.DECRASING_DISCOUNT;break;case a.LOWEST_DISCOUNT_RATIO:this._sort=I.INCREASING_DISCOUNT;break;case a.HIGHEST_PRICE:this._sort=I.DECREASING_PRICE;break;case a.LOWEST_PRICE:this._sort=I.INCREASING_PRICE;break;case a.NEWEST:this._sort=I.LAST_ADDED;break;case a.OLDEST:this._sort=I.FIRST_ADDED;break;case a.MANUALLY:this._sort=I.FEATURED}},S.prototype.getSortParams=function(){var t,e;switch(this._sort){case I.INCREASING_PRICE:t=f.ASC,e=m.PRICE;break;case I.DECREASING_PRICE:t=f.DESC,e=m.PRICE;break;case I.FIRST_ADDED:t=f.ASC,e=m.CREATED_AT;break;case I.LAST_ADDED:t=f.DESC,e=m.CREATED_AT;break;case I.INCREASING_DISCOUNT:t=f.ASC,e=m.DISCOUNT_RATIO;break;case I.DECRASING_DISCOUNT:t=f.DESC,e=m.DISCOUNT_RATIO;break;case I.FEATURED:if(this.isSearch)return;t=f.ASC,e=m.MANUAL_SORT;break;case I.DEFAULT:t=void 0,e=void 0}if(t&&e)return{direction:t,type:e}},S.prototype.searchProducts=function(i,r,s){var a,d,u;return t(this,void 0,void 0,(function(){var t,l,h,f;return e(this,(function(e){switch(e.label){case 0:return t=[],l=[],null===(a=this.filters)||void 0===a||a.forEach((function(e){e.valueList.length&&t.push(new c({id:e.id,type:e.type,displayType:e.displayType,valueList:e.valueList})),e.isFacetFilter&&l.push({id:e.id,type:e.type,displayType:e.displayType})})),h=null===(d=this._filterCategories)||void 0===d?void 0:d.filter((function(t){return t.isSelected})).map((function(t){return t.id})),f=this.getSortParams(),this.isRelatedProducts&&this._relatedProductData?[4,p.getRelatedProducts({priceListId:g.getPriceListId(),salesChannelId:g.getSalesChannelId(),productId:this._relatedProductData.productId,brandIds:this._relatedProductData.brandIds,categoryIds:this._relatedProductData.categoryIds})]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return[4,p.searchProducts({input:{page:i,perPage:r,productIdList:this.isStatic?null===(u=this._productListPropValue.productIds)||void 0===u?void 0:u.map((function(t){return t.productId})):s,filterList:t,facetList:l,brandId:this._pageType===o.BRAND&&this._type!==y.SEARCH?this._filterBrandId:void 0,categoryIdList:h&&h.length?h:this._filterCategoryId?[this._filterCategoryId]:void 0,priceListId:g.getPriceListId(),salesChannelId:g.getSalesChannelId(),query:this._searchKeyword,order:this._type===y.SEARCH?[]:f?[f]:[],showStockOption:g.getStockPreference()||n.SHOW_ALL}})]}}))}))},S.prototype.getFilters=function(){var i,r,s;return t(this,void 0,void 0,(function(){var t,a,n=this;return e(this,(function(e){switch(e.label){case 0:return[4,p.getProductFilterData({categoryId:this._filterCategoryId?this._filterCategoryId:void 0})];case 1:return t=e.sent(),this.filters=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.filters.map((function(t){return new u(t,n)})),this._filterCategories=null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.categories,this.pageType!==o.CATEGORY&&this._filterCategoryId&&(a=null===(s=this._filterCategories)||void 0===s?void 0:s.find((function(t){return t.id===n._filterCategoryId})))&&(a.isSelected=!0),this.filters&&this.filters.sort((function(t,e){return t.order>e.order?1:-1})),[2]}}))}))},S.prototype.applyQueryParamFilters=function(t){var e,i=this;try{null==t||t.forEach((function(t,e){var r,s=null===(r=i.filters)||void 0===r?void 0:r.find((function(t){return t.key===e}));s&&s.applyQueryParam(t)}));var r=null==t?void 0:t.get("s");if(r&&(this._searchKeyword=r),this._pageType!==o.CATEGORY){var s=null==t?void 0:t.get("c"),a=null==s?void 0:s.split(",");a&&a.length&&(null===(e=this.filterCategories)||void 0===e||e.forEach((function(t){t.isSelected=a.some((function(e){return e===t.slug}))})))}}catch(t){console.log(t)}},S.prototype.applyFacets=function(t){var e,i;null===(e=this.filters)||void 0===e||e.forEach((function(e){var i,r,s,a=null==t?void 0:t.find((function(t){return t.id===e.id}));a?null===(i=e.values)||void 0===i||i.forEach((function(t){var i=a.values.find((function(e){return e.id===t.id}));i?t.resultCount=i.count:e.isCustomValueFilter?t.resultCount=null:t.resultCount=0})):e.isCustomValueFilter?null===(r=e.values)||void 0===r||r.forEach((function(t){return t.resultCount=null})):null===(s=e.values)||void 0===s||s.forEach((function(t){return t.resultCount=0}))}));var r=null==t?void 0:t.find((function(t){return"category"===t.id}));r&&(null===(i=this._filterCategories)||void 0===i||i.forEach((function(t){var e=r.values.find((function(e){return e.id===t.id}));t.resultCount=e?e.count:0})))},S.prototype.clearFilters=function(){var t,e;null===(t=this.filters)||void 0===t||t.forEach((function(t){return t.clear()})),this._searchKeyword="",this._pageType!==o.CATEGORY&&(this._filterCategoryId=void 0),null===(e=this._filterCategories)||void 0===e||e.forEach((function(t){return t.isSelected=!1})),this.applyFilters()},S.prototype.setSortType=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this._sort=i,[4,this.getInitial()];case 1:return t.sent(),[2]}}))}))},S.prototype.onFilterCategoryClick=function(i,r){var s,a;return void 0===r&&(r=!1),t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r?(null===(s=this._filterCategories)||void 0===s||s.forEach((function(t){t.id===i.id&&(t.isSelected=!t.isSelected)})),[4,this.applyFilters()]):[3,2];case 1:return t.sent(),[3,3];case 2:g.getIsEditor()||null===(a=_.getInstance().router)||void 0===a||a.push(i.href+(this.filterQueryParams?"?"+this.filterQueryParams:"")),t.label=3;case 3:return[2]}}))}))},S.prototype.toJSON=function(){return{data:this.data,type:this._type,pageType:this._pageType,sort:this._sort,limit:this._limit,page:this._page,count:this._count,searchKeyword:this._searchKeyword,initialized:this._initialized,minPage:this._minPage,filterBrandId:this._filterBrandId,filterCategoryId:this._filterCategoryId,filterCategories:this._filterCategories,filters:this.filters,recommendFor:this._recommendFor,productListPropValue:this._productListPropValue,pageSpecificData:this.pageSpecificData}},S.prototype.restoreInfiniteScrollPage=function(){var t=this.getQueryParams(),e=null==t?void 0:t.get("page");if(e){var i=parseInt(e);isNaN(i)||(this._page=i,this._infiniteScrollPage=i)}},S.prototype.getQueryParams=function(){if(this.isBrowser())return new URLSearchParams(location.search)},S.prototype.isBrowser=function(){return"undefined"!=typeof window},S.prototype.waitForCustomerStoreInit=function(){return new Promise((function(t){var e=setInterval((function(){_.getInstance().customerStore.initialized&&(clearInterval(e),t(null))}),1e3)}))},S.prototype.handleListingEvent=function(){this.searchKeyword&&this.data.length?v.viewSearchResults(this._searchKeyword,this.data):this.data.length&&this._type===y.ALL&&v.viewListing(this.data)},S}();!function(t){t.ALL="ALL",t.STATIC="STATIC",t.DISCOUNTED="DISCOUNTED",t.RECOMMENDED="RECOMMENDED",t.CATEGORY="CATEGORY",t.SEARCH="SEARCH",t.LAST_VIEWED="LAST_VIEWED",t.RELATED_PRODUCTS="RELATED_PRODUCTS"}(y||(y={})),function(t){t.INCREASING_PRICE="INCREASING_PRICE",t.DECREASING_PRICE="DECREASING_PRICE",t.LAST_ADDED="LAST_ADDED",t.FIRST_ADDED="FIRST_ADDED",t.INCREASING_DISCOUNT="INCREASING_DISCOUNT",t.DECRASING_DISCOUNT="DECRASING_DISCOUNT",t.FEATURED="FEATURED",t.DEFAULT="DEFAULT"}(I||(I={})),function(t){t.CATEGORY="CATEGORY",t.BRAND="BRAND"}(S||(S={}));export{b as IkasProductList,I as IkasProductListSortType,y as IkasProductListType,S as IkasRelatedProductsType};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as i}from'./../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import s from"lodash/debounce";import"../../data/blog/category/index.js";import"../../data/blog/content/index.js";import"../../data/blog/meta-data/index.js";import"../../data/blog/tag/index.js";import"../../data/blog/index.js";import"../../data/brand/index.js";import{IkasCategoryProductsOrderType as a,IkasThemeJsonPageType as o,IkasThemeJsonStockPreference as n}from"@ikas/storefront-models";import"../../data/campaign-offer/index.js";import"../../data/cart/campaign-offer/index.js";import"../../data/cart/index.js";import"../../data/category/path-item/index.js";import"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/checkout-settings/index.js";import"../../data/city/index.js";import"../../data/country/index.js";import"../../data/customer/address/index.js";import"../../data/customer/attribute/index.js";import"../../data/customer/review/summary/index.js";import"../../data/customer/review/index.js";import"../../data/customer/index.js";import"../../data/district/index.js";import"../../data/favorite-product/index.js";import{IkasFilterCategory as d}from"../../data/filter-category/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/order/address/index.js";import"../../data/order/line-item/variant/value/index.js";import"../../data/order/line-item/variant/index.js";import"../../data/order/line-item/index.js";import"../../data/order/package/index.js";import"../../data/order/index.js";import"../../data/payment-gateway/index.js";import"../../data/product/attribute-value/index.js";import{IkasProductFilter as u,IkasProductFilterValue as c}from"../../data/product/filter/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/variant/price/index.js";import"../../data/product/variant/index.js";import"../../data/variant-type/index.js";import{IkasProduct as l}from"../../data/product/index.js";import"../../data/raffle/index.js";import"../../data/state/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import p from"../../../store/product/index.js";import h from"query-string";import{SortByDirectionEnum as f,SortByTypeEnum as m}from"@ikas/storefront-api";import{IkasStorefrontConfig as g}from"@ikas/storefront-config";import{Analytics as v}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import"../../../components/page/index.js";import"../../../components/page/head.js";import"react";import"next/image.js";import"@ikas/storefront-model-functions";import"../../../components/link/index.js";import"../../../components/page-editor/loader/style.module.scss.js";import"../../../components/google-captcha/index.js";import"../blog-list/index.js";import"../blog-category-list/index.js";import"../brand-list/index.js";import"../category-list/index.js";import"../product-attribute-detail/index.js";import"../product-attribute-list/index.js";import"../customer-review-list/index.js";import"../customer-review-summary-list/index.js";import"../validator/index.js";import"../validator/rules/index.js";import"../validator/form/login.js";import"../validator/form/address.js";import"../validator/form/register.js";import"../validator/form/contact-form.js";import"../validator/form/forgot-password.js";import"../validator/form/recover-password.js";import"../validator/form/account-info.js";import"../validator/form/raffle-form.js";import"../validator/form/customer-review.js";import"../raffle-list/index.js";import"../../../pages/home.js";import"../../../pages/_slug_/index.js";import"../../../pages/pages/_slug_.js";import"../../../pages/checkout.js";import"../../../pages/account/index.js";import"../../../pages/account/addresses.js";import"../../../pages/account/orders/index.js";import"../../../pages/account/orders/_id_.js";import"../../../pages/account/login.js";import"../../../pages/account/register.js";import"../../../pages/account/forgot-password.js";import"../../../pages/account/recover-password.js";import"../../../pages/cart.js";import"../../../pages/editor.js";import"../../../pages/account/favorite-products.js";import"../../../pages/search.js";import"next/error.js";import"../../../pages/blog/index.js";import"../../../pages/blog/_slug_.js";import"../../../pages/raffle/_slug_.js";import"../../../pages/raffle/index.js";import"../../../pages/account/raffles.js";import{IkasBaseStore as _}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import"lodash/get";var y,I,S,b=function(){function S(a,n){var c=this;this.filters=null,this._filterCategories=null,this._infiniteScrollPage=null,this._initialized=!1,this._minPage=null,this._filterBrandId=null,this._filterCategoryId=null,this._relatedProductData=null,this.pageSpecificData=null,this._recommendFor=null,this._isLoading=!1,this._fetchRequestTime=0,this.router=null,this.applyFilters=function(){return t(c,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,this.getInitial()];case 1:return t=e.sent(),[o.CATEGORY,o.BRAND,o.SEARCH].includes(this._pageType)?(t&&this.isBrowser()&&!this.isSearch&&!g.getIsEditor()&&(null===(i=this.router)||void 0===i||i.replace("".concat(location.pathname).concat(this.filterQueryParams?"?"+this.filterQueryParams:""),void 0,{shallow:!0})),[2]):[2]}}))}))},this.getInitial=function(r,s){return t(c,void 0,void 0,(function(){var t,a,o,n,d,u,c,p,h,f,m,g,v;return e(this,(function(e){switch(e.label){case 0:this._isLoading=!0,t=Date.now(),this._fetchRequestTime=t,e.label=1;case 1:return e.trys.push([1,12,13,14]),a=s?this._page:1,o=this._limit,!this.isFilterable||this.filters?[3,3]:[4,this.getFilters()];case 2:e.sent(),e.label=3;case 3:return this.applyQueryParamFilters(r),this.isSearch&&!this.hasAppliedfilter?(this.data=[],this._page=1,this._minPage=1,this._count=0,this._initialized=!0,[2,!0]):(n=void 0,this.isStatic?(a=void 0,o=200,[3,10]):[3,4]);case 4:return this.isDiscounted?(a=1,o=10,[3,10]):[3,5];case 5:return this.isRecommended?(a=1,o=10,[3,10]):[3,6];case 6:return this.isLastViewed?this.isBrowser()?[4,this.waitForCustomerStoreInit()]:[3,9]:[3,10];case 7:return e.sent(),[4,_.getInstance().customerStore.getLastViewedProducts()];case 8:return(d=e.sent())&&d.length?(n=d.map((function(t){return t.productId})),[3,10]):[2];case 9:return[2];case 10:return[4,this.searchProducts(a||1,o||10,n)];case 11:return(u=e.sent())&&this._fetchRequestTime===t?(c=[],this.isStatic||this.isLastViewed?(p=this.isStatic?this._productListPropValue.productIds:_.getInstance().customerStore._lastViewedProducts,c=(null==p?void 0:p.map((function(t){var e,r,s=null===(r=null===(e=u.data)||void 0===e?void 0:e.data)||void 0===r?void 0:r.find((function(e){return e.id===t.productId})),a=null==s?void 0:s.variants.find((function(e){return e.id===t.variantId}));if((null==a?void 0:a.isActive)||(a=null==s?void 0:s.variants.find((function(t){return t.isActive}))),s&&a)return new l(i(i({},s),{selectedVariantValues:a.variantValues}))})).filter((function(t){return!!t})))||[]):c=(null===(m=null===(f=u.data)||void 0===f?void 0:f.data)||void 0===m?void 0:m.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})))||[],this.applyFacets(null===(g=u.data)||void 0===g?void 0:g.facets),this.data=c,this._count=(null===(v=u.data)||void 0===v?void 0:v.count)||0,this._initialized=!0,this._page=a||1,this._minPage=this.page,s||(this._infiniteScrollPage=null),this.handleListingEvent(),[2,!0]):[2];case 12:return h=e.sent(),console.log(h),[3,14];case 13:return t===this._fetchRequestTime&&(this._isLoading=!1),[7];case 14:return[2]}}))}))},this.getPrev=function(){return t(c,void 0,void 0,(function(){var t,r,s,a,o,n,d;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.searchProducts(t,this.limit)];case 2:return(r=e.sent())?(s=null===(n=null===(o=r.data)||void 0===o?void 0:o.data)||void 0===n?void 0:n.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=(null==s?void 0:s.concat(this.data))||this.data,this._count=(null===(d=r.data)||void 0===d?void 0:d.count)||this._count,this._minPage=t,[3,5]):[2];case 3:return a=e.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(c,void 0,void 0,(function(){var t,r,s,a,o,n;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasNext)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(this.page+1,this.limit)];case 2:return(t=e.sent())?(r=null===(o=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===o?void 0:o.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=this.data.concat(r||[]),this._count=(null===(n=t.data)||void 0===n?void 0:n.count)||this._count,this._page=this.page+1,[3,5]):[2];case 3:return s=e.sent(),console.log(s),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(r){return t(c,void 0,void 0,(function(){var t,s,a,o,n,d;return e(this,(function(e){switch(e.label){case 0:if(this._isLoading||this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(r,this.limit)];case 2:return(t=e.sent())?(s=null===(n=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===n?void 0:n.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=s||[],this._count=(null===(d=t.data)||void 0===d?void 0:d.count)||0,this._page=r,this._minPage=r,[3,5]):[2];case 3:return a=e.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.setVisibleInfiniteScrollPage=function(t){var e;c._infiniteScrollPage!==t&&(c._infiniteScrollPage=t,g.getIsEditor()||null===(e=c.router)||void 0===e||e.replace("".concat(location.pathname).concat(c.filterQueryParams?"?"+c.filterQueryParams:""),void 0,{shallow:!0}))},this.searchDebouncer=s((function(){c.applyFilters()}),500),this.searchAnalyticsDebouncer=s((function(){v.search(c._searchKeyword)}),1e3);var p=a,h=a;if(this.data=a.data?a.data.map((function(t){return new l(t)})):[],this._type=p.type||h._type||p.productListPropValue.productListType||h._productListPropValue.productListType||y.ALL,this._pageType=a.pageType,this._sort=a.sort||a.productListPropValue.initialSort||I.LAST_ADDED,this._limit=a.limit||p.productListPropValue.initialLimit||h._productListPropValue.initialLimit||20,this._page=a.page||1,this._minPage=a.minPage||null,this._count=a.count||0,this._searchKeyword=a.searchKeyword||"",this._productListPropValue=p.productListPropValue||h._productListPropValue,this._filterBrandId=p.filterBrandId||h._filterBrandId||null,this._filterCategoryId=p.filterCategoryId||h._filterCategoryId||null,this._relatedProductData=p.relatedProductData||h._relatedProductData||null,this._recommendFor=p.recommendFor||h._recommendFor,this.filters=a.filters?a.filters.map((function(t){return new u(t,c)})):null,this._filterCategories=a.filterCategories?a.filterCategories.map((function(t){return new d(t)})):null,this.pageSpecificData=p.pageSpecificData||h.pageSpecificData||null,this.router=n,r(this),this.setPageSpecificSort(),this.isBrowser())if(this.restoreInfiniteScrollPage(),location.search&&(this.isFilterable||this._type===y.SEARCH)){var f=this.getQueryParams();this.getInitial(f,this._page>1)}else this._page>1?this.getInitial(void 0,!0):this.isLastViewed?this.getInitial():this.handleListingEvent()}return Object.defineProperty(S.prototype,"sort",{get:function(){return this._sort},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"pageType",{get:function(){return this._pageType},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"minPage",{get:function(){return this._minPage||1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"searchKeyword",{get:function(){return this._searchKeyword},set:function(t){t!==this._searchKeyword&&(this._searchKeyword=t,this.searchDebouncer(),this.searchAnalyticsDebouncer())},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isFilterable",{get:function(){return this._type===y.ALL||this._type===y.CATEGORY},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isFiltered",{get:function(){var t,e;return(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))||!!this._searchKeyword||this._pageType!==o.CATEGORY&&(!!this._filterCategoryId||(null===(e=this._filterCategories)||void 0===e?void 0:e.some((function(t){return t.isSelected}))))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isStatic",{get:function(){return this._type===y.STATIC},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isDiscounted",{get:function(){return this._type===y.DISCOUNTED},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isRecommended",{get:function(){return this._type===y.RECOMMENDED},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isLastViewed",{get:function(){return this._type===y.LAST_VIEWED},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isRelatedProducts",{get:function(){return this._type===y.RELATED_PRODUCTS},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isSearch",{get:function(){return this._type===y.SEARCH},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasPrev",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended||!this._minPage)&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasNext",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended)&&this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"filterQueryParams",{get:function(){var t,e,i,r,s=this,a={};if(null===(t=this.filters)||void 0===t||t.forEach((function(t){t.keyList.length&&(a[t.key]=t.keyList)})),this._searchKeyword&&(a.s=this._searchKeyword),this._infiniteScrollPage&&(a.page=this._infiniteScrollPage),this._pageType!==o.CATEGORY){var n=null===(e=this.filterCategories)||void 0===e?void 0:e.filter((function(t){return t.isSelected}));if(!!(null==n?void 0:n.length))a.c=null==n?void 0:n.map((function(t){return t.slug}));else if(this._filterCategoryId){var d=null===(r=null===(i=this.filterCategories)||void 0===i?void 0:i.find((function(t){return t.id===s._filterCategoryId})))||void 0===r?void 0:r.slug;d&&(a.c=d)}}return h.stringify(a,{arrayFormat:"comma"})},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"filterCategories",{get:function(){var t;return null===(t=this._filterCategories)||void 0===t?void 0:t.filter((function(t){return 0!==t.resultCount}))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasAppliedfilter",{get:function(){var t;return!!this._searchKeyword||(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isFeaturedSortEnabled",{get:function(){var t;return(null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)===a.MANUALLY&&[y.ALL,y.CATEGORY].includes(this._type)},enumerable:!1,configurable:!0}),S.prototype.setPageSpecificSort=function(){var t;if((null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)&&[y.ALL].includes(this._type))switch(this.pageSpecificData.orderType){case a.HIGHEST_DISCOUNT_RATIO:this._sort=I.DECRASING_DISCOUNT;break;case a.LOWEST_DISCOUNT_RATIO:this._sort=I.INCREASING_DISCOUNT;break;case a.HIGHEST_PRICE:this._sort=I.DECREASING_PRICE;break;case a.LOWEST_PRICE:this._sort=I.INCREASING_PRICE;break;case a.NEWEST:this._sort=I.LAST_ADDED;break;case a.OLDEST:this._sort=I.FIRST_ADDED;break;case a.MANUALLY:this._sort=I.FEATURED}},S.prototype.getSortParams=function(){var t,e;switch(this._sort){case I.INCREASING_PRICE:t=f.ASC,e=m.PRICE;break;case I.DECREASING_PRICE:t=f.DESC,e=m.PRICE;break;case I.FIRST_ADDED:t=f.ASC,e=m.CREATED_AT;break;case I.LAST_ADDED:t=f.DESC,e=m.CREATED_AT;break;case I.INCREASING_DISCOUNT:t=f.ASC,e=m.DISCOUNT_RATIO;break;case I.DECRASING_DISCOUNT:t=f.DESC,e=m.DISCOUNT_RATIO;break;case I.FEATURED:if(this.isSearch)return;t=f.ASC,e=m.MANUAL_SORT;break;case I.DEFAULT:t=void 0,e=void 0}if(t&&e)return{direction:t,type:e}},S.prototype.searchProducts=function(i,r,s){var a,d,u;return t(this,void 0,void 0,(function(){var t,l,h,f;return e(this,(function(e){switch(e.label){case 0:return t=[],l=[],null===(a=this.filters)||void 0===a||a.forEach((function(e){e.valueList.length&&t.push(new c({id:e.id,type:e.type,displayType:e.displayType,valueList:e.valueList})),e.isFacetFilter&&l.push({id:e.id,type:e.type,displayType:e.displayType})})),h=null===(d=this._filterCategories)||void 0===d?void 0:d.filter((function(t){return t.isSelected})).map((function(t){return t.id})),f=this.getSortParams(),this.isRelatedProducts&&this._relatedProductData?[4,p.getRelatedProducts({priceListId:g.getPriceListId(),salesChannelId:g.getSalesChannelId(),productId:this._relatedProductData.productId,brandIds:this._relatedProductData.brandIds,categoryIds:this._relatedProductData.categoryIds})]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return[4,p.searchProducts({input:{page:i,perPage:r,productIdList:this.isStatic?null===(u=this._productListPropValue.productIds)||void 0===u?void 0:u.map((function(t){return t.productId})):s,filterList:t,facetList:l,brandId:this._pageType===o.BRAND&&this._type!==y.SEARCH?this._filterBrandId:void 0,categoryIdList:h&&h.length?h:this._filterCategoryId?[this._filterCategoryId]:void 0,priceListId:g.getPriceListId(),salesChannelId:g.getSalesChannelId(),query:this._searchKeyword,order:this._type===y.SEARCH?[]:f?[f]:[],showStockOption:g.getStockPreference()||n.SHOW_ALL}})]}}))}))},S.prototype.getFilters=function(){var i,r,s;return t(this,void 0,void 0,(function(){var t,a,n=this;return e(this,(function(e){switch(e.label){case 0:return[4,p.getProductFilterData({categoryId:this._filterCategoryId?this._filterCategoryId:void 0})];case 1:return t=e.sent(),this.filters=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.filters.map((function(t){return new u(t,n)})),this._filterCategories=null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.categories,this.pageType!==o.CATEGORY&&this._filterCategoryId&&(a=null===(s=this._filterCategories)||void 0===s?void 0:s.find((function(t){return t.id===n._filterCategoryId})))&&(a.isSelected=!0),this.filters&&this.filters.sort((function(t,e){return t.order>e.order?1:-1})),[2]}}))}))},S.prototype.applyQueryParamFilters=function(t){var e,i=this;try{null==t||t.forEach((function(t,e){var r,s=null===(r=i.filters)||void 0===r?void 0:r.find((function(t){return t.key===e}));s&&s.applyQueryParam(t)}));var r=null==t?void 0:t.get("s");if(r&&(this._searchKeyword=r),this._pageType!==o.CATEGORY){var s=null==t?void 0:t.get("c"),a=null==s?void 0:s.split(",");a&&a.length&&(null===(e=this.filterCategories)||void 0===e||e.forEach((function(t){t.isSelected=a.some((function(e){return e===t.slug}))})))}}catch(t){console.log(t)}},S.prototype.applyFacets=function(t){var e,i;null===(e=this.filters)||void 0===e||e.forEach((function(e){var i,r,s,a=null==t?void 0:t.find((function(t){return t.id===e.id}));a?null===(i=e.values)||void 0===i||i.forEach((function(t){var i=a.values.find((function(e){return e.id===t.id}));i?t.resultCount=i.count:e.isCustomValueFilter?t.resultCount=null:t.resultCount=0})):e.isCustomValueFilter?null===(r=e.values)||void 0===r||r.forEach((function(t){return t.resultCount=null})):null===(s=e.values)||void 0===s||s.forEach((function(t){return t.resultCount=0}))}));var r=null==t?void 0:t.find((function(t){return"category"===t.id}));r&&(null===(i=this._filterCategories)||void 0===i||i.forEach((function(t){var e=r.values.find((function(e){return e.id===t.id}));t.resultCount=e?e.count:0})))},S.prototype.clearFilters=function(){var t,e;null===(t=this.filters)||void 0===t||t.forEach((function(t){return t.clear()})),this._searchKeyword="",this._pageType!==o.CATEGORY&&(this._filterCategoryId=void 0),null===(e=this._filterCategories)||void 0===e||e.forEach((function(t){return t.isSelected=!1})),this.applyFilters()},S.prototype.setSortType=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this._sort=i,[4,this.getInitial()];case 1:return t.sent(),[2]}}))}))},S.prototype.onFilterCategoryClick=function(i,r){var s,a;return void 0===r&&(r=!1),t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r?(null===(s=this._filterCategories)||void 0===s||s.forEach((function(t){t.id===i.id&&(t.isSelected=!t.isSelected)})),[4,this.applyFilters()]):[3,2];case 1:return t.sent(),[3,3];case 2:g.getIsEditor()||null===(a=_.getInstance().router)||void 0===a||a.push(i.href+(this.filterQueryParams?"?"+this.filterQueryParams:"")),t.label=3;case 3:return[2]}}))}))},S.prototype.toJSON=function(){return{data:this.data,type:this._type,pageType:this._pageType,sort:this._sort,limit:this._limit,page:this._page,count:this._count,searchKeyword:this._searchKeyword,initialized:this._initialized,minPage:this._minPage,filterBrandId:this._filterBrandId,filterCategoryId:this._filterCategoryId,filterCategories:this._filterCategories,filters:this.filters,recommendFor:this._recommendFor,productListPropValue:this._productListPropValue,pageSpecificData:this.pageSpecificData}},S.prototype.restoreInfiniteScrollPage=function(){var t=this.getQueryParams(),e=null==t?void 0:t.get("page");if(e){var i=parseInt(e);isNaN(i)||(this._page=i,this._infiniteScrollPage=i)}},S.prototype.getQueryParams=function(){if(this.isBrowser())return new URLSearchParams(location.search)},S.prototype.isBrowser=function(){return"undefined"!=typeof window},S.prototype.waitForCustomerStoreInit=function(){return new Promise((function(t){var e=setInterval((function(){_.getInstance().customerStore.initialized&&(clearInterval(e),t(null))}),1e3)}))},S.prototype.handleListingEvent=function(){this.searchKeyword&&this.data.length?v.viewSearchResults(this._searchKeyword,this.data):this.data.length&&this._type===y.ALL&&v.viewListing(this.data)},S}();!function(t){t.ALL="ALL",t.STATIC="STATIC",t.DISCOUNTED="DISCOUNTED",t.RECOMMENDED="RECOMMENDED",t.CATEGORY="CATEGORY",t.SEARCH="SEARCH",t.LAST_VIEWED="LAST_VIEWED",t.RELATED_PRODUCTS="RELATED_PRODUCTS"}(y||(y={})),function(t){t.INCREASING_PRICE="INCREASING_PRICE",t.DECREASING_PRICE="DECREASING_PRICE",t.LAST_ADDED="LAST_ADDED",t.FIRST_ADDED="FIRST_ADDED",t.INCREASING_DISCOUNT="INCREASING_DISCOUNT",t.DECRASING_DISCOUNT="DECRASING_DISCOUNT",t.FEATURED="FEATURED",t.DEFAULT="DEFAULT"}(I||(I={})),function(t){t.CATEGORY="CATEGORY",t.BRAND="BRAND"}(S||(S={}));export{b as IkasProductList,I as IkasProductListSortType,y as IkasProductListType,S as IkasRelatedProductsType};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from'./../ext/tslib/tslib.es6.js';import{renderComponent as t}from"../components/page/index.js";import{IkasAttributeList as i}from"../models/ui/product-attribute-list/index.js";import{IkasBlogCategory as a}from"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import"mobx";import{IkasBlog as r}from"../models/data/blog/index.js";import{IkasBrand as o}from"../models/data/brand/index.js";import{IkasThemeJsonPageType as n,IkasThemeJsonComponentPropType as s}from"@ikas/storefront-models";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import{IkasCategory as u}from"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import{IkasImage as l}from"../models/data/image/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/package/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as p}from"../models/data/product/index.js";import{IkasRaffle as d}from"../models/data/raffle/index.js";import"../models/data/state/index.js";import"../models/data/theme-json/index.js";import{IkasThemeJsonCustomData as m}from"../models/data/theme-json/custom-data/index.js";import{IkasThemeJsonPageComponent as c}from"../models/data/theme-json/page/component/index.js";import"../models/data/variant-type/variant-value/index.js";import{IkasBlogList as f}from"../models/ui/blog-list/index.js";import{IkasBlogCategoryList as P}from"../models/ui/blog-category-list/index.js";import{IkasBrandList as g}from"../models/ui/brand-list/index.js";import{IkasCategoryList as V}from"../models/ui/category-list/index.js";import{IkasNavigationLink as L}from"../models/ui/navigation-link/index.js";import{IkasProductList as v}from"../models/ui/product-list/index.js";import{IkasAttributeDetail as D}from"../models/ui/product-attribute-detail/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import{IkasComponentRenderer as j}from"../models/ui/component-renderer/index.js";import{IkasRaffleList as h}from"../models/ui/raffle-list/index.js";import{IkasPageComponentPropValue as T,getPlaceholderBrand as x,getPlaceholderCategory as C,getPlaceholderProduct as S,getPlaceholderBlog as w,getPlaceholderBlogCategory as I,getPlaceholderRaffle as b}from"@ikas/storefront-providers";var y=function(){function y(){}return y.setPageSpecificData=function(t,i,o){if(t)switch(i){case n.PRODUCT:var s=t;y.pageSpecificData=new p(e(e({},s),{selectedVariantValues:s.selectedVariantValues||s.variants[0].variantValues})),o&&this._initProductOnBrowser(y.pageSpecificData);break;case n.CATEGORY:var l=t;y.pageSpecificData=new u(l);break;case n.BRAND:var m=t;y.pageSpecificData=new u(m);break;case n.BLOG:var c=t;y.pageSpecificData=new r(c);break;case n.BLOG_CATEGORY:var f=t;y.pageSpecificData=new a(f);break;case n.RAFFLE_DETAIL:var P=t;y.pageSpecificData=new d(P)}else this.pageSpecificData=void 0},y.isServer=function(){return"undefined"==typeof window},y.initPagePropValues=function(e,t,i,a){return e.map((function(e){return y.initPageComponentPropValue(e,t,i,a)}))},y.initPageComponentPropValue=function(t,i,a,r){var o=i.find((function(e){return e.id===t.pageComponent.componentId})),n=null==o?void 0:o.props,s={};return null==n||n.map((function(e){var i=t.propValues[e.name];s[e.name]=y.initPropValue(e,i,a,r)})),new T(e(e({},t),{pageComponent:new c(e(e({},t.pageComponent),{propValues:s,componentId:o.id})),component:o,propValues:s}))},y.initPropValue=function(e,t,i,a){if(null==t)return null;switch(e.type){case s.IMAGE:return y.initImagePropValue(t);case s.IMAGE_LIST:return y.initImageListPropValue(t);case s.BRAND:return y.initBrandPropValue(t);case s.BRAND_LIST:return y.initBrandListPropValue(t);case s.CATEGORY:return y.initCategoryPropValue(t);case s.CATEGORY_LIST:return y.initCategoryListPropValue(t);case s.PRODUCT_LIST:return y.initProductListPropValue(t);case s.PRODUCT_DETAIL:return y.initProductPropValue(t);case s.PRODUCT_ATTRIBUTE:return y.initAttributePropValue(t);case s.PRODUCT_ATTRIBUTE_LIST:return y.initAttributeListPropValue(t);case s.LINK:case s.LIST_OF_LINK:return y.initLinkPropValue(t);case s.COMPONENT:return y.initComponentPropValue(t,i,a);case s.COMPONENT_LIST:return y.initComponentListPropValue(t,i,a);case s.CUSTOM:return y.initCustomDataPropValue(t,i,a);case s.BLOG:return y.initBlogPropValue(t);case s.BLOG_LIST:return y.initBlogListPropValue(t);case s.BLOG_CATEGORY:return y.initBlogCategoryPropValue(t);case s.BLOG_LIST:return y.initBlogCategoryListPropValue(t);case s.RAFFLE:return y.initRafflePropValue(t);case s.RAFFLE_LIST:return y.initRaffleListPropValue(t);case s.SLIDER:return y.initSliderPropValue(t);default:return t}},y.initBrandPropValue=function(e){return e.brandPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.brand?new o(e.brand):x()},y.initBrandListPropValue=function(e){return new g(e)},y.initCategoryPropValue=function(e){return e.categoryPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.category?new u(e.category):C()},y.initCategoryListPropValue=function(e){return new V(e)},y.initProductListPropValue=function(e){return new v(e)},y.initProductPropValue=function(t){var i=new p(S());if(t.productDetailPropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(t.productDetail){var a=t.productDetail;i=new p(e(e({},a),{selectedVariantValues:a.selectedVariantValues}))}return i},y._initProductOnBrowser=function(e){var t=new URLSearchParams(window.location.search),i=t.get("vid");if(i){var a=e.variants.find((function(e){return e.id===i}));a&&(e.selectedVariantValues=a.variantValues)}else{var r=e.variantTypes.map((function(e){return e.variantType.slug})),o=[];r.forEach((function(i,a){var r=e.variantTypes[a],n=t.get(i);if(n){var s=r.variantType.values.find((function(e){return e.slug===n}));s&&o.push(s)}})),o.length===e.selectedVariantValues.length&&(e.selectedVariantValues=o)}},y.initAttributePropValue=function(t){var i=null;if(t.attributePropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(t.productDetail){var a=t.productDetail;i=new p(e(e({},a),{selectedVariantValues:a.selectedVariantValues}))}return new D(i,t.attributePropValue)},y.initAttributeListPropValue=function(t){var a=null;if(t.attributeListPropValue.usePageData&&this.pageSpecificData)a=this.pageSpecificData;else if(t.productDetail){var r=t.productDetail;a=new p(e(e({},r),{selectedVariantValues:r.selectedVariantValues}))}return new i(a,t.attributeListPropValue)},y.initLinkPropValue=function(e){return Array.isArray(e)?e.map((function(e){return new L(e.href,e.label,e.subLinks,e.isExternal||void 0)})):e?new L(e.href,e.label,e.subLinks,e.isExternal||void 0):void 0},y.initImagePropValue=function(e){return new l(e)},y.initImageListPropValue=function(e){return e.map((function(e){return new l(e)}))},y.initCustomDataPropValue=function(e,t,i){if(e&&e.value&&e.customData)return this._initCustomDataPropValue(e,new m(e.customData),t,i)},y._initCustomDataPropValue=function(e,t,i,a){var r=this;if(!e)return null;var o=e.value;if(null==o)return null;switch(t.type){case s.BRAND:return this.initBrandPropValue(o);case s.BRAND_LIST:return this.initBrandListPropValue(o);case s.CATEGORY_LIST:return this.initCategoryListPropValue(o);case s.CATEGORY:return this.initCategoryPropValue(o);case s.IMAGE_LIST:return this.initImageListPropValue(o);case s.IMAGE:return this.initImagePropValue(o);case s.LINK:return this.initLinkPropValue(o);case s.PRODUCT_DETAIL:return this.initProductPropValue(o);case s.PRODUCT_LIST:return this.initProductListPropValue(o);case s.PRODUCT_ATTRIBUTE:return this.initAttributePropValue(o);case s.PRODUCT_ATTRIBUTE_LIST:return this.initAttributeListPropValue(o);case s.BLOG:return this.initBlogPropValue(o);case s.BLOG_LIST:return this.initBlogListPropValue(o);case s.BLOG_CATEGORY:return this.initBlogCategoryPropValue(o);case s.BLOG_CATEGORY_LIST:return this.initBlogCategoryListPropValue(o);case s.RAFFLE:return this.initRafflePropValue(o);case s.RAFFLE_LIST:return this.initRaffleListPropValue(o);case s.SLIDER:return this.initSliderPropValue(o);case s.OBJECT:for(var n={},u=0,l=t.nestedData||[];u<l.length;u++){var p=l[u],d=o[p.key],m=void 0;p.customDataId&&(m=d.customData),n[p.key]=this._initCustomDataPropValue(d,m||p,i,a)}return n;case s.DYNAMIC_LIST:case s.STATIC_LIST:try{if(!o||!o.length)return null;var c=[],f=t.nestedData[0];return o.forEach((function(e){var t;f.customDataId&&(t=e.customData),c.push(r._initCustomDataPropValue(e,t||f,i,a))})),c}catch(e){return[]}case s.COMPONENT:return this.initComponentPropValue(o,i,a);case s.COMPONENT_LIST:return this.initComponentListPropValue(o,i,a);default:return o}},y.initComponentPropValue=function(e,t,i){return this._initComponentPropValue(e,t,i)},y._initComponentPropValue=function(e,i,a){var r=e.length?e[0]:void 0;if(r){var o=new T(r),n=y.initPageComponentPropValue(o,[o.component],i,a);if(n)return new j((function(){return t(n,i,-10)}))}},y.initComponentListPropValue=function(e,t,i){return this._initComponentListPropValue(e,t,i)},y._initComponentListPropValue=function(e,i,a){return e&&e.length?e.map((function(e){var r=new T(e),o=y.initPageComponentPropValue(r,[r.component],i,a);return new j((function(){return t(o,i,-1)}))})):[]},y.initBlogPropValue=function(e){return e.blogPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.blog?new r(e.blog):w()},y.initBlogListPropValue=function(e){return new f(e)},y.initBlogCategoryPropValue=function(e){return e.blogCategoryPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.blogCategory?new a(e.blogCategory):I()},y.initBlogCategoryListPropValue=function(e){return new P(e)},y.initRafflePropValue=function(e){return e.rafflePropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.raffle?new d(e.raffle):new d(b())},y.initRaffleListPropValue=function(e){return new h(e)},y.initSliderPropValue=function(e){return e},y.pageSpecificData={},y}();export{y as IkasPageDataInit};
|
|
1
|
+
import{__assign as e}from'./../ext/tslib/tslib.es6.js';import{renderComponent as t}from"../components/page/index.js";import{IkasAttributeList as i}from"../models/ui/product-attribute-list/index.js";import{IkasBlogCategory as a}from"../models/data/blog/category/index.js";import"../models/data/blog/content/index.js";import"../models/data/blog/meta-data/index.js";import"../models/data/blog/tag/index.js";import"mobx";import{IkasBlog as r}from"../models/data/blog/index.js";import{IkasBrand as o}from"../models/data/brand/index.js";import{IkasThemeJsonPageType as n,IkasThemeJsonComponentPropType as s}from"@ikas/storefront-models";import"../models/data/campaign-offer/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/path-item/index.js";import{IkasCategory as u}from"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/checkout-settings/index.js";import"../models/data/city/index.js";import"../models/data/country/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/attribute/index.js";import"../models/data/customer/review/summary/index.js";import"../models/data/customer/review/index.js";import"../models/data/customer/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/filter-category/index.js";import"../models/data/html-meta-data/index.js";import{IkasImage as l}from"../models/data/image/index.js";import"../models/data/order/address/index.js";import"../models/data/order/line-item/variant/value/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/package/index.js";import"../models/data/order/index.js";import"../models/data/payment-gateway/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product/filter/index.js";import"../models/data/product/option-set/option/index.js";import"../models/data/product/option-set/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product/variant/index.js";import"../models/data/variant-type/index.js";import{IkasProduct as p}from"../models/data/product/index.js";import{IkasRaffle as d}from"../models/data/raffle/index.js";import"../models/data/state/index.js";import"../models/data/theme-json/index.js";import{IkasThemeJsonCustomData as m}from"../models/data/theme-json/custom-data/index.js";import{IkasThemeJsonPageComponent as c}from"../models/data/theme-json/page/component/index.js";import"../models/data/variant-type/variant-value/index.js";import{IkasBlogList as f}from"../models/ui/blog-list/index.js";import{IkasBlogCategoryList as P}from"../models/ui/blog-category-list/index.js";import{IkasBrandList as g}from"../models/ui/brand-list/index.js";import{IkasCategoryList as V}from"../models/ui/category-list/index.js";import{IkasNavigationLink as L}from"../models/ui/navigation-link/index.js";import{IkasProductList as v}from"../models/ui/product-list/index.js";import{IkasAttributeDetail as j}from"../models/ui/product-attribute-detail/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import{IkasComponentRenderer as D}from"../models/ui/component-renderer/index.js";import{IkasRaffleList as h}from"../models/ui/raffle-list/index.js";import{IkasPageComponentPropValue as x,getPlaceholderBrand as T,getPlaceholderCategory as C,getPlaceholderProduct as S,getPlaceholderBlog as w,getPlaceholderBlogCategory as I,getPlaceholderRaffle as b}from"@ikas/storefront-providers";import{IkasBaseStore as y}from"../store/base.js";import"../store/customer/index.js";import"../store/cart/index.js";var _=function(){function _(){}return _.setPageSpecificData=function(t,i,o){if(t)switch(i){case n.PRODUCT:var s=t;_.pageSpecificData=new p(e(e({},s),{selectedVariantValues:s.selectedVariantValues||s.variants[0].variantValues})),o&&this._initProductOnBrowser(_.pageSpecificData);break;case n.CATEGORY:var l=t;_.pageSpecificData=new u(l);break;case n.BRAND:var m=t;_.pageSpecificData=new u(m);break;case n.BLOG:var c=t;_.pageSpecificData=new r(c);break;case n.BLOG_CATEGORY:var f=t;_.pageSpecificData=new a(f);break;case n.RAFFLE_DETAIL:var P=t;_.pageSpecificData=new d(P)}else this.pageSpecificData=void 0},_.isServer=function(){return"undefined"==typeof window},_.initPagePropValues=function(e,t,i,a){return e.map((function(e){return _.initPageComponentPropValue(e,t,i,a)}))},_.initPageComponentPropValue=function(t,i,a,r){var o=i.find((function(e){return e.id===t.pageComponent.componentId})),n=null==o?void 0:o.props,s={};return null==n||n.map((function(e){var i=t.propValues[e.name];s[e.name]=_.initPropValue(e,i,a,r)})),new x(e(e({},t),{pageComponent:new c(e(e({},t.pageComponent),{propValues:s,componentId:o.id})),component:o,propValues:s}))},_.initPropValue=function(e,t,i,a){if(null==t)return null;switch(e.type){case s.IMAGE:return _.initImagePropValue(t);case s.IMAGE_LIST:return _.initImageListPropValue(t);case s.BRAND:return _.initBrandPropValue(t);case s.BRAND_LIST:return _.initBrandListPropValue(t);case s.CATEGORY:return _.initCategoryPropValue(t);case s.CATEGORY_LIST:return _.initCategoryListPropValue(t);case s.PRODUCT_LIST:return _.initProductListPropValue(t);case s.PRODUCT_DETAIL:return _.initProductPropValue(t);case s.PRODUCT_ATTRIBUTE:return _.initAttributePropValue(t);case s.PRODUCT_ATTRIBUTE_LIST:return _.initAttributeListPropValue(t);case s.LINK:case s.LIST_OF_LINK:return _.initLinkPropValue(t);case s.COMPONENT:return _.initComponentPropValue(t,i,a);case s.COMPONENT_LIST:return _.initComponentListPropValue(t,i,a);case s.CUSTOM:return _.initCustomDataPropValue(t,i,a);case s.BLOG:return _.initBlogPropValue(t);case s.BLOG_LIST:return _.initBlogListPropValue(t);case s.BLOG_CATEGORY:return _.initBlogCategoryPropValue(t);case s.BLOG_LIST:return _.initBlogCategoryListPropValue(t);case s.RAFFLE:return _.initRafflePropValue(t);case s.RAFFLE_LIST:return _.initRaffleListPropValue(t);case s.SLIDER:return _.initSliderPropValue(t);default:return t}},_.initBrandPropValue=function(e){return e.brandPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.brand?new o(e.brand):T()},_.initBrandListPropValue=function(e){return new g(e)},_.initCategoryPropValue=function(e){return e.categoryPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.category?new u(e.category):C()},_.initCategoryListPropValue=function(e){return new V(e)},_.initProductListPropValue=function(e){return new v(e,y.getInstance().router)},_.initProductPropValue=function(t){var i=new p(S());if(t.productDetailPropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(t.productDetail){var a=t.productDetail;i=new p(e(e({},a),{selectedVariantValues:a.selectedVariantValues}))}return i},_._initProductOnBrowser=function(e){var t=new URLSearchParams(window.location.search),i=t.get("vid");if(i){var a=e.variants.find((function(e){return e.id===i}));a&&(e.selectedVariantValues=a.variantValues)}else{var r=e.variantTypes.map((function(e){return e.variantType.slug})),o=[];r.forEach((function(i,a){var r=e.variantTypes[a],n=t.get(i);if(n){var s=r.variantType.values.find((function(e){return e.slug===n}));s&&o.push(s)}})),o.length===e.selectedVariantValues.length&&(e.selectedVariantValues=o)}},_.initAttributePropValue=function(t){var i=null;if(t.attributePropValue.usePageData&&this.pageSpecificData)i=this.pageSpecificData;else if(t.productDetail){var a=t.productDetail;i=new p(e(e({},a),{selectedVariantValues:a.selectedVariantValues}))}return new j(i,t.attributePropValue)},_.initAttributeListPropValue=function(t){var a=null;if(t.attributeListPropValue.usePageData&&this.pageSpecificData)a=this.pageSpecificData;else if(t.productDetail){var r=t.productDetail;a=new p(e(e({},r),{selectedVariantValues:r.selectedVariantValues}))}return new i(a,t.attributeListPropValue)},_.initLinkPropValue=function(e){return Array.isArray(e)?e.map((function(e){return new L(e.href,e.label,e.subLinks,e.isExternal||void 0)})):e?new L(e.href,e.label,e.subLinks,e.isExternal||void 0):void 0},_.initImagePropValue=function(e){return new l(e)},_.initImageListPropValue=function(e){return e.map((function(e){return new l(e)}))},_.initCustomDataPropValue=function(e,t,i){if(e&&e.value&&e.customData)return this._initCustomDataPropValue(e,new m(e.customData),t,i)},_._initCustomDataPropValue=function(e,t,i,a){var r=this;if(!e)return null;var o=e.value;if(null==o)return null;switch(t.type){case s.BRAND:return this.initBrandPropValue(o);case s.BRAND_LIST:return this.initBrandListPropValue(o);case s.CATEGORY_LIST:return this.initCategoryListPropValue(o);case s.CATEGORY:return this.initCategoryPropValue(o);case s.IMAGE_LIST:return this.initImageListPropValue(o);case s.IMAGE:return this.initImagePropValue(o);case s.LINK:return this.initLinkPropValue(o);case s.PRODUCT_DETAIL:return this.initProductPropValue(o);case s.PRODUCT_LIST:return this.initProductListPropValue(o);case s.PRODUCT_ATTRIBUTE:return this.initAttributePropValue(o);case s.PRODUCT_ATTRIBUTE_LIST:return this.initAttributeListPropValue(o);case s.BLOG:return this.initBlogPropValue(o);case s.BLOG_LIST:return this.initBlogListPropValue(o);case s.BLOG_CATEGORY:return this.initBlogCategoryPropValue(o);case s.BLOG_CATEGORY_LIST:return this.initBlogCategoryListPropValue(o);case s.RAFFLE:return this.initRafflePropValue(o);case s.RAFFLE_LIST:return this.initRaffleListPropValue(o);case s.SLIDER:return this.initSliderPropValue(o);case s.OBJECT:for(var n={},u=0,l=t.nestedData||[];u<l.length;u++){var p=l[u],d=o[p.key],m=void 0;p.customDataId&&(m=d.customData),n[p.key]=this._initCustomDataPropValue(d,m||p,i,a)}return n;case s.DYNAMIC_LIST:case s.STATIC_LIST:try{if(!o||!o.length)return null;var c=[],f=t.nestedData[0];return o.forEach((function(e){var t;f.customDataId&&(t=e.customData),c.push(r._initCustomDataPropValue(e,t||f,i,a))})),c}catch(e){return[]}case s.COMPONENT:return this.initComponentPropValue(o,i,a);case s.COMPONENT_LIST:return this.initComponentListPropValue(o,i,a);default:return o}},_.initComponentPropValue=function(e,t,i){return this._initComponentPropValue(e,t,i)},_._initComponentPropValue=function(e,i,a){var r=e.length?e[0]:void 0;if(r){var o=new x(r),n=_.initPageComponentPropValue(o,[o.component],i,a);if(n)return new D((function(){return t(n,i,-10)}))}},_.initComponentListPropValue=function(e,t,i){return this._initComponentListPropValue(e,t,i)},_._initComponentListPropValue=function(e,i,a){return e&&e.length?e.map((function(e){var r=new x(e),o=_.initPageComponentPropValue(r,[r.component],i,a);return new D((function(){return t(o,i,-1)}))})):[]},_.initBlogPropValue=function(e){return e.blogPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.blog?new r(e.blog):w()},_.initBlogListPropValue=function(e){return new f(e)},_.initBlogCategoryPropValue=function(e){return e.blogCategoryPropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.blogCategory?new a(e.blogCategory):I()},_.initBlogCategoryListPropValue=function(e){return new P(e)},_.initRafflePropValue=function(e){return e.rafflePropValue.usePageData&&this.pageSpecificData?this.pageSpecificData:e.raffle?new d(e.raffle):new d(b())},_.initRaffleListPropValue=function(e){return new h(e)},_.initSliderPropValue=function(e){return e},_.pageSpecificData={},_}();export{_ as IkasPageDataInit};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as d}from'./../../ext/tslib/tslib.es6.js';import{APIResponse as o}from'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import{listCategory as a}from"@ikas/storefront-api";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"mobx";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import{IkasCategory as i}from"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";var s=function(){function s(){}return s.listCategory=function(s){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a(s)];case 1:return t=e.sent(),[2,new o(d(d({},t.data),{data:null===(r=t.data)||void 0===r?void 0:r.data.map((function(t){return new i(t)}))}),t.graphQLErrors)]}}))}))},s}();export{s as default};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as d}from'./../../ext/tslib/tslib.es6.js';import{APIResponse as o}from'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import{listCategory as a}from"@ikas/storefront-api";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"mobx";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import{IkasCategory as i}from"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/customer/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";var s=function(){function s(){}return s.listCategory=function(s){var r,m;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a(s)];case 1:return t=e.sent(),[2,new o(d(d({},t.data),{data:null===(m=null===(r=t.data)||void 0===r?void 0:r.data)||void 0===m?void 0:m.map((function(t){return new i(t)}))}),t.graphQLErrors)]}}))}))},s}();export{s as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IkasContactForm, IkasCustomer, IkasCustomerAttributeValue, IkasFavoriteProduct, IkasOrderTransaction, IkasProduct, IkasOrder } from "../../models/data";
|
|
1
|
+
import { IkasContactForm, IkasCustomer, IkasCustomerAttributeValue, IkasFavoriteProduct, IkasOrderTransaction, IkasProduct, IkasOrder, IkasRaffleParticipant } from "../../models/data";
|
|
2
2
|
import { IkasBaseStore } from "../base";
|
|
3
3
|
export declare class IkasCustomerStore {
|
|
4
4
|
customer?: IkasCustomer | null;
|
|
@@ -47,7 +47,7 @@ export declare class IkasCustomerStore {
|
|
|
47
47
|
waitUntilCaptchaTokenInitialized: () => Promise<unknown>;
|
|
48
48
|
setCaptchaToken: (token: string) => void;
|
|
49
49
|
private getCaptcha;
|
|
50
|
-
getRaffles: () => Promise<
|
|
50
|
+
getRaffles: () => Promise<IkasRaffleParticipant[] | undefined>;
|
|
51
51
|
getCustomerAttributes: () => Promise<import("../../models/data").IkasCustomerAttribute[]>;
|
|
52
52
|
getOrderByEmail: (email: string, orderNumber: string) => Promise<IkasOrder | null>;
|
|
53
53
|
private init;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import o from"lodash/uniqBy";import s from"./api.js";import{IkasCustomer as n}from"../../models/data/customer/index.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as a}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import c from"../raffle/index.js";import'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import u from"../product/index.js";import{Analytics as d}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as l}from"@ikas/storefront-config";import{SaveMyCustomerInput as h}from"@ikas/storefront-api";import{populateRaffleProducts as m}from"@ikas/storefront-providers";var p="undefined"==typeof localStorage,f=function(){function f(o){var n=this;this.customer=null,this.token=null,this.tokenExpiry=null,this.baseStore=null,this._initialized=!1,this._visitorSubscribedEmail=!1,this._lastViewedProducts=[],this._customerConsentGranted=!1,this._refundSettings=null,this._captchaToken=null,this.toAnalyticsCustomer=function(t){return r(r({},t),{consentGranted:n._customerConsentGranted})},this.login=function(r,i){return t(n,void 0,void 0,(function(){var t,o,n,a;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.login({email:r,password:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer&&d.customerLogin(),(n=null===(a=this.baseStore)||void 0===a?void 0:a.cartStore.cart)?[4,this.baseStore.cartStore.changeItemQuantity(n.orderLineItems[0],n.orderLineItems[0].quantity)]:[3,4]):[3,5];case 3:e.sent(),e.label=4;case 4:return this.saveLocalLastViewedProducts(),[2,!0];case 5:return[2,!1]}}))}))},this.logout=function(){var t;n.clearLocalData(),null===(t=n.baseStore)||void 0===t||t.cartStore.removeCart(),d.customerLogout()},this.register=function(r,i,o,a,c,u){return t(n,void 0,void 0,(function(){var t,n;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.register({email:o,password:a,firstName:r,lastName:i,isAcceptMarketing:c,attributes:u,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(n=t.data)||void 0===n?void 0:n.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),d.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,!0]):[2,!1]}}))}))},this.saveContactForm=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return d.contactForm(i),[4,this.getCaptcha()];case 1:return e.sent(),[4,s.sendContactFormToMerchant(r(r({},i),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(r){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.checkEmail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.forgotPassword=function(r){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.forgotPassword({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.recoverPassword=function(r,i,o){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.recoverPassword({password:r,passwordAgain:i,token:o,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.saveCustomer=function(r){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s.saveCustomer({input:new h(r)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(r){return t(n,void 0,void 0,(function(){var t,i,o;return e(this,(function(e){switch(e.label){case 0:return[4,s.getOrders({orderId:r})];case 1:return(t=e.sent()).isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.length)?(i=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),i.refundSettings=this._refundSettings,[2,i]}}))}))},this.getOrderTransactions=function(r){return void 0===r&&(r={}),t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.listOrderTransactions({checkoutId:{eq:r.checkoutId},id:{eq:r.checkoutId},orderId:{eq:r.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProductsIds=function(){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.listFavoriteProducts()];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(n,void 0,void 0,(function(){var t,r,i,o;return e(this,(function(e){switch(e.label){case 0:return[4,s.listFavoriteProducts()];case 1:return(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?[4,u.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:l.getPriceListId(),salesChannelId:l.getSalesChannelId()}})]:[2,[]];case 2:return r=e.sent(),[2,(null===(o=null==r?void 0:r.data)||void 0===o?void 0:o.data)||[]]}}))}))},this.addProductToFavorites=function(r){return t(n,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.customer)||void 0===i?void 0:i.id))throw Error("Unauthorized");return[4,s.saveFavoriteProduct({isFavorite:!0,productId:r})];case 1:return t=e.sent(),d.addToWishlist(r),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(r){return t(n,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.customer)||void 0===i?void 0:i.id))throw Error("Unauthorized");return[4,s.saveFavoriteProduct({isFavorite:!1,productId:r})];case 1:return t=e.sent(),d.addToWishlist(r),[2,t.data||!1]}}))}))},this.isProductFavorite=function(r){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!(null===(t=this.customer)||void 0===t?void 0:t.id))throw Error("Unauthorized");return[4,s.isFavoriteProduct({productId:r})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(r){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.subscribeToMarketingNotifications({input:{email:r,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,a.SUBSCRIBED):this._visitorSubscribedEmail=!0,d.createEmailSubscripition(r)),[2,t.isSuccess]}}))}))},this.sendReview=function(i){return t(n,void 0,void 0,(function(){var t,o,n,a;return e(this,(function(e){switch(e.label){case 0:if(t=l.getCustomerReviewSettings(),o=l.getSalesChannelId(),!t)return[2];if(!(n=null===(a=this.customer)||void 0===a?void 0:a.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,s.createCustomerReview({input:r(r({},i),{customerId:t.customerLoginRequired?n:void 0,salesChannelId:o||""})})];case 1:return[2,e.sent().data]}}))}))},this.onCustomerConsentGrant=function(){n.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){n.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){n._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.setCaptchaToken=function(t){n._captchaToken=t},this.getRaffles=function(){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,c.listRaffleParticipants()];case 1:return(t=e.sent())&&t.data?[4,m(t.data.filter((function(t){return!!t.raffle})).map((function(t){return t.raffle})))]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,t]}}))}))},this.getCustomerAttributes=function(){return t(n,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,s.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(r=this.customer.attributes)||void 0===r||r.forEach((function(e){var r,i,o;e.customerAttribute=(null===(r=t.data)||void 0===r?void 0:r.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(o=null===(i=e.customerAttribute)||void 0===i?void 0:i.options)||void 0===o?void 0:o.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderByEmail=function(r,i){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.getOrderByEmail({email:r,orderNumber:i})];case 1:return[2,t.sent().data||null]}}))}))},this.getOrderRefundSettings=function(){return t(n,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,s.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(r=t.data)||void 0===r?void 0:r.length)&&(this._refundSettings=t.data[0]),e.label=2;case 2:return[2]}}))}))},this.baseStore=o,i(this)}return Object.defineProperty(f.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||p||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(f.prototype,"isCaptchaRequired",{get:function(){var t;return null===(t=l.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation},enumerable:!1,configurable:!0}),f.prototype.socialLogin=function(r){return t(this,void 0,void 0,(function(){var t,i,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",i="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(r,"/login/authenticate?redirect=").concat(t),[4,fetch(i,{headers:{"x-api-key":l.getApiKey()||"","x-sfid":l.getStorefrontId()||"","x-sfrid":l.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),window.location.href=o.redirectUrl,[2]}}))}))},f.prototype.socialLoginToken=function(r){var i;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s.socialLogin({code:r})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(i=t.data)||void 0===i?void 0:i.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer&&d.customerLogin(),[2,!0]):[2,!1]}}))}))},f.prototype.refundOrder=function(r){return t(this,void 0,void 0,(function(){var t,i,o=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=[],r.orderLineItems.map((function(e){null!==e.refundQuantity&&(null==t||t.push({orderLineItemId:e.id,quantity:e.refundQuantity?e.refundQuantity:0}))})),[4,s.createOrderRefundRequest({input:{orderId:r.id,orderLineItems:t}})];case 1:return(i=e.sent()).isSuccess&&i.data?(Object.entries(i.data).forEach((function(t){var e=t[0],r=t[1];o[e]=r})),[2,!0]):[3,3];case 2:return e.sent(),[3,3];case 3:return[2,!1]}}))}))},f.prototype.getCaptcha=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.isCaptchaRequired?(window.grecaptcha.execute(),[4,this.waitUntilCaptchaTokenInitialized()]):[3,2];case 1:e.sent(),window.grecaptcha.reset(),e.label=2;case 2:return[3,4];case 3:return t=e.sent(),console.log("Get captcha error",t),[3,4];case 4:return[2]}}))}))},f.prototype.init=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.loadToken(),this.loadLastViewedProducts(),this.loadCustomerConsent(),[4,this.refreshToken()];case 1:return t.sent(),[4,this.getCustomer()];case 2:return t.sent(),this._initialized=!0,this.customer&&d.customerVisit(),[2]}}))}))},f.prototype.routeChangeInit=function(){this.customer||(this.loadToken(),this.getCustomer())},f.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return p||!this.token?[2]:[4,s.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},f.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,s.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},f.prototype.setCustomer=function(t){this.customer=new n(t)},f.prototype.getLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,s.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=t.data||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},f.prototype.saveLastViewedProducts=function(){p||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},f.prototype.loadLastViewedProducts=function(){if(!p)try{var t=window.localStorage.getItem("lastViewedProducts");t&&(this._lastViewedProducts=JSON.parse(t),this._lastViewedProducts=this._lastViewedProducts.reverse(),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"))}catch(t){}},f.prototype.removeLastViewedProducts=function(){p||window.localStorage.removeItem("lastViewedProducts")},f.prototype.onProductView=function(r,i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?this._lastViewedProducts.find((function(t){return t.productId===r}))?[2]:[4,s.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:r,variantId:i}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:r,variantId:i}),[3,3];case 2:this._lastViewedProducts.push({productId:r,variantId:i}),this._lastViewedProducts=this._lastViewedProducts.slice(0,20),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},f.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:if(p)return[2];t.label=1;case 1:return t.trys.push([1,4,,5]),this.loadLastViewedProducts(),this._lastViewedProducts.length?[4,s.saveLastViewedProducts({input:{customerId:this.customer.id,products:this._lastViewedProducts}})]:[3,3];case 2:t.sent()&&this.removeLastViewedProducts(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},f.prototype.saveCustomerConsent=function(){p||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},f.prototype.loadCustomerConsent=function(){p||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},f.prototype.removeCustomerConsent=function(){p||window.localStorage.removeItem("customerConsent")},f.prototype.setToken=function(t,e){p||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),l.init({customerToken:t}))},f.prototype.loadToken=function(){if(!p){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e&&this.setToken(t,parseInt(e))}},f.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},f.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,l.init({customerToken:""}),this.clearCaptchaToken()},f.prototype.clearCaptchaToken=function(){this._captchaToken=null},f}();export{f as IkasCustomerStore};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import o from"lodash/uniqBy";import s from"./api.js";import{IkasCustomer as n}from"../../models/data/customer/index.js";import"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as a}from"@ikas/storefront-models";import"../../models/data/campaign-offer/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/path-item/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/checkout-settings/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute/index.js";import"../../models/data/customer/review/summary/index.js";import"../../models/data/customer/review/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/filter-category/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/variant/value/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/index.js";import"../../models/data/payment-gateway/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product/filter/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/index.js";import{IkasRaffleParticipant as c}from"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import u from"../raffle/index.js";import'./../../ext/@ikas/fe-api-client/build/utils/api.js';import'./../../ext/axios/index.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_defineProperty.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseGetTag.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_stringToPath.js';import'./../../ext/@ikas/fe-api-client/build/ext/lodash/_baseToString.js';import d from"../product/index.js";import{Analytics as l}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as h}from"@ikas/storefront-config";import{SaveMyCustomerInput as m}from"@ikas/storefront-api";import{populateRaffleParticipantProducts as p}from"@ikas/storefront-providers";var f="undefined"==typeof localStorage,v=function(){function v(o){var n=this;this.customer=null,this.token=null,this.tokenExpiry=null,this.baseStore=null,this._initialized=!1,this._visitorSubscribedEmail=!1,this._lastViewedProducts=[],this._customerConsentGranted=!1,this._refundSettings=null,this._captchaToken=null,this.toAnalyticsCustomer=function(t){return i(i({},t),{consentGranted:n._customerConsentGranted})},this.login=function(i,r){return t(n,void 0,void 0,(function(){var t,o,n,a;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.login({email:i,password:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer&&l.customerLogin(),(n=null===(a=this.baseStore)||void 0===a?void 0:a.cartStore.cart)?[4,this.baseStore.cartStore.changeItemQuantity(n.orderLineItems[0],n.orderLineItems[0].quantity)]:[3,4]):[3,5];case 3:e.sent(),e.label=4;case 4:return this.saveLocalLastViewedProducts(),[2,!0];case 5:return[2,!1]}}))}))},this.logout=function(){var t;n.clearLocalData(),null===(t=n.baseStore)||void 0===t||t.cartStore.removeCart(),l.customerLogout()},this.register=function(i,r,o,a,c,u){return t(n,void 0,void 0,(function(){var t,n;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.register({email:o,password:a,firstName:i,lastName:r,isAcceptMarketing:c,attributes:u,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(n=t.data)||void 0===n?void 0:n.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),l.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,!0]):[2,!1]}}))}))},this.saveContactForm=function(r){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return l.contactForm(r),[4,this.getCaptcha()];case 1:return e.sent(),[4,s.sendContactFormToMerchant(i(i({},r),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.checkEmail({email:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.forgotPassword=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.forgotPassword({email:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.recoverPassword=function(i,r,o){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.recoverPassword({password:i,passwordAgain:r,token:o,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.saveCustomer=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s.saveCustomer({input:new m(i)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(i){return t(n,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,s.getOrders({orderId:i})];case 1:return(t=e.sent()).isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.length)?(r=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),r.refundSettings=this._refundSettings,[2,r]}}))}))},this.getOrderTransactions=function(i){return void 0===i&&(i={}),t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.listOrderTransactions({checkoutId:{eq:i.checkoutId},id:{eq:i.checkoutId},orderId:{eq:i.orderId}})];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProductsIds=function(){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.listFavoriteProducts()];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(n,void 0,void 0,(function(){var t,i,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,s.listFavoriteProducts()];case 1:return(t=e.sent()).isSuccess&&(null===(r=t.data)||void 0===r?void 0:r.length)?[4,d.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:h.getPriceListId(),salesChannelId:h.getSalesChannelId()}})]:[2,[]];case 2:return i=e.sent(),[2,(null===(o=null==i?void 0:i.data)||void 0===o?void 0:o.data)||[]]}}))}))},this.addProductToFavorites=function(i){return t(n,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(r=this.customer)||void 0===r?void 0:r.id))throw Error("Unauthorized");return[4,s.saveFavoriteProduct({isFavorite:!0,productId:i})];case 1:return t=e.sent(),l.addToWishlist(i),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(i){return t(n,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(r=this.customer)||void 0===r?void 0:r.id))throw Error("Unauthorized");return[4,s.saveFavoriteProduct({isFavorite:!1,productId:i})];case 1:return t=e.sent(),l.addToWishlist(i),[2,t.data||!1]}}))}))},this.isProductFavorite=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(!(null===(t=this.customer)||void 0===t?void 0:t.id))throw Error("Unauthorized");return[4,s.isFavoriteProduct({productId:i})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(i){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,s.subscribeToMarketingNotifications({input:{email:i,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,a.SUBSCRIBED):this._visitorSubscribedEmail=!0,l.createEmailSubscripition(i)),[2,t.isSuccess]}}))}))},this.sendReview=function(r){return t(n,void 0,void 0,(function(){var t,o,n,a;return e(this,(function(e){switch(e.label){case 0:if(t=h.getCustomerReviewSettings(),o=h.getSalesChannelId(),!t)return[2];if(!(n=null===(a=this.customer)||void 0===a?void 0:a.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,s.createCustomerReview({input:i(i({},r),{customerId:t.customerLoginRequired?n:void 0,salesChannelId:o||""})})];case 1:return[2,e.sent().data]}}))}))},this.onCustomerConsentGrant=function(){n.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){n.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){n._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.setCaptchaToken=function(t){n._captchaToken=t},this.getRaffles=function(){return t(n,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,u.listRaffleParticipants()];case 1:return(t=e.sent())&&t.data?[4,p(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new c(t)}))]}}))}))},this.getCustomerAttributes=function(){return t(n,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,s.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(i=this.customer.attributes)||void 0===i||i.forEach((function(e){var i,r,o;e.customerAttribute=(null===(i=t.data)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(o=null===(r=e.customerAttribute)||void 0===r?void 0:r.options)||void 0===o?void 0:o.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderByEmail=function(i,r){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s.getOrderByEmail({email:i,orderNumber:r})];case 1:return[2,t.sent().data||null]}}))}))},this.getOrderRefundSettings=function(){return t(n,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,s.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)&&(this._refundSettings=t.data[0]),e.label=2;case 2:return[2]}}))}))},this.baseStore=o,r(this)}return Object.defineProperty(v.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||f||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"isCaptchaRequired",{get:function(){var t;return null===(t=h.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation},enumerable:!1,configurable:!0}),v.prototype.socialLogin=function(i){return t(this,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",r="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(i,"/login/authenticate?redirect=").concat(t),[4,fetch(r,{headers:{"x-api-key":h.getApiKey()||"","x-sfid":h.getStorefrontId()||"","x-sfrid":h.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),window.location.href=o.redirectUrl,[2]}}))}))},v.prototype.socialLoginToken=function(i){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s.socialLogin({code:i})];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(r=t.data)||void 0===r?void 0:r.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.customer&&l.customerLogin(),[2,!0]):[2,!1]}}))}))},v.prototype.refundOrder=function(i){return t(this,void 0,void 0,(function(){var t,r,o=this;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),t=[],i.orderLineItems.map((function(e){null!==e.refundQuantity&&(null==t||t.push({orderLineItemId:e.id,quantity:e.refundQuantity?e.refundQuantity:0}))})),[4,s.createOrderRefundRequest({input:{orderId:i.id,orderLineItems:t}})];case 1:return(r=e.sent()).isSuccess&&r.data?(Object.entries(r.data).forEach((function(t){var e=t[0],i=t[1];o[e]=i})),[2,!0]):[3,3];case 2:return e.sent(),[3,3];case 3:return[2,!1]}}))}))},v.prototype.getCaptcha=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),this.isCaptchaRequired?(window.grecaptcha.execute(),[4,this.waitUntilCaptchaTokenInitialized()]):[3,2];case 1:e.sent(),window.grecaptcha.reset(),e.label=2;case 2:return[3,4];case 3:return t=e.sent(),console.log("Get captcha error",t),[3,4];case 4:return[2]}}))}))},v.prototype.init=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.loadToken(),this.loadLastViewedProducts(),this.loadCustomerConsent(),[4,this.refreshToken()];case 1:return t.sent(),[4,this.getCustomer()];case 2:return t.sent(),this._initialized=!0,this.customer&&l.customerVisit(),[2]}}))}))},v.prototype.routeChangeInit=function(){this.customer||(this.loadToken(),this.getCustomer())},v.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return f||!this.token?[2]:[4,s.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},v.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,s.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},v.prototype.setCustomer=function(t){this.customer=new n(t)},v.prototype.getLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,s.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=t.data||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},v.prototype.saveLastViewedProducts=function(){f||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},v.prototype.loadLastViewedProducts=function(){if(!f)try{var t=window.localStorage.getItem("lastViewedProducts");t&&(this._lastViewedProducts=JSON.parse(t),this._lastViewedProducts=this._lastViewedProducts.reverse(),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"))}catch(t){}},v.prototype.removeLastViewedProducts=function(){f||window.localStorage.removeItem("lastViewedProducts")},v.prototype.onProductView=function(i,r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?this._lastViewedProducts.find((function(t){return t.productId===i}))?[2]:[4,s.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:i,variantId:r}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:i,variantId:r}),[3,3];case 2:this._lastViewedProducts.push({productId:i,variantId:r}),this._lastViewedProducts=this._lastViewedProducts.slice(0,20),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},v.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:if(f)return[2];t.label=1;case 1:return t.trys.push([1,4,,5]),this.loadLastViewedProducts(),this._lastViewedProducts.length?[4,s.saveLastViewedProducts({input:{customerId:this.customer.id,products:this._lastViewedProducts}})]:[3,3];case 2:t.sent()&&this.removeLastViewedProducts(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},v.prototype.saveCustomerConsent=function(){f||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},v.prototype.loadCustomerConsent=function(){f||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},v.prototype.removeCustomerConsent=function(){f||window.localStorage.removeItem("customerConsent")},v.prototype.setToken=function(t,e){f||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),h.init({customerToken:t}))},v.prototype.loadToken=function(){if(!f){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e&&this.setToken(t,parseInt(e))}},v.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},v.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,h.init({customerToken:""}),this.clearCaptchaToken()},v.prototype.clearCaptchaToken=function(){this._captchaToken=null},v}();export{v as IkasCustomerStore};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"libphonenumber-js": "^1.10.6"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@ikas/storefront-api": "^4.0.0
|
|
27
|
-
"@ikas/storefront-config": "^4.0.0
|
|
28
|
-
"@ikas/storefront-model-functions": "^4.0.0
|
|
29
|
-
"@ikas/storefront-models": "^4.0.0
|
|
30
|
-
"@ikas/storefront-providers": "^4.0.0
|
|
26
|
+
"@ikas/storefront-api": "^4.0.0",
|
|
27
|
+
"@ikas/storefront-config": "^4.0.0",
|
|
28
|
+
"@ikas/storefront-model-functions": "^4.0.0",
|
|
29
|
+
"@ikas/storefront-models": "^4.0.0",
|
|
30
|
+
"@ikas/storefront-providers": "^4.0.0",
|
|
31
31
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
32
32
|
"@rollup/plugin-json": "^4.1.0",
|
|
33
33
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
@@ -53,11 +53,11 @@
|
|
|
53
53
|
"query-string": "^6.13.8"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@ikas/storefront-api": "^4.0.0
|
|
57
|
-
"@ikas/storefront-config": "^4.0.0
|
|
58
|
-
"@ikas/storefront-model-functions": "^4.0.0
|
|
59
|
-
"@ikas/storefront-models": "^4.0.0
|
|
60
|
-
"@ikas/storefront-providers": "^4.0.0
|
|
56
|
+
"@ikas/storefront-api": "^4.0.0",
|
|
57
|
+
"@ikas/storefront-config": "^4.0.0",
|
|
58
|
+
"@ikas/storefront-model-functions": "^4.0.0",
|
|
59
|
+
"@ikas/storefront-models": "^4.0.0",
|
|
60
|
+
"@ikas/storefront-providers": "^4.0.0",
|
|
61
61
|
"mobx": "^6.1.3",
|
|
62
62
|
"mobx-react-lite": "^3.1.5",
|
|
63
63
|
"next": "12.2.0",
|