@ikas/storefront 5.0.0-beta.9 → 5.0.1
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 +4 -0
- package/build/analytics/analytics.js +1 -1
- package/build/analytics/facebookPixel.d.ts +1 -0
- package/build/analytics/facebookPixel.js +1 -1
- package/build/analytics/googleAnalytics.d.ts +1 -0
- package/build/analytics/googleAnalytics.js +1 -1
- package/build/analytics/googleTagManager.d.ts +12 -21
- package/build/analytics/googleTagManager.js +1 -1
- package/build/analytics/head/index.js +1 -1
- package/build/analytics/ikas.d.ts +2 -1
- package/build/analytics/ikas.js +1 -1
- package/build/analytics/tiktokPixel.d.ts +1 -0
- package/build/analytics/tiktokPixel.js +1 -1
- package/build/components/checkout/components/address-form/index.js +1 -1
- package/build/components/checkout/components/address-form/model.d.ts +13 -2
- package/build/components/checkout/components/address-form/model.js +1 -1
- package/build/components/checkout/components/cart-summary/cart-item/bundle-product-item/index.d.ts +7 -0
- package/build/components/checkout/components/cart-summary/cart-item/bundle-product-item/index.js +1 -0
- package/build/components/checkout/components/cart-summary/cart-item/bundle-product-item/style.module.scss.js +1 -0
- package/build/components/checkout/components/cart-summary/cart-item/index.d.ts +1 -0
- package/build/components/checkout/components/cart-summary/cart-item/index.js +1 -1
- package/build/components/checkout/components/cart-summary/cart-item/style.module.scss.js +1 -1
- package/build/components/checkout/components/cart-summary/cart-item/svg/arrow-down.d.ts +2 -0
- package/build/components/checkout/components/cart-summary/cart-item/svg/arrow-down.js +1 -0
- package/build/components/checkout/components/cart-summary/index.d.ts +11 -0
- package/build/components/checkout/components/cart-summary/index.js +1 -1
- package/build/components/checkout/components/cart-summary/style.module.scss.js +1 -1
- package/build/components/checkout/components/credit-card-form/model.js +1 -1
- package/build/components/checkout/components/customer-addresses/index.js +1 -1
- package/build/components/checkout/components/customer-addresses/model.js +1 -1
- package/build/components/checkout/components/customer-addresses/style.module.scss.js +1 -1
- package/build/components/checkout/components/epaykolay-button/index.d.ts +5 -0
- package/build/components/checkout/components/epaykolay-button/index.js +1 -0
- package/build/components/checkout/components/epaykolay-button/style.module.scss.js +1 -0
- package/build/components/checkout/components/error/customer-account-disabled-error/index.d.ts +8 -0
- package/build/components/checkout/components/error/customer-account-disabled-error/index.js +1 -0
- package/build/components/checkout/components/error/customer-login-required-error/index.js +1 -1
- package/build/components/checkout/components/error/index.js +1 -1
- package/build/components/checkout/components/form-item/index.js +1 -1
- package/build/components/checkout/components/form-item/model.js +1 -1
- package/build/components/checkout/components/notification-box/index.d.ts +2 -0
- package/build/components/checkout/components/notification-box/index.js +1 -1
- package/build/components/checkout/components/offer-product/index.js +1 -1
- package/build/components/checkout/components/paypal/index.d.ts +7 -0
- package/build/components/checkout/components/paypal/index.js +1 -0
- package/build/components/checkout/components/paypal/style.module.scss.js +1 -0
- package/build/components/checkout/components/product-files/index.d.ts +7 -0
- package/build/components/checkout/components/product-files/index.js +1 -0
- package/build/components/checkout/components/product-files/style.module.scss.js +1 -0
- package/build/components/checkout/components/quick-registration/model.js +1 -1
- package/build/components/checkout/components/select-box/index.d.ts +1 -0
- package/build/components/checkout/components/select-box/index.js +1 -1
- package/build/components/checkout/components/stripe/index.js +1 -1
- package/build/components/checkout/components/svg/epaykolay.d.ts +6 -0
- package/build/components/checkout/components/svg/epaykolay.js +1 -0
- package/build/components/checkout/components/toggle/index.d.ts +1 -0
- package/build/components/checkout/components/toggle/index.js +1 -1
- package/build/components/checkout/components/toggle/style.module.scss.js +1 -1
- package/build/components/checkout/index.d.ts +2 -0
- package/build/components/checkout/index.js +1 -1
- package/build/components/checkout/model.d.ts +44 -17
- package/build/components/checkout/model.js +1 -1
- package/build/components/checkout/steps/step-payment/index.js +1 -1
- package/build/components/checkout/steps/step-payment/payment-gateways/index.js +1 -1
- package/build/components/checkout/steps/step-payment/style.module.scss.js +1 -1
- package/build/components/checkout/steps/step-shipping/index.js +1 -1
- package/build/components/checkout/steps/step-success/index.js +1 -1
- package/build/components/checkout/steps/step-success/style.module.scss.js +1 -1
- package/build/components/checkout/style.module.scss.js +1 -1
- package/build/components/google-captcha/index.js +1 -1
- package/build/components/link/index.js +1 -1
- package/build/components/page/head.js +1 -1
- package/build/components/page/index.js +1 -1
- package/build/components/page-editor/ThemeComponentEditor.js +1 -1
- package/build/components/page-editor/model.d.ts +1 -0
- package/build/components/page-editor/model.js +1 -1
- package/build/hooks/useCustomerReviews.js +1 -1
- package/build/hooks/useStore.js +1 -1
- package/build/index.js +1 -1
- package/build/models/data/cart/available-shipping-method/estimated-delivery-time/index.d.ts +6 -0
- package/build/models/data/cart/available-shipping-method/estimated-delivery-time/index.js +1 -0
- package/build/models/data/cart/available-shipping-method/index.d.ts +2 -0
- package/build/models/data/cart/available-shipping-method/index.js +1 -1
- package/build/models/data/category/conditions/index.d.ts +21 -0
- package/build/models/data/category/conditions/index.js +1 -0
- package/build/models/data/category/index.d.ts +3 -0
- package/build/models/data/category/index.js +1 -1
- package/build/models/data/checkout/index.d.ts +2 -2
- package/build/models/data/checkout-settings/index.d.ts +2 -1
- package/build/models/data/checkout-settings/index.js +1 -1
- package/build/models/data/checkout-settings/price/index.d.ts +2 -1
- package/build/models/data/checkout-settings/price/index.js +1 -1
- package/build/models/data/contact-form/index.d.ts +1 -0
- package/build/models/data/contact-form/index.js +1 -1
- package/build/models/data/customer/address/ikas-localized-customer-address.d.ts +26 -12
- package/build/models/data/customer/address/ikas-localized-customer-address.js +1 -1
- package/build/models/data/customer/address/index.d.ts +5 -0
- package/build/models/data/customer/address/index.js +1 -1
- package/build/models/data/customer/address/region/index.d.ts +6 -0
- package/build/models/data/customer/address/region/index.js +1 -0
- package/build/models/data/customer/index.d.ts +7 -0
- package/build/models/data/customer/index.js +1 -1
- package/build/models/data/customer/price-list-rule/filter/index.d.ts +7 -0
- package/build/models/data/customer/price-list-rule/filter/index.js +1 -0
- package/build/models/data/customer/price-list-rule/index.d.ts +10 -0
- package/build/models/data/customer/price-list-rule/index.js +1 -0
- package/build/models/data/customer/review/index.d.ts +1 -0
- package/build/models/data/customer/review/index.js +1 -1
- package/build/models/data/favorite-product/index.d.ts +2 -0
- package/build/models/data/favorite-product/index.js +1 -1
- package/build/models/data/filter-category/index.d.ts +4 -0
- package/build/models/data/filter-category/index.js +1 -1
- package/build/models/data/html-meta-data/translations/index.d.ts +1 -0
- package/build/models/data/html-meta-data/translations/index.js +1 -1
- package/build/models/data/image/index.d.ts +1 -0
- package/build/models/data/image/index.js +1 -1
- package/build/models/data/index.d.ts +15 -1
- package/build/models/data/order/address/ikas-localized-order-address.d.ts +48 -18
- package/build/models/data/order/address/ikas-localized-order-address.js +1 -1
- package/build/models/data/order/address/index.d.ts +5 -0
- package/build/models/data/order/address/index.js +1 -1
- package/build/models/data/order/address/region/index.d.ts +6 -0
- package/build/models/data/order/address/region/index.js +1 -0
- package/build/models/data/order/index.d.ts +3 -0
- package/build/models/data/order/index.js +1 -1
- package/build/models/data/order/line-item/index.d.ts +5 -0
- package/build/models/data/order/line-item/index.js +1 -1
- package/build/models/data/order/line-item/variant/bundle-product/bundle-variant/index.d.ts +33 -0
- package/build/models/data/order/line-item/variant/bundle-product/bundle-variant/index.js +1 -0
- package/build/models/data/order/line-item/variant/bundle-product/index.d.ts +15 -0
- package/build/models/data/order/line-item/variant/bundle-product/index.js +1 -0
- package/build/models/data/order/line-item/variant/index.d.ts +4 -0
- package/build/models/data/order/line-item/variant/index.js +1 -1
- package/build/models/data/order/transaction/index.d.ts +1 -0
- package/build/models/data/order/transaction/index.js +1 -1
- package/build/models/data/order/transaction/payment-method-detail/index.d.ts +1 -0
- package/build/models/data/order/transaction/payment-method-detail/index.js +1 -1
- package/build/models/data/product/campaign-offer/index.d.ts +15 -0
- package/build/models/data/product/campaign-offer/index.js +1 -0
- package/build/models/data/product/filter/index.d.ts +2 -0
- package/build/models/data/product/filter/index.js +1 -1
- package/build/models/data/product/group/index.d.ts +11 -0
- package/build/models/data/product/group/index.js +1 -0
- package/build/models/data/product/group/translation/index.d.ts +13 -0
- package/build/models/data/product/group/translation/index.js +1 -0
- package/build/models/data/product/group/value/index.d.ts +7 -0
- package/build/models/data/product/group/value/index.js +1 -0
- package/build/models/data/product/image/index.d.ts +1 -0
- package/build/models/data/product/image/index.js +1 -1
- package/build/models/data/product/index.d.ts +34 -1
- package/build/models/data/product/index.js +1 -1
- package/build/models/data/product/variant/bundle-settings/bundle-product/index.d.ts +28 -0
- package/build/models/data/product/variant/bundle-settings/bundle-product/index.js +1 -0
- package/build/models/data/product/variant/bundle-settings/index.d.ts +8 -0
- package/build/models/data/product/variant/bundle-settings/index.js +1 -0
- package/build/models/data/product/variant/index.d.ts +35 -3
- package/build/models/data/product/variant/index.js +1 -1
- package/build/models/data/product/variant/price/index.d.ts +26 -0
- package/build/models/data/product/variant/price/index.js +1 -1
- package/build/models/data/product/variant/price/product-campaign-price/index.d.ts +6 -0
- package/build/models/data/product/variant/price/product-campaign-price/index.js +1 -0
- package/build/models/data/product-file/index.d.ts +8 -0
- package/build/models/data/product-file/index.js +1 -0
- package/build/models/data/shipping-zone/index.d.ts +9 -0
- package/build/models/data/shipping-zone/index.js +1 -0
- package/build/models/data/shipping-zone/state/city/district/index.d.ts +7 -0
- package/build/models/data/shipping-zone/state/city/district/index.js +1 -0
- package/build/models/data/shipping-zone/state/city/district/region/index.d.ts +6 -0
- package/build/models/data/shipping-zone/state/city/district/region/index.js +1 -0
- package/build/models/data/shipping-zone/state/city/index.d.ts +8 -0
- package/build/models/data/shipping-zone/state/city/index.js +1 -0
- package/build/models/data/shipping-zone/state/index.d.ts +9 -0
- package/build/models/data/shipping-zone/state/index.js +1 -0
- package/build/models/data/storefront/b2b-settings/index.d.ts +8 -0
- package/build/models/data/storefront/b2b-settings/index.js +1 -0
- package/build/models/data/storefront/index-page-seo-setting/index.d.ts +17 -0
- package/build/models/data/storefront/index-page-seo-setting/index.js +1 -0
- package/build/models/data/storefront/index.d.ts +6 -1
- package/build/models/data/storefront/index.js +1 -1
- package/build/models/data/theme-json/component/index.d.ts +2 -0
- package/build/models/data/theme-json/component/index.js +1 -1
- package/build/models/data/theme-json/component/prop/index.d.ts +2 -0
- package/build/models/data/theme-json/component/prop/index.js +1 -1
- package/build/models/data/theme-json/custom-data/index.d.ts +2 -0
- package/build/models/data/theme-json/custom-data/index.js +1 -1
- package/build/models/data/theme-json/index.js +1 -1
- package/build/models/data/video/index.d.ts +11 -0
- package/build/models/data/video/index.js +1 -0
- package/build/models/ui/blog-category-list/index.js +1 -1
- package/build/models/ui/brand-list/index.js +1 -1
- package/build/models/ui/category-list/index.js +1 -1
- package/build/models/ui/customer-review-list/index.js +1 -1
- package/build/models/ui/customer-review-summary-list/index.js +1 -1
- package/build/models/ui/index.d.ts +1 -1
- package/build/models/ui/product-attribute-list/index.js +1 -1
- package/build/models/ui/product-list/index.d.ts +25 -3
- package/build/models/ui/product-list/index.js +1 -1
- package/build/models/ui/raffle-list/index.js +1 -1
- package/build/models/ui/validator/form/account-info.js +1 -1
- package/build/models/ui/validator/form/address.js +1 -1
- package/build/models/ui/validator/form/contact-form.d.ts +6 -0
- package/build/models/ui/validator/form/contact-form.js +1 -1
- package/build/models/ui/validator/form/ikas-address.d.ts +46 -20
- package/build/models/ui/validator/form/ikas-address.js +1 -1
- package/build/models/ui/validator/form/login.d.ts +7 -4
- package/build/models/ui/validator/form/login.js +1 -1
- package/build/models/ui/validator/form/register.d.ts +10 -1
- package/build/models/ui/validator/form/register.js +1 -1
- package/build/page-data-init/index.d.ts +9 -1
- package/build/page-data-init/index.js +1 -1
- package/build/pages/account/activate.d.ts +4 -0
- package/build/pages/account/activate.js +1 -0
- package/build/pages/checkout.js +1 -1
- package/build/pages/home.js +1 -1
- package/build/pages/index.d.ts +1 -0
- package/build/store/base.d.ts +1 -0
- package/build/store/base.js +1 -1
- package/build/store/blog/index.js +1 -1
- package/build/store/brand/index.js +1 -1
- package/build/store/cart/index.d.ts +6 -2
- package/build/store/cart/index.js +1 -1
- package/build/store/category/index.js +1 -1
- package/build/store/checkout/index.d.ts +7 -2
- package/build/store/checkout/index.js +1 -1
- package/build/store/customer/api.d.ts +5 -1
- package/build/store/customer/api.js +1 -1
- package/build/store/customer/index.d.ts +25 -5
- package/build/store/customer/index.js +1 -1
- package/build/store/html-meta-data/index.js +1 -1
- package/build/store/index.d.ts +1 -1
- package/build/store/location/index.d.ts +2 -1
- package/build/store/location/index.js +1 -1
- package/build/store/product/index.d.ts +4 -1
- package/build/store/product/index.js +1 -1
- package/build/utils/constants.js +1 -1
- package/build/utils/helper.d.ts +1 -0
- package/build/utils/helper.js +1 -1
- package/package.json +18 -14
- package/build/analytics/googleUniversal.d.ts +0 -9
- package/build/analytics/googleUniversal.js +0 -1
- package/build/ext/@builder.io/partytown/integration/index.mjs.js +0 -1
- package/build/ext/@builder.io/partytown/react/index.mjs.js +0 -1
- package/build/models/data/checkout/country-settings-model.d.ts +0 -141
- package/build/models/data/checkout/country-settings-model.js +0 -1
package/build/pages/home.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e}from'./../ext/tslib/tslib.es6.js';import*as t from"react";import{observer as o}from"mobx-react-lite";import{IkasPage as r}from"../components/page/index.js";var m=o((function(o){return t.createElement(r,e({},o))}));export{m as default};
|
|
1
|
+
import{__assign as e}from'./../ext/tslib/tslib.es6.js';import*as t from"react";import{observer as o}from"mobx-react-lite";import{IkasPage as r}from"../components/page/index.js";var m=o((function(o){return t.createElement(r,e({},o,{addOgpMetas:!0}))}));export{m as default};
|
package/build/pages/index.d.ts
CHANGED
package/build/store/base.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare class IkasBaseStore {
|
|
|
17
17
|
router?: NextRouter;
|
|
18
18
|
private constructor();
|
|
19
19
|
static getInstance(): IkasBaseStore;
|
|
20
|
+
handleRouting(routing: IkasStorefrontRouting): void;
|
|
20
21
|
setLocalization(localeOption: IkasLocaleOption): void;
|
|
21
22
|
setLanguage(language: IkasLanguageOption): void;
|
|
22
23
|
private checkLocalization;
|
package/build/store/base.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as o,__generator as t}from'./../ext/tslib/tslib.es6.js';import{configure as n,makeObservable as i,observable as e}from"mobx";import{enableStaticRendering as r}from"mobx-react-lite";import s from"lodash/sortBy";import
|
|
1
|
+
import{__awaiter as o,__generator as t}from'./../ext/tslib/tslib.es6.js';import{configure as n,makeObservable as i,observable as e}from"mobx";import{enableStaticRendering as r}from"mobx-react-lite";import s from"lodash/sortBy";import a from"lodash/flatten";import{IkasCartStore as u}from"./cart/index.js";import{IkasCustomerStore as c}from"./customer/index.js";import l from"./location/index.js";import{IkasThemeJsonPageType as d}from"@ikas/storefront-models";import{IkasStorefrontConfig as h}from"@ikas/storefront-config";import{IkasPageDataInit as p}from"../page-data-init/index.js";n({enforceActions:"never"}),r("undefined"==typeof window);var g=function(){function n(){this.currentPageType=null,this.localeOptions=[],this.languageOptions=[],this.showLocaleOptions=!1,this.currentCountryCode=null,this.spaLinksDisabled=!1,this.localeChecked=!1,this.customerStore=new c(this),this.cartStore=new u(this),"undefined"!=typeof window&&(this.spaLinksDisabled=navigator.userAgent.includes("Instagram")),this.init(),i(this,{currentPageType:e,localeOptions:e,languageOptions:e,showLocaleOptions:e,currentCountryCode:e,spaLinksDisabled:e})}return n.getInstance=function(){return this._instance||(this._instance=new n),this._instance},n.prototype.handleRouting=function(o){var t,n;if(this.currentPageType===d.CATEGORY||this.currentPageType===d.BRAND||this.currentPageType===d.PRODUCT){var i=null===(n=null===(t=p.pageSpecificData.metaData)||void 0===t?void 0:t.translations)||void 0===n?void 0:n.find((function(t){return t.locale===o.locale}));if(i&&(null==i?void 0:i.slug)){var e="";e=o.path?"".concat(window.location.origin,"/").concat(o.path,"/").concat(i.slug):"".concat(window.location.origin,"/").concat(i.slug),window.location.replace(e)}else window.location.replace(window.location.origin+(o.path?"/"+o.path:"")+(this.router?this.router.asPath:""))}else window.location.replace(window.location.origin+(o.path?"/"+o.path:"")+(this.router?this.router.asPath:""))},n.prototype.setLocalization=function(o){var t=o.routing;t.domain?window.location.replace("https://"+t.domain):this.handleRouting(t)},n.prototype.setLanguage=function(o){var t=h.getRoutings().find((function(t){return t.id===o.id}));t&&this.handleRouting(t)},n.prototype.checkLocalization=function(){return o(this,void 0,void 0,(function(){var o,n,i,e,r,u,c,d,p,g,f;return t(this,(function(t){switch(t.label){case 0:return this.localeChecked?[2]:"undefined"==typeof window?(console.warn("checkLocalization should be called on the client side!"),[2]):[4,l.getMyCountry()];case 1:return(o=t.sent()).isSuccess?(n=o.data,i=h.getCurrentRouting(),this.currentCountryCode=n,i&&n?(e=!0,r=h.getRoutings().filter((function(o){var t;return null===(t=o.countryCodes)||void 0===t?void 0:t.includes(n)})),u=h.getRoutings().find((function(o){var t;return!(null===(t=o.countryCodes)||void 0===t?void 0:t.length)})),r.length?r.some((function(o){return o.id===i.id}))||(e=!1):u&&i.id!==u.id&&(e=!1),c=[],d=[],p=a(h.getRoutings().map((function(o){return o.countryCodes||[]}))),[4,l.listCountry({iso2:{in:p}})]):[3,3]):[2];case 2:if(!(g=t.sent()).isSuccess)return[2];f=g.data||[],h.getRoutings().forEach((function(o){var t;(null===(t=o.countryCodes)||void 0===t?void 0:t.length)?o.countryCodes.forEach((function(t){var i=f.find((function(o){return o.iso2===t}));c.some((function(o){return o.iso2===(null==i?void 0:i.iso2)}))||c.push({id:(null==i?void 0:i.iso2)||(null==i?void 0:i.iso3)||Date.now()+"",countryName:(null==i?void 0:i.native)||(null==i?void 0:i.name)||"",iso2:(null==i?void 0:i.iso2)||void 0,iso3:(null==i?void 0:i.iso3)||void 0,routing:o,isRecommended:t===n})})):c.push({id:o.id,routing:o,isRecommended:!h.getRoutings().some((function(o){var t;return null===(t=o.countryCodes)||void 0===t?void 0:t.includes(n)}))})})),r.length&&(h.getRoutings().forEach((function(o){var t;r.some((function(t){return t.id===o.id}))&&d.push({id:o.id,currencyCode:o.currencyCode,currencySymbol:o.currencySymbol,language:"undefined"!=typeof Intl&&void 0!==Intl.DisplayNames&&new Intl.DisplayNames([],{type:"language"}).of(o.locale)||o.locale,locale:o.locale,isSelected:o.id===(null===(t=h.getCurrentRouting())||void 0===t?void 0:t.id)||!1})})),this.languageOptions=s(d,"language")),this.localeOptions=s(c,"countryName"),e||(this.showLocaleOptions=!0),this.localeChecked=!0,t.label=3;case 3:return[2]}}))}))},n.prototype.init=function(){this.customerStore.init()},n}();export{g as IkasBaseStore};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as o}from'./../../ext/tslib/tslib.es6.js';import{APIResponse as d}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{listBlog as a,listBlogMetaData as i,listBlogCategory as s}from"@ikas/storefront-api";import{IkasBlogCategory as r}from"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import{IkasBlogMetaData as n}from"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import{IkasBlog as m}from"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"@ikas/storefront-models";import"mobx";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
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as o}from'./../../ext/tslib/tslib.es6.js';import{APIResponse as d}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{listBlog as a,listBlogMetaData as i,listBlogCategory as s}from"@ikas/storefront-api";import{IkasBlogCategory as r}from"../../models/data/blog/category/index.js";import"../../models/data/blog/content/index.js";import{IkasBlogMetaData as n}from"../../models/data/blog/meta-data/index.js";import"../../models/data/blog/tag/index.js";import{IkasBlog as m}from"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"@ikas/storefront-models";import"mobx";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/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/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/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";var l=function(){function l(){}return l.listBlog=function(i){var s,r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a(i)];case 1:return t=e.sent(),[2,new d(o(o({},t.data),{data:null===(r=null===(s=t.data)||void 0===s?void 0:s.data)||void 0===r?void 0:r.map((function(t){return new m(t)}))}),t.graphQLErrors)]}}))}))},l.listBlogMetaData=function(a){var s,r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,i(a)];case 1:return t=e.sent(),[2,new d(o(o({},t.data),{data:null===(r=null===(s=t.data)||void 0===s?void 0:s.data)||void 0===r?void 0:r.map((function(t){return new n(t)}))}),t.graphQLErrors)]}}))}))},l.listBlogCategory=function(a){var i,n;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,s(a)];case 1:return t=e.sent(),[2,new d(o(o({},t.data),{data:null===(n=null===(i=t.data)||void 0===i?void 0:i.data)||void 0===n?void 0:n.map((function(t){return new r(t)}))}),t.graphQLErrors)]}}))}))},l}();export{l as default};
|
|
@@ -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{listProductBrand 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"../../models/data/blog/index.js";import{IkasBrand as i}from"../../models/data/brand/index.js";import"@ikas/storefront-models";import"mobx";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
|
|
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{listProductBrand 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"../../models/data/blog/index.js";import{IkasBrand as i}from"../../models/data/brand/index.js";import"@ikas/storefront-models";import"mobx";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/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/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/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";var s=function(){function s(){}return s.listProductBrand=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,5 +1,5 @@
|
|
|
1
1
|
import { IkasBaseStore } from "../base";
|
|
2
|
-
import { IkasCart, IkasOrderLineItem, IkasProduct, IkasProductVariant } from "../../models/data";
|
|
2
|
+
import { IkasCart, IkasOrderLineItem, IkasProduct, IkasProductOffer, IkasProductVariant } from "../../models/data";
|
|
3
3
|
import { APIResponse } from "@ikas/storefront-api";
|
|
4
4
|
export declare const CART_LS_KEY = "cartId";
|
|
5
5
|
export declare class IkasCartStore {
|
|
@@ -13,20 +13,24 @@ export declare class IkasCartStore {
|
|
|
13
13
|
get checkoutId(): string | undefined;
|
|
14
14
|
get checkoutUrl(): string | undefined;
|
|
15
15
|
addItem: (variant: IkasProductVariant, product: IkasProduct, initialQuantity?: number) => Promise<IkasCartOperationResult>;
|
|
16
|
-
changeItemQuantity: (item: IkasOrderLineItem, quantity: number) => Promise<IkasCartOperationResult>;
|
|
16
|
+
changeItemQuantity: (item: IkasOrderLineItem, quantity: number, campaignOffers?: IkasProductOffer[]) => Promise<IkasCartOperationResult>;
|
|
17
17
|
removeItem: (item: IkasOrderLineItem) => Promise<IkasCartOperationResult>;
|
|
18
18
|
removeCart: () => void;
|
|
19
19
|
waitUntilInitialized: () => Promise<unknown>;
|
|
20
|
+
private getEditLineID;
|
|
20
21
|
findExistingItem: (variant: IkasProductVariant, product: IkasProduct) => IkasOrderLineItem | undefined;
|
|
22
|
+
private isSameBundleItem;
|
|
21
23
|
saveCouponCode: (couponCode?: string | null) => Promise<IkasCartOperationResult>;
|
|
22
24
|
removeCouponCode: () => Promise<IkasCartOperationResult>;
|
|
23
25
|
saveCart: (cart: IkasCart) => Promise<IkasCartOperationResult>;
|
|
24
26
|
private removeCardIfEmpty;
|
|
25
27
|
getCart: () => Promise<void>;
|
|
28
|
+
private getAcceptedOffers;
|
|
26
29
|
private setCart;
|
|
27
30
|
private beforeCartOperationCheck;
|
|
28
31
|
private createCartLineOptions;
|
|
29
32
|
private getOptionValues;
|
|
33
|
+
private _windowAddToCart;
|
|
30
34
|
}
|
|
31
35
|
export declare type IkasCartOperationResult = {
|
|
32
36
|
success: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import n from"./api.js";import{IkasStorefrontConfig as r}from"@ikas/storefront-config";import{Analytics as o}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as s}from"@ikas/storefront-api";var a,c="cartId",u=function(){function c(c){var u=this;this.cart=null,this._isLoadingCart=!1,this._isCartLoadFinished=!1,this.addItem=function(i,s,c){return void 0===c&&(c=1),t(u,void 0,void 0,(function(){var t,u,d,l,h,v,f,p,I,m;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),s.hasValidProductOptionValues?i.hasStock||i.sellIfOutOfStock?[4,this.beforeCartOperationCheck()]:[2,{success:!1,validationError:a.INSUFFICIENT_STOCK}]:[2,{success:!1,validationError:a.INVALID_PRODUCT_OPTION_VALUES}];case 1:return e.sent(),this.cart&&(t=this.findExistingItem(i,s))?(null===(p=s.productOptionSet)||void 0===p||p.initOptionValues(),[2,this.changeItemQuantity(t,t.quantity+1)]):(u=this.getOptionValues(s),d=(null===(I=this.cart)||void 0===I?void 0:I.id)||localStorage.getItem("cartId"),[4,n.addItemToCart({input:{cartId:d,item:{id:null,quantity:c,variant:{id:i.id,name:s.name}},options:u.length?u:null,priceListId:r.getPriceListId()||null,salesChannelId:r.getSalesChannelId(),storefrontThemeId:r.getStorefrontThemeId()}})]);case 2:return(l=e.sent()).isSuccess&&l.data?[4,this.setCart(l.data)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&(h="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(v=this.cart.items.find((function(t){return t.variant.id===i.id})))&&o.addToCart(v,c,h,this.cart)),null===(m=s.productOptionSet)||void 0===m||m.initOptionValues(),[2,{success:l.isSuccess,response:l}];case 5:return f=e.sent(),console.log(f),[2,{success:!1}];case 6:return[2]}}))}))},this.changeItemQuantity=function(i,s){return t(u,void 0,void 0,(function(){var t,a,c,u,d;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:{cartId:(null===(d=this.cart)||void 0===d?void 0:d.id)||null,item:{id:i.id,quantity:s,variant:{id:i.variant.id,name:i.variant.name}},options:this.createCartLineOptions(i),priceListId:r.getPriceListId()||null,salesChannelId:r.getSalesChannelId(),storefrontThemeId:r.getStorefrontThemeId()}})];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.removeCardIfEmpty(),this.cart&&(a="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(c=i.quantity)>s?o.removeFromCart(i,c-s,this.cart):o.addToCart(i,s-c,a,this.cart)),[2,{success:t.isSuccess,response:t}];case 5:return u=e.sent(),console.log(u),[2,{success:!1}];case 6:return[2]}}))}))},this.removeItem=function(i){return t(u,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"),u.cart=void 0},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){u.isCartLoadFinished&&(clearInterval(e),t(null))}),100)}))},this.findExistingItem=function(t,e){var i,n,r,o,s;if(!e.productOptionSetId)return null===(i=u.cart)||void 0===i?void 0:i.orderLineItems.find((function(e){return e.variant.id===t.id}));for(var a=u.getOptionValues(e),c=(null===(n=u.cart)||void 0===n?void 0:n.orderLineItems.filter((function(e){var i;return e.variant.id===t.id&&(null===(i=e.options)||void 0===i?void 0:i.length)===a.length})))||[],d=0,l=c;d<l.length;d++){var h=l[d];if(h.options){for(var v=!0,f=function(t){var i=t.values.map((function(t){return t.value})),n=null===(s=null===(o=null===(r=e.productOptionSet)||void 0===r?void 0:r.options)||void 0===o?void 0:o.find((function(e){return e.id===t.productOptionId})))||void 0===s?void 0:s.values;if(!(v=v&&i.length===(null==n?void 0:n.length)&&i.every((function(t){return null==n?void 0:n.includes(t)}))))return"break"},p=0,I=h.options;p<I.length;p++){if("break"===f(I[p]))break}if(v)return h}}},this.saveCouponCode=function(i){return t(u,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:a.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(u,void 0,void 0,(function(){return e(this,(function(t){return[2,this.saveCouponCode(null)]}))}))},this.saveCart=function(i){return t(u,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return t=new s(i),[4,n.saveCart({input:t})];case 1:return[2,{success:(r=e.sent()).isSuccess,response:r}]}}))}))},this.removeCardIfEmpty=function(){var t;0===(null===(t=u.cart)||void 0===t?void 0:t.itemCount)&&u.removeCart()},this.getCart=function(){return t(u,void 0,void 0,(function(){var t,i,r,o,s,a;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===(s=this.baseStore.customerStore.customer)||void 0===s?void 0:s.id,(i=(null===(a=this.cart)||void 0===a?void 0:a.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 o=e.sent(),console.log(o),[3,8];case 7:return this._isLoadingCart=!1,this._isCartLoadFinished=!0,[7];case 8:return[2]}}))}))},this.setCart=function(i){return t(u,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(u,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,n=t.options;i<n.length;i++){var r=n[i],o={productOptionId:r.productOptionId,productOptionsSetId:r.productOptionsSetId,values:r.values.map((function(t){return t.value}))};e.push(o)}return e}return null},this.getOptionValues=function(t){var e,i=[];return null===(e=t.productOptionSet)||void 0===e||e.options.forEach((function(t){t.values.length&&i.push({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:t.values})})),i},this.baseStore=c,i(this)}return Object.defineProperty(c.prototype,"isLoadingCart",{get:function(){return this._isLoadingCart},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isCartLoadFinished",{get:function(){return this._isCartLoadFinished},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"checkoutId",{get:function(){var t;return null===(t=this.cart)||void 0===t?void 0:t.id},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"checkoutUrl",{get:function(){if(this.checkoutId)return"/checkout?id=".concat(this.checkoutId,"&step=info")},enumerable:!1,configurable:!0}),c}();!function(t){t.INSUFFICIENT_STOCK="INSUFFICIENT_STOCK",t.INVALID_PRODUCT_OPTION_VALUES="INVALID_PRODUCT_OPTION_VALUES",t.EMPTY_CART="EMPTY_CART"}(a||(a={}));export{c as CART_LS_KEY,a as IkasCartOperationValidationError,u as IkasCartStore};
|
|
1
|
+
import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import r 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{IkasCustomerEmailSubscriptionStatus as n}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/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/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/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 o}from"@ikas/storefront-config";import{Analytics as a}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{SaveCartInput as s}from"@ikas/storefront-api";import{getCookieValue as d}from"../../utils/helper.js";var u,c="cartId",l=function(){function c(c){var l=this;this.cart=null,this._isLoadingCart=!1,this._isCartLoadFinished=!1,this.addItem=function(i,n,s){return void 0===s&&(s=1),t(l,void 0,void 0,(function(){var t,c,l,m,p,f,v,h,I,g,C,b,S;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,,6]),n.productOptionSetId&&!n.productOptionSet&&this.baseStore.router?(this.baseStore.router.push(n.productHref),[2,{success:!1,validationError:u.INVALID_PRODUCT_OPTION_VALUES}]):n.hasValidProductOptionValues?i.hasStock||i.sellIfOutOfStock?[4,this.beforeCartOperationCheck()]:[2,{success:!1,validationError:u.INSUFFICIENT_STOCK}]:[2,{success:!1,validationError:u.INVALID_PRODUCT_OPTION_VALUES}];case 1:if(e.sent(),t=void 0,this.cart&&(t=this.findExistingItem(i,n))){if(null===(h=n.productOptionSet)||void 0===h||h.initOptionValues(),!i.bundleSettings)return[2,this.changeItemQuantity(t,t.quantity+1,n.offers)];if(!this.getEditLineID())return[2,this.changeItemQuantity(t,t.quantity+1,n.offers)]}return c=this.getOptionValues(n),l=(null===(I=this.cart)||void 0===I?void 0:I.id)||localStorage.getItem("cartId"),[4,r.addItemToCart({input:{cartId:l,item:{id:null!==(g=null==t?void 0:t.id)&&void 0!==g?g:null,quantity:null!==(C=null==t?void 0:t.quantity)&&void 0!==C?C:s,variant:{id:i.id,name:n.name,bundleProducts:null===(b=i.bundleSettings)||void 0===b?void 0:b.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(n.offers),options:c.length?c:null,priceListId:o.getPriceListId()||null,salesChannelId:o.getSalesChannelId(),storefrontThemeId:o.getStorefrontThemeId(),metadata:{_fbp:d("_fbp"),_fbc:d("_fbc")}}})];case 2:return(m=e.sent()).isSuccess&&m.data?[4,this.setCart(m.data)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&(p="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(f=this.cart.items.find((function(t){return t.variant.id===i.id})))&&a.addToCart(f,s,p,this.cart)),null===(S=n.productOptionSet)||void 0===S||S.initOptionValues(),[2,{success:m.isSuccess,response:m}];case 5:return v=e.sent(),console.log(v),[2,{success:!1}];case 6:return[2]}}))}))},this.changeItemQuantity=function(i,n,s){return t(l,void 0,void 0,(function(){var t,u,c,l,m,p;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,r.addItemToCart({input:{cartId:(null===(m=this.cart)||void 0===m?void 0:m.id)||null,item:{id:i.id,quantity:n,variant:{id:i.variant.id,name:i.variant.name,bundleProducts:null===(p=i.variant.bundleProducts)||void 0===p?void 0:p.map((function(t){return{id:t.id,productId:t.variant.productId||"",variantId:t.variant.id||"",quantity:t.quantity}}))}},acceptedOffers:this.getAcceptedOffers(s),options:this.createCartLineOptions(i),priceListId:o.getPriceListId()||null,salesChannelId:o.getSalesChannelId(),storefrontThemeId:o.getStorefrontThemeId(),metadata:{_fbp:d("_fbp"),_fbc:d("_fbc")}}})];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),(c=i.quantity)>n?a.removeFromCart(i,c-n,this.cart):a.addToCart(i,n-c,u,this.cart)),this.removeCardIfEmpty(),[2,{success:t.isSuccess,response:t}];case 5:return l=e.sent(),console.log(l),[2,{success:!1}];case 6:return[2]}}))}))},this.removeItem=function(i){return t(l,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"),l.cart=void 0},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){l.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,o,a,s;if(!e.productOptionSetId&&!t.bundleSettings)return null===(i=l.cart)||void 0===i?void 0:i.orderLineItems.find((function(e){return e.variant.id===t.id}));if(t.bundleSettings){var d=l.getEditLineID();if(d)if(S=null===(r=l.cart)||void 0===r?void 0:r.orderLineItems.find((function(t){return t.id===d})))return S}var u=(null===(n=l.cart)||void 0===n?void 0:n.orderLineItems.filter((function(e){return e.variant.id===t.id})))||[];if(e.productOptionSetId)for(var c=l.getOptionValues(e),m=u.filter((function(t){var e;return(null===(e=t.options)||void 0===e?void 0:e.length)===c.length}))||[],p=0,f=m;p<f.length;p++){if((S=f[p]).options){for(var v=!0,h=function(t){var i=t.values.map((function(t){return t.value})),r=null===(s=null===(a=null===(o=e.productOptionSet)||void 0===o?void 0:o.options)||void 0===a?void 0:a.find((function(e){return e.id===t.productOptionId})))||void 0===s?void 0:s.values;if(!(v=v&&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(v){if(!t.bundleSettings)return S;if(l.isSameBundleItem(t,S))return S}}}else if(t.bundleSettings)for(var C=0,b=u;C<b.length;C++){var S=b[C];if(l.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(l,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.cart?[4,r.saveCartCouponCode({cartId:this.cart.id,couponCode:i})]:[2,{success:!1,validationError:u.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(l,void 0,void 0,(function(){return e(this,(function(t){return[2,this.saveCouponCode(null)]}))}))},this.saveCart=function(i){return t(l,void 0,void 0,(function(){var t,o;return e(this,(function(e){switch(e.label){case 0:return(t=new s(i)).customer&&this.baseStore.customerStore.customer&&(t.customer.notificationsAccepted=this.baseStore.customerStore.customer.subscriptionStatus===n.SUBSCRIBED),[4,r.saveCart({input:t})];case 1:return[2,{success:(o=e.sent()).isSuccess,response:o}]}}))}))},this.removeCardIfEmpty=function(){var t;0===(null===(t=l.cart)||void 0===t?void 0:t.itemCount)&&l.removeCart()},this.getCart=function(){return t(l,void 0,void 0,(function(){var t,i,n,o,a,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===(a=this.baseStore.customerStore.customer)||void 0===a?void 0:a.id,(i=(null===(s=this.cart)||void 0===s?void 0:s.id)||localStorage.getItem("cartId"))||t?[4,r.getCartById({id:i})]:[2];case 2:return(n=e.sent()).isSuccess&&n.data?[4,this.setCart(n.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 o=e.sent(),console.log(o),[3,8];case 7:return this._isLoadingCart=!1,this._isCartLoadFinished=!0,[7];case 8:return[2]}}))}))},this.setCart=function(i){return t(l,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(l,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],o={productOptionId:n.productOptionId,productOptionsSetId:n.productOptionsSetId,values:n.values.map((function(t){return t.value}))};e.push(o)}return e}return null},this.getOptionValues=function(t){var e,i=[];return null===(e=t.productOptionSet)||void 0===e||e.options.forEach((function(t){t.values.length&&i.push({productOptionId:t.id,productOptionsSetId:t.productOptionSetId,values:t.values})})),i},this._windowAddToCart=function(i){return t(l,void 0,void 0,(function(){var t,n,s,u,c,l,m,p,f,v,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===(f=this.cart)||void 0===f?void 0:f.items.find((function(t){return t.id===i.itemId})):null,[4,r.addItemToCart({input:{cartId:(null===(v=this.cart)||void 0===v?void 0:v.id)||null,item:{id:i.itemId||null,quantity:i.quantity,variant:{id:i.variantId}},priceListId:o.getPriceListId()||null,salesChannelId:o.getSalesChannelId(),storefrontThemeId:o.getStorefrontThemeId(),metadata:{_fbp:d("_fbp"),_fbc:d("_fbc")}}})];case 2:return(n=e.sent()).isSuccess&&n.data?(i.itemId||(s=(null===(h=this.cart)||void 0===h?void 0:h.items.map((function(t){return t.id})))||[],u=n.data.items.map((function(t){return t.id})),(c=u.find((function(t){return!s.includes(t)})))&&(t=n.data.items.find((function(t){return t.id===c})))),[4,this.setCart(n.data)]):[3,4];case 3:e.sent(),e.label=4;case 4:return this.cart&&t&&(l="".concat(this.cart.id,"-").concat(this.cart.updatedAt),(m=i.quantity)>i.quantity?a.removeFromCart(t,m-i.quantity,this.cart):a.addToCart(t,i.quantity-m,l,this.cart)),this.removeCardIfEmpty(),[2,{success:n.isSuccess,response:n}];case 5:return p=e.sent(),console.log(p),[2,{success:!1}];case 6:return[2]}}))}))},this.baseStore=c,i(this)}return Object.defineProperty(c.prototype,"isLoadingCart",{get:function(){return this._isLoadingCart},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"isCartLoadFinished",{get:function(){return this._isCartLoadFinished},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"checkoutId",{get:function(){var t;return null===(t=this.cart)||void 0===t?void 0:t.id},enumerable:!1,configurable:!0}),Object.defineProperty(c.prototype,"checkoutUrl",{get:function(){if(this.checkoutId)return"/checkout?id=".concat(this.checkoutId,"&step=info")},enumerable:!1,configurable:!0}),c.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},c}();!function(t){t.INSUFFICIENT_STOCK="INSUFFICIENT_STOCK",t.INVALID_PRODUCT_OPTION_VALUES="INVALID_PRODUCT_OPTION_VALUES",t.EMPTY_CART="EMPTY_CART"}(u||(u={}));export{c as CART_LS_KEY,u as IkasCartOperationValidationError,l as IkasCartStore};
|
|
@@ -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"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"@ikas/storefront-models";import"mobx";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
|
|
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"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"@ikas/storefront-models";import"mobx";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/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/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/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/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";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,11 +1,14 @@
|
|
|
1
1
|
import { APIResponse } from "@ikas/fe-api-client";
|
|
2
|
-
import { CheckStocksQueryParams, CreateAdyenClientTokenParams, CreateKlarnaClientTokenParams, CreateSaleTransactionQueryParams, CreateStripePaymentIntentParams, GetAvailableShippingCountriesQueryParams, GetAvailableStockLocationQueryParams, ListCheckoutSettingsQueryParams, ListPaymentGatewayQueryParams, ListStockLocationQueryParams, RetrieveInstallmentInfoQueryParams } from "@ikas/storefront-api";
|
|
3
|
-
import { IkasAvailableStockLocation, IkasCheckoutSettings, IkasPaymentGateway, IkasStockLocation } from "../../models/data";
|
|
2
|
+
import { CheckStocksQueryParams, CreateAdyenClientTokenParams, CreateKlarnaClientTokenParams, CreateSaleTransactionQueryParams, CreateStripePaymentIntentParams, GetAvailableShippingCountriesQueryParams, GetAvailableStockLocationQueryParams, ListCheckoutSettingsQueryParams, ListPaymentGatewayQueryParams, ListProductFileQueryParams, ListStockLocationQueryParams, RetrieveInstallmentInfoQueryParams, GetPayPalClientIdTokenParams, CreatePayPalOrderParams, GetDigitalProductFileDownloadUrlQueryParams, CheckCartStocksQueryParams } from "@ikas/storefront-api";
|
|
3
|
+
import { IkasAvailableStockLocation, IkasCheckoutSettings, IkasPaymentGateway, IkasStockLocation, IkasProductFile } from "../../models/data";
|
|
4
4
|
export default class CheckoutStore {
|
|
5
5
|
static createSaleTransactionWithCart(params: CreateSaleTransactionQueryParams): Promise<APIResponse<import("@ikas/storefront-api").TransactionResponse> | APIResponse<undefined>>;
|
|
6
6
|
static listPaymentGateway(params: ListPaymentGatewayQueryParams): Promise<APIResponse<IkasPaymentGateway[]>>;
|
|
7
|
+
static listProductFile(params: ListProductFileQueryParams): Promise<APIResponse<IkasProductFile[]>>;
|
|
8
|
+
static getDigitalProductFileDownloadUrl(params: GetDigitalProductFileDownloadUrlQueryParams): Promise<APIResponse<string>>;
|
|
7
9
|
static retrieveInstallmentInfo(params: RetrieveInstallmentInfoQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api").RetrieveInstallmentInfoResponse>>;
|
|
8
10
|
static checkStocks(params: CheckStocksQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api/build/__api/types").CheckStocksResponse>>;
|
|
11
|
+
static checkCartStocks(params: CheckCartStocksQueryParams): Promise<APIResponse<undefined> | APIResponse<import("@ikas/storefront-api/build/__api/types").CheckStocksResponse>>;
|
|
9
12
|
static listCheckoutSettings(params: ListCheckoutSettingsQueryParams): Promise<APIResponse<IkasCheckoutSettings[]>>;
|
|
10
13
|
static getAvailableShippingCountries(params: GetAvailableShippingCountriesQueryParams): Promise<APIResponse<undefined> | APIResponse<string[]>>;
|
|
11
14
|
static listStockLocation(params: ListStockLocationQueryParams): Promise<APIResponse<IkasStockLocation[]>>;
|
|
@@ -13,4 +16,6 @@ export default class CheckoutStore {
|
|
|
13
16
|
static createStripePaymentIntent(params: CreateStripePaymentIntentParams): Promise<APIResponse<import("@ikas/storefront-api").CreateStripePaymentIntentResponse>>;
|
|
14
17
|
static createKlarnaClientToken(params: CreateKlarnaClientTokenParams): Promise<APIResponse<import("@ikas/storefront-api").CreateKlarnaTokenResponse>>;
|
|
15
18
|
static createAdyenClientToken(params: CreateAdyenClientTokenParams): Promise<APIResponse<import("@ikas/storefront-api").CreateAdyenSessionResponse>>;
|
|
19
|
+
static getPayPalClientId(params: GetPayPalClientIdTokenParams): Promise<APIResponse<import("@ikas/storefront-api").GetPaypalClientIdResponse>>;
|
|
20
|
+
static createPayPalOrder(params: CreatePayPalOrderParams): Promise<APIResponse<import("@ikas/storefront-api").CreatePaypalOrderResponse>>;
|
|
16
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{APIResponse as
|
|
1
|
+
import{__awaiter as t,__generator as e}from'./../../ext/tslib/tslib.es6.js';import{APIResponse as r}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{createSaleTransactionWithCart as i,listPaymentGateway as o,listProductFile as n,getDigitalProductFileDownloadUrl as a,retrieveInstallmentInfo as s,checkStocks as d,checkCartStocks as c,listCheckoutSettings as m,getAvailableShippingCountries as u,listStockLocations as l,getAvailableStockLocations as p,createStripePaymentIntent as f,createKlarnaClientToken as h,createAdyenClientToken as v,getPayPalClientId as j,createPayPalOrder as x}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"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"@ikas/storefront-models";import"mobx";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{IkasCheckoutSettings as g}from"../../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/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/package/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import{IkasPaymentGateway as b}from"../../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{IkasProductFile as w}from"../../models/data/product-file/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{IkasAvailableStockLocation as k}from"../../models/data/stock-location/available/index.js";import{IkasStockLocation as y}from"../../models/data/stock-location/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";var L=function(){function L(){}return L.createSaleTransactionWithCart=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,i(r)];case 1:return[2,t.sent()]}}))}))},L.listPaymentGateway=function(i){var n;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,o(i)];case 1:return t=e.sent(),[2,new r(null===(n=t.data)||void 0===n?void 0:n.map((function(t){return new b(t)})),t.graphQLErrors)]}}))}))},L.listProductFile=function(i){var o;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n(i)];case 1:return t=e.sent(),[2,new r(null===(o=t.data)||void 0===o?void 0:o.map((function(t){return new w(t)})),t.graphQLErrors)]}}))}))},L.getDigitalProductFileDownloadUrl=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a(i)];case 1:return t=e.sent(),[2,new r(t.data,t.graphQLErrors)]}}))}))},L.retrieveInstallmentInfo=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s(r)];case 1:return[2,t.sent()]}}))}))},L.checkStocks=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,d(r)];case 1:return[2,t.sent()]}}))}))},L.checkCartStocks=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,c(r)];case 1:return[2,t.sent()]}}))}))},L.listCheckoutSettings=function(i){var o;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,m(i)];case 1:return t=e.sent(),[2,new r(null===(o=t.data)||void 0===o?void 0:o.map((function(t){return new g(t)})),t.graphQLErrors)]}}))}))},L.getAvailableShippingCountries=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u(r)];case 1:return[2,t.sent()]}}))}))},L.listStockLocation=function(i){var o;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,l(i)];case 1:return t=e.sent(),[2,new r(null===(o=t.data)||void 0===o?void 0:o.map((function(t){return new y(t)})),t.graphQLErrors)]}}))}))},L.getAvailableStockLocations=function(i){var o;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,p(i)];case 1:return t=e.sent(),[2,new r(null===(o=t.data)||void 0===o?void 0:o.map((function(t){return new k(t)})),t.graphQLErrors)]}}))}))},L.createStripePaymentIntent=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,f(i)];case 1:return t=e.sent(),[2,new r(t.data,t.graphQLErrors)]}}))}))},L.createKlarnaClientToken=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,h(i)];case 1:return t=e.sent(),[2,new r(t.data,t.graphQLErrors)]}}))}))},L.createAdyenClientToken=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,v(i)];case 1:return t=e.sent(),[2,new r(t.data,t.graphQLErrors)]}}))}))},L.getPayPalClientId=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,j(i)];case 1:return t=e.sent(),[2,new r(t.data,t.graphQLErrors)]}}))}))},L.createPayPalOrder=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,x(i)];case 1:return t=e.sent(),[2,new r(t.data,t.graphQLErrors)]}}))}))},L}();export{L as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIResponse } from "@ikas/fe-api-client";
|
|
2
|
-
import { CheckCustomerEmailQueryParams, SubscribeToMarketingNotificationsQueryParams, CreateCustomerReviewQueryParams, CreateOrderRefundRequestQueryParams, CustomerForgotPasswordQueryParams, CustomerLoginQueryParams, CustomerRecoverPasswordQueryParams, CustomerRefreshTokenQueryParams, CustomerSocialLoginQueryParams, GetCustomerOrdersQueryParams, GetLastViewedProductsQueryParams, GetOrderByEmailQueryParams, IsFavoriteProductQueryParams, ListCustomerReviewsQueryParams, ListCustomerReviewSummaryQueryParams, ListOrderRefundSettingsQueryParams, ListOrderTransactionsQueryParams, RegisterCustomerQueryParams, SaveFavoriteProductQueryParams, SaveLastViewedProductsQueryParams, SaveMyCustomerQueryParams, SendContactFormToMerchantQueryParams } from "@ikas/storefront-api";
|
|
2
|
+
import { CheckCustomerEmailQueryParams, SubscribeToMarketingNotificationsQueryParams, CreateCustomerReviewQueryParams, CreateOrderRefundRequestQueryParams, CustomerForgotPasswordQueryParams, CustomerLoginQueryParams, CustomerRecoverPasswordQueryParams, CustomerRefreshTokenQueryParams, CustomerSocialLoginQueryParams, GetCustomerOrdersQueryParams, GetLastViewedProductsQueryParams, GetOrderByEmailQueryParams, IsFavoriteProductQueryParams, ListCustomerReviewsQueryParams, ListCustomerReviewSummaryQueryParams, ListOrderRefundSettingsQueryParams, ListOrderTransactionsQueryParams, RegisterCustomerQueryParams, SaveFavoriteProductQueryParams, SaveLastViewedProductsQueryParams, SaveMyCustomerQueryParams, SendContactFormToMerchantQueryParams, ActivateCustomerQueryParams, ResendCustomerActivationMailQueryParams, ValidateCustomerPhoneVerificationCodeQueryParams, ResendCustomerPhoneVerificationCodeQueryParams } from "@ikas/storefront-api";
|
|
3
3
|
import { IkasCustomer, IkasCustomerAttribute, IkasCustomerReview, IkasCustomerReviewSummary, IkasFavoriteProduct, IkasLastViewedProduct, IkasOrder, IkasOrderRefundSettings, IkasOrderTransaction } from "../../models/data";
|
|
4
4
|
export default class CustomerStoreAPI {
|
|
5
5
|
static login(params: CustomerLoginQueryParams): Promise<APIResponse<{
|
|
@@ -51,4 +51,8 @@ export default class CustomerStoreAPI {
|
|
|
51
51
|
page?: number | undefined;
|
|
52
52
|
}>>;
|
|
53
53
|
static listCustomerAttribute(): Promise<APIResponse<IkasCustomerAttribute[]>>;
|
|
54
|
+
static activateCustomer(params: ActivateCustomerQueryParams): Promise<APIResponse<undefined> | APIResponse<string>>;
|
|
55
|
+
static resendCustomerActivationMail(params: ResendCustomerActivationMailQueryParams): Promise<APIResponse<undefined> | APIResponse<boolean>>;
|
|
56
|
+
static resendCustomerPhoneVerificationCode(params: ResendCustomerPhoneVerificationCodeQueryParams): Promise<APIResponse<undefined> | APIResponse<boolean>>;
|
|
57
|
+
static validateCustomerPhoneVerificationCode(params: ValidateCustomerPhoneVerificationCodeQueryParams): Promise<APIResponse<undefined> | APIResponse<boolean>>;
|
|
54
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{APIResponse as n}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{login as i,socialLogin as o,register as a,refreshToken as s,forgotPassword as d,recoverPassword as u,checkEmail as c,getCustomer as l,saveCustomer as m,getOrders as f,getOrderByEmail as p,listOrderTransactions as v,createOrderRefundRequest as h,subscribeToMarketingNotifications as w,getLastViewedProducts as j,saveLastViewedProducts as x,listOrderRefundSettings as g,sendContactFormToMerchant as b,listFavoriteProducts as L,saveFavoriteProduct as E,isFavoriteProduct as k,createCustomerReview as Q,listCustomerReviews as y,listCustomerReviewSummary as _,listCustomerAttribute as P}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"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"@ikas/storefront-models";import"mobx";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/country-settings-model.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/address/ikas-localized-customer-address.js";import{IkasCustomerAttribute as C}from"../../models/data/customer/attribute/index.js";import{IkasCustomerReviewSummary as R}from"../../models/data/customer/review/summary/index.js";import{IkasCustomerReview as T}from"../../models/data/customer/review/index.js";import{IkasCustomer as O}from"../../models/data/customer/index.js";import"../../models/data/district/index.js";import{IkasFavoriteProduct as F}from"../../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{IkasLastViewedProduct as I}from"../../models/data/last-viewed-product/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/package/index.js";import{IkasOrderRefundSettings as S}from"../../models/data/order/refund/settings/index.js";import{IkasOrderTransaction as A}from"../../models/data/order/transaction/index.js";import{IkasOrder as M}from"../../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/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/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 V=function(){function V(){}return V.login=function(o){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,i(o)];case 1:return t=e.sent(),[2,new n(t.data?r(r({},t.data),{customer:t.data.customer?new O(t.data.customer):null}):null,t.graphQLErrors)]}}))}))},V.socialLogin=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,o(i)];case 1:return t=e.sent(),[2,new n(t.data?r(r({},t.data),{customer:t.data.customer?new O(t.data.customer):null}):null,t.graphQLErrors)]}}))}))},V.register=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a(i)];case 1:return t=e.sent(),[2,new n(t.data?r(r({},t.data),{customer:t.data.customer?new O(t.data.customer):null}):null,t.graphQLErrors)]}}))}))},V.refreshToken=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s(r)];case 1:return[2,t.sent()]}}))}))},V.forgotPassword=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,d(r)];case 1:return[2,t.sent()]}}))}))},V.recoverPassword=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u(r)];case 1:return[2,t.sent()]}}))}))},V.checkEmail=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,c(r)];case 1:return[2,t.sent()]}}))}))},V.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,l()];case 1:return t=e.sent(),[2,new n(t.data?new O(t.data):null,t.graphQLErrors)]}}))}))},V.saveCustomer=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,m(r)];case 1:return t=e.sent(),[2,new n(t.data?new O(t.data):null,t.graphQLErrors)]}}))}))},V.getOrders=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,f(r)];case 1:return t=e.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new M(t)})),t.graphQLErrors)]}}))}))},V.getOrderByEmail=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,p(r)];case 1:return t=e.sent(),[2,new n(t.data?new M(t.data):null,t.graphQLErrors)]}}))}))},V.listOrderTransactions=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,v(r)];case 1:return t=e.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new A(t)})),t.graphQLErrors)]}}))}))},V.createOrderRefundRequest=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,h(r)];case 1:return t=e.sent(),[2,new n(t.data?new M(t.data):null,t.graphQLErrors)]}}))}))},V.subscribeToMarketingNotifications=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,w(r)];case 1:return[2,t.sent()]}}))}))},V.getLastViewedProducts=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,j(r)];case 1:return t=e.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new I(t)})),t.graphQLErrors)]}}))}))},V.saveLastViewedProducts=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,x(r)];case 1:return[2,t.sent()]}}))}))},V.listOrderRefundSettings=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,g(r)];case 1:return t=e.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new S(t)})),t.graphQLErrors)]}}))}))},V.sendContactFormToMerchant=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,b(r)];case 1:return[2,t.sent()]}}))}))},V.listFavoriteProducts=function(){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,L()];case 1:return t=e.sent(),[2,new n(null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new F(t)})),t.graphQLErrors)]}}))}))},V.saveFavoriteProduct=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,E(r)];case 1:return[2,t.sent()]}}))}))},V.isFavoriteProduct=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,k({productId:r.productId})];case 1:return[2,t.sent()]}}))}))},V.createCustomerReview=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,Q(r)];case 1:return t=e.sent(),[2,new n(t.data?new T(t.data):null,t.graphQLErrors)]}}))}))},V.listCustomerReviews=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,y(i)];case 1:return t=e.sent(),[2,new n(t.data?r(r({},t.data),{data:t.data.data.map((function(t){return new T(t)}))}):null,t.graphQLErrors)]}}))}))},V.listCustomerReviewSummary=function(i){var o;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,_(i)];case 1:return t=e.sent(),[2,new n(r(r({},t.data),{data:null===(o=t.data)||void 0===o?void 0:o.data.map((function(t){return new R(t)}))}),t.graphQLErrors)]}}))}))},V.listCustomerAttribute=function(){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,P()];case 1:return t=e.sent(),[2,new n(null===(r=t.data)||void 0===r?void 0:r.sort((function(t,e){return t.order&&e.order?t.order-e.order:-1})).map((function(t){return new C(t)}),t.graphQLErrors))]}}))}))},V}();export{V as default};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{APIResponse as n}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{login as i,socialLogin as o,register as a,refreshToken as s,forgotPassword as d,recoverPassword as u,checkEmail as c,getCustomer as l,saveCustomer as m,getOrders as f,getOrderByEmail as p,listOrderTransactions as v,createOrderRefundRequest as h,subscribeToMarketingNotifications as w,getLastViewedProducts as j,saveLastViewedProducts as x,listOrderRefundSettings as g,sendContactFormToMerchant as b,listFavoriteProducts as L,saveFavoriteProduct as E,isFavoriteProduct as k,createCustomerReview as Q,listCustomerReviews as y,listCustomerReviewSummary as C,listCustomerAttribute as P,activateCustomer as _,resendCustomerActivationMail as R,resendCustomerPhoneVerificationCode as T,validateCustomerPhoneVerificationCode as O}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"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"@ikas/storefront-models";import"mobx";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{IkasCustomerAttribute as F}from"../../models/data/customer/attribute/index.js";import{IkasCustomerReviewSummary as V}from"../../models/data/customer/review/summary/index.js";import{IkasCustomerReview as z}from"../../models/data/customer/review/index.js";import{IkasCustomer as A}from"../../models/data/customer/index.js";import"../../models/data/district/index.js";import{IkasFavoriteProduct as I}from"../../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{IkasLastViewedProduct as M}from"../../models/data/last-viewed-product/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/package/index.js";import{IkasOrderRefundSettings as S}from"../../models/data/order/refund/settings/index.js";import{IkasOrderTransaction as q}from"../../models/data/order/transaction/index.js";import{IkasOrder as B}from"../../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/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";var G=function(){function G(){}return G.login=function(o){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,i(o)];case 1:return t=e.sent(),[2,new n(t.data?r(r({},t.data),{customer:t.data.customer?new A(t.data.customer):null}):null,t.graphQLErrors)]}}))}))},G.socialLogin=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,o(i)];case 1:return t=e.sent(),[2,new n(t.data?r(r({},t.data),{customer:t.data.customer?new A(t.data.customer):null}):null,t.graphQLErrors)]}}))}))},G.register=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a(i)];case 1:return t=e.sent(),[2,new n(t.data?r(r({},t.data),{customer:t.data.customer?new A(t.data.customer):null}):null,t.graphQLErrors)]}}))}))},G.refreshToken=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,s(r)];case 1:return[2,t.sent()]}}))}))},G.forgotPassword=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,d(r)];case 1:return[2,t.sent()]}}))}))},G.recoverPassword=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u(r)];case 1:return[2,t.sent()]}}))}))},G.checkEmail=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,c(r)];case 1:return[2,t.sent()]}}))}))},G.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,l()];case 1:return t=e.sent(),[2,new n(t.data?new A(t.data):null,t.graphQLErrors)]}}))}))},G.saveCustomer=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,m(r)];case 1:return t=e.sent(),[2,new n(t.data?new A(t.data):null,t.graphQLErrors)]}}))}))},G.getOrders=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,f(r)];case 1:return t=e.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new B(t)})),t.graphQLErrors)]}}))}))},G.getOrderByEmail=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,p(r)];case 1:return t=e.sent(),[2,new n(t.data?new B(t.data):null,t.graphQLErrors)]}}))}))},G.listOrderTransactions=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,v(r)];case 1:return t=e.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new q(t)})),t.graphQLErrors)]}}))}))},G.createOrderRefundRequest=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,h(r)];case 1:return t=e.sent(),[2,new n(t.data?new B(t.data):null,t.graphQLErrors)]}}))}))},G.subscribeToMarketingNotifications=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,w(r)];case 1:return[2,t.sent()]}}))}))},G.getLastViewedProducts=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,j(r)];case 1:return t=e.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new M(t)})),t.graphQLErrors)]}}))}))},G.saveLastViewedProducts=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,x(r)];case 1:return[2,t.sent()]}}))}))},G.listOrderRefundSettings=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,g(r)];case 1:return t=e.sent(),[2,new n(null===(i=t.data)||void 0===i?void 0:i.map((function(t){return new S(t)})),t.graphQLErrors)]}}))}))},G.sendContactFormToMerchant=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,b(r)];case 1:return[2,t.sent()]}}))}))},G.listFavoriteProducts=function(){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,L()];case 1:return t=e.sent(),[2,new n(null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new I(t)})),t.graphQLErrors)]}}))}))},G.saveFavoriteProduct=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,E(r)];case 1:return[2,t.sent()]}}))}))},G.isFavoriteProduct=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,k({productId:r.productId})];case 1:return[2,t.sent()]}}))}))},G.createCustomerReview=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,Q(r)];case 1:return t=e.sent(),[2,new n(t.data?new z(t.data):null,t.graphQLErrors)]}}))}))},G.listCustomerReviews=function(i){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,y(i)];case 1:return t=e.sent(),[2,new n(t.data?r(r({},t.data),{data:t.data.data.map((function(t){return new z(t)}))}):null,t.graphQLErrors)]}}))}))},G.listCustomerReviewSummary=function(i){var o;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,C(i)];case 1:return t=e.sent(),[2,new n(r(r({},t.data),{data:null===(o=t.data)||void 0===o?void 0:o.data.map((function(t){return new V(t)}))}),t.graphQLErrors)]}}))}))},G.listCustomerAttribute=function(){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,P()];case 1:return t=e.sent(),[2,new n(null===(r=t.data)||void 0===r?void 0:r.sort((function(t,e){return t.order&&e.order?t.order-e.order:-1})).map((function(t){return new F(t)}),t.graphQLErrors))]}}))}))},G.activateCustomer=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,_(r)];case 1:return[2,t.sent()]}}))}))},G.resendCustomerActivationMail=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,R(r)];case 1:return[2,t.sent()]}}))}))},G.resendCustomerPhoneVerificationCode=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,T(r)];case 1:return[2,t.sent()]}}))}))},G.validateCustomerPhoneVerificationCode=function(r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,O(r)];case 1:return[2,t.sent()]}}))}))},G}();export{G as default};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { IkasContactForm, IkasCustomer, IkasCustomerAttributeValue, IkasFavoriteProduct, IkasOrderTransaction, IkasProduct, IkasOrder, IkasRaffleParticipant } from "../../models/data";
|
|
1
|
+
import { IkasContactForm, IkasCustomer, IkasCustomerAttributeValue, IkasFavoriteProduct, IkasOrderTransaction, IkasProduct, IkasOrder, IkasRaffleParticipant, IkasProductFile } from "../../models/data";
|
|
2
|
+
import { IkasLoginError, IkasRegisterError } from "@ikas/storefront-api";
|
|
2
3
|
import { IkasBaseStore } from "../base";
|
|
4
|
+
export declare type SocialLoginProvider = "facebook" | "google" | "twitch";
|
|
3
5
|
export declare class IkasCustomerStore {
|
|
4
6
|
customer?: IkasCustomer | null;
|
|
5
7
|
private token?;
|
|
@@ -20,15 +22,29 @@ export declare class IkasCustomerStore {
|
|
|
20
22
|
get isCaptchaRequired(): boolean;
|
|
21
23
|
private get useLastViewedProductResponse();
|
|
22
24
|
private toAnalyticsCustomer;
|
|
23
|
-
socialLogin(provider:
|
|
25
|
+
socialLogin(provider: SocialLoginProvider): Promise<void>;
|
|
24
26
|
socialLoginToken(token: string): Promise<boolean>;
|
|
25
|
-
refundOrder(order: IkasOrder): Promise<boolean>;
|
|
27
|
+
refundOrder(order: IkasOrder, email?: string | null): Promise<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Use customerLogin instead.
|
|
30
|
+
*/
|
|
26
31
|
login: (email: string, password: string) => Promise<boolean>;
|
|
32
|
+
customerLogin: (email: string, password: string) => Promise<{
|
|
33
|
+
isSuccess: boolean;
|
|
34
|
+
errorCodes: IkasLoginError[];
|
|
35
|
+
}>;
|
|
27
36
|
logout: () => void;
|
|
28
|
-
register: (firstName: string, lastName: string, email: string, password: string, isMarketingAccepted?: boolean, attributes?: IkasCustomerAttributeValue[]) => Promise<
|
|
37
|
+
register: (firstName: string, lastName: string, email: string, password: string, isMarketingAccepted?: boolean, attributes?: IkasCustomerAttributeValue[], phone?: string | null) => Promise<{
|
|
38
|
+
isSuccess: boolean;
|
|
39
|
+
errorCodes: IkasRegisterError[];
|
|
40
|
+
}>;
|
|
41
|
+
activateCustomer: () => Promise<boolean>;
|
|
42
|
+
resendCustomerActivationMail: (email: string) => Promise<boolean>;
|
|
43
|
+
validateCustomerPhoneVerificationCode: (verificationCode: string) => Promise<boolean>;
|
|
44
|
+
resendCustomerPhoneVerificationCode: (email: string) => Promise<boolean>;
|
|
29
45
|
saveContactForm: (input: IkasContactForm) => Promise<boolean>;
|
|
30
46
|
checkEmail: (email: string) => Promise<boolean>;
|
|
31
|
-
forgotPassword: (email: string) => Promise<boolean>;
|
|
47
|
+
forgotPassword: (email: string) => Promise<boolean | undefined>;
|
|
32
48
|
recoverPassword: (password: string, passwordAgain: string, token: string) => Promise<boolean>;
|
|
33
49
|
saveCustomer: (customer: IkasCustomer) => Promise<boolean>;
|
|
34
50
|
getOrders: () => Promise<IkasOrder[]>;
|
|
@@ -51,6 +67,8 @@ export declare class IkasCustomerStore {
|
|
|
51
67
|
waitUntilCaptchaTokenInitialized: () => Promise<unknown>;
|
|
52
68
|
getRaffles: () => Promise<IkasRaffleParticipant[] | undefined>;
|
|
53
69
|
getCustomerAttributes: () => Promise<import("../../models/data").IkasCustomerAttribute[]>;
|
|
70
|
+
getOrderProductFiles: (fileIds: string[]) => Promise<IkasProductFile[]>;
|
|
71
|
+
getDigitalProductFileDownloadUrl: (order: IkasOrder, productFile: IkasProductFile) => Promise<void>;
|
|
54
72
|
private init;
|
|
55
73
|
private getOrderRefundSettings;
|
|
56
74
|
private routeChangeInit;
|
|
@@ -82,3 +100,5 @@ export declare type IkasCustomerReviewForm = {
|
|
|
82
100
|
star: number;
|
|
83
101
|
title?: string;
|
|
84
102
|
};
|
|
103
|
+
export type { IkasRegisterError as RegisterResponseErrorCode };
|
|
104
|
+
export type { IkasLoginError as LoginResponseErrorCode };
|
|
@@ -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 o from"lodash/xorBy";import s from"lodash/cloneDeep";import n from"./api.js";import{IkasCustomer as a}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 c}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/country-settings-model.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/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/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/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/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/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{IkasRaffleParticipant as d}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 l from"../product/index.js";import{Analytics as h}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as m}from"@ikas/storefront-config";import{SaveMyCustomerInput as p}from"@ikas/storefront-api";import{populateRaffleParticipantProducts as f}from"@ikas/storefront-providers";var v="undefined"==typeof localStorage,g=function(){function g(o){var a=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._savedLastViewedProducts=[],this._savedLastViewedProductsResponse=null,this.toAnalyticsCustomer=function(t){return i(i({},t),{consentGranted:a._customerConsentGranted})},this.login=function(i,r){return t(a,void 0,void 0,(function(){var t,o;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.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&&h.customerLogin(),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.logout=function(){var t;a.clearLocalData(),null===(t=a.baseStore)||void 0===t||t.cartStore.removeCart(),h.customerLogout()},this.register=function(i,r,o,s,c,d){return t(a,void 0,void 0,(function(){var t,a;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.register({email:o,password:s,firstName:i,lastName:r,isAcceptMarketing:c,attributes:d,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),h.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,!0]):[2,!1]}}))}))},this.saveContactForm=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return h.contactForm(r),[4,this.getCaptcha()];case 1:return e.sent(),[4,n.sendContactFormToMerchant(i(i({},r),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(i){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.checkEmail({email:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&!!(null===(r=t.data)||void 0===r?void 0:r.exists)]}}))}))},this.forgotPassword=function(i){return t(a,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,n.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(a,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,n.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(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.saveCustomer({input:new p(i)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(i){return t(a,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,n.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.getOrderByEmail=function(i,r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.getOrderByEmail({email:i,orderNumber:r})];case 1:return[2,t.sent().data||null]}}))}))},this.getOrderTransactions=function(i){return void 0===i&&(i={}),t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.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(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(a,void 0,void 0,(function(){var t,i,r,o,s,a;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return(t=e.sent()).isSuccess&&(null===(r=t.data)||void 0===r?void 0:r.length)?[4,l.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:m.getPriceListId(),salesChannelId:m.getSalesChannelId()}})]:[2,[]];case 2:return i=e.sent(),null===(s=null===(o=i.data)||void 0===o?void 0:o.data)||void 0===s||s.forEach((function(t){t.selectedVariantValues=t.variants[0].variantValues})),[2,(null===(a=null==i?void 0:i.data)||void 0===a?void 0:a.data)||[]]}}))}))},this.addProductToFavorites=function(i){return t(a,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,n.saveFavoriteProduct({isFavorite:!0,productId:i})];case 1:return t=e.sent(),h.addToWishlist(i),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(i){return t(a,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,n.saveFavoriteProduct({isFavorite:!1,productId:i})];case 1:return t=e.sent(),h.addToWishlist(i),[2,t.data||!1]}}))}))},this.isProductFavorite=function(i){return t(a,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,n.isFavoriteProduct({productId:i})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(i){return t(a,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,n.subscribeToMarketingNotifications({input:{email:i,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,h.createEmailSubscripition(i)),[2,t.isSuccess]}}))}))},this.sendReview=function(r){return t(a,void 0,void 0,(function(){var t,o,s,a;return e(this,(function(e){switch(e.label){case 0:if(t=m.getCustomerReviewSettings(),o=m.getSalesChannelId(),!t)return[2];if(!(s=null===(a=this.customer)||void 0===a?void 0:a.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,n.createCustomerReview({input:i(i({},r),{customerId:t.customerLoginRequired?s:void 0,salesChannelId:o||""})})];case 1:return[2,e.sent().data]}}))}))},this.onCustomerConsentGrant=function(){a.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(a,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,f(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 d(t)}))]}}))}))},this.getCustomerAttributes=function(){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,n.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.getOrderRefundSettings=function(){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,n.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.setSavedLastViewedProductsResponse=function(t){a._savedLastViewedProducts=s(a._lastViewedProducts),a._savedLastViewedProductsResponse=t},this.setCaptchaToken=function(t){a._captchaToken=t},this.baseStore=o,r(this)}return Object.defineProperty(g.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||v||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"isCaptchaRequired",{get:function(){var t;return(null===(t=m.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation)||!1},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"useLastViewedProductResponse",{get:function(){var t;return(null===(t=this._savedLastViewedProducts)||void 0===t?void 0:t.length)&&this._savedLastViewedProductsResponse&&0===o(this._lastViewedProducts,this._savedLastViewedProducts,"productId").length},enumerable:!1,configurable:!0}),g.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":m.getApiKey()||"","x-sfid":m.getStorefrontId()||"","x-sfrid":m.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),window.location.href=o.redirectUrl,[2]}}))}))},g.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,n.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&&h.customerLogin(),[2,!0]):[2,!1]}}))}))},g.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,n.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]}}))}))},g.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&&h.customerVisit(),[2]}}))}))},g.prototype.routeChangeInit=function(){this.loadToken(),!this.token&&this.customer&&this.clearLocalData(),this.token&&!this.customer&&this.getCustomer()},g.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return v||!this.token?[2]:[4,n.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},g.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,n.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]}}))}))},g.prototype.setCustomer=function(t){this.customer=new a(t)},g.prototype.getLastViewedProducts=function(){var i;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=(null===(i=s(t.data))||void 0===i?void 0:i.reverse())||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},g.prototype.saveLastViewedProducts=function(){v||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},g.prototype.loadLastViewedProducts=function(){v||(this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=s(this._lastViewedProducts).reverse())},g.prototype.getLocalLastViewedProducts=function(){if(v)return[];try{var t=window.localStorage.getItem("lastViewedProducts");if(t)return JSON.parse(t)}catch(t){}return[]},g.prototype.removeLastViewedProducts=function(){v||window.localStorage.removeItem("lastViewedProducts")},g.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,n.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=this.getLocalLastViewedProducts(),this._lastViewedProducts=this._lastViewedProducts.filter((function(t){return t.productId!==i})),this._lastViewedProducts.push({productId:i,variantId:r}),this._lastViewedProducts=this._lastViewedProducts.slice(-20),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},g.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(v)return[2];e.label=1;case 1:return e.trys.push([1,4,,5]),(t=this.getLocalLastViewedProducts()).length?[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:t}})]:[3,3];case 2:e.sent()&&this.removeLastViewedProducts(),e.label=3;case 3:return[3,5];case 4:return e.sent(),[3,5];case 5:return[2]}}))}))},g.prototype.saveCustomerConsent=function(){v||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},g.prototype.loadCustomerConsent=function(){v||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},g.prototype.removeCustomerConsent=function(){v||window.localStorage.removeItem("customerConsent")},g.prototype.setToken=function(t,e){v||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),m.init({customerToken:t}))},g.prototype.loadToken=function(){if(!v){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e?this.setToken(t,parseInt(e)):this.clearLocalTokenData()}},g.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},g.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,m.init({customerToken:""}),this.clearCaptchaToken()},g.prototype.clearCaptchaToken=function(){this._captchaToken=null},g.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]}}))}))},g}();export{g as IkasCustomerStore};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as r}from'./../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import s from"lodash/xorBy";import o from"lodash/cloneDeep";import n from"./api.js";import{IkasCustomer as a}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 c}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/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/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{IkasRaffleParticipant as d}from"../../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/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 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 l from"../product/index.js";import{Analytics as h}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as m}from"@ikas/storefront-config";import{IkasLoginError as p,IkasRegisterError as f,SaveMyCustomerInput as v}from"@ikas/storefront-api";import{populateRaffleParticipantProducts as g}from"@ikas/storefront-providers";import w from"../checkout/index.js";var k="undefined"==typeof localStorage,b=function(){function b(s){var a=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._savedLastViewedProducts=[],this._savedLastViewedProductsResponse=null,this.toAnalyticsCustomer=function(t){return r(r({},t),{consentGranted:a._customerConsentGranted})},this.login=function(r,i){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(s=t.data,this.setToken(s.token,s.tokenExpiry),s.customer&&this.setCustomer(s.customer),this.customer&&h.customerLogin(),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.customerLogin=function(r,i){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.login({email:r,password:i,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&t.data?(s=t.data,this.setToken(s.token,s.tokenExpiry),s.customer&&this.setCustomer(s.customer),this.customer&&h.customerLogin(),this.saveLocalLastViewedProducts(),[2,{isSuccess:!0,errorCodes:[]}]):[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(p).includes(t)?t:p.UNKOWN}))}]}}))}))},this.logout=function(){var t;a.clearLocalData(),null===(t=a.baseStore)||void 0===t||t.cartStore.removeCart(),h.customerLogout()},this.register=function(r,i,s,o,c,d,u){return t(a,void 0,void 0,(function(){var t,a;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.register({email:s,password:o,firstName:r,lastName:i,isAcceptMarketing:c,attributes:d,captchaToken:this._captchaToken,phone:u})];case 2:return t=e.sent(),this.clearCaptchaToken(),t&&t.isSuccess&&(null===(a=t.data)||void 0===a?void 0:a.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),h.completeRegistration(this.toAnalyticsCustomer(this.customer)),[2,{isSuccess:!0,errorCodes:[]}]):[2,{isSuccess:!1,errorCodes:t.errorCodes.map((function(t){return Object.values(f).includes(t)?t:f.UNKOWN}))}]}}))}))},this.activateCustomer=function(){return t(a,void 0,void 0,(function(){var t,r,i;return e(this,(function(e){switch(e.label){case 0:return t=new URLSearchParams(window.location.search),(r=t.get("token"))?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.activateCustomer({token:r,captchaToken:this._captchaToken})];case 2:return i=e.sent(),this.clearCaptchaToken(),[2,i.isSuccess];case 3:return[2,!1]}}))}))},this.resendCustomerActivationMail=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.resendCustomerActivationMail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess];case 3:return[2,!1]}}))}))},this.validateCustomerPhoneVerificationCode=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.validateCustomerPhoneVerificationCode({verificationCode:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!(!t.isSuccess||!t.data)&&t.data];case 3:return[2,!1]}}))}))},this.resendCustomerPhoneVerificationCode=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return r?[4,this.getCaptcha()]:[3,3];case 1:return e.sent(),[4,n.resendCustomerActivationMail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!(!t.isSuccess||!t.data)&&t.data];case 3:return[2,!1]}}))}))},this.saveContactForm=function(i){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return h.contactForm(i),[4,this.getCaptcha()];case 1:return e.sent(),[4,n.sendContactFormToMerchant(r(r({},i),{captchaToken:this._captchaToken}))];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.checkEmail=function(r){return t(a,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,this.getCaptcha()];case 1:return e.sent(),[4,n.checkEmail({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&!!(null===(i=t.data)||void 0===i?void 0:i.exists)]}}))}))},this.forgotPassword=function(r){return t(a,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,n.forgotPassword({email:r,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,!!t.isSuccess&&t.data]}}))}))},this.recoverPassword=function(r,i,s){return t(a,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,n.recoverPassword({password:r,passwordAgain:i,token:s,captchaToken:this._captchaToken})];case 2:return t=e.sent(),this.clearCaptchaToken(),[2,t.isSuccess]}}))}))},this.saveCustomer=function(r){return t(a,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,n.saveCustomer({input:new v(r)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(r){return t(a,void 0,void 0,(function(){var t,i,s;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrders({orderId:r})];case 1:return(t=e.sent()).isSuccess&&(null===(s=t.data)||void 0===s?void 0:s.length)?(i=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),i.refundSettings=this._refundSettings,[2,i]}}))}))},this.getOrderByEmail=function(r,i){return t(a,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return[4,n.getOrderByEmail({email:r,orderNumber:i})];case 1:return(t=e.sent()).isSuccess&&t.data?(s=t.data,[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),s.refundSettings=this._refundSettings,[2,s]}}))}))},this.getOrderTransactions=function(r){return void 0===r&&(r={}),t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,n.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(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(a,void 0,void 0,(function(){var t,r,i,s,o,a;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.listFavoriteProducts()]:[2,[]];case 1:return(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)?[4,l.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:m.getPriceListId(),salesChannelId:m.getSalesChannelId()}})]:[2,[]];case 2:return r=e.sent(),null===(o=null===(s=r.data)||void 0===s?void 0:s.data)||void 0===o||o.forEach((function(t){t.selectedVariantValues=t.variants[0].variantValues})),[2,(null===(a=null==r?void 0:r.data)||void 0===a?void 0:a.data)||[]]}}))}))},this.addProductToFavorites=function(r){return t(a,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,n.saveFavoriteProduct({isFavorite:!0,productId:r})];case 1:return t=e.sent(),h.addToWishlist(r),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(r){return t(a,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,n.saveFavoriteProduct({isFavorite:!1,productId:r})];case 1:return t=e.sent(),h.addToWishlist(r),[2,t.data||!1]}}))}))},this.isProductFavorite=function(r){return t(a,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,n.isFavoriteProduct({productId:r})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(r){return t(a,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,n.subscribeToMarketingNotifications({input:{email:r,captchaToken:this._captchaToken}})];case 2:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,c.SUBSCRIBED):this._visitorSubscribedEmail=!0,h.createEmailSubscripition(r)),[2,t.isSuccess]}}))}))},this.sendReview=function(i){return t(a,void 0,void 0,(function(){var t,s,o,a;return e(this,(function(e){switch(e.label){case 0:if(t=m.getCustomerReviewSettings(),s=m.getSalesChannelId(),!t)return[2];if(!(o=null===(a=this.customer)||void 0===a?void 0:a.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,n.createCustomerReview({input:r(r({},i),{customerId:t.customerLoginRequired?o:void 0,salesChannelId:s||""})})];case 1:return[2,e.sent().data]}}))}))},this.onCustomerConsentGrant=function(){a.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a.initialized&&(clearInterval(e),t(null))}),100)}))},this.waitUntilCaptchaTokenInitialized=function(){return new Promise((function(t){var e=setInterval((function(){a._captchaToken&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,u.listRaffleParticipants()];case 1:return(t=e.sent())&&t.data?[4,g(t.data)]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new d(t)}))]}}))}))},this.getCustomerAttributes=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,n.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(r=this.customer.attributes)||void 0===r||r.forEach((function(e){var r,i,s;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===(s=null===(i=e.customerAttribute)||void 0===i?void 0:i.options)||void 0===s?void 0:s.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderProductFiles=function(r){return t(a,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r.length?[4,w.listProductFile({id:{in:r}})]:[2,[]];case 1:return[2,t.sent().data||[]]}}))}))},this.getDigitalProductFileDownloadUrl=function(r,i){return t(a,void 0,void 0,(function(){var t,s,o,n,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),(t=r.orderLineItems.find((function(t){return t.variant.id===i.variantId})))?[4,w.getDigitalProductFileDownloadUrl({orderId:r.id,orderLineItemId:t.id})]:[3,2];case 1:s=e.sent(),(o=s.data)&&((n=document.createElement("a")).href=o,n.download=decodeURIComponent(i.name.split("/")[i.name.split("/").length-1])||"",n.click(),n.remove()),e.label=2;case 2:return[3,4];case 3:return a=e.sent(),console.error(a),[3,4];case 4:return[2]}}))}))},this.getOrderRefundSettings=function(){return t(a,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,n.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.setSavedLastViewedProductsResponse=function(t){a._savedLastViewedProducts=o(a._lastViewedProducts),a._savedLastViewedProductsResponse=t},this.setCaptchaToken=function(t){a._captchaToken=t},this.baseStore=s,i(this)}return Object.defineProperty(b.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||k||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"isCaptchaRequired",{get:function(){var t;return(null===(t=m.getCustomerSettings())||void 0===t?void 0:t.requireCaptchaValidation)||!1},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"useLastViewedProductResponse",{get:function(){var t;return(null===(t=this._savedLastViewedProducts)||void 0===t?void 0:t.length)&&this._savedLastViewedProductsResponse&&0===s(this._lastViewedProducts,this._savedLastViewedProducts,"productId").length},enumerable:!1,configurable:!0}),b.prototype.socialLogin=function(r){return t(this,void 0,void 0,(function(){var t,i,s;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":m.getApiKey()||"","x-sfid":m.getStorefrontId()||"","x-sfrid":m.getStorefrontRoutingId()||""}})]);case 1:return[4,e.sent().json()];case 2:return s=e.sent(),window.location.href=s.redirectUrl,[2]}}))}))},b.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,n.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&&h.customerLogin(),[2,!0]):[2,!1]}}))}))},b.prototype.refundOrder=function(r,i){return t(this,void 0,void 0,(function(){var t,s,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,n.createOrderRefundRequest({input:{email:i,orderId:r.id,orderLineItems:t}})];case 1:return(s=e.sent()).isSuccess&&s.data?(Object.entries(s.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]}}))}))},b.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&&h.customerVisit(),[2]}}))}))},b.prototype.routeChangeInit=function(){this.loadToken(),!this.token&&this.customer&&this.clearLocalData(),this.token&&!this.customer&&this.getCustomer()},b.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return k||!this.token?[2]:[4,n.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},b.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,n.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]}}))}))},b.prototype.setCustomer=function(t){this.customer=new a(t)},b.prototype.getLastViewedProducts=function(){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,n.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=(null===(r=o(t.data))||void 0===r?void 0:r.reverse())||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},b.prototype.saveLastViewedProducts=function(){k||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},b.prototype.loadLastViewedProducts=function(){k||(this._lastViewedProducts=this.getLocalLastViewedProducts(),this._lastViewedProducts=o(this._lastViewedProducts).reverse())},b.prototype.getLocalLastViewedProducts=function(){if(k)return[];try{var t=window.localStorage.getItem("lastViewedProducts");if(t)return JSON.parse(t)}catch(t){}return[]},b.prototype.removeLastViewedProducts=function(){k||window.localStorage.removeItem("lastViewedProducts")},b.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,n.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=this.getLocalLastViewedProducts(),this._lastViewedProducts=this._lastViewedProducts.filter((function(t){return t.productId!==r})),this._lastViewedProducts.push({productId:r,variantId:i}),this._lastViewedProducts=this._lastViewedProducts.slice(-20),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},b.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:if(k)return[2];e.label=1;case 1:return e.trys.push([1,4,,5]),(t=this.getLocalLastViewedProducts()).length?[4,n.saveLastViewedProducts({input:{customerId:this.customer.id,products:t}})]:[3,3];case 2:e.sent()&&this.removeLastViewedProducts(),e.label=3;case 3:return[3,5];case 4:return e.sent(),[3,5];case 5:return[2]}}))}))},b.prototype.saveCustomerConsent=function(){k||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},b.prototype.loadCustomerConsent=function(){k||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},b.prototype.removeCustomerConsent=function(){k||window.localStorage.removeItem("customerConsent")},b.prototype.setToken=function(t,e){k||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),m.init({customerToken:t}))},b.prototype.loadToken=function(){if(!k){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e?this.setToken(t,parseInt(e)):this.clearLocalTokenData()}},b.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},b.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,m.init({customerToken:""}),this.clearCaptchaToken()},b.prototype.clearCaptchaToken=function(){this._captchaToken=null},b.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]}}))}))},b}();export{b as IkasCustomerStore};
|