@ikas/storefront 2.0.71 → 2.0.73
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/__generated__/global-types.d.ts +14 -17
- package/build/__generated__/global-types.js +1 -1
- package/build/_virtual/index.js_commonjs-proxy3.js +1 -1
- package/build/_virtual/index.js_commonjs-proxy4.js +1 -1
- package/build/api/category/__generated__/listCategoryPaths.d.ts +19 -0
- package/build/api/category/index.js +1 -1
- package/build/api/product-search/__generated__/getProductFilterData.d.ts +1 -0
- package/build/api/product-search/index.js +1 -1
- package/build/api/raffle/__generated__/listRaffleParticipants.d.ts +67 -0
- package/build/api/raffle/__generated__/listStorefrontRaffle.d.ts +82 -0
- package/build/api/raffle/__generated__/saveRaffleParticipant.d.ts +46 -6
- package/build/api/raffle/index.d.ts +2 -2
- package/build/api/raffle/index.js +1 -1
- package/build/assets/translations/checkout/de.js +1 -0
- package/build/ikas.js +54 -3
- package/build/index.js +1 -1
- package/build/models/data/category/index.d.ts +2 -0
- package/build/models/data/category/index.js +1 -1
- package/build/models/data/index.d.ts +1 -1
- package/build/models/data/product-filter/index.d.ts +3 -1
- package/build/models/data/product-filter/index.js +1 -1
- package/build/models/data/raffle/index.d.ts +10 -4
- package/build/models/data/raffle/index.js +1 -1
- package/build/models/ui/product-list/index.d.ts +37 -0
- package/build/models/ui/product-list/index.js +1 -1
- package/build/models/ui/raffle-list/index.js +1 -1
- package/build/providers/helpers/raffles.js +1 -1
- package/build/providers/page-data-get.js +1 -1
- package/build/providers/prop-value/raffle.js +1 -1
- package/build/store/customer.d.ts +1 -1
- package/build/store/customer.js +1 -1
- package/build/utils/constants.js +1 -1
- package/build/utils/i18n.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as i,__generator as t}from'../../ext/tslib/tslib.es6.js';import"../../api/blog/index.js";import"../../api/brand/index.js";import"../../api/cart/index.js";import"../../api/category/index.js";import"../../api/checkout/index.js";import"../../api/city/index.js";import"../../api/country/index.js";import"../../api/customer/index.js";import"../../api/customer-review/index.js";import"../../api/customer-review-summary/index.js";import"../../api/district/index.js";import"../../api/html-meta-data/index.js";import"../../api/merchant/index.js";import"../../api/product-search/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"mobx";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/merchant-settings/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import"../../api/apollo.js";import"../../api/favorite-product/index.js";import"../../api/contact-form/index.js";import"../../api/state/index.js";import"../../api/product-option-set/index.js";import{IkasRaffleAPI as e}from"../../api/raffle/index.js";import"../../api/back-in-stock-reminder/index.js";import"../../api/product-campaign/index.js";import{getPlaceholderRaffle as o}from"../placeholders.js";import{populateRaffleProducts as r}from"../helpers/raffles.js";var s=function(){function s(i){this.rafflePropValue=i}return s.prototype.getValue=function(){var s;return i(this,void 0,void 0,(function(){var i,a;return t(this,(function(t){switch(t.label){case 0:return(null===(s=this.rafflePropValue)||void 0===s?void 0:s.usePageData)?[2,{raffle:null,rafflePropValue:this.rafflePropValue}]:this.rafflePropValue.raffleId?[4,e.
|
|
1
|
+
import{__awaiter as i,__generator as t}from'../../ext/tslib/tslib.es6.js';import"../../api/blog/index.js";import"../../api/brand/index.js";import"../../api/cart/index.js";import"../../api/category/index.js";import"../../api/checkout/index.js";import"../../api/city/index.js";import"../../api/country/index.js";import"../../api/customer/index.js";import"../../api/customer-review/index.js";import"../../api/customer-review-summary/index.js";import"../../api/district/index.js";import"../../api/html-meta-data/index.js";import"../../api/merchant/index.js";import"../../api/product-search/index.js";import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/category/index.js";import"../../models/data/checkout/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/index.js";import"../../models/data/customer-review/index.js";import"mobx";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/installment-info/index.js";import"../../models/data/merchant-settings/index.js";import"../../models/data/order/index.js";import"../../models/data/order/line-item/index.js";import"../../api/product-option-file/index.js";import"../../models/data/product/index.js";import"../../models/data/variant-type/index.js";import"../../models/data/product/variant/index.js";import"../../models/data/product/variant/price/index.js";import"../../models/data/product-attribute/index.js";import"../../models/data/product/attribute-value/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/variant-type/variant-value/index.js";import"../../models/data/order-transaction/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/product-campaing/campaign/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/theme/theme.js";import"../../models/theme/page/index.js";import"../../models/theme/component/prop/index.js";import"../../models/theme/page/component/prop-value/link.js";import"../../models/ui/brand-list/index.js";import"../../models/ui/blog-list/index.js";import"../../models/ui/blog-category-list/index.js";import"../../models/ui/category-list/index.js";import"../../models/ui/product-detail/index.js";import"../../models/ui/product-list/index.js";import"../../models/ui/product-attribute-detail/index.js";import"../../models/ui/product-attribute-list/index.js";import"../../models/ui/customer-review-list/index.js";import"../../models/ui/customer-review-summary-list/index.js";import"../../models/ui/validator/index.js";import"../../models/ui/validator/rules/index.js";import"../../models/ui/validator/form/login.js";import"../../models/ui/validator/form/address.js";import"../../models/ui/validator/form/register.js";import"../../models/ui/validator/form/contact-form.js";import"../../models/ui/validator/form/forgot-password.js";import"../../models/ui/validator/form/recover-password.js";import"../../models/ui/validator/form/account-info.js";import"../../models/ui/validator/form/raffle-form.js";import"../../models/ui/validator/form/customer-review.js";import"../../models/ui/raffle-list/index.js";import"../../models/theme/settings/index.js";import"../../models/theme/custom-data/index.js";import"../../api/apollo.js";import"../../api/favorite-product/index.js";import"../../api/contact-form/index.js";import"../../api/state/index.js";import"../../api/product-option-set/index.js";import{IkasRaffleAPI as e}from"../../api/raffle/index.js";import"../../api/back-in-stock-reminder/index.js";import"../../api/product-campaign/index.js";import{getPlaceholderRaffle as o}from"../placeholders.js";import{populateRaffleProducts as r}from"../helpers/raffles.js";var s=function(){function s(i){this.rafflePropValue=i}return s.prototype.getValue=function(){var s;return i(this,void 0,void 0,(function(){var i,a;return t(this,(function(t){switch(t.label){case 0:return(null===(s=this.rafflePropValue)||void 0===s?void 0:s.usePageData)?[2,{raffle:null,rafflePropValue:this.rafflePropValue}]:this.rafflePropValue.raffleId?[4,e.listStorefrontRaffle({id:this.rafflePropValue.raffleId})]:[2,null];case 1:return(i=t.sent()).raffles.length?(a=i.raffles[0],[4,r([a])]):[2,null];case 2:return t.sent(),[2,{raffle:a||o(),rafflePropValue:this.rafflePropValue}]}}))}))},s}();export{s as IkasRafflePropValueProvider};
|
|
@@ -59,7 +59,7 @@ export declare class IkasCustomerStore {
|
|
|
59
59
|
sendReview: (input: IkasCustomerReviewForm) => Promise<false | import("../api/customer-review/__generated__/createCustomerReview").createCustomerReview_createCustomerReview | undefined>;
|
|
60
60
|
onCustomerConsentGrant: () => void;
|
|
61
61
|
waitUntilInitialized: () => Promise<unknown>;
|
|
62
|
-
getRaffles: () => Promise<import("../models").
|
|
62
|
+
getRaffles: () => Promise<import("../models").IkasRaffleParticipant[] | undefined>;
|
|
63
63
|
getCustomerAttributes: () => Promise<import("../models").IkasCustomerAttribute[]>;
|
|
64
64
|
getOrderByEmail: (email: string, orderNumber: string) => Promise<import("../models").IkasOrder | undefined>;
|
|
65
65
|
private init;
|
package/build/store/customer.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as r}from'../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import{apollo as o}from"../api/apollo.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/customer/address/index.js";import{IkasCustomer as s,IkasCustomerEmailSubscriptionStatus as n}from"../models/data/customer/index.js";import"../models/data/customer-review/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/installment-info/index.js";import"../models/data/merchant-settings/index.js";import"../models/data/order/index.js";import"../models/data/order/line-item/index.js";import"../api/product-option-file/index.js";import"../models/data/product/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/variant/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product-filter/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/data/order-transaction/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/product-campaing/campaign/index.js";import"../models/data/customer-attribute/index.js";import"../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../models/theme/theme.js";import"../models/theme/page/index.js";import"../models/theme/component/prop/index.js";import"../models/theme/page/component/prop-value/link.js";import"../models/ui/brand-list/index.js";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-detail/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import"../models/theme/settings/index.js";import"../models/theme/custom-data/index.js";import"../api/blog/index.js";import"../api/brand/index.js";import"../api/cart/index.js";import"../api/category/index.js";import"../api/checkout/index.js";import"../api/city/index.js";import"../api/country/index.js";import{IkasCustomerAPI as a}from"../api/customer/index.js";import{IkasCustomerReviewAPI as u}from"../api/customer-review/index.js";import"../api/customer-review-summary/index.js";import"../api/district/index.js";import"../api/html-meta-data/index.js";import"../api/merchant/index.js";import{IkasProductSearchAPI as c}from"../api/product-search/index.js";import{IkasFavoriteProductAPI as d}from"../api/favorite-product/index.js";import{IkasContactFormAPI as l}from"../api/contact-form/index.js";import"../api/state/index.js";import"../api/product-option-set/index.js";import{IkasRaffleAPI as m}from"../api/raffle/index.js";import"../api/back-in-stock-reminder/index.js";import"../api/product-campaign/index.js";import{Analytics as p}from"../analytics/analytics.js";import"../analytics/head/index.js";import{IkasStorefrontConfig as h}from"../storefront/index.js";import{populateRaffleProducts as f}from"../providers/helpers/raffles.js";import v from'../ext/lodash/uniqBy.js';import{IkasCustomerAttributeAPI as w}from"../api/customer-attribute/index.js";var g="undefined"==typeof localStorage,b=function(){function b(o){var s=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.login=function(r,i){return t(s,void 0,void 0,(function(){var t,o,s;return e(this,(function(e){switch(e.label){case 0:return[4,a.login(r,i)];case 1:return(t=e.sent())?(this.setToken(t.token,t.tokenExpiry),this.setCustomer(t.customer),this.customer&&p.customerLogin(),(o=null===(s=this.baseStore)||void 0===s?void 0:s.cartStore.cart)?[4,this.baseStore.cartStore.changeItemQuantity(o.items[0],o.items[0].quantity)]:[3,3]):[3,4];case 2:e.sent(),e.label=3;case 3:return this.saveLocalLastViewedProducts(),[2,!0];case 4:return[2,!1]}}))}))},this.register=function(r,i,o,n,u,c){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.register(o,n,r,i,u,c)];case 1:return(t=e.sent())?(this.setToken(t.token,t.tokenExpiry),this.setCustomer(t.customer),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.saveContactForm=function(r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return p.contactForm(r),[4,l.sendContactFormToMerchant(r)];case 1:return[2,t.sent()]}}))}))},this.checkEmail=function(r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.checkEmail(r)];case 1:return[2,t.sent()]}}))}))},this.forgotPassword=function(r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.forgotPassword(r)];case 1:return[2,t.sent()]}}))}))},this.recoverPassword=function(r,i,o){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.recoverPassword(r,i,o)];case 1:return[2,t.sent()]}}))}))},this.logout=function(){var t;s.clearLocalData(),null===(t=s.baseStore)||void 0===t||t.cartStore.removeCart(),p.customerLogout()},this.saveCustomer=function(r){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.saveCustomer(r)];case 1:return(t=e.sent())?(this.setCustomer(t),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.getOrders()];case 1:return[2,t.sent()]}}))}))},this.getOrder=function(r){return t(s,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,a.getOrders(r)];case 1:return t=e.sent(),Array.isArray(t)&&t.length?((i=t[0])._refundSettings=this._refundSettings,[2,i]):[2,null]}}))}))},this.getOrderTransactions=function(r){return void 0===r&&(r={}),t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.getOrderTransactions(r)];case 1:return[2,t.sent()]}}))}))},this.getFavoriteProductsIds=function(){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,d.listFavoriteProducts()];case 1:return[2,t.sent()];case 2:return t.sent(),[2,[]];case 3:return[2]}}))}))},this.getFavoriteProducts=function(){return t(s,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,d.listFavoriteProducts()];case 1:return(t=e.sent()).length?[4,c.searchProducts({productIdList:t.map((function(t){return t.productId})),priceListId:h.priceListId,salesChannelId:h.salesChannelId})]:[2,[]];case 2:return[2,(null==(r=e.sent())?void 0:r.data)||[]];case 3:return e.sent(),[2,[]];case 4:return[2]}}))}))},this.getOrderRefundSettings=function(){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:(t=this,[4,a.getOrderRefundSettings()]);case 1:t._refundSettings=e.sent(),e.label=2;case 2:return[2]}}))}))},this.addItemToFavorite=function(r){return t(s,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");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,d.saveFavoriteProduct(!0,r)];case 2:return t=e.sent(),p.addToWishlist(r),[2,t];case 3:return e.sent(),[2,!1];case 4:return[2]}}))}))},this.removeItemFromFavorite=function(r){return t(s,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");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,d.saveFavoriteProduct(!1,r)];case 2:return[2,e.sent()];case 3:return e.sent(),[2,!1];case 4:return[2]}}))}))},this.isProductFavorite=function(r){return t(s,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,d.isFavoriteProduct(r)];case 1:return[2,e.sent()]}}))}))},this.createEmailSubscription=function(r){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.createCustomerEmailSubscription(r)];case 1:return(t=e.sent())&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,n.SUBSCRIBED):this._visitorSubscribedEmail=!0,p.createEmailSubscripition(r)),[2,t]}}))}))},this.sendReview=function(i){return t(s,void 0,void 0,(function(){var t,o,s,n,a;return e(this,(function(e){switch(e.label){case 0:if(e.trys.push([0,2,,3]),t=h.customerReviewSettings,o=h.salesChannelId,!t)return[2];if(!(s=null===(a=this.customer)||void 0===a?void 0:a.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,u.createCustomerReview(r(r({},i),{customerId:t.customerLoginRequired?s:void 0,salesChannelId:o||""}))];case 1:return[2,e.sent()];case 2:return n=e.sent(),console.log(n),[3,3];case 3:return[2]}}))}))},this.onCustomerConsentGrant=function(){s.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){s.initialized&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(s,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return[4,m.getRafflesByCustomerId()];case 1:return t=e.sent(),[4,m.getRafflesByCustomerId(!0)];case 2:return r=e.sent(),null==t||t.forEach((function(t){(null==r?void 0:r.find((function(e){return e.id===t.id})))&&(t.isCustomerWinner=!0)})),t?[4,f(t)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2,t]}}))}))},this.getCustomerAttributes=function(){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,w.listCustomerAttributes()];case 1:return t=e.sent(),this.customer&&this.customer.attributes.forEach((function(e){var r,i;e.customerAttribute=t.find((function(t){return t.id===e.customerAttributeId})),e.customerAttributeOptionId&&(e.customerAttributeOption=null===(i=null===(r=e.customerAttribute)||void 0===r?void 0:r.options)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeOptionId})))})),[2,t]}}))}))},this.getOrderByEmail=function(r,i){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.getOrderByEmail(r,i)];case 1:return[2,t.sent()]}}))}))},this.baseStore=o,this.init(),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)||g||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),b.prototype.socialLogin=function(r){return t(this,void 0,void 0,(function(){var t,i,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",i="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(r,"/login/authenticate?redirect=").concat(t),[4,fetch(i,{headers:{"x-api-key":h.config.apiKey||"","x-sfid":h.storefrontId||"","x-sfrid":h.storefrontRoutingId||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),h.router?h.router.replace(o.redirectUrl):window.location.href=o.redirectUrl,[2]}}))}))},b.prototype.socialLoginToken=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.socialLogin(r)];case 1:return(null==(t=e.sent())?void 0:t.customer)?(this.setToken(t.token,t.tokenExpiry),this.setCustomer(t.customer),this.customer&&p.customerLogin(),[2,!0]):[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(),[4,this.getOrderRefundSettings()];case 3:return t.sent(),this._initialized=!0,this.customer&&p.customerVisit(),[2]}}))}))},b.prototype.routeChangeInit=function(){this.customer||(this.loadToken(),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 g||!this.token?[2]:[4,a.getCustomer()];case 1:return(t=e.sent())&&this.setCustomer(t),[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,a.refreshToken(this.token)]:[2];case 1:return(null==(t=e.sent())?void 0:t.token)||(null==t?void 0:t.tokenExpiry)?this.setToken(t.token,t.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},b.prototype.setCustomer=function(t){this.customer=new s(t)},b.prototype.getLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?(t=this,[4,a.getLastViewedProducts(this.customer.id)]):[3,2];case 1:return t._lastViewedProducts=e.sent(),[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},b.prototype.saveLastViewedProducts=function(){g||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},b.prototype.loadLastViewedProducts=function(){if(!g)try{var t=window.localStorage.getItem("lastViewedProducts");t&&(this._lastViewedProducts=JSON.parse(t),this._lastViewedProducts=this._lastViewedProducts.reverse(),this._lastViewedProducts=v(this._lastViewedProducts,"variantId"))}catch(t){}},b.prototype.removeLastViewedProducts=function(){g||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,a.saveLastViewedProducts({customerId:this.customer.id,products:[{productId:r,variantId:i}]})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:r,variantId:i}),[3,3];case 2:this._lastViewedProducts.push({productId:r,variantId:i}),this._lastViewedProducts=this._lastViewedProducts.slice(0,20),this._lastViewedProducts=v(this._lastViewedProducts,"variantId"),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},b.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:if(g)return[2];t.label=1;case 1:return t.trys.push([1,4,,5]),this.loadLastViewedProducts(),this._lastViewedProducts.length?[4,a.saveLastViewedProducts({customerId:this.customer.id,products:this._lastViewedProducts})]:[3,3];case 2:t.sent()&&this.removeLastViewedProducts(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},b.prototype.saveCustomerConsent=function(){g||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},b.prototype.loadCustomerConsent=function(){g||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},b.prototype.removeCustomerConsent=function(){g||window.localStorage.removeItem("customerConsent")},b.prototype.setToken=function(t,e){g||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),o.setCustomerToken(t))},b.prototype.loadToken=function(){if(!g){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e&&this.setToken(t,parseInt(e))}},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,o.setCustomerToken()},b}();export{b 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{apollo as o}from"../api/apollo.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/customer/address/index.js";import{IkasCustomer as s,IkasCustomerEmailSubscriptionStatus as n}from"../models/data/customer/index.js";import"../models/data/customer-review/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/installment-info/index.js";import"../models/data/merchant-settings/index.js";import"../models/data/order/index.js";import"../models/data/order/line-item/index.js";import"../api/product-option-file/index.js";import"../models/data/product/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/variant/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product-filter/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/data/order-transaction/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/product-campaing/campaign/index.js";import"../models/data/customer-attribute/index.js";import"../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../models/theme/theme.js";import"../models/theme/page/index.js";import"../models/theme/component/prop/index.js";import"../models/theme/page/component/prop-value/link.js";import"../models/ui/brand-list/index.js";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-detail/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import"../models/theme/settings/index.js";import"../models/theme/custom-data/index.js";import"../api/blog/index.js";import"../api/brand/index.js";import"../api/cart/index.js";import"../api/category/index.js";import"../api/checkout/index.js";import"../api/city/index.js";import"../api/country/index.js";import{IkasCustomerAPI as a}from"../api/customer/index.js";import{IkasCustomerReviewAPI as u}from"../api/customer-review/index.js";import"../api/customer-review-summary/index.js";import"../api/district/index.js";import"../api/html-meta-data/index.js";import"../api/merchant/index.js";import{IkasProductSearchAPI as c}from"../api/product-search/index.js";import{IkasFavoriteProductAPI as d}from"../api/favorite-product/index.js";import{IkasContactFormAPI as l}from"../api/contact-form/index.js";import"../api/state/index.js";import"../api/product-option-set/index.js";import{IkasRaffleAPI as m}from"../api/raffle/index.js";import"../api/back-in-stock-reminder/index.js";import"../api/product-campaign/index.js";import{Analytics as p}from"../analytics/analytics.js";import"../analytics/head/index.js";import{IkasStorefrontConfig as h}from"../storefront/index.js";import{populateRaffleProducts as f}from"../providers/helpers/raffles.js";import v from'../ext/lodash/uniqBy.js';import{IkasCustomerAttributeAPI as w}from"../api/customer-attribute/index.js";var g="undefined"==typeof localStorage,b=function(){function b(o){var s=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.login=function(r,i){return t(s,void 0,void 0,(function(){var t,o,s;return e(this,(function(e){switch(e.label){case 0:return[4,a.login(r,i)];case 1:return(t=e.sent())?(this.setToken(t.token,t.tokenExpiry),this.setCustomer(t.customer),this.customer&&p.customerLogin(),(o=null===(s=this.baseStore)||void 0===s?void 0:s.cartStore.cart)?[4,this.baseStore.cartStore.changeItemQuantity(o.items[0],o.items[0].quantity)]:[3,3]):[3,4];case 2:e.sent(),e.label=3;case 3:return this.saveLocalLastViewedProducts(),[2,!0];case 4:return[2,!1]}}))}))},this.register=function(r,i,o,n,u,c){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.register(o,n,r,i,u,c)];case 1:return(t=e.sent())?(this.setToken(t.token,t.tokenExpiry),this.setCustomer(t.customer),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.saveContactForm=function(r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return p.contactForm(r),[4,l.sendContactFormToMerchant(r)];case 1:return[2,t.sent()]}}))}))},this.checkEmail=function(r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.checkEmail(r)];case 1:return[2,t.sent()]}}))}))},this.forgotPassword=function(r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.forgotPassword(r)];case 1:return[2,t.sent()]}}))}))},this.recoverPassword=function(r,i,o){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.recoverPassword(r,i,o)];case 1:return[2,t.sent()]}}))}))},this.logout=function(){var t;s.clearLocalData(),null===(t=s.baseStore)||void 0===t||t.cartStore.removeCart(),p.customerLogout()},this.saveCustomer=function(r){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.saveCustomer(r)];case 1:return(t=e.sent())?(this.setCustomer(t),[2,!0]):[2,!1]}}))}))},this.getOrders=function(){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.getOrders()];case 1:return[2,t.sent()]}}))}))},this.getOrder=function(r){return t(s,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,a.getOrders(r)];case 1:return t=e.sent(),Array.isArray(t)&&t.length?((i=t[0])._refundSettings=this._refundSettings,[2,i]):[2,null]}}))}))},this.getOrderTransactions=function(r){return void 0===r&&(r={}),t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.getOrderTransactions(r)];case 1:return[2,t.sent()]}}))}))},this.getFavoriteProductsIds=function(){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,d.listFavoriteProducts()];case 1:return[2,t.sent()];case 2:return t.sent(),[2,[]];case 3:return[2]}}))}))},this.getFavoriteProducts=function(){return t(s,void 0,void 0,(function(){var t,r;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,3,,4]),[4,d.listFavoriteProducts()];case 1:return(t=e.sent()).length?[4,c.searchProducts({productIdList:t.map((function(t){return t.productId})),priceListId:h.priceListId,salesChannelId:h.salesChannelId})]:[2,[]];case 2:return[2,(null==(r=e.sent())?void 0:r.data)||[]];case 3:return e.sent(),[2,[]];case 4:return[2]}}))}))},this.getOrderRefundSettings=function(){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:(t=this,[4,a.getOrderRefundSettings()]);case 1:t._refundSettings=e.sent(),e.label=2;case 2:return[2]}}))}))},this.addItemToFavorite=function(r){return t(s,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");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,d.saveFavoriteProduct(!0,r)];case 2:return t=e.sent(),p.addToWishlist(r),[2,t];case 3:return e.sent(),[2,!1];case 4:return[2]}}))}))},this.removeItemFromFavorite=function(r){return t(s,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");e.label=1;case 1:return e.trys.push([1,3,,4]),[4,d.saveFavoriteProduct(!1,r)];case 2:return[2,e.sent()];case 3:return e.sent(),[2,!1];case 4:return[2]}}))}))},this.isProductFavorite=function(r){return t(s,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,d.isFavoriteProduct(r)];case 1:return[2,e.sent()]}}))}))},this.createEmailSubscription=function(r){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.createCustomerEmailSubscription(r)];case 1:return(t=e.sent())&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,n.SUBSCRIBED):this._visitorSubscribedEmail=!0,p.createEmailSubscripition(r)),[2,t]}}))}))},this.sendReview=function(i){return t(s,void 0,void 0,(function(){var t,o,s,n,a;return e(this,(function(e){switch(e.label){case 0:if(e.trys.push([0,2,,3]),t=h.customerReviewSettings,o=h.salesChannelId,!t)return[2];if(!(s=null===(a=this.customer)||void 0===a?void 0:a.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,u.createCustomerReview(r(r({},i),{customerId:t.customerLoginRequired?s:void 0,salesChannelId:o||""}))];case 1:return[2,e.sent()];case 2:return n=e.sent(),console.log(n),[3,3];case 3:return[2]}}))}))},this.onCustomerConsentGrant=function(){s.saveCustomerConsent()},this.waitUntilInitialized=function(){return new Promise((function(t){var e=setInterval((function(){s.initialized&&(clearInterval(e),t(null))}),100)}))},this.getRaffles=function(){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,m.listRaffleParticipants()];case 1:return(t=e.sent())?[4,f(t.map((function(t){return t.raffle})))]:[3,3];case 2:e.sent(),e.label=3;case 3:return[2,t]}}))}))},this.getCustomerAttributes=function(){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,w.listCustomerAttributes()];case 1:return t=e.sent(),this.customer&&this.customer.attributes.forEach((function(e){var r,i;e.customerAttribute=t.find((function(t){return t.id===e.customerAttributeId})),e.customerAttributeOptionId&&(e.customerAttributeOption=null===(i=null===(r=e.customerAttribute)||void 0===r?void 0:r.options)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeOptionId})))})),[2,t]}}))}))},this.getOrderByEmail=function(r,i){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a.getOrderByEmail(r,i)];case 1:return[2,t.sent()]}}))}))},this.baseStore=o,this.init(),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)||g||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(b.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),b.prototype.socialLogin=function(r){return t(this,void 0,void 0,(function(){var t,i,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",i="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(r,"/login/authenticate?redirect=").concat(t),[4,fetch(i,{headers:{"x-api-key":h.config.apiKey||"","x-sfid":h.storefrontId||"","x-sfrid":h.storefrontRoutingId||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),h.router?h.router.replace(o.redirectUrl):window.location.href=o.redirectUrl,[2]}}))}))},b.prototype.socialLoginToken=function(r){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,a.socialLogin(r)];case 1:return(null==(t=e.sent())?void 0:t.customer)?(this.setToken(t.token,t.tokenExpiry),this.setCustomer(t.customer),this.customer&&p.customerLogin(),[2,!0]):[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(),[4,this.getOrderRefundSettings()];case 3:return t.sent(),this._initialized=!0,this.customer&&p.customerVisit(),[2]}}))}))},b.prototype.routeChangeInit=function(){this.customer||(this.loadToken(),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 g||!this.token?[2]:[4,a.getCustomer()];case 1:return(t=e.sent())&&this.setCustomer(t),[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,a.refreshToken(this.token)]:[2];case 1:return(null==(t=e.sent())?void 0:t.token)||(null==t?void 0:t.tokenExpiry)?this.setToken(t.token,t.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},b.prototype.setCustomer=function(t){this.customer=new s(t)},b.prototype.getLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?(t=this,[4,a.getLastViewedProducts(this.customer.id)]):[3,2];case 1:return t._lastViewedProducts=e.sent(),[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},b.prototype.saveLastViewedProducts=function(){g||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},b.prototype.loadLastViewedProducts=function(){if(!g)try{var t=window.localStorage.getItem("lastViewedProducts");t&&(this._lastViewedProducts=JSON.parse(t),this._lastViewedProducts=this._lastViewedProducts.reverse(),this._lastViewedProducts=v(this._lastViewedProducts,"productId"))}catch(t){}},b.prototype.removeLastViewedProducts=function(){g||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,a.saveLastViewedProducts({customerId:this.customer.id,products:[{productId:r,variantId:i}]})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:r,variantId:i}),[3,3];case 2:this._lastViewedProducts.push({productId:r,variantId:i}),this._lastViewedProducts=this._lastViewedProducts.slice(0,20),this._lastViewedProducts=v(this._lastViewedProducts,"productId"),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},b.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:if(g)return[2];t.label=1;case 1:return t.trys.push([1,4,,5]),this.loadLastViewedProducts(),this._lastViewedProducts.length?[4,a.saveLastViewedProducts({customerId:this.customer.id,products:this._lastViewedProducts})]:[3,3];case 2:t.sent()&&this.removeLastViewedProducts(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},b.prototype.saveCustomerConsent=function(){g||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},b.prototype.loadCustomerConsent=function(){g||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},b.prototype.removeCustomerConsent=function(){g||window.localStorage.removeItem("customerConsent")},b.prototype.setToken=function(t,e){g||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),o.setCustomerToken(t))},b.prototype.loadToken=function(){if(!g){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e&&this.setToken(t,parseInt(e))}},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,o.setCustomerToken()},b}();export{b as IkasCustomerStore};
|
package/build/utils/constants.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var r=["DE","US"],S=["US"];export{S as DISTRICT_HIDDEN_COUNTRY_LIST,r as FREE_TEXT_CITY_COUNTRY_LIST};
|
|
1
|
+
var r=["DE","US","AT"],S=["US"];export{S as DISTRICT_HIDDEN_COUNTRY_LIST,r as FREE_TEXT_CITY_COUNTRY_LIST};
|
package/build/utils/i18n.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t}from'../ext/tslib/tslib.es6.js';import r from"fs";import n from"path";import
|
|
1
|
+
import{__awaiter as e,__generator as t}from'../ext/tslib/tslib.es6.js';import r from"fs";import n from"path";import s from'../ext/lodash/get.js';import{IkasStorefrontConfig as a}from"../storefront/index.js";import{findAllIndexes as o}from"./helper.js";var i="checkout-page",l=function(){function s(e,t,r){this.locale=e,this.namespaces=t,this.localePath=r}return s.prototype.read=function(){return e(this,void 0,void 0,(function(){var e,s,a,o,i,l,u,c,h;return t(this,(function(t){switch(t.label){case 0:e={},s=0,a=this.namespaces,t.label=1;case 1:if(!(s<a.length))return[3,14];o=a[s],t.label=2;case 2:return t.trys.push([2,12,,13]),i=this.localePath?n.join(this.localePath,this.locale,o+".json"):n.join(process.cwd(),"public","locales",this.locale,o+".json"),r.existsSync(i)?[4,this.readLocaleFile(i)]:[3,4];case 3:return l=t.sent(),e[o]=l,[3,11];case 4:return"checkout-page"!==o?[3,11]:(u={},"tr"!==this.locale?[3,6]:[4,import("../assets/translations/checkout/tr.js")]);case 5:return c=t.sent(),u=c.default,[3,10];case 6:return"de"!==this.locale?[3,8]:[4,import("../assets/translations/checkout/de.js")];case 7:return c=t.sent(),u=c.default,[3,10];case 8:return[4,import("../assets/translations/checkout/en.js")];case 9:c=t.sent(),u=c.default,t.label=10;case 10:e[o]=u,t.label=11;case 11:return[3,13];case 12:return h=t.sent(),console.error(h),[3,13];case 13:return s++,[3,1];case 14:return[2,e]}}))}))},s.prototype.readLocaleFile=function(n){return e(this,void 0,void 0,(function(){return t(this,(function(e){return[2,new Promise((function(e,t){r.readFile(n,{flag:"r"},(function(r,n){if(r)return t(r);var s=n.length?JSON.parse(n.toString()):{};e(s)}))}))]}))}))},s}();function u(e,t){var r="common",n="",o=e.split(":");if(o.length>2)return e;2===o.length?(r=o[0],n=o[1]):n=o[0];var i=a.translations[r];if(!i)return e;var l=s(i,n);if(l){if(t){for(var u="",c=0,f=h(l);c<f.length;c++){var p=f[c];if(p.isVariable){var m=p.value.replace("{{","").replace("}}","").trim();t[m]?u+=t[m]:u+=p.value}else u+=p.value}return u}return l}return e}function c(e){return{t:u}}function h(e){var t=[];if(!e)return t;for(var r=o(e,"{{"),n=o(e,"}}"),s=r.map((function(e,t){return{start:e,end:n[t]+1}})),a=function(e){return s.some((function(t){return t.start<=e&&t.end>=e}))},i="",l=!1,u=0;u<e.length;u++){var c=e.charAt(u);l?a(u)?i+=c:(t.push({isVariable:!0,value:i}),i=c,l=!1):a(u)?(t.push({isVariable:!1,value:i}),i=c,l=!0):i+=c,u===e.length-1&&t.push({isVariable:l,value:i})}return t}export{i as CHECKOUT_TRANSLATION_NAMESPACE,l as I18NFileReader,h as createTranslationInputData,c as useTranslation};
|