@ikas/storefront 6.1.0-beta.340 → 6.1.0-beta.342
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/analytics/analytics.d.ts +1 -1
- package/build/components/checkout/modelMasterPass.d.ts +1 -1
- package/build/components/page/widgets/popupWidget.js +1 -1
- package/build/store/cart/api.d.ts +1 -1
- package/build/store/cart/index.d.ts +1 -0
- package/build/store/cart/index.js +1 -1
- package/build/store/checkout/index.d.ts +4 -4
- package/build/store/customer/api.d.ts +3 -3
- package/build/store/product/index.d.ts +5 -5
- package/package.json +11 -11
|
@@ -15,7 +15,7 @@ export declare class Analytics {
|
|
|
15
15
|
isEmailVerified: boolean | null;
|
|
16
16
|
isPhoneVerified: boolean | null;
|
|
17
17
|
orderCount: number | null;
|
|
18
|
-
subscriptionStatus: import("@ikas/storefront-models/
|
|
18
|
+
subscriptionStatus: import("@ikas/storefront-models/build-cjs/models/customer").IkasCustomerEmailSubscriptionStatus | null;
|
|
19
19
|
} | null>;
|
|
20
20
|
static pageView(pageType: IkasThemeJsonPageType): Promise<void>;
|
|
21
21
|
static productView(productDetail: IkasProduct): Promise<void>;
|
|
@@ -101,7 +101,7 @@ export default class MasterPassModel {
|
|
|
101
101
|
paymentGatewayId: string;
|
|
102
102
|
operationType: MasterPassOperationTypeEnum;
|
|
103
103
|
phoneNumber: string;
|
|
104
|
-
}) => Promise<import("@ikas/storefront-api/
|
|
104
|
+
}) => Promise<import("@ikas/storefront-api/build/__api/types").MasterPassTokenResponse | undefined>;
|
|
105
105
|
phoneNumber: ({ store, checkout, withPlus, }: {
|
|
106
106
|
store: IkasBaseStore;
|
|
107
107
|
checkout: IkasCheckout;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as n}from'./../../../ext/tslib/tslib.es6.js';import*as r from"react";import{reaction as o}from"mobx";import{listStorefrontPopup as i,SortByDirectionEnum as a}from"@ikas/storefront-api";import{IkasStorefrontConfig as u}from"@ikas/storefront-config";import{Analytics as s}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasBaseStore as c}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import d from"../../../store/product/index.js";import{POPUP_CONTEXT_UPDATE_EVENT as l}from'./../../../ext/@ikas/popup-script-injector/dist/popup-script-injector.es.js';import{resolveStoreUrl as p,resolveCartUrl as f}from"./common.js";var m=function(n){return t(void 0,void 0,void 0,(function(){var r,o,i,a,l,m,I,w,S,P,y,C,k,b,j,L;return e(this,(function(E){switch(E.label){case 0:return r={popups:n,cartUrl:""},[4,function(){return new Promise((function(t){var e=setInterval((function(){var n=u.getSessionId();n&&(clearInterval(e),t(n))}),100)}))}()];case 1:return E.sent(),(o=u.getSessionId())&&(r.sessionId=o),(i=u.getCdnUrl())&&(r.cdnUrl=i),(a=null===(b=u.getMerchantSettings())||void 0===b?void 0:b.merchantId)&&(r.merchantId=a),(l=p())&&(r.storeUrl=l),(m=f())&&(r.cartUrl=m),(I=u.getCustomerToken())&&(r.customerToken=I),(w=u.getCurrentLocale())&&(r.locale=w),(S=null===(L=null===(j=u.getCurrentRouting())||void 0===j?void 0:j.countryCodes)||void 0===L?void 0:L[0])&&(r.countryCode=S),(P=u.getPriceListId())&&(r.priceListId=P),(y=u.getSalesChannelId())&&(r.salesChannelId=y),T=c.getInstance().customerStore.customer,(C=T?g(T):null)&&(r.customer=C),D=c.getInstance().cartStore.cart,(k=D?h(D):null)&&(r.cart=k),r.services=function(){var n=this,r=c.getInstance();return{searchProducts:function(r){return t(n,void 0,void 0,(function(){var t,n,o;return e(this,(function(e){switch(e.label){case 0:return[4,d.searchProducts(v(r))];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(o=null===(n=t.data)||void 0===n?void 0:n.data)||void 0===o?void 0:o.length)?[2,t.data.data]:[2,[]]}}))}))},addItemToCart:function(o){var i=o.product,a=o.variant,u=o.quantity;return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,r.cartStore.addItem(a,i,null!=u?u:1)];case 1:return[2,{success:!!(null==(t=e.sent())?void 0:t.success)}]}}))}))},saveCustomerFormData:function(o){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,r.customerStore.saveCustomerFormData({email:o.email,firstName:o.firstName,lastName:o.lastName,birthDate:o.birthDate||null,phone:o.phone||"",storefrontPopupId:o.popupId,subscriptions:o.subscriptions})];case 1:return t.sent(),[2]}}))}))},getLastViewedProducts:function(){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){return"function"==typeof(t=r.customerStore).getLastViewedProducts?[2,t.getLastViewedProducts()]:[2,[]]}))}))},formatVariantSellPrice:function(t){return t.formattedSellPrice||""},formatVariantDiscountPrice:function(t){return t.formattedDiscountPrice||null},hasVariantDiscount:function(t){return!!t.hasDiscount},getVariantDiscountPercentage:function(t){var e=t.discountPercentage;return null==e?null:"number"==typeof e?e.toString():e},redirectToProduct:function(t){return!!t.url&&(window.location.href=t.url,!0)},viewPopup:function(t){s.viewStorefrontPopup(t)}}}(),[2,r]}var D,T}))}))};function v(t){var e,n,r,o,i,s=null===(e=t.order)||void 0===e?void 0:e.map((function(t){return{direction:"ASC"===t.direction?a.ASC:a.DESC,type:t.type}}));return{input:{page:null!==(n=t.page)&&void 0!==n?n:1,perPage:null!==(r=t.perPage)&&void 0!==r?r:10,order:s,productIdList:t.productIdList,categoryIdList:t.categoryIdList,priceListId:null!==(o=t.priceListId)&&void 0!==o?o:u.getPriceListId(),salesChannelId:null!==(i=t.salesChannelId)&&void 0!==i?i:u.getSalesChannelId()}}}function g(t){return{email:t.email,firstName:t.firstName,lastName:t.lastName,birthDate:t.birthDate,phone:t.phone,gender:t.gender?String(t.gender):null,customerGroupIds:t.customerGroupIds||[],customerSegmentIds:t.customerSegmentIds||[],subscriptionStatus:t.subscriptionStatus?String(t.subscriptionStatus):null}}function h(t){var e,n,r=[],o=new Set,i=new Set,a=new Set,u=new Set,s=new Set,c=new Set;return t.items.forEach((function(t){var e,n,s,d=t.variant,l=(null==d?void 0:d.productId)||null,p=(null==d?void 0:d.id)||null,f=(null===(e=null==d?void 0:d.brand)||void 0===e?void 0:e.id)||null,m=(null===(n=null==d?void 0:d.categories)||void 0===n?void 0:n.map((function(t){return t.id})).filter(Boolean))||[];r.push({productId:l,variantId:p,brandId:f,categoryIds:m,quantity:t.quantity,finalPrice:t.finalPrice}),l&&o.add(l),p&&i.add(p),f&&a.add(f),m.forEach((function(t){return t&&u.add(t)})),(null===(s=t.discount)||void 0===s?void 0:s.campaignOfferId)&&c.add(t.discount.campaignOfferId)})),null===(e=t.campaignOffers)||void 0===e||e.forEach((function(t){t.campaignOfferId&&c.add(t.campaignOfferId)})),null===(n=t.orderAdjustments)||void 0===n||n.forEach((function(t){t.campaignId&&s.add(t.campaignId)})),{totalPrice:t.totalPrice,totalFinalPrice:t.totalFinalPrice,itemCount:t.itemCount,itemQuantity:t.itemQuantity,currencyCode:t.currencyCode||null,lines:r,productIds:Array.from(o),variantIds:Array.from(i),brandIds:Array.from(a),categoryIds:Array.from(u),appliedCampaignIds:Array.from(s),appliedCampaignOfferIds:Array.from(c),couponCode:t.couponCode||null}}function I(t){"undefined"!=typeof window&&(window.ikasPopupConfig&&(void 0!==t.customer&&(window.ikasPopupConfig.customer=t.customer),void 0!==t.cart&&(window.ikasPopupConfig.cart=t.cart),void 0!==t.customerToken&&(window.ikasPopupConfig.customerToken=t.customerToken||void 0)),"function"!=typeof window.updateIkasPopupContext?window.dispatchEvent(new CustomEvent(l,{detail:t})):window.updateIkasPopupContext(t))}function w(a){var s=this;a.router;var d=a.pageSpecificDataId,l=a.pageType;r.useEffect((function(){if("undefined"!=typeof window&&"undefined"!=typeof document){var r,a=!1,d=[],l=function(t,e){if(function(t){t.setAttribute("data-ikas-popup-widget","true"),!t.dataset.ikasPopupWidgetUrl&&t.src&&(t.dataset.ikasPopupWidgetUrl=t.src)}(t),"true"===t.dataset.ikasPopupWidgetLoaded)return e(),function(){};var n=function(){t.dataset.ikasPopupWidgetLoaded="true",e()},r=function(e){console.error("[@ikas/storefront] Failed to load popup widget script",t.src,e)};return t.addEventListener("load",n,{once:!0}),t.addEventListener("error",r,{once:!0}),function(){t.removeEventListener("load",n),t.removeEventListener("error",r)}},p=function(t){var e=window.location.href.includes("http://localhost:3333/")?"http://localhost:9000/popup-script-injector.iife.js":"/sf/assets/popup/popup-script-injector.iife.js";if(e){var n=function(){a||function(t){if("function"==typeof window.startIkasPopupWidget)try{window.startIkasPopupWidget(t)}catch(t){console.error("[@ikas/storefront] Failed to start popup widget",t)}}(t)},o=document.querySelector('script[data-ikas-popup-widget="true"]');if(o)r=l(o,n);else{var i=document.createElement("script");i.src=e,i.defer=!0,r=l(i,n),document.body.appendChild(i)}}},f=function(t){var e=window.location.href.includes("http://localhost:3333/")?"http://localhost:9000/style.css":"/sf/assets/popup/style.css";if(e&&!document.querySelector('link[href="'.concat(e,'"]'))){var n=document.createElement("link");n.rel="stylesheet",n.href=e,n.setAttribute("data-ikas-popup-widget","true");n.addEventListener("error",(function(t){console.error("[@ikas/storefront] Failed to load popup widget CSS",e,t)}),{once:!0}),document.head.appendChild(n)}};return t(s,void 0,void 0,(function(){var r,l,v;return e(this,(function(w){switch(w.label){case 0:return r=u.getStorefrontPopups()||[],[4,(C=r,t(s,void 0,void 0,(function(){var t,r,o,a,u;return e(this,(function(e){switch(e.label){case 0:if(!(t=C.map((function(t){return t.id})).filter(Boolean)).length)return[2,C];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,i({idList:t})];case 2:return(null==(r=e.sent())?void 0:r.isSuccess)&&(null===(u=r.data)||void 0===u?void 0:u.length)?(o=r.data,[2,C.map((function(t){var e=o.find((function(e){return e.id===t.id}));return e?n(n({},e),{isFilteredOnServerSide:t.isFilteredOnServerSide}):t}))]):[3,4];case 3:return a=e.sent(),console.error("[@ikas/storefront] Failed to fetch popup details",a),[3,4];case 4:return[2,C]}}))})))];case 1:return l=w.sent(),a?[2]:[4,m(l)];case 2:return v=w.sent(),window.ikasPopupConfig=v,p(v),f(),S=c.getInstance(),P=o((function(){var t=S.customerStore.customer;return t?{email:t.email,gender:t.gender,groupIds:(t.customerGroupIds||[]).join(","),segmentIds:(t.customerSegmentIds||[]).join(","),subscriptionStatus:t.subscriptionStatus}:null}),(function(){var t=S.customerStore.customer;I({customer:t?g(t):null,customerToken:u.getCustomerToken()||null})})),y=o((function(){var t=S.cartStore.cart;return t?{total:t.totalFinalPrice,itemCount:t.itemCount,quantity:t.itemQuantity,productSignature:t.items.map((function(t){var e,n;return"".concat((null===(e=t.variant)||void 0===e?void 0:e.productId)||"",":").concat((null===(n=t.variant)||void 0===n?void 0:n.id)||"",":").concat(t.quantity)})).join("|"),campaignSignature:(t.orderAdjustments||[]).map((function(t){return t.campaignId||""})).join("|"),couponCode:t.couponCode}:null}),(function(){var t=S.cartStore.cart;I({cart:t?h(t):null})})),d.push(P,y),[2]}var S,P,y,C}))})),function(){a=!0,null==r||r(),d.forEach((function(t){return t()})),d=[],"function"==typeof window.destroyIkasPopupWidget&&window.destroyIkasPopupWidget()}}}),[d,l])}export{w as usePopupWidget};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as n}from'./../../../ext/tslib/tslib.es6.js';import*as o from"react";import{reaction as r}from"mobx";import{listStorefrontPopup as i,SortByDirectionEnum as a}from"@ikas/storefront-api";import{IkasStorefrontConfig as u}from"@ikas/storefront-config";import{Analytics as s}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasBaseStore as c}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import d from"../../../store/product/index.js";import{POPUP_CONTEXT_UPDATE_EVENT as l}from'./../../../ext/@ikas/popup-script-injector/dist/popup-script-injector.es.js';import{resolveStoreUrl as p,resolveCartUrl as f}from"./common.js";var m=["scroll","keydown","pointerdown","touchstart","mousemove"],v=function(n){return t(void 0,void 0,void 0,(function(){var o,r,i,a,l,m,v,I,S,y,P,C,k,b,E,L;return e(this,(function(j){switch(j.label){case 0:return o={popups:n,cartUrl:""},[4,function(){return new Promise((function(t){var e=setInterval((function(){var n=u.getSessionId();n&&(clearInterval(e),t(n))}),100)}))}()];case 1:return j.sent(),(r=u.getSessionId())&&(o.sessionId=r),(i=u.getCdnUrl())&&(o.cdnUrl=i),(a=null===(b=u.getMerchantSettings())||void 0===b?void 0:b.merchantId)&&(o.merchantId=a),(l=p())&&(o.storeUrl=l),(m=f())&&(o.cartUrl=m),(v=u.getCustomerToken())&&(o.customerToken=v),(I=u.getCurrentLocale())&&(o.locale=I),(S=null===(L=null===(E=u.getCurrentRouting())||void 0===E?void 0:E.countryCodes)||void 0===L?void 0:L[0])&&(o.countryCode=S),(y=u.getPriceListId())&&(o.priceListId=y),(P=u.getSalesChannelId())&&(o.salesChannelId=P),D=c.getInstance().customerStore.customer,(C=D?h(D):null)&&(o.customer=C),T=c.getInstance().cartStore.cart,(k=T?w(T):null)&&(o.cart=k),o.services=function(){var n=this,o=c.getInstance();return{searchProducts:function(o){return t(n,void 0,void 0,(function(){var t,n,r;return e(this,(function(e){switch(e.label){case 0:return[4,d.searchProducts(g(o))];case 1:return(null==(t=e.sent())?void 0:t.isSuccess)&&(null===(r=null===(n=t.data)||void 0===n?void 0:n.data)||void 0===r?void 0:r.length)?[2,t.data.data]:[2,[]]}}))}))},addItemToCart:function(r){var i=r.product,a=r.variant,u=r.quantity;return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,o.cartStore.addItem(a,i,null!=u?u:1)];case 1:return[2,{success:!!(null==(t=e.sent())?void 0:t.success)}]}}))}))},saveCustomerFormData:function(r){return t(n,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,o.customerStore.saveCustomerFormData({email:r.email,firstName:r.firstName,lastName:r.lastName,birthDate:r.birthDate||null,phone:r.phone||"",storefrontPopupId:r.popupId,subscriptions:r.subscriptions})];case 1:return t.sent(),[2]}}))}))},getLastViewedProducts:function(){return t(n,void 0,void 0,(function(){var t;return e(this,(function(e){return"function"==typeof(t=o.customerStore).getLastViewedProducts?[2,t.getLastViewedProducts()]:[2,[]]}))}))},formatVariantSellPrice:function(t){return t.formattedSellPrice||""},formatVariantDiscountPrice:function(t){return t.formattedDiscountPrice||null},hasVariantDiscount:function(t){return!!t.hasDiscount},getVariantDiscountPercentage:function(t){var e=t.discountPercentage;return null==e?null:"number"==typeof e?e.toString():e},redirectToProduct:function(t){return!!t.url&&(window.location.href=t.url,!0)},viewPopup:function(t){s.viewStorefrontPopup(t)}}}(),[2,o]}var T,D}))}))};function g(t){var e,n,o,r,i,s=null===(e=t.order)||void 0===e?void 0:e.map((function(t){return{direction:"ASC"===t.direction?a.ASC:a.DESC,type:t.type}}));return{input:{page:null!==(n=t.page)&&void 0!==n?n:1,perPage:null!==(o=t.perPage)&&void 0!==o?o:10,order:s,productIdList:t.productIdList,categoryIdList:t.categoryIdList,priceListId:null!==(r=t.priceListId)&&void 0!==r?r:u.getPriceListId(),salesChannelId:null!==(i=t.salesChannelId)&&void 0!==i?i:u.getSalesChannelId()}}}function h(t){return{email:t.email,firstName:t.firstName,lastName:t.lastName,birthDate:t.birthDate,phone:t.phone,gender:t.gender?String(t.gender):null,customerGroupIds:t.customerGroupIds||[],customerSegmentIds:t.customerSegmentIds||[],subscriptionStatus:t.subscriptionStatus?String(t.subscriptionStatus):null}}function w(t){var e,n,o=[],r=new Set,i=new Set,a=new Set,u=new Set,s=new Set,c=new Set;return t.items.forEach((function(t){var e,n,s,d=t.variant,l=(null==d?void 0:d.productId)||null,p=(null==d?void 0:d.id)||null,f=(null===(e=null==d?void 0:d.brand)||void 0===e?void 0:e.id)||null,m=(null===(n=null==d?void 0:d.categories)||void 0===n?void 0:n.map((function(t){return t.id})).filter(Boolean))||[];o.push({productId:l,variantId:p,brandId:f,categoryIds:m,quantity:t.quantity,finalPrice:t.finalPrice}),l&&r.add(l),p&&i.add(p),f&&a.add(f),m.forEach((function(t){return t&&u.add(t)})),(null===(s=t.discount)||void 0===s?void 0:s.campaignOfferId)&&c.add(t.discount.campaignOfferId)})),null===(e=t.campaignOffers)||void 0===e||e.forEach((function(t){t.campaignOfferId&&c.add(t.campaignOfferId)})),null===(n=t.orderAdjustments)||void 0===n||n.forEach((function(t){t.campaignId&&s.add(t.campaignId)})),{totalPrice:t.totalPrice,totalFinalPrice:t.totalFinalPrice,itemCount:t.itemCount,itemQuantity:t.itemQuantity,currencyCode:t.currencyCode||null,lines:o,productIds:Array.from(r),variantIds:Array.from(i),brandIds:Array.from(a),categoryIds:Array.from(u),appliedCampaignIds:Array.from(s),appliedCampaignOfferIds:Array.from(c),couponCode:t.couponCode||null}}function I(t){"undefined"!=typeof window&&(window.ikasPopupConfig&&(void 0!==t.customer&&(window.ikasPopupConfig.customer=t.customer),void 0!==t.cart&&(window.ikasPopupConfig.cart=t.cart),void 0!==t.customerToken&&(window.ikasPopupConfig.customerToken=t.customerToken||void 0)),"function"!=typeof window.updateIkasPopupContext?window.dispatchEvent(new CustomEvent(l,{detail:t})):window.updateIkasPopupContext(t))}function S(a){var s=this;a.router;var d=a.pageSpecificDataId,l=a.pageType;o.useEffect((function(){if("undefined"!=typeof window&&"undefined"!=typeof document){var o,a,d=!1,l=[],p=function(t,e){if(function(t){t.setAttribute("data-ikas-popup-widget","true"),!t.dataset.ikasPopupWidgetUrl&&t.src&&(t.dataset.ikasPopupWidgetUrl=t.src)}(t),"true"===t.dataset.ikasPopupWidgetLoaded)return e(),function(){};var n=function(){t.dataset.ikasPopupWidgetLoaded="true",e()},o=function(e){console.error("[@ikas/storefront] Failed to load popup widget script",t.src,e)};return t.addEventListener("load",n,{once:!0}),t.addEventListener("error",o,{once:!0}),function(){t.removeEventListener("load",n),t.removeEventListener("error",o)}},f=function(t){var e=window.location.href.includes("http://localhost:3333/")?"http://localhost:9000/popup-script-injector.iife.js":"/sf/assets/popup/popup-script-injector.iife.js";if(e){var n=function(){d||function(t){if("function"==typeof window.startIkasPopupWidget)try{window.startIkasPopupWidget(t)}catch(t){console.error("[@ikas/storefront] Failed to start popup widget",t)}}(t)},r=document.querySelector('script[data-ikas-popup-widget="true"]');if(r)o=p(r,n);else{var i=document.createElement("script");i.src=e,i.defer=!0,o=p(i,n),document.body.appendChild(i)}}},g=function(t){var e=window.location.href.includes("http://localhost:3333/")?"http://localhost:9000/style.css":"/sf/assets/popup/style.css";if(e&&!document.querySelector('link[href="'.concat(e,'"]'))){var n=document.createElement("link");n.rel="stylesheet",n.href=e,n.setAttribute("data-ikas-popup-widget","true");n.addEventListener("error",(function(t){console.error("[@ikas/storefront] Failed to load popup widget CSS",e,t)}),{once:!0}),document.head.appendChild(n)}};return t(s,void 0,void 0,(function(){var o,p,S;return e(this,(function(y){switch(y.label){case 0:return(o=u.getStorefrontPopups()||[]).length?[4,(F=o,t(s,void 0,void 0,(function(){var t,o,r,a,u;return e(this,(function(e){switch(e.label){case 0:if(!(t=F.map((function(t){return t.id})).filter(Boolean)).length)return[2,F];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,i({idList:t})];case 2:return(null==(o=e.sent())?void 0:o.isSuccess)&&(null===(u=o.data)||void 0===u?void 0:u.length)?(r=o.data,[2,F.map((function(t){var e=r.find((function(e){return e.id===t.id}));return e?n(n({},e),{isFilteredOnServerSide:t.isFilteredOnServerSide}):t}))]):[3,4];case 3:return a=e.sent(),console.error("[@ikas/storefront] Failed to fetch popup details",a),[3,4];case 4:return[2,F]}}))})))]:[2];case 1:return p=y.sent(),d?[2]:[4,v(p)];case 2:return S=y.sent(),window.ikasPopupConfig=S,b=function(){d||(f(S),g())},j=window,T=!1,D=function(){m.forEach((function(t){return window.removeEventListener(t,A)})),void 0!==E&&"function"==typeof j.cancelIdleCallback&&j.cancelIdleCallback(E),void 0!==L&&window.clearTimeout(L)},A=function(){T||(T=!0,D(),b())},m.forEach((function(t){return window.addEventListener(t,A,{once:!0,passive:!0})})),"function"==typeof j.requestIdleCallback?E=j.requestIdleCallback(A,{timeout:3e3}):L=window.setTimeout(A,1500),a=D,P=c.getInstance(),C=r((function(){var t=P.customerStore.customer;return t?{email:t.email,gender:t.gender,groupIds:(t.customerGroupIds||[]).join(","),segmentIds:(t.customerSegmentIds||[]).join(","),subscriptionStatus:t.subscriptionStatus}:null}),(function(){var t=P.customerStore.customer;I({customer:t?h(t):null,customerToken:u.getCustomerToken()||null})})),k=r((function(){var t=P.cartStore.cart;return t?{total:t.totalFinalPrice,itemCount:t.itemCount,quantity:t.itemQuantity,productSignature:t.items.map((function(t){var e,n;return"".concat((null===(e=t.variant)||void 0===e?void 0:e.productId)||"",":").concat((null===(n=t.variant)||void 0===n?void 0:n.id)||"",":").concat(t.quantity)})).join("|"),campaignSignature:(t.orderAdjustments||[]).map((function(t){return t.campaignId||""})).join("|"),couponCode:t.couponCode}:null}),(function(){var t=P.cartStore.cart;I({cart:t?w(t):null})})),l.push(C,k),[2]}var P,C,k,b,E,L,j,T,D,A,F}))})),function(){d=!0,null==o||o(),null==a||a(),l.forEach((function(t){return t()})),l=[],"function"==typeof window.destroyIkasPopupWidget&&window.destroyIkasPopupWidget()}}}),[d,l])}export{S as usePopupWidget};
|
|
@@ -10,5 +10,5 @@ export default class CartStoreAPI {
|
|
|
10
10
|
static addItemToCart: (params: AddItemToCartQueryParams) => Promise<APIResponse<IkasCart | null>>;
|
|
11
11
|
static updateCartCampaignOffer: (params: UpdateCartCampaignOfferQueryParams) => Promise<APIResponse<IkasCart | null>>;
|
|
12
12
|
static createCart: (params: CreateCartQueryParams) => Promise<APIResponse<IkasCart | null>>;
|
|
13
|
-
static createPayWithIkasSessionUrl: (params: CreatePayWithIkasSessionUrlQueryParams) => Promise<APIResponse<import("@ikas/storefront-api/
|
|
13
|
+
static createPayWithIkasSessionUrl: (params: CreatePayWithIkasSessionUrlQueryParams) => Promise<APIResponse<import("@ikas/storefront-api/build/__api/types").CreatePayWithIkasSessionUrlResponse | null>>;
|
|
14
14
|
}
|
|
@@ -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 n from"./api.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{IkasProductOptionType as a,IkasCustomerEmailSubscriptionStatus as o}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/region/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.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/customer-form-data-input/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/region/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/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/order-transaction-with-prices/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/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/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/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/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../models/data/storefront-popup/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import{IkasStorefrontConfig as s}from"@ikas/storefront-config";import{Analytics as d}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as c,createPayWithIkasSessionUrl as u}from"@ikas/storefront-api";import{getCookieValue as l}from"../../utils/helper.js";var p,m="cartId",v=function(){function m(u){var m=this;this.cart=null,this._isLoadingCart=!1,this._isCartLoadFinished=!1,this.addItem=function(r,a,o,c){return void 0===o&&(o=1),t(m,void 0,void 0,(function(){var t,u,m,v,f,h,I,g,C,b,S,y,j,x,O,P,_,T,L,E;return e(this,(function(e){switch(e.label){case 0:t=null!==(y=null==c?void 0:c.isPayWithIkas)&&void 0!==y&&y,e.label=1;case 1:return e.trys.push([1,7,,8]),!t&&a.productOptionSetId&&!a.productOptionSet&&this.baseStore.router?(this.baseStore.router.push(a.productHref),[2,{success:!1,validationError:p.INVALID_PRODUCT_OPTION_VALUES}]):a.hasValidProductOptionValues?r.hasStock||r.sellIfOutOfStock?(u=void 0,t?[3,3]:[4,this.beforeCartOperationCheck()]):[2,{success:!1,validationError:p.INSUFFICIENT_STOCK}]:[2,{success:!1,validationError:p.INVALID_PRODUCT_OPTION_VALUES}];case 2:if(e.sent(),this.cart&&(u=this.findExistingItem(r,a))){if(null===(j=a.productOptionSet)||void 0===j||j.initOptionValues(),!r.bundleSettings)return[2,this.changeItemQuantity(u,u.quantity+1,a.offers,a)];if(!this.getEditLineID())return[2,this.changeItemQuantity(u,u.quantity+1,a.offers,a)]}e.label=3;case 3:return m=this.getOptionValues(a),v=o,(null==(f=null===(x=a.salesChannels)||void 0===x?void 0:x.find((function(t){return t.id===s.getSalesChannelId()})))?void 0:f.minQuantityPerCart)&&o<f.minQuantityPerCart&&(v=f.minQuantityPerCart),(null==f?void 0:f.maxQuantityPerCart)&&o>f.maxQuantityPerCart&&(v=f.maxQuantityPerCart),h=t?null:(null===(O=this.cart)||void 0===O?void 0:O.id)||localStorage.getItem("cartId"),[4,n.addItemToCart({input:i({cartId:h,item:{id:null!==(P=null==u?void 0:u.id)&&void 0!==P?P:null,quantity:null!==(_=null==u?void 0:u.quantity)&&void 0!==_?_:v,variant:{id:r.id,name:a.name,bundleProducts:null===(T=r.bundleSettings)||void 0===T?void 0:T.products.map((function(t){var e,i,r;return{id:t.id,productId:(null===(e=t.product)||void 0===e?void 0:e.id)||"",variantId:(null===(r=null===(i=t.product)||void 0===i?void 0:i.selectedVariant)||void 0===r?void 0:r.id)||"",quantity:t.quantity}}))}},acceptedOffers:this.getAcceptedOffers(a.offers),options:m.length?m:null,priceListId:s.getPriceListId()||null,salesChannelId:s.getSalesChannelId(),storefrontThemeId:s.getStorefrontThemeId(),metadata:{_fbp:l("_fbp"),_fbc:l("_fbc"),_ga:l("_ga")}},a.selectedVariant.subscriptionPlan&&a.selectedVariant.subscriptionPlan.isSelected?{subscriptionPlanId:a.selectedVariant.subscriptionPlan.subscriptionPlanId,subscriptionPlanPeriodId:null===(L=a.selectedVariant.subscriptionPlan.periods.find((function(t){return t.isSelected})))||void 0===L?void 0:L.id}:{})})];case 4:return I=e.sent(),t?[3,6]:I.isSuccess&&I.data?[4,this.setCart(I.data)]:[3,6];case 5:e.sent(),e.label=6;case 6:return(g=t?I.data:this.cart)&&(C="".concat(g.id,"-").concat(g.updatedAt),(b=g.items.find((function(t){return t.variant.id===r.id})))&&d.addToCart(b,o,C,g,a)),null===(E=a.productOptionSet)||void 0===E||E.initOptionValues(),[2,{success:I.isSuccess,response:I}];case 7:return S=e.sent(),console.log(S),[2,{success:!1}];case 8:return[2]}}))}))},this.changeItemQuantity=function(r,a,o,c){return t(m,void 0,void 0,(function(){var t,u,p,m,v,f,h,I,g;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,this.beforeCartOperationCheck()];case 1:return e.sent(),[4,n.addItemToCart({input:i({cartId:(null===(v=this.cart)||void 0===v?void 0:v.id)||null,item:{id:r.id,quantity:a,variant:{id:r.variant.id,name:r.variant.name,bundleProducts:null===(f=r.variant.bundleProducts)||void 0===f?void 0:f.map((function(t){return{id:t.id,productId:t.variant.productId||"",variantId:t.variant.id||"",quantity:t.quantity}}))}},acceptedOffers:this.getAcceptedOffers(o),options:this.createCartLineOptions(r),priceListId:s.getPriceListId()||null,salesChannelId:s.getSalesChannelId(),storefrontThemeId:s.getStorefrontThemeId(),metadata:{_fbp:l("_fbp"),_fbc:l("_fbc"),_ga:l("_ga")}},(null===(h=null==c?void 0:c.selectedVariant)||void 0===h?void 0:h.subscriptionPlan)&&(null===(I=null==c?void 0:c.selectedVariant)||void 0===I?void 0:I.subscriptionPlan.isSelected)?{subscriptionPlanId:null==c?void 0:c.selectedVariant.subscriptionPlan.subscriptionPlanId,subscriptionPlanPeriodId:null===(g=null==c?void 0:c.selectedVariant.subscriptionPlan.periods.find((function(t){return t.isSelected})))||void 0===g?void 0:g.id}:{})})];case 2:return(t=e.sent()).isSuccess&&t.data?[4,this.setCart(t.data)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&(u="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(p=r.quantity)>a?d.removeFromCart(r,p-a,this.cart):d.addToCart(r,a-p,u,this.cart,c)),this.removeCardIfEmpty(),[2,{success:t.isSuccess,response:t}];case 5:return m=e.sent(),console.log(m),[2,{success:!1}];case 6:return[2]}}))}))},this.createCart=function(i){return t(m,void 0,void 0,(function(){var t,r=this;return e(this,(function(e){switch(e.label){case 0:return[4,n.createCart({input:{items:i.variantLines.map((function(t){return{variant:{id:t.variantId},quantity:t.quantity}})),couponCode:i.couponCode,salesChannelId:s.getSalesChannelId(),storefrontThemeId:s.getStorefrontThemeId()}})];case 1:return(t=e.sent()).isSuccess&&t.data?[4,this.setCart(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return i.variantLines.forEach((function(t){if(r.cart){var e="".concat(r.cart.id,"-").concat(r.cart.updatedAt),i=r.cart.items.find((function(e){return e.variant.id===t.variantId}));i&&d.addToCart(i,t.quantity,e,r.cart)}})),[2,{success:t.isSuccess,response:t}]}}))}))},this.removeItem=function(i){return t(m,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.changeItemQuantity(i,0)];case 1:return[2,t.sent()]}}))}))},this.removeCart=function(){localStorage.removeItem("cartId"),m.cart=void 0},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){m.isCartLoadFinished&&(clearInterval(e),t(null))}),100)}))},this.getEditLineID=function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("editLineID")||""},this.findExistingItem=function(t,e){var i,r,n,a,o,s;if(!e.productOptionSetId&&!t.bundleSettings)return null===(i=m.cart)||void 0===i?void 0:i.orderLineItems.find((function(e){return e.variant.id===t.id}));if(t.bundleSettings){var d=m.getEditLineID();if(d)if(S=null===(r=m.cart)||void 0===r?void 0:r.orderLineItems.find((function(t){return t.id===d})))return S}var c=(null===(n=m.cart)||void 0===n?void 0:n.orderLineItems.filter((function(e){return e.variant.id===t.id})))||[];if(e.productOptionSetId)for(var u=m.getOptionValues(e),l=c.filter((function(t){var e;return(null===(e=t.options)||void 0===e?void 0:e.length)===u.length}))||[],p=0,v=l;p<v.length;p++){if((S=v[p]).options){for(var f=!0,h=function(t){var i=t.values.map((function(t){return t.value})),r=null===(s=null===(o=null===(a=e.productOptionSet)||void 0===a?void 0:a.options)||void 0===o?void 0:o.find((function(e){return e.id===t.productOptionId})))||void 0===s?void 0:s.values;if(!(f=f&&i.length===(null==r?void 0:r.length)&&i.every((function(t){return null==r?void 0:r.includes(t)}))))return"break"},I=0,g=S.options;I<g.length;I++){if("break"===h(g[I]))break}if(f){if(!t.bundleSettings)return S;if(m.isSameBundleItem(t,S))return S}}}else if(t.bundleSettings)for(var C=0,b=c;C<b.length;C++){var S=b[C];if(m.isSameBundleItem(t,S))return S}},this.isSameBundleItem=function(t,e){var i,r=null===(i=t.bundleSettings)||void 0===i?void 0:i.products,n=e.variant.bundleProducts;return!!r&&((null==r?void 0:r.length)===(null==n?void 0:n.length)&&(null==r?void 0:r.every((function(t){return!!(null==n?void 0:n.find((function(e){var i;return e.id===t.id&&e.quantity===t.quantity&&e.variant.id===(null===(i=t.product)||void 0===i?void 0:i.selectedVariant.id)})))}))))},this.saveCouponCode=function(i){return t(m,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.cart?[4,n.saveCartCouponCode({cartId:this.cart.id,couponCode:i})]:[2,{success:!1,validationError:p.EMPTY_CART}];case 1:return(t=e.sent()).isSuccess&&t.data&&(this.cart=t.data),[2,{success:t.isSuccess,response:t}]}}))}))},this.removeCouponCode=function(){return t(m,void 0,void 0,(function(){return e(this,(function(t){return[2,this.saveCouponCode(null)]}))}))},this.removeGiftCardLine=function(i){return t(m,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.cart?[4,n.removeGiftCardFromCart({cartId:this.cart.id,giftCardId:i})]:[2,{success:!1,validationError:p.EMPTY_CART}];case 1:return(t=e.sent()).isSuccess&&t.data&&(this.cart=t.data),[2,{success:t.isSuccess,response:t}]}}))}))},this.removeLoyaltyPointsFromCart=function(i){return t(m,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.cart?[4,n.removeLoyaltyPointsFromCart({cartId:this.cart.id,loyaltySpendingMethodId:i})]:[2,{success:!1,validationError:p.EMPTY_CART}];case 1:return(t=e.sent()).isSuccess&&t.data&&(this.cart=t.data),[2,{success:t.isSuccess,response:t}]}}))}))},this.saveCart=function(i){return t(m,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return(t=new c(i)).customer&&this.baseStore.customerStore.customer&&(t.customer.notificationsAccepted=this.baseStore.customerStore.customer.subscriptionStatus===o.SUBSCRIBED),[4,n.saveCart({input:t})];case 1:return[2,{success:(r=e.sent()).isSuccess,response:r}]}}))}))},this.removeCardIfEmpty=function(){var t;0===(null===(t=m.cart)||void 0===t?void 0:t.itemCount)&&m.removeCart()},this.getCart=function(){return t(m,void 0,void 0,(function(){var t,i,r,a,o,s;return e(this,(function(e){switch(e.label){case 0:if(!("undefined"!=typeof localStorage))return[2];e.label=1;case 1:return e.trys.push([1,6,7,8]),this._isLoadingCart=!0,t=null===(o=this.baseStore.customerStore.customer)||void 0===o?void 0:o.id,(i=(null===(s=this.cart)||void 0===s?void 0:s.id)||localStorage.getItem("cartId"))||t?[4,n.getCartById({id:i})]:[2];case 2:return(r=e.sent()).isSuccess&&r.data?[4,this.setCart(r.data)]:[3,4];case 3:return e.sent(),[3,5];case 4:this.removeCart(),e.label=5;case 5:return[3,8];case 6:return a=e.sent(),console.log(a),[3,8];case 7:return this._isLoadingCart=!1,this._isCartLoadFinished=!0,[7];case 8:return[2]}}))}))},this.setCart=function(i){return t(m,void 0,void 0,(function(){return e(this,(function(t){return localStorage.setItem("cartId",i.id),this.cart=i,[2]}))}))},this.beforeCartOperationCheck=function(){return t(m,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t=localStorage.getItem("cartId"),!this.cart||t?[3,1]:(this.removeCart(),[3,3]);case 1:return this.cart||!t?[3,3]:[4,this.getCart()];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))},this.createCartLineOptions=function(t){if(t&&t.options){for(var e=[],i=0,r=t.options;i<r.length;i++){var n=r[i],a={productOptionId:n.productOptionId,productOptionsSetId:n.productOptionsSetId,values:n.values.map((function(t){return t.value}))};e.push(a)}return e}return null},this.getOptionValues=function(t){var e,i=[];return null===(e=t.productOptionSet)||void 0===e||e.options.forEach((function(t){var e=t.values;t.type===a.DATE_PICKER&&(e=t.values.map((function(t){var e=new Date(t);return isNaN(e.getTime())?t:e.toISOString().split("T")[0]}))),t.values.length&&i.push({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:e})})),i},this._windowAddToCart=function(i){return t(m,void 0,void 0,(function(){var t,r,a,o,c,u,p,m,v,f,h;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,this.beforeCartOperationCheck()];case 1:return e.sent(),t=i.itemId?null===(v=this.cart)||void 0===v?void 0:v.items.find((function(t){return t.id===i.itemId})):null,[4,n.addItemToCart({input:{cartId:(null===(f=this.cart)||void 0===f?void 0:f.id)||null,item:{id:i.itemId||null,quantity:i.quantity,variant:{id:i.variantId}},priceListId:s.getPriceListId()||null,salesChannelId:s.getSalesChannelId(),storefrontThemeId:s.getStorefrontThemeId(),metadata:{_fbp:l("_fbp"),_fbc:l("_fbc"),_ga:l("_ga")}}})];case 2:return(r=e.sent()).isSuccess&&r.data?(i.itemId||(a=(null===(h=this.cart)||void 0===h?void 0:h.items.map((function(t){return t.id})))||[],o=r.data.items.map((function(t){return t.id})),(c=o.find((function(t){return!a.includes(t)})))&&(t=r.data.items.find((function(t){return t.id===c})))),[4,this.setCart(r.data)]):[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&t&&(u="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(p=i.quantity)>i.quantity?d.removeFromCart(t,p-i.quantity,this.cart):d.addToCart(t,i.quantity-p,u,this.cart)),this.removeCardIfEmpty(),[2,{success:r.isSuccess,response:r}];case 5:return m=e.sent(),console.log(m),[2,{success:!1}];case 6:return[2]}}))}))},this.baseStore=u,r(this)}return Object.defineProperty(m.prototype,"isLoadingCart",{get:function(){return this._isLoadingCart},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"isCartLoadFinished",{get:function(){return this._isCartLoadFinished},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"checkoutId",{get:function(){var t;return null===(t=this.cart)||void 0===t?void 0:t.id},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"checkoutUrl",{get:function(){if(this.checkoutId)return"/checkout/".concat(this.checkoutId,"?step=info")},enumerable:!1,configurable:!0}),m.prototype.getAcceptedOffers=function(t){var e=(null==t?void 0:t.filter((function(t){return t.isSelected&&!t.isAccepted})).map((function(t){return{campaignOfferId:t.campaignOfferId,campaignOfferProductId:t.campaignOfferProductId,productId:t.product.id,quantity:t.quantity,variantId:t.product.selectedVariant.id}})))||[];return e.length?e:void 0},m.prototype.createPayWithIkasSession=function(i,r,n){var a,o,d,c,l,p,m,v;return void 0===r&&(r=1),t(this,void 0,void 0,(function(){var t,f,h,I,g,C,b;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),t=n,n?[3,2]:(f=s.getSalesChannelId(),h=s.getStorefrontThemeId(),f&&h&&i?(I=i.selectedVariant)?[4,this.addItem(I,i,r,{isPayWithIkas:!0})]:[2,{success:!1,error:"No variant selected"}]:[2,{success:!1,error:"Missing storefront configuration"}]);case 1:if(!(g=e.sent()).success||!(null===(o=null===(a=g.response)||void 0===a?void 0:a.data)||void 0===o?void 0:o.id))return[2,{success:!1,error:(null===(l=null===(c=null===(d=g.response)||void 0===d?void 0:d.graphQLErrors)||void 0===c?void 0:c[0])||void 0===l?void 0:l.message)||"Failed to create cart"}];t=g.response.data.id,e.label=2;case 2:return t?[4,u({cartId:t})]:[2,{success:!1,error:"Failed to create cart"}];case 3:return!(C=e.sent()).data||(null===(p=C.graphQLErrors)||void 0===p?void 0:p.length)?[2,{success:!1,error:(null===(v=null===(m=C.graphQLErrors)||void 0===m?void 0:m[0])||void 0===v?void 0:v.message)||"Failed to create Pay with ikas session"}]:[2,{success:!0,payUrl:C.data.payUrl,expiresAt:C.data.expiresAt}];case 4:return[2,{success:!1,error:(b=e.sent())instanceof Error?b.message:"Unknown error occurred"}];case 5:return[2]}}))}))},m}();!function(t){t.INSUFFICIENT_STOCK="INSUFFICIENT_STOCK",t.INVALID_PRODUCT_OPTION_VALUES="INVALID_PRODUCT_OPTION_VALUES",t.EMPTY_CART="EMPTY_CART"}(p||(p={}));export{m as CART_LS_KEY,p as IkasCartOperationValidationError,v as IkasCartStore};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as i}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import n from"./api.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{IkasProductOptionType as a,IkasCustomerEmailSubscriptionStatus as o}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/region/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/address/ikas-localized-customer-address.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/customer-form-data-input/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/region/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/line-item/option/value/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/order-transaction-with-prices/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/transaction/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/campaign-offer/index.js";import"../../models/data/product/option-set/option/index.js";import"../../models/data/product/option-set/index.js";import"../../models/data/product/stock-location/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/shipping-zone/state/city/district/region/index.js";import"../../models/data/state/index.js";import"../../models/data/storefront-popup/storefront-popup-display-settings/index.js";import"../../models/data/storefront-popup/storefront-popup-page-filter/index.js";import"../../models/data/storefront-popup/index.js";import"../../models/data/theme-json/index.js";import"../../models/data/theme-json/component/index.js";import"../../models/data/theme-json/custom-data/index.js";import"../../models/data/variant-type/variant-value/index.js";import"@ikas/localized-address";import{IkasStorefrontConfig as s}from"@ikas/storefront-config";import{Analytics as d}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as u,createPayWithIkasSessionUrl as c}from"@ikas/storefront-api";import{getCookieValue as l}from"../../utils/helper.js";var p,m="cartId",v=function(){function m(c){var m=this;this.cart=null,this._isLoadingCart=!1,this._isCartLoadFinished=!1,this.addItem=function(r,a,o,u){return void 0===o&&(o=1),t(m,void 0,void 0,(function(){var t,c,m,v,f,h,I,g,C,b,S,y,j,x,O,P,_,T,L,E;return e(this,(function(e){switch(e.label){case 0:if(t=null!==(y=null==u?void 0:u.isPayWithIkas)&&void 0!==y&&y,this.checkBundleProductsStock(r,a).length>0)return[2,{success:!1,validationError:p.INSUFFICIENT_STOCK}];e.label=1;case 1:return e.trys.push([1,7,,8]),!t&&a.productOptionSetId&&!a.productOptionSet&&this.baseStore.router?(this.baseStore.router.push(a.productHref),[2,{success:!1,validationError:p.INVALID_PRODUCT_OPTION_VALUES}]):a.hasValidProductOptionValues?r.hasStock||r.sellIfOutOfStock?(c=void 0,t?[3,3]:[4,this.beforeCartOperationCheck()]):[2,{success:!1,validationError:p.INSUFFICIENT_STOCK}]:[2,{success:!1,validationError:p.INVALID_PRODUCT_OPTION_VALUES}];case 2:if(e.sent(),this.cart&&(c=this.findExistingItem(r,a))){if(null===(j=a.productOptionSet)||void 0===j||j.initOptionValues(),!r.bundleSettings)return[2,this.changeItemQuantity(c,c.quantity+1,a.offers,a)];if(!this.getEditLineID())return[2,this.changeItemQuantity(c,c.quantity+1,a.offers,a)]}e.label=3;case 3:return m=this.getOptionValues(a),v=o,(null==(f=null===(x=a.salesChannels)||void 0===x?void 0:x.find((function(t){return t.id===s.getSalesChannelId()})))?void 0:f.minQuantityPerCart)&&o<f.minQuantityPerCart&&(v=f.minQuantityPerCart),(null==f?void 0:f.maxQuantityPerCart)&&o>f.maxQuantityPerCart&&(v=f.maxQuantityPerCart),h=t?null:(null===(O=this.cart)||void 0===O?void 0:O.id)||localStorage.getItem("cartId"),[4,n.addItemToCart({input:i({cartId:h,item:{id:null!==(P=null==c?void 0:c.id)&&void 0!==P?P:null,quantity:null!==(_=null==c?void 0:c.quantity)&&void 0!==_?_:v,variant:{id:r.id,name:a.name,bundleProducts:null===(T=r.bundleSettings)||void 0===T?void 0:T.products.map((function(t){var e,i,r;return{id:t.id,productId:(null===(e=t.product)||void 0===e?void 0:e.id)||"",variantId:(null===(r=null===(i=t.product)||void 0===i?void 0:i.selectedVariant)||void 0===r?void 0:r.id)||"",quantity:t.quantity}}))}},acceptedOffers:this.getAcceptedOffers(a.offers),options:m.length?m:null,priceListId:s.getPriceListId()||null,salesChannelId:s.getSalesChannelId(),storefrontThemeId:s.getStorefrontThemeId(),metadata:{_fbp:l("_fbp"),_fbc:l("_fbc"),_ga:l("_ga")}},a.selectedVariant.subscriptionPlan&&a.selectedVariant.subscriptionPlan.isSelected?{subscriptionPlanId:a.selectedVariant.subscriptionPlan.subscriptionPlanId,subscriptionPlanPeriodId:null===(L=a.selectedVariant.subscriptionPlan.periods.find((function(t){return t.isSelected})))||void 0===L?void 0:L.id}:{})})];case 4:return I=e.sent(),t?[3,6]:I.isSuccess&&I.data?[4,this.setCart(I.data)]:[3,6];case 5:e.sent(),e.label=6;case 6:return(g=t?I.data:this.cart)&&(C="".concat(g.id,"-").concat(g.updatedAt),(b=g.items.find((function(t){return t.variant.id===r.id})))&&d.addToCart(b,o,C,g,a)),null===(E=a.productOptionSet)||void 0===E||E.initOptionValues(),[2,{success:I.isSuccess,response:I}];case 7:return S=e.sent(),console.log(S),[2,{success:!1}];case 8:return[2]}}))}))},this.changeItemQuantity=function(r,a,o,u){return t(m,void 0,void 0,(function(){var t,c,p,m,v,f,h,I,g;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,this.beforeCartOperationCheck()];case 1:return e.sent(),[4,n.addItemToCart({input:i({cartId:(null===(v=this.cart)||void 0===v?void 0:v.id)||null,item:{id:r.id,quantity:a,variant:{id:r.variant.id,name:r.variant.name,bundleProducts:null===(f=r.variant.bundleProducts)||void 0===f?void 0:f.map((function(t){return{id:t.id,productId:t.variant.productId||"",variantId:t.variant.id||"",quantity:t.quantity}}))}},acceptedOffers:this.getAcceptedOffers(o),options:this.createCartLineOptions(r),priceListId:s.getPriceListId()||null,salesChannelId:s.getSalesChannelId(),storefrontThemeId:s.getStorefrontThemeId(),metadata:{_fbp:l("_fbp"),_fbc:l("_fbc"),_ga:l("_ga")}},(null===(h=null==u?void 0:u.selectedVariant)||void 0===h?void 0:h.subscriptionPlan)&&(null===(I=null==u?void 0:u.selectedVariant)||void 0===I?void 0:I.subscriptionPlan.isSelected)?{subscriptionPlanId:null==u?void 0:u.selectedVariant.subscriptionPlan.subscriptionPlanId,subscriptionPlanPeriodId:null===(g=null==u?void 0:u.selectedVariant.subscriptionPlan.periods.find((function(t){return t.isSelected})))||void 0===g?void 0:g.id}:{})})];case 2:return(t=e.sent()).isSuccess&&t.data?[4,this.setCart(t.data)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&(c="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(p=r.quantity)>a?d.removeFromCart(r,p-a,this.cart):d.addToCart(r,a-p,c,this.cart,u)),this.removeCardIfEmpty(),[2,{success:t.isSuccess,response:t}];case 5:return m=e.sent(),console.log(m),[2,{success:!1}];case 6:return[2]}}))}))},this.createCart=function(i){return t(m,void 0,void 0,(function(){var t,r=this;return e(this,(function(e){switch(e.label){case 0:return[4,n.createCart({input:{items:i.variantLines.map((function(t){return{variant:{id:t.variantId},quantity:t.quantity}})),couponCode:i.couponCode,salesChannelId:s.getSalesChannelId(),storefrontThemeId:s.getStorefrontThemeId()}})];case 1:return(t=e.sent()).isSuccess&&t.data?[4,this.setCart(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return i.variantLines.forEach((function(t){if(r.cart){var e="".concat(r.cart.id,"-").concat(r.cart.updatedAt),i=r.cart.items.find((function(e){return e.variant.id===t.variantId}));i&&d.addToCart(i,t.quantity,e,r.cart)}})),[2,{success:t.isSuccess,response:t}]}}))}))},this.removeItem=function(i){return t(m,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,this.changeItemQuantity(i,0)];case 1:return[2,t.sent()]}}))}))},this.removeCart=function(){localStorage.removeItem("cartId"),m.cart=void 0},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){m.isCartLoadFinished&&(clearInterval(e),t(null))}),100)}))},this.getEditLineID=function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("editLineID")||""},this.findExistingItem=function(t,e){var i,r,n,a,o,s;if(!e.productOptionSetId&&!t.bundleSettings)return null===(i=m.cart)||void 0===i?void 0:i.orderLineItems.find((function(e){return e.variant.id===t.id}));if(t.bundleSettings){var d=m.getEditLineID();if(d)if(S=null===(r=m.cart)||void 0===r?void 0:r.orderLineItems.find((function(t){return t.id===d})))return S}var u=(null===(n=m.cart)||void 0===n?void 0:n.orderLineItems.filter((function(e){return e.variant.id===t.id})))||[];if(e.productOptionSetId)for(var c=m.getOptionValues(e),l=u.filter((function(t){var e;return(null===(e=t.options)||void 0===e?void 0:e.length)===c.length}))||[],p=0,v=l;p<v.length;p++){if((S=v[p]).options){for(var f=!0,h=function(t){var i=t.values.map((function(t){return t.value})),r=null===(s=null===(o=null===(a=e.productOptionSet)||void 0===a?void 0:a.options)||void 0===o?void 0:o.find((function(e){return e.id===t.productOptionId})))||void 0===s?void 0:s.values;if(!(f=f&&i.length===(null==r?void 0:r.length)&&i.every((function(t){return null==r?void 0:r.includes(t)}))))return"break"},I=0,g=S.options;I<g.length;I++){if("break"===h(g[I]))break}if(f){if(!t.bundleSettings)return S;if(m.isSameBundleItem(t,S))return S}}}else if(t.bundleSettings)for(var C=0,b=u;C<b.length;C++){var S=b[C];if(m.isSameBundleItem(t,S))return S}},this.isSameBundleItem=function(t,e){var i,r=null===(i=t.bundleSettings)||void 0===i?void 0:i.products,n=e.variant.bundleProducts;return!!r&&((null==r?void 0:r.length)===(null==n?void 0:n.length)&&(null==r?void 0:r.every((function(t){return!!(null==n?void 0:n.find((function(e){var i;return e.id===t.id&&e.quantity===t.quantity&&e.variant.id===(null===(i=t.product)||void 0===i?void 0:i.selectedVariant.id)})))}))))},this.saveCouponCode=function(i){return t(m,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.cart?[4,n.saveCartCouponCode({cartId:this.cart.id,couponCode:i})]:[2,{success:!1,validationError:p.EMPTY_CART}];case 1:return(t=e.sent()).isSuccess&&t.data&&(this.cart=t.data),[2,{success:t.isSuccess,response:t}]}}))}))},this.removeCouponCode=function(){return t(m,void 0,void 0,(function(){return e(this,(function(t){return[2,this.saveCouponCode(null)]}))}))},this.removeGiftCardLine=function(i){return t(m,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.cart?[4,n.removeGiftCardFromCart({cartId:this.cart.id,giftCardId:i})]:[2,{success:!1,validationError:p.EMPTY_CART}];case 1:return(t=e.sent()).isSuccess&&t.data&&(this.cart=t.data),[2,{success:t.isSuccess,response:t}]}}))}))},this.removeLoyaltyPointsFromCart=function(i){return t(m,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.cart?[4,n.removeLoyaltyPointsFromCart({cartId:this.cart.id,loyaltySpendingMethodId:i})]:[2,{success:!1,validationError:p.EMPTY_CART}];case 1:return(t=e.sent()).isSuccess&&t.data&&(this.cart=t.data),[2,{success:t.isSuccess,response:t}]}}))}))},this.saveCart=function(i){return t(m,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return(t=new u(i)).customer&&this.baseStore.customerStore.customer&&(t.customer.notificationsAccepted=this.baseStore.customerStore.customer.subscriptionStatus===o.SUBSCRIBED),[4,n.saveCart({input:t})];case 1:return[2,{success:(r=e.sent()).isSuccess,response:r}]}}))}))},this.removeCardIfEmpty=function(){var t;0===(null===(t=m.cart)||void 0===t?void 0:t.itemCount)&&m.removeCart()},this.getCart=function(){return t(m,void 0,void 0,(function(){var t,i,r,a,o,s;return e(this,(function(e){switch(e.label){case 0:if(!("undefined"!=typeof localStorage))return[2];e.label=1;case 1:return e.trys.push([1,6,7,8]),this._isLoadingCart=!0,t=null===(o=this.baseStore.customerStore.customer)||void 0===o?void 0:o.id,(i=(null===(s=this.cart)||void 0===s?void 0:s.id)||localStorage.getItem("cartId"))||t?[4,n.getCartById({id:i})]:[2];case 2:return(r=e.sent()).isSuccess&&r.data?[4,this.setCart(r.data)]:[3,4];case 3:return e.sent(),[3,5];case 4:this.removeCart(),e.label=5;case 5:return[3,8];case 6:return a=e.sent(),console.log(a),[3,8];case 7:return this._isLoadingCart=!1,this._isCartLoadFinished=!0,[7];case 8:return[2]}}))}))},this.setCart=function(i){return t(m,void 0,void 0,(function(){return e(this,(function(t){return localStorage.setItem("cartId",i.id),this.cart=i,[2]}))}))},this.beforeCartOperationCheck=function(){return t(m,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return t=localStorage.getItem("cartId"),!this.cart||t?[3,1]:(this.removeCart(),[3,3]);case 1:return this.cart||!t?[3,3]:[4,this.getCart()];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))},this.createCartLineOptions=function(t){if(t&&t.options){for(var e=[],i=0,r=t.options;i<r.length;i++){var n=r[i],a={productOptionId:n.productOptionId,productOptionsSetId:n.productOptionsSetId,values:n.values.map((function(t){return t.value}))};e.push(a)}return e}return null},this.getOptionValues=function(t){var e,i=[];return null===(e=t.productOptionSet)||void 0===e||e.options.forEach((function(t){var e=t.values;t.type===a.DATE_PICKER&&(e=t.values.map((function(t){var e=new Date(t);return isNaN(e.getTime())?t:e.toISOString().split("T")[0]}))),t.values.length&&i.push({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:e})})),i},this.checkBundleProductsStock=function(t,e){var i,r=null===(i=t.bundleSettings)||void 0===i?void 0:i.products,n=null==r?void 0:r.reduce((function(t,e){var i,r=null===(i=e.product)||void 0===i?void 0:i.selectedVariant;return null==(null==r?void 0:r.id)||r.sellIfOutOfStock||(t[r.id]=r.stock),t}),{}),a=null==r?void 0:r.reduce((function(t,e){var i,r,n=null===(i=e.product)||void 0===i?void 0:i.selectedVariant;return null==(null==n?void 0:n.id)||n.sellIfOutOfStock||(t[n.id]=(null!==(r=t[n.id])&&void 0!==r?r:0)+e.quantity),t}),{}),o=Object.entries(null!=a?a:{}).filter((function(t){var e,i=t[0];return t[1]>(null!==(e=null==n?void 0:n[i])&&void 0!==e?e:0)})).map((function(t){var e,i=t[0];return{variantId:i,neededQuantity:t[1],availableStock:null!==(e=null==n?void 0:n[i])&&void 0!==e?e:0}}));return o},this._windowAddToCart=function(i){return t(m,void 0,void 0,(function(){var t,r,a,o,u,c,p,m,v,f,h;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),[4,this.beforeCartOperationCheck()];case 1:return e.sent(),t=i.itemId?null===(v=this.cart)||void 0===v?void 0:v.items.find((function(t){return t.id===i.itemId})):null,[4,n.addItemToCart({input:{cartId:(null===(f=this.cart)||void 0===f?void 0:f.id)||null,item:{id:i.itemId||null,quantity:i.quantity,variant:{id:i.variantId}},priceListId:s.getPriceListId()||null,salesChannelId:s.getSalesChannelId(),storefrontThemeId:s.getStorefrontThemeId(),metadata:{_fbp:l("_fbp"),_fbc:l("_fbc"),_ga:l("_ga")}}})];case 2:return(r=e.sent()).isSuccess&&r.data?(i.itemId||(a=(null===(h=this.cart)||void 0===h?void 0:h.items.map((function(t){return t.id})))||[],o=r.data.items.map((function(t){return t.id})),(u=o.find((function(t){return!a.includes(t)})))&&(t=r.data.items.find((function(t){return t.id===u})))),[4,this.setCart(r.data)]):[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&t&&(c="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(p=i.quantity)>i.quantity?d.removeFromCart(t,p-i.quantity,this.cart):d.addToCart(t,i.quantity-p,c,this.cart)),this.removeCardIfEmpty(),[2,{success:r.isSuccess,response:r}];case 5:return m=e.sent(),console.log(m),[2,{success:!1}];case 6:return[2]}}))}))},this.baseStore=c,r(this)}return Object.defineProperty(m.prototype,"isLoadingCart",{get:function(){return this._isLoadingCart},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"isCartLoadFinished",{get:function(){return this._isCartLoadFinished},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"checkoutId",{get:function(){var t;return null===(t=this.cart)||void 0===t?void 0:t.id},enumerable:!1,configurable:!0}),Object.defineProperty(m.prototype,"checkoutUrl",{get:function(){if(this.checkoutId)return"/checkout/".concat(this.checkoutId,"?step=info")},enumerable:!1,configurable:!0}),m.prototype.getAcceptedOffers=function(t){var e=(null==t?void 0:t.filter((function(t){return t.isSelected&&!t.isAccepted})).map((function(t){return{campaignOfferId:t.campaignOfferId,campaignOfferProductId:t.campaignOfferProductId,productId:t.product.id,quantity:t.quantity,variantId:t.product.selectedVariant.id}})))||[];return e.length?e:void 0},m.prototype.createPayWithIkasSession=function(i,r,n){var a,o,d,u,l,p,m,v;return void 0===r&&(r=1),t(this,void 0,void 0,(function(){var t,f,h,I,g,C,b;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,4,,5]),t=n,n?[3,2]:(f=s.getSalesChannelId(),h=s.getStorefrontThemeId(),f&&h&&i?(I=i.selectedVariant)?[4,this.addItem(I,i,r,{isPayWithIkas:!0})]:[2,{success:!1,error:"No variant selected"}]:[2,{success:!1,error:"Missing storefront configuration"}]);case 1:if(!(g=e.sent()).success||!(null===(o=null===(a=g.response)||void 0===a?void 0:a.data)||void 0===o?void 0:o.id))return[2,{success:!1,error:(null===(l=null===(u=null===(d=g.response)||void 0===d?void 0:d.graphQLErrors)||void 0===u?void 0:u[0])||void 0===l?void 0:l.message)||"Failed to create cart"}];t=g.response.data.id,e.label=2;case 2:return t?[4,c({cartId:t})]:[2,{success:!1,error:"Failed to create cart"}];case 3:return!(C=e.sent()).data||(null===(p=C.graphQLErrors)||void 0===p?void 0:p.length)?[2,{success:!1,error:(null===(v=null===(m=C.graphQLErrors)||void 0===m?void 0:m[0])||void 0===v?void 0:v.message)||"Failed to create Pay with ikas session"}]:[2,{success:!0,payUrl:C.data.payUrl,expiresAt:C.data.expiresAt}];case 4:return[2,{success:!1,error:(b=e.sent())instanceof Error?b.message:"Unknown error occurred"}];case 5:return[2]}}))}))},m}();!function(t){t.INSUFFICIENT_STOCK="INSUFFICIENT_STOCK",t.INVALID_PRODUCT_OPTION_VALUES="INVALID_PRODUCT_OPTION_VALUES",t.EMPTY_CART="EMPTY_CART"}(p||(p={}));export{m as CART_LS_KEY,p as IkasCartOperationValidationError,v as IkasCartStore};
|
|
@@ -9,8 +9,8 @@ export default class CheckoutStore {
|
|
|
9
9
|
static getDigitalProductFileDownloadUrl(params: GetDigitalProductFileDownloadUrlQueryParams): Promise<APIResponse<string>>;
|
|
10
10
|
static getOrderInvoicePdfUrl(params: GetOrderInvoicePdfUrlQueryParams): Promise<APIResponse<string>>;
|
|
11
11
|
static retrieveInstallmentInfo(params: RetrieveInstallmentInfoQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api").RetrieveInstallmentInfoResponse>>;
|
|
12
|
-
static checkStocks(params: CheckStocksQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api/
|
|
13
|
-
static checkCartStocks(params: CheckCartStocksQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api/
|
|
12
|
+
static checkStocks(params: CheckStocksQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api/build/__api/types").CheckStocksResponse>>;
|
|
13
|
+
static checkCartStocks(params: CheckCartStocksQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api/build/__api/types").CheckStocksResponse>>;
|
|
14
14
|
static listCheckoutSettings(params: ListCheckoutSettingsQueryParams): Promise<APIResponse<IkasCheckoutSettings[]>>;
|
|
15
15
|
static getAvailableShippingCountries(params: GetAvailableShippingCountriesQueryParams): Promise<APIResponse<undefined> | APIResponse<string[]>>;
|
|
16
16
|
static listStockLocation(params: ListStockLocationQueryParams): Promise<APIResponse<IkasStockLocation[]>>;
|
|
@@ -23,6 +23,6 @@ export default class CheckoutStore {
|
|
|
23
23
|
static updatePaypalOrder(params: UpdatePayPalOrderParams): Promise<APIResponse<boolean>>;
|
|
24
24
|
static hepsipayFrameInit(params: HepsipayFrameInitParams): Promise<APIResponse<import("@ikas/storefront-api").HepsipayFrameInitResponse>>;
|
|
25
25
|
static createIyzicoCheckoutForm(params: CreateIyzicoCheckoutFormParams): Promise<APIResponse<import("@ikas/storefront-api").CreateIyzicoCheckoutFormResponse>>;
|
|
26
|
-
static createStripeExpressCheckoutSession(params: CreateStripeExpressCheckoutSessionParams): Promise<APIResponse<import("@ikas/storefront-api/
|
|
27
|
-
static updateStripeExpressCheckoutSession(params: UpdateStripeExpressCheckoutSessionParams): Promise<APIResponse<import("@ikas/storefront-api/
|
|
26
|
+
static createStripeExpressCheckoutSession(params: CreateStripeExpressCheckoutSessionParams): Promise<APIResponse<import("@ikas/storefront-api/build/__api/types").CreateStripeExpressCheckoutSessionResponse>>;
|
|
27
|
+
static updateStripeExpressCheckoutSession(params: UpdateStripeExpressCheckoutSessionParams): Promise<APIResponse<import("@ikas/storefront-api/build/__api/types").StripeExpressCheckoutSessionContextResponse>>;
|
|
28
28
|
}
|
|
@@ -23,10 +23,10 @@ export default class CustomerStoreAPI {
|
|
|
23
23
|
token: string;
|
|
24
24
|
tokenExpiry: number;
|
|
25
25
|
} | null>>;
|
|
26
|
-
static refreshToken(params: CustomerRefreshTokenQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api/
|
|
26
|
+
static refreshToken(params: CustomerRefreshTokenQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api/build/__api/types").CustomerRefreshTokenResponse>>;
|
|
27
27
|
static forgotPassword(params: CustomerForgotPasswordQueryParams): Promise<APIResponse<undefined> | APIResponse<boolean>>;
|
|
28
28
|
static recoverPassword(params: CustomerRecoverPasswordQueryParams): Promise<APIResponse<undefined> | APIResponse<boolean>>;
|
|
29
|
-
static checkEmail(params: CheckCustomerEmailQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api/
|
|
29
|
+
static checkEmail(params: CheckCustomerEmailQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api/build/__api/types").CustomerCheckResponse>>;
|
|
30
30
|
static getCustomer(): Promise<APIResponse<IkasCustomer | null>>;
|
|
31
31
|
static saveCustomer(params: SaveMyCustomerQueryParams): Promise<APIResponse<IkasCustomer | null>>;
|
|
32
32
|
static getOrders(params: GetCustomerOrdersQueryParams): Promise<APIResponse<IkasOrder[]>>;
|
|
@@ -36,7 +36,7 @@ export default class CustomerStoreAPI {
|
|
|
36
36
|
static createOrderRefundRequest(params: CreateOrderRefundRequestQueryParams): Promise<APIResponse<IkasOrder | null>>;
|
|
37
37
|
static subscribeToMarketingNotifications(params: SubscribeToMarketingNotificationsQueryParams): Promise<APIResponse<undefined> | APIResponse<boolean>>;
|
|
38
38
|
static getLastViewedProducts(params: GetLastViewedProductsQueryParams): Promise<APIResponse<IkasLastViewedProduct[]>>;
|
|
39
|
-
static saveLastViewedProducts(params: SaveLastViewedProductsQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api/
|
|
39
|
+
static saveLastViewedProducts(params: SaveLastViewedProductsQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api/build/__api/types").ProductLastViewed>>;
|
|
40
40
|
static listOrderRefundSettings(params: ListOrderRefundSettingsQueryParams): Promise<APIResponse<IkasOrderRefundSettings[]>>;
|
|
41
41
|
static sendContactFormToMerchant(params: SendContactFormToMerchantQueryParams): Promise<APIResponse<undefined> | APIResponse<boolean>>;
|
|
42
42
|
static listFavoriteProducts(): Promise<APIResponse<IkasFavoriteProduct[]>>;
|
|
@@ -8,16 +8,16 @@ import { IkasFilterCategory } from "../../models/data/filter-category";
|
|
|
8
8
|
import { IkasProductStockLocations } from "../../models/data/product/stock-location";
|
|
9
9
|
import { IkasCampaignOffer } from "../../models";
|
|
10
10
|
export default class ProductStore {
|
|
11
|
-
static listProductBackInStockRemind(params: ListProductBackInStockRemindQueryParams): Promise<APIResponse<import("@ikas/storefront-api/
|
|
12
|
-
static saveProductBackInStockRemind(params: SaveProductBackInStockRemindQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api/
|
|
11
|
+
static listProductBackInStockRemind(params: ListProductBackInStockRemindQueryParams): Promise<APIResponse<import("@ikas/storefront-api/build/__api/types").ProductBackInStockRemind[]> | APIResponse<undefined>>;
|
|
12
|
+
static saveProductBackInStockRemind(params: SaveProductBackInStockRemindQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api/build/__api/types").ProductBackInStockRemind>>;
|
|
13
13
|
static searchProducts(params: SearchProductsQueryParams, excludedFields?: string[] | null): Promise<APIResponse<{
|
|
14
14
|
data: IkasProduct[] | undefined;
|
|
15
15
|
count?: number | undefined;
|
|
16
|
-
facets?: import("@ikas/storefront-api/
|
|
16
|
+
facets?: import("@ikas/storefront-api/build/__api/types").ProductFacetCount[] | null | undefined;
|
|
17
17
|
limit?: number | undefined;
|
|
18
18
|
page?: number | undefined;
|
|
19
|
-
results?: import("@ikas/storefront-api/
|
|
20
|
-
suggestions?: import("@ikas/storefront-api/
|
|
19
|
+
results?: import("@ikas/storefront-api/build/__api/types").SearchProduct[] | undefined;
|
|
20
|
+
suggestions?: import("@ikas/storefront-api/build/__api/types").SearchSuggestion[] | null | undefined;
|
|
21
21
|
totalCount?: number | undefined;
|
|
22
22
|
locale: string;
|
|
23
23
|
}>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ikas/storefront",
|
|
3
|
-
"version": "6.1.0-beta.
|
|
3
|
+
"version": "6.1.0-beta.342",
|
|
4
4
|
"description": "Storefront functionality for ikas storefront themes.",
|
|
5
5
|
"author": "ikas",
|
|
6
6
|
"license": "ISC",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"swiper": "11.0.6"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@ikas/storefront-api": "^6.1.0-beta.
|
|
27
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
28
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
29
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
30
|
-
"@ikas/storefront-providers": "^6.1.0-beta.
|
|
26
|
+
"@ikas/storefront-api": "^6.1.0-beta.342",
|
|
27
|
+
"@ikas/storefront-config": "^6.1.0-beta.342",
|
|
28
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.342",
|
|
29
|
+
"@ikas/storefront-models": "^6.1.0-beta.342",
|
|
30
|
+
"@ikas/storefront-providers": "^6.1.0-beta.342",
|
|
31
31
|
"@ikas/localized-address": "1.0.0-beta.6",
|
|
32
32
|
"@adyen/adyen-web": "^5.57.0",
|
|
33
33
|
"@rollup/plugin-commonjs": "^22.0.0",
|
|
@@ -62,11 +62,11 @@
|
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"@ikas/localized-address": "1.0.0-beta.6",
|
|
65
|
-
"@ikas/storefront-api": "^6.1.0-beta.
|
|
66
|
-
"@ikas/storefront-config": "^6.1.0-beta.
|
|
67
|
-
"@ikas/storefront-model-functions": "^6.1.0-beta.
|
|
68
|
-
"@ikas/storefront-models": "^6.1.0-beta.
|
|
69
|
-
"@ikas/storefront-providers": "^6.1.0-beta.
|
|
65
|
+
"@ikas/storefront-api": "^6.1.0-beta.342",
|
|
66
|
+
"@ikas/storefront-config": "^6.1.0-beta.342",
|
|
67
|
+
"@ikas/storefront-model-functions": "^6.1.0-beta.342",
|
|
68
|
+
"@ikas/storefront-models": "^6.1.0-beta.342",
|
|
69
|
+
"@ikas/storefront-providers": "^6.1.0-beta.342",
|
|
70
70
|
"mobx": "^6.1.3",
|
|
71
71
|
"mobx-react-lite": "^3.1.5",
|
|
72
72
|
"next": "12.2.0",
|