@ikas/storefront 3.0.0-alpha.28 → 3.0.0-alpha.29

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.
Files changed (32) hide show
  1. package/build/__api/models/CreateStripePaymentIntentResponse.d.ts +12 -0
  2. package/build/__api/models/CreateStripePaymentIntentResponse.js +1 -0
  3. package/build/__api/mutations/createStripePaymentIntent.d.ts +13 -0
  4. package/build/__api/mutations/createStripePaymentIntent.js +1 -0
  5. package/build/__api/types/index.d.ts +6 -0
  6. package/build/_virtual/index.js_commonjs-proxy13.js +1 -1
  7. package/build/_virtual/index.js_commonjs-proxy14.js +1 -1
  8. package/build/_virtual/index.js_commonjs-proxy3.js +1 -1
  9. package/build/_virtual/index.js_commonjs-proxy4.js +1 -1
  10. package/build/assets/translations/checkout/en.js +1 -1
  11. package/build/assets/translations/checkout/tr.js +1 -1
  12. package/build/components/checkout/components/stripe/checkout-form.d.ts +8 -0
  13. package/build/components/checkout/components/stripe/checkout-form.js +1 -0
  14. package/build/components/checkout/components/stripe/index.d.ts +9 -0
  15. package/build/components/checkout/components/stripe/index.js +1 -0
  16. package/build/components/checkout/index.js +1 -1
  17. package/build/components/checkout/model.d.ts +3 -1
  18. package/build/components/checkout/model.js +1 -1
  19. package/build/components/checkout/steps/step-payment/payment-gateways/index.js +1 -1
  20. package/build/components/checkout/steps/step-success/index.js +1 -1
  21. package/build/components/checkout/steps/step-success/style.module.scss.js +1 -1
  22. package/build/ext/@stripe/react-stripe-js/dist/react-stripe.esm.js +1 -0
  23. package/build/ext/@stripe/stripe-js/dist/stripe.esm.js +1 -0
  24. package/build/ikas.cjs +1 -1
  25. package/build/models/data/order/index.js +1 -1
  26. package/build/providers/page-data-next.d.ts +4 -0
  27. package/build/providers/page-data-next.js +1 -1
  28. package/build/scripts/generators/config/content.js +1 -1
  29. package/build/store/checkout/index.d.ts +3 -0
  30. package/build/store/checkout/index.js +1 -1
  31. package/build/store/customer/index.js +1 -1
  32. package/package.json +3 -1
@@ -1 +1 @@
1
- import{__extends as e,__awaiter as t,__generator as r,__assign as n}from'../../../ext/tslib/tslib.es6.js';import{IkasOrderAddress as i}from"./address/index.js";import{IkasOrderShippingLine as s}from"./shipping-line/index.js";import{IkasOrderLineItem as o}from"./line-item/index.js";import{makeObservable as d,observable as u,computed as a}from"mobx";import"../../../storefront/index.js";import'../../../ext/lodash/isArguments.js';import'../../../ext/lodash/isBuffer.js';import'../../../ext/lodash/isTypedArray.js';import'../../../ext/lodash/_baseGetTag.js';import{getCurrencySymbol as l}from"../../../utils/currency.js";import"../../../utils/i18n.js";import m from"../../../__api/models/_base.js";import{IkasOrderGiftPackageLine as c}from"./gift-line/index.js";import{IkasInvoice as f}from"./invoice/index.js";import{IkasOrderPaymentMethod as p}from"./payment-method/index.js";import{OrderLineItemStatusEnum as g,ShippingMethodEnum as h,OrderStatusEnum as y}from"../../../__api/types/index.js";export{CancelledReasonEnum as IkasOrderCancelReason,OrderPackageStatusEnum as IkasOrderPackageStatus,OrderPaymentStatusEnum as IkasOrderPaymentStatus,ShippingMethodEnum as IkasOrderShippingMethod,OrderStatusEnum as IkasOrderStatus}from"../../../__api/types/index.js";import{IkasOrderAdjustment as v}from"./adjustment/index.js";import{IkasOrderPackage as I}from"./package/index.js";import{IkasOrderTaxLine as P}from"./tax-line/index.js";import b from"../../../store/customer/api.js";var L=function(m){function L(e){var g,L,j,E,A,S,k,_=m.call(this,e)||this;return _._refundSettings=null,_.refund=function(){return t(_,void 0,void 0,(function(){var e,t,n=this;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e=[],this.orderLineItems.map((function(t){null!==t.refundQuantity&&(null==e||e.push({orderLineItemId:t.id,quantity:t.refundQuantity?t.refundQuantity:0}))})),[4,b.createOrderRefundRequest({input:{orderId:this.id,orderLineItems:e}})];case 1:return(t=r.sent()).isSuccess&&t.data?(Object.entries(t.data).forEach((function(e){var t=e[0],r=e[1];n[t]=r})),[2,!0]):[3,3];case 2:return r.sent(),[3,3];case 3:return[2,!1]}}))}))},_.billingAddress=e.billingAddress?new i(e.billingAddress):null,_.cancelReason=e.cancelReason||null,_.cancelledAt=e.cancelledAt||null,_.currencyCode=e.currencyCode||"",_.currencySymbol=l(_.currencyCode),_.customer=e.customer||null,_.customerId=e.customerId||null,_.giftPackageLines=(null===(g=e.giftPackageLines)||void 0===g?void 0:g.map((function(e){return new c(e)})))||null,_.giftPackageNote=e.giftPackageNote||null,_.invoices=(null===(L=e.invoices)||void 0===L?void 0:L.map((function(e){return new f(e)})))||null,_.isGiftPackage=e.isGiftPackage||null,_.note=e.note||null,_.orderAdjustments=(null===(j=e.orderAdjustments)||void 0===j?void 0:j.map((function(e){return new v(e)})))||[],_.orderLineItems=e.orderLineItems?e.orderLineItems.map((function(t){return new o(n(n({},t),{orderedAt:e.orderedAt||void 0}))})):[],_.orderNumber=e.orderNumber||null,_.orderPackageStatus=e.orderPackageStatus||null,_.orderPackages=(null===(E=e.orderPackages)||void 0===E?void 0:E.map((function(e){return new I(e)})))||null,_.orderPaymentStatus=e.orderPaymentStatus||null,_.orderedAt=e.orderedAt||null,_.paymentMethods=(null===(A=e.paymentMethods)||void 0===A?void 0:A.map((function(e){return new p(e)})))||null,_.shippingAddress=e.shippingAddress?new i(e.shippingAddress):null,_.shippingLines=(null===(S=e.shippingLines)||void 0===S?void 0:S.map((function(e){return new s(e)})))||null,_.shippingMethod=e.shippingMethod||h.NO_SHIPMENT,_.status=e.status||y.CREATED,_.taxLines=(null===(k=e.taxLines)||void 0===k?void 0:k.map((function(e){return new P(e)})))||null,_.totalFinalPrice=e.totalFinalPrice||0,_.totalPrice=e.totalPrice||0,d(_,{billingAddress:u,cancelReason:u,cancelledAt:u,currencyCode:u,currencySymbol:u,customer:u,customerId:u,giftPackageLines:u,giftPackageNote:u,invoices:u,isGiftPackage:u,note:u,orderAdjustments:u,orderLineItems:u,orderNumber:u,orderPackageStatus:u,orderPackages:u,orderPaymentStatus:u,orderedAt:u,paymentMethods:u,shippingAddress:u,shippingLines:u,shippingMethod:u,status:u,taxLines:u,totalFinalPrice:u,totalPrice:u,items:a,itemCount:a,refundableItems:a,unfullfilledItems:a,refundedItems:a}),_}return e(L,m),Object.defineProperty(L.prototype,"items",{get:function(){return this.orderLineItems},set:function(e){this.orderLineItems=e},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"itemCount",{get:function(){var e;return(null===(e=this.orderLineItems)||void 0===e?void 0:e.length)||0},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"refundableItems",{get:function(){var e=this;return!this._refundSettings||this._refundSettings&&!this._refundSettings.isActiveRefundSection?[]:this.orderLineItems.filter((function(t){var r;return[g.FULFILLED,g.UNFULFILLED,g.DELIVERED].includes(t.status)&&(!(null===(r=e._refundSettings)||void 0===r?void 0:r.orderRefundDayLimit)||e._refundSettings.orderRefundDayLimit>=e.getItemOrderedAtDays(t))}))},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"unfullfilledItems",{get:function(){var e=this;return this.orderLineItems.filter((function(t){var r;return!(null===(r=e.orderPackages)||void 0===r?void 0:r.some((function(e){return e.orderLineItemIds.includes(t.id)})))}))},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"refundedItems",{get:function(){return this.orderLineItems.filter((function(e){return e.status===g.REFUNDED||e.status===g.REFUND_REQUESTED||e.status===g.REFUND_REQUEST_ACCEPTED||e.status===g.REFUND_REJECTED}))},enumerable:!1,configurable:!0}),L.prototype.getItemOrderedAtDays=function(e){var t=e.orderedAt,r=Date.now();return Math.abs(r-t)/864e5},L}(m);export{L as IkasOrder};
1
+ import{__extends as e,__awaiter as t,__generator as r,__assign as n}from'../../../ext/tslib/tslib.es6.js';import{IkasOrderAddress as i}from"./address/index.js";import{IkasOrderShippingLine as s}from"./shipping-line/index.js";import{IkasOrderLineItem as o}from"./line-item/index.js";import{makeObservable as d,observable as u,computed as a}from"mobx";import"../../../storefront/index.js";import'../../../ext/lodash/isArguments.js';import'../../../ext/lodash/isBuffer.js';import'../../../ext/lodash/isTypedArray.js';import'../../../ext/lodash/_baseGetTag.js';import{getCurrencySymbol as l}from"../../../utils/currency.js";import"../../../utils/i18n.js";import m from"../../../__api/models/_base.js";import{IkasOrderGiftPackageLine as c}from"./gift-line/index.js";import{IkasInvoice as f}from"./invoice/index.js";import{IkasOrderPaymentMethod as p}from"./payment-method/index.js";import{OrderLineItemStatusEnum as g,ShippingMethodEnum as h,OrderStatusEnum as y}from"../../../__api/types/index.js";export{CancelledReasonEnum as IkasOrderCancelReason,OrderPackageStatusEnum as IkasOrderPackageStatus,OrderPaymentStatusEnum as IkasOrderPaymentStatus,ShippingMethodEnum as IkasOrderShippingMethod,OrderStatusEnum as IkasOrderStatus}from"../../../__api/types/index.js";import{IkasOrderAdjustment as v}from"./adjustment/index.js";import{IkasOrderPackage as I}from"./package/index.js";import{IkasOrderTaxLine as P}from"./tax-line/index.js";import b from"../../../store/customer/api.js";var L=function(m){function L(e){var g,L,j,E,A,S,k,_=m.call(this,e)||this;return _._refundSettings=null,_.refund=function(){return t(_,void 0,void 0,(function(){var e,t,n=this;return r(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e=[],this.orderLineItems.map((function(t){null!==t.refundQuantity&&(null==e||e.push({orderLineItemId:t.id,quantity:t.refundQuantity?t.refundQuantity:0}))})),[4,b.createOrderRefundRequest({input:{orderId:this.id,orderLineItems:e}})];case 1:return(t=r.sent()).isSuccess&&t.data?(Object.entries(t.data).forEach((function(e){var t=e[0],r=e[1];n[t]=r})),[2,!0]):[3,3];case 2:return r.sent(),[3,3];case 3:return[2,!1]}}))}))},_.billingAddress=e.billingAddress?new i(e.billingAddress):null,_.cancelReason=e.cancelReason||null,_.cancelledAt=e.cancelledAt||null,_.currencyCode=e.currencyCode||"",_.currencySymbol=l(_.currencyCode),_.customer=e.customer||null,_.customerId=e.customerId||null,_.giftPackageLines=(null===(g=e.giftPackageLines)||void 0===g?void 0:g.map((function(e){return new c(e)})))||null,_.giftPackageNote=e.giftPackageNote||null,_.invoices=(null===(L=e.invoices)||void 0===L?void 0:L.map((function(e){return new f(e)})))||null,_.isGiftPackage=e.isGiftPackage||null,_.note=e.note||null,_.orderAdjustments=(null===(j=e.orderAdjustments)||void 0===j?void 0:j.map((function(e){return new v(e)})))||[],_.orderLineItems=e.orderLineItems?e.orderLineItems.filter((function(e){return!e.deleted})).map((function(t){return new o(n(n({},t),{orderedAt:e.orderedAt||void 0}))})):[],_.orderNumber=e.orderNumber||null,_.orderPackageStatus=e.orderPackageStatus||null,_.orderPackages=(null===(E=e.orderPackages)||void 0===E?void 0:E.map((function(e){return new I(e)})))||null,_.orderPaymentStatus=e.orderPaymentStatus||null,_.orderedAt=e.orderedAt||null,_.paymentMethods=(null===(A=e.paymentMethods)||void 0===A?void 0:A.map((function(e){return new p(e)})))||null,_.shippingAddress=e.shippingAddress?new i(e.shippingAddress):null,_.shippingLines=(null===(S=e.shippingLines)||void 0===S?void 0:S.map((function(e){return new s(e)})))||null,_.shippingMethod=e.shippingMethod||h.NO_SHIPMENT,_.status=e.status||y.CREATED,_.taxLines=(null===(k=e.taxLines)||void 0===k?void 0:k.map((function(e){return new P(e)})))||null,_.totalFinalPrice=e.totalFinalPrice||0,_.totalPrice=e.totalPrice||0,d(_,{billingAddress:u,cancelReason:u,cancelledAt:u,currencyCode:u,currencySymbol:u,customer:u,customerId:u,giftPackageLines:u,giftPackageNote:u,invoices:u,isGiftPackage:u,note:u,orderAdjustments:u,orderLineItems:u,orderNumber:u,orderPackageStatus:u,orderPackages:u,orderPaymentStatus:u,orderedAt:u,paymentMethods:u,shippingAddress:u,shippingLines:u,shippingMethod:u,status:u,taxLines:u,totalFinalPrice:u,totalPrice:u,items:a,itemCount:a,refundableItems:a,unfullfilledItems:a,refundedItems:a}),_}return e(L,m),Object.defineProperty(L.prototype,"items",{get:function(){return this.orderLineItems},set:function(e){this.orderLineItems=e},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"itemCount",{get:function(){var e;return(null===(e=this.orderLineItems)||void 0===e?void 0:e.length)||0},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"refundableItems",{get:function(){var e=this;return!this._refundSettings||this._refundSettings&&!this._refundSettings.isActiveRefundSection?[]:this.orderLineItems.filter((function(t){var r;return[g.FULFILLED,g.UNFULFILLED,g.DELIVERED].includes(t.status)&&(!(null===(r=e._refundSettings)||void 0===r?void 0:r.orderRefundDayLimit)||e._refundSettings.orderRefundDayLimit>=e.getItemOrderedAtDays(t))}))},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"unfullfilledItems",{get:function(){var e=this;return this.orderLineItems.filter((function(t){var r;return!(null===(r=e.orderPackages)||void 0===r?void 0:r.some((function(e){return e.orderLineItemIds.includes(t.id)})))}))},enumerable:!1,configurable:!0}),Object.defineProperty(L.prototype,"refundedItems",{get:function(){return this.orderLineItems.filter((function(e){return e.status===g.REFUNDED||e.status===g.REFUND_REQUESTED||e.status===g.REFUND_REQUEST_ACCEPTED||e.status===g.REFUND_REJECTED}))},enumerable:!1,configurable:!0}),L.prototype.getItemOrderedAtDays=function(e){var t=e.orderedAt,r=Date.now();return Math.abs(r-t)/864e5},L}(m);export{L as IkasOrder};
@@ -5,6 +5,7 @@ import { IkasTheme, IkasThemePageType, IkasCustomerReviewSettings } from "../mod
5
5
  import { IkasStorefront } from "../models/data/storefront";
6
6
  import { IkasSalesChannel } from "../models/data/sales-channel";
7
7
  import { IkasStorefrontRouting } from "../models/data/storefront/routing";
8
+ import { IkasPageDataProvider } from "./page-data-get";
8
9
  import { IkasStorefrontThemeLocalization } from "../models/data/storefront/theme-localization";
9
10
  import { IkasThemeFavicon } from "../models/theme/settings/favicon";
10
11
  import { IkasThemeSettings, IkasThemeStockPreference } from "../models/theme/settings";
@@ -15,6 +16,9 @@ export declare class IkasNextPageDataProvider {
15
16
  static getLocalSettings(locale: string): Promise<SettingsData | null>;
16
17
  static getProdSettings(locale: string): Promise<SettingsData | null>;
17
18
  static getSettings(locale: string): Promise<SettingsData | null>;
19
+ static setStorefrontConfig(settings: SettingsData): Promise<void>;
20
+ static setTranslations(settings: SettingsData, componentIds: string[], pageType?: IkasThemePageType, isEditor?: boolean): Promise<void>;
21
+ static getExtraProps(settings: SettingsData, provider: IkasPageDataProvider, pageType?: IkasThemePageType): Promise<Record<string, any>>;
18
22
  static getPageData(context: GetStaticPropsContext<ParsedUrlQuery> | GetServerSidePropsContext<ParsedUrlQuery>, isServer: boolean, pageType?: IkasThemePageType, possiblePageTypes?: IkasThemePageType[], isEditor?: boolean): Promise<{
19
23
  props: {};
20
24
  notFound: boolean;
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__assign as o,__spreadArray as r}from'../ext/tslib/tslib.es6.js';import i from"fs";import n from"next/config.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/index.js";import"../models/data/city/index.js";import"mobx";import"../models/data/country/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/attribute-value/index.js";import"../models/data/customer/index.js";import"../models/data/customer-attribute/customer-attribute-option/index.js";import"../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../models/data/customer-attribute/index.js";import"../models/data/customer-review/index.js";import"../models/data/customer-review-summary/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/merchant-settings/index.js";import"../models/data/order/address/index.js";import"../models/data/order/adjustment/index.js";import"../models/data/order/gift-line/index.js";import"../models/data/order/invoice/index.js";import"../models/data/order/line-item/discount/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/option/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/package/tracking-info/index.js";import"../models/data/order/package/index.js";import"../models/data/order/payment-method/index.js";import"../models/data/order/refund/line-item/index.js";import"../models/data/order/shipping-line/index.js";import"../models/data/order/tax-line/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/product/attribute-value/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/product-attribute/index.js";import"../models/data/product-filter/index.js";import"../models/data/product-campaign/campaign/index.js";import"../models/data/product-campaign/filter/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/state/index.js";import"../models/data/variant-type/variant-value/index.js";import{IkasTheme as s}from"../models/theme/theme.js";import{IkasThemePageType as a}from"../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{IkasStorefront as d}from"../models/data/storefront/index.js";import{IkasSalesChannel as l}from"../models/data/sales-channel/index.js";import{IkasStorefrontRouting as m}from"../models/data/storefront/routing/index.js";import{IkasStorefrontConfig as c}from"../storefront/index.js";import{IkasPageDataProvider as u}from"./page-data-get.js";import{IkasStorefrontThemeLocalization as p}from"../models/data/storefront/theme-localization/index.js";import{I18NFileReader as f}from"../utils/i18n.js";import{getGoogleFontHref as g}from"../utils/google-fonts.js";import v from"../store/storefront/index.js";import j from"../store/checkout/index.js";var h=function(){function h(){}return h.readLocalTheme=function(){return new Promise((function(e,t){i.readFile("./src/theme.json",{flag:"a+"},(function(o,r){if(o)return t(o);var i=r.length?JSON.parse(r.toString()):{};e(new s(i))}))}))},h.readSettingsFile=function(){return new Promise((function(e){var t=n().serverRuntimeConfig.SETTINGS;i.readFile(t,{flag:"a+"},(function(t,o){if(t)return console.error("SETTINGS FILE READ ERROR!!!"),console.error(t),e(null);var r=o.length?JSON.parse(o.toString()):{};e(r)}))}))},h.getLocalSettings=function(o){return e(this,void 0,void 0,(function(){var e,r,i,n,s,a;return t(this,(function(t){switch(t.label){case 0:return c.storefrontId?[4,v.getStorefront({id:c.storefrontId})]:(console.error("Missing storefrontId in the config.json file!"),[2,null]);case 1:return(e=t.sent()).isSuccess&&e.data?(r=e.data,[4,h.readLocalTheme()]):[2,null];case 2:return i=t.sent(),n=h.createColorScript(i.settings),s=h.createFontScript(i.settings),a=[],n&&a.push(n),s&&a.push(s),[2,{storefront:r,themeLocalization:new p({themeJson:i}),salesChannel:new l({id:r.salesChannelId}),routing:r.routings.length?r.routings.find((function(e){return e.locale===o||e.id===o}))||r.routings[0]:new m({}),favicon:i.settings.favicon,stockPreference:i.settings.stockPreference,storefrontJSScripts:a,domain:"",productBackInStockSettings:{customerLoginRequired:!0},customerReviewSettings:{customerLoginRequired:!0,customerPurchaseRequired:!1}}]}}))}))},h.getProdSettings=function(o){return e(this,void 0,void 0,(function(){var r=this;return t(this,(function(n){return[2,new Promise((function(n){return e(r,void 0,void 0,(function(){var e,r,s,a,m,c,u,f,g,v;return t(this,(function(t){switch(t.label){case 0:return[4,h.readSettingsFile()];case 1:return(e=t.sent())&&e.localizationMap?(r=new d(e.storefront),s=new l(e.salesChannel),a=e.localizationMap,m=e.storefrontJSScripts||[],c=e.domain,u=e.productBackInStockSettings?{customerLoginRequired:e.productBackInStockSettings.customerLoginRequired}:null,f=e.customerReviewSettings?{customerLoginRequired:e.customerReviewSettings.customerLoginRequired||!1,customerPurchaseRequired:e.customerReviewSettings.customerPurchaseRequired||!1}:null,g=a[o],v=r.routings.find((function(e){return e.id===o||e.path===o})),g&&v?(i.readFile(g,{flag:"a+"},(function(e,t){if(e)return console.error("THEME LOCALZIATION FILE READ ERROR!!!"),console.error(e),n(null);var o=t.length?JSON.parse(t.toString()):{},i=new p(o),a=i.themeJson.settings.favicon,d=i.themeJson.settings.stockPreference;if(i.themeJson.settings){var l=h.createColorScript(i.themeJson.settings),g=h.createFontScript(i.themeJson.settings);l&&m.push(l),g&&m.push(g)}n({storefront:r,themeLocalization:i,salesChannel:s,routing:v,favicon:a,stockPreference:d,storefrontJSScripts:m,domain:c,productBackInStockSettings:u,customerReviewSettings:f})})),[2]):(console.error("THEME LOCALIZATION PATH OR ROUTING MISSING!!!"),[2,n(null)])):[2,n(null)]}}))}))}))]}))}))},h.getSettings=function(o){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return"local"===process.env.NEXT_PUBLIC_ENV?[4,this.getLocalSettings(o)]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return[4,this.getProdSettings(o)]}}))}))},h.getPageData=function(i,s,d,l,m){var p,g,v,x;return e(this,void 0,void 0,(function(){var e,S,C,I,y,b,k,w,L,P,R,T,B,E,V,J,F,O,N,D,A,U,q,z,M,G;return t(this,(function(t){switch(t.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,S=!e&&m,C=n().serverRuntimeConfig,S?[3,7]:(I=i.locale)?[4,h.getSettings(I)]:[2,{props:{},notFound:!0}];case 1:return(y=t.sent())&&y.storefront.mainStorefrontThemeId&&y.storefront.salesChannelId?(b=y.storefront,k=y.themeLocalization,w=y.salesChannel,L=y.routing,P=y.favicon,R=y.stockPreference,T=y.storefrontJSScripts,B=y.domain,E=y.productBackInStockSettings,V=y.customerReviewSettings,c.storefrontId=b.id,c.storefrontRoutingId=L.id,c.storefrontThemeId=b.mainStorefrontThemeId,c.salesChannelId=b.salesChannelId,c.priceListId=L.priceListId||void 0,c.stockLocationIds=null===(p=w.stockLocations)||void 0===p?void 0:p.map((function(e){return e.id})),c.routings=b.routings,c.paymentGateways=w.paymentGateways||[],c.gtmId=b.gtmId||void 0,c.fbpId=b.fbpId||void 0,c.analytics4Id=b.analytics4Id||void 0,c.universalAnalyticsId=b.universalAnalyticsId||void 0,c.tiktokPixelId=b.tiktokPixelId||void 0,c.favicon=P||null,c.pickUpStockLocationIds=b.pickUpStockLocationIds&&b.pickUpStockLocationIds.length?b.pickUpStockLocationIds:null,c.stockPreference=R||null,c.storefrontJSScripts=T||[],c.domain=B,c.productBackInStockSettings=E,c.customerReviewSettings=V,(J=new u(k.themeJson,i.params,d)).possiblePageTypes=l||(d?[d]:[]),m?[3,3]:[4,J.getPageData()]):[2,{props:{},notFound:!0}];case 2:if(t.sent(),!J.page)return[2,{props:{},notFound:!0}];t.label=3;case 3:return F=m?J.theme.components.map((function(e){return e.id})):J.page.components.map((function(e){return e.componentId})),O=k.themeJson.components.filter((function(e){return m||F.includes(e.id)})),N=r(["common"],O.map((function(e){return e.dir})),!0),(d===a.CHECKOUT||m)&&N.push("checkout-page"),D=C.nextI18nConf,A=L.locale,[4,new f(A,N,e?void 0:D.localePath).read()];case 4:return U=t.sent(),c.translations=U,q={},d!==a.CHECKOUT?[3,6]:(z=null===(g=J.page)||void 0===g?void 0:g.components[0])?[4,j.listCheckoutSettings({})]:[3,6];case 5:M=t.sent(),G={showTax:null===(v=z.propValues.showTax)||void 0===v||v,buttonBgColor:z.propValues.buttonBgColor,buttonTextColor:z.propValues.buttonTextColor,buttonDisabledBgColor:z.propValues.buttonDisabledBgColor,buttonDisabledTextColor:z.propValues.buttonDisabledTextColor,primaryTextColor:z.propValues.primaryTextColor,secondaryTextColor:z.propValues.secondaryTextColor,primaryBgColor:z.propValues.primaryBgColor,secondaryBgColor:z.propValues.secondaryBgColor,borderColor:z.propValues.borderColor,cardBgColor:z.propValues.cardBgColor,errorColor:z.propValues.errorColor,errorLightColor:z.propValues.errorLightColor,warningColor:z.propValues.warningColor,warningLightColor:z.propValues.warningLightColor,successColor:z.propValues.successColor,successLightColor:z.propValues.successLightColor},q.customizationProps=G,q.returnPolicy=k.returnPolicy,q.privacyPolicy=k.privacyPolicy,q.termsOfService=k.termsOfService,q.checkoutSettingsStr=(null===(x=null==M?void 0:M.data)||void 0===x?void 0:x.length)?JSON.stringify(M.data[0]):null,t.label=6;case 6:return s?[2,{props:o(o({},J.nextPageData.props),q)}]:[2,{props:o(o({},J.nextPageData.props),q),revalidate:60}];case 7:return[2,{props:{}}];case 8:return[2]}}))}))},h.getStaticProps=function(o,r,i,n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,h.getPageData(o,!1,r,i,n)];case 1:return[2,e.sent()]}}))}))},h.getServerSideProps=function(o,r){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,h.getPageData(o,!0,r)];case 1:return[2,e.sent()]}}))}))},h.createColorScript=function(e){if(e.colors)return"<script>".concat(e.colors.map((function(e){return'document.documentElement.style.setProperty("'.concat(e.key,'","').concat(e.color,'");')})).join("\r\n"),"<\/script> \n ")},h.createFontScript=function(e){var t=g(e.fontFamily);if(t)return'<link id="ikas-font" rel="stylesheet" href="'.concat(t,"\"> \n <style>\n body { \n font-family: '").concat(e.fontFamily.name,'\', -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;\n } \n </style>')},h}();export{h as IkasNextPageDataProvider};
1
+ import{__awaiter as t,__generator as e,__spreadArray as o,__assign as r}from'../ext/tslib/tslib.es6.js';import i from"fs";import n from"next/config.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/cart/campaign-offer/index.js";import"../models/data/cart/index.js";import"../models/data/category/index.js";import"../models/data/city/index.js";import"mobx";import"../models/data/country/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/attribute-value/index.js";import"../models/data/customer/index.js";import"../models/data/customer-attribute/customer-attribute-option/index.js";import"../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../models/data/customer-attribute/index.js";import"../models/data/customer-review/index.js";import"../models/data/customer-review-summary/index.js";import"../models/data/district/index.js";import"../models/data/favorite-product/index.js";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/merchant-settings/index.js";import"../models/data/order/address/index.js";import"../models/data/order/adjustment/index.js";import"../models/data/order/gift-line/index.js";import"../models/data/order/invoice/index.js";import"../models/data/order/line-item/discount/index.js";import"../models/data/order/line-item/option/value/index.js";import"../models/data/order/line-item/option/index.js";import"../models/data/order/line-item/variant/index.js";import"../models/data/order/line-item/index.js";import"../models/data/order/package/tracking-info/index.js";import"../models/data/order/package/index.js";import"../models/data/order/payment-method/index.js";import"../models/data/order/refund/line-item/index.js";import"../models/data/order/shipping-line/index.js";import"../models/data/order/tax-line/index.js";import"../models/data/order/transaction/index.js";import"../models/data/order/index.js";import"../models/data/product/attribute-value/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/product-attribute/index.js";import"../models/data/product-filter/index.js";import"../models/data/product-campaign/campaign/index.js";import"../models/data/product-campaign/filter/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/state/index.js";import"../models/data/variant-type/variant-value/index.js";import{IkasTheme as s}from"../models/theme/theme.js";import{IkasThemePageType as a}from"../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{IkasStorefront as d}from"../models/data/storefront/index.js";import{IkasSalesChannel as l}from"../models/data/sales-channel/index.js";import{IkasStorefrontRouting as m}from"../models/data/storefront/routing/index.js";import{IkasStorefrontConfig as c}from"../storefront/index.js";import{IkasPageDataProvider as u}from"./page-data-get.js";import{IkasStorefrontThemeLocalization as p}from"../models/data/storefront/theme-localization/index.js";import{I18NFileReader as f}from"../utils/i18n.js";import{getGoogleFontHref as g}from"../utils/google-fonts.js";import v from"../store/storefront/index.js";import h from"../store/checkout/index.js";var x=function(){function x(){}return x.readLocalTheme=function(){return new Promise((function(t,e){i.readFile("./src/theme.json",{flag:"a+"},(function(o,r){if(o)return e(o);var i=r.length?JSON.parse(r.toString()):{};t(new s(i))}))}))},x.readSettingsFile=function(){return new Promise((function(t){var e=n().serverRuntimeConfig.SETTINGS;i.readFile(e,{flag:"a+"},(function(e,o){if(e)return console.error("SETTINGS FILE READ ERROR!!!"),console.error(e),t(null);var r=o.length?JSON.parse(o.toString()):{};t(r)}))}))},x.getLocalSettings=function(o){return t(this,void 0,void 0,(function(){var t,r,i,n,s,a;return e(this,(function(e){switch(e.label){case 0:return c.storefrontId?[4,v.getStorefront({id:c.storefrontId})]:(console.error("Missing storefrontId in the config.json file!"),[2,null]);case 1:return(t=e.sent()).isSuccess&&t.data?(r=t.data,[4,x.readLocalTheme()]):[2,null];case 2:return i=e.sent(),n=x.createColorScript(i.settings),s=x.createFontScript(i.settings),a=[],n&&a.push(n),s&&a.push(s),[2,{storefront:r,themeLocalization:new p({themeJson:i}),salesChannel:new l({id:r.salesChannelId}),routing:r.routings.length?r.routings.find((function(t){return t.locale===o||t.id===o}))||r.routings[0]:new m({}),favicon:i.settings.favicon,stockPreference:i.settings.stockPreference,storefrontJSScripts:a,domain:"",productBackInStockSettings:{customerLoginRequired:!0},customerReviewSettings:{customerLoginRequired:!0,customerPurchaseRequired:!1}}]}}))}))},x.getProdSettings=function(o){return t(this,void 0,void 0,(function(){var r=this;return e(this,(function(n){return[2,new Promise((function(n){return t(r,void 0,void 0,(function(){var t,r,s,a,m,c,u,f,g,v;return e(this,(function(e){switch(e.label){case 0:return[4,x.readSettingsFile()];case 1:return(t=e.sent())&&t.localizationMap?(r=new d(t.storefront),s=new l(t.salesChannel),a=t.localizationMap,m=t.storefrontJSScripts||[],c=t.domain,u=t.productBackInStockSettings?{customerLoginRequired:t.productBackInStockSettings.customerLoginRequired}:null,f=t.customerReviewSettings?{customerLoginRequired:t.customerReviewSettings.customerLoginRequired||!1,customerPurchaseRequired:t.customerReviewSettings.customerPurchaseRequired||!1}:null,g=a[o],v=r.routings.find((function(t){return t.id===o||t.path===o})),g&&v?(i.readFile(g,{flag:"a+"},(function(t,e){if(t)return console.error("THEME LOCALZIATION FILE READ ERROR!!!"),console.error(t),n(null);var o=e.length?JSON.parse(e.toString()):{},i=new p(o),a=i.themeJson.settings.favicon,d=i.themeJson.settings.stockPreference;if(i.themeJson.settings){var l=x.createColorScript(i.themeJson.settings),g=x.createFontScript(i.themeJson.settings);l&&m.push(l),g&&m.push(g)}n({storefront:r,themeLocalization:i,salesChannel:s,routing:v,favicon:a,stockPreference:d,storefrontJSScripts:m,domain:c,productBackInStockSettings:u,customerReviewSettings:f})})),[2]):(console.error("THEME LOCALIZATION PATH OR ROUTING MISSING!!!"),[2,n(null)])):[2,n(null)]}}))}))}))]}))}))},x.getSettings=function(o){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return"local"===process.env.NEXT_PUBLIC_ENV?[4,this.getLocalSettings(o)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return[4,this.getProdSettings(o)]}}))}))},x.setStorefrontConfig=function(o){var r;return t(this,void 0,void 0,(function(){var t,i,n,s,a,d,l,m,u;return e(this,(function(e){return t=o.storefront,i=o.salesChannel,n=o.routing,s=o.favicon,a=o.stockPreference,d=o.storefrontJSScripts,l=o.domain,m=o.productBackInStockSettings,u=o.customerReviewSettings,c.storefrontId=t.id,c.storefrontRoutingId=n.id,c.storefrontThemeId=t.mainStorefrontThemeId,c.salesChannelId=t.salesChannelId,c.priceListId=n.priceListId||void 0,c.stockLocationIds=null===(r=i.stockLocations)||void 0===r?void 0:r.map((function(t){return t.id})),c.routings=t.routings,c.paymentGateways=i.paymentGateways||[],c.gtmId=t.gtmId||void 0,c.fbpId=t.fbpId||void 0,c.analytics4Id=t.analytics4Id||void 0,c.universalAnalyticsId=t.universalAnalyticsId||void 0,c.tiktokPixelId=t.tiktokPixelId||void 0,c.favicon=s||null,c.pickUpStockLocationIds=t.pickUpStockLocationIds&&t.pickUpStockLocationIds.length?t.pickUpStockLocationIds:null,c.stockPreference=a||null,c.storefrontJSScripts=d||[],c.domain=l,c.productBackInStockSettings=m,c.customerReviewSettings=u,[2]}))}))},x.setTranslations=function(r,i,s,d){return t(this,void 0,void 0,(function(){var t,l,m,u,p,g,v,h;return e(this,(function(e){switch(e.label){case 0:return t=n().serverRuntimeConfig,l=r.routing,m="local"===process.env.NEXT_PUBLIC_ENV,u=r.themeLocalization.themeJson.components.filter((function(t){return d||i.includes(t.id)})),p=o(["common"],u.map((function(t){return t.dir})),!0),(s===a.CHECKOUT||d)&&p.push("checkout-page"),g=t.nextI18nConf,v=l.locale,[4,new f(v,p,m?void 0:g.localePath).read()];case 1:return h=e.sent(),c.translations=h,[2]}}))}))},x.getExtraProps=function(o,r,i){var n,s,d;return t(this,void 0,void 0,(function(){var t,l,m,c,u;return e(this,(function(e){switch(e.label){case 0:return t={},l=o.themeLocalization,i!==a.CHECKOUT?[3,2]:(m=null===(n=r.page)||void 0===n?void 0:n.components[0])?[4,h.listCheckoutSettings({})]:[3,2];case 1:c=e.sent(),u={showTax:null===(s=m.propValues.showTax)||void 0===s||s,buttonBgColor:m.propValues.buttonBgColor,buttonTextColor:m.propValues.buttonTextColor,buttonDisabledBgColor:m.propValues.buttonDisabledBgColor,buttonDisabledTextColor:m.propValues.buttonDisabledTextColor,primaryTextColor:m.propValues.primaryTextColor,secondaryTextColor:m.propValues.secondaryTextColor,primaryBgColor:m.propValues.primaryBgColor,secondaryBgColor:m.propValues.secondaryBgColor,borderColor:m.propValues.borderColor,cardBgColor:m.propValues.cardBgColor,errorColor:m.propValues.errorColor,errorLightColor:m.propValues.errorLightColor,warningColor:m.propValues.warningColor,warningLightColor:m.propValues.warningLightColor,successColor:m.propValues.successColor,successLightColor:m.propValues.successLightColor},t.customizationProps=u,t.returnPolicy=l.returnPolicy,t.privacyPolicy=l.privacyPolicy,t.termsOfService=l.termsOfService,t.checkoutSettingsStr=(null===(d=null==c?void 0:c.data)||void 0===d?void 0:d.length)?JSON.stringify(c.data[0]):null,e.label=2;case 2:return[2,t]}}))}))},x.getPageData=function(o,i,n,s,a){var d;return t(this,void 0,void 0,(function(){var t,l,m,c,p,f,g;return e(this,(function(e){switch(e.label){case 0:return t="local"===process.env.NEXT_PUBLIC_ENV,!t&&a?[3,7]:(l=o.locale)?[4,x.getSettings(l)]:[2,{props:{},notFound:!0}];case 1:return(m=e.sent())&&m.storefront.mainStorefrontThemeId&&m.storefront.salesChannelId?[4,this.setStorefrontConfig(m)]:[2,{props:{},notFound:!0}];case 2:return e.sent(),c=m.themeLocalization,(p=new u(c.themeJson,o.params,n)).possiblePageTypes=s||(n?[n]:[]),a?[3,4]:[4,p.getPageData()];case 3:if(e.sent(),!p.page)return[2,{props:{},notFound:!0}];e.label=4;case 4:return f=a?p.theme.components.map((function(t){return t.id})):(null===(d=p.page)||void 0===d?void 0:d.components.map((function(t){return t.componentId})))||[],[4,this.setTranslations(m,f,n,a)];case 5:return e.sent(),[4,this.getExtraProps(m,p,n)];case 6:return g=e.sent(),i?[2,{props:r(r({},p.nextPageData.props),g)}]:[2,{props:r(r({},p.nextPageData.props),g),revalidate:60}];case 7:return[2,{props:{}}];case 8:return[2]}}))}))},x.getStaticProps=function(o,r,i,n){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,x.getPageData(o,!1,r,i,n)];case 1:return[2,t.sent()]}}))}))},x.getServerSideProps=function(o,r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,x.getPageData(o,!0,r)];case 1:return[2,t.sent()]}}))}))},x.createColorScript=function(t){if(t.colors)return"<script>".concat(t.colors.map((function(t){return'document.documentElement.style.setProperty("'.concat(t.key,'","').concat(t.color,'");')})).join("\r\n"),"<\/script> \n ")},x.createFontScript=function(t){var e=g(t.fontFamily);if(e)return'<link id="ikas-font" rel="stylesheet" href="'.concat(e,"\"> \n <style>\n body { \n font-family: '").concat(t.fontFamily.name,'\', -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;\n } \n </style>')},x}();export{x as IkasNextPageDataProvider};
@@ -1 +1 @@
1
- var e={next:"12.0.7",react:"17.0.2","react-dom":"17.0.2",mobx:"^6.1.3","mobx-react-lite":"^3.1.5","next-transpile-modules":"^9.0.0","@ikas/storefront-utils":"^3.0.0-alpha.28"},n={"@types/node":"^14.14.6","@types/react":"^17.0.2","@types/react-dom":"^17.0.2","@typescript-eslint/eslint-plugin":"^2.10.0","@typescript-eslint/parser":"^2.10.0",eslint:"^6.6.0","eslint-config-react-app":"^5.2.1","eslint-loader":"3.0.3","eslint-plugin-flowtype":"4.6.0","eslint-plugin-import":"2.20.1","eslint-plugin-jsx-a11y":"6.2.3","eslint-plugin-react":"7.19.0","eslint-plugin-react-hooks":"^1.6.1",sass:"^1.43.4",typescript:"^4.5.2"},t={"@types/react":"17.0.2","@types/react-dom":"17.0.2"},s={upgradeDependencies:"yarn upgrade @ikas/storefront @ikas/storefront-utils",dev:"next dev -p 3333",build:"next build",start:"next start",generate:"ikas --generate","prettier:all":"npx prettier@^2.1 './**/src/**/*.(ts|tsx|css|scss)' --write"},i='{\n "compilerOptions": {\n "target": "esnext",\n "lib": [\n "dom",\n "dom.iterable",\n "esnext"\n ],\n "allowJs": true,\n "skipLibCheck": true,\n "strict": true,\n "forceConsistentCasingInFileNames": true,\n "experimentalDecorators": true,\n "noEmit": true,\n "esModuleInterop": true,\n "module": "esnext",\n "moduleResolution": "node",\n "resolveJsonModule": true,\n "isolatedModules": true,\n "jsx": "preserve",\n "baseUrl": ".",\n "useUnknownInCatchVariables": false,\n "incremental": true\n },\n "typeRoots": [\n "./node_modules/@types"\n ],\n "include": [\n "next-env.d.ts",\n "**/*.ts",\n "**/*.tsx",\n "**/typings/global.d.ts",\n ],\n "exclude": [\n "node_modules",\n "./src/pages/api",\n ]\n}',a='const withTM = require("next-transpile-modules")(["@ikas/storefront"]);\n\nconst config = {\n i18n: {\n defaultLocale: "en",\n locales: ["en"],\n localeDetection: false,\n },\n basePath: process.env.NEXTJS_BASE_PATH || "",\n\n images: {\n deviceSizes: [\n 180,\n 360,\n 540,\n 720,\n 900,\n 1080,\n 1296,\n 1512,\n 1728,\n 1950,\n 2560,\n 3840,\n ],\n },\n\n webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {\n if (!isServer) {\n config.resolve.fallback.fs = false;\n }\n return config;\n },\n};\n\nmodule.exports = withTM(config);',r="NEXT_PUBLIC_ENV=local\nNEXT_PUBLIC_BASE_URL=https://api.myikas.dev/api/sf\nNEXT_PUBLIC_IMG_BASE_URL=https://cdn.myikas.dev/\nNEXT_PUBLIC_UPLOAD_GQL_URL=https://api.myikas.dev/api/admin/graphql\nNEXT_PUBLIC_GQL_URL=https://api.myikas.dev/api/sf/graphql\n",l="NEXT_PUBLIC_ENV=local\nNEXT_PUBLIC_BASE_URL=https://api.myikas.com/api/sf\nNEXT_PUBLIC_IMG_BASE_URL=https://cdn.myikas.com/\nNEXT_PUBLIC_UPLOAD_GQL_URL=https://api.myikas.com/api/admin/graphql\nNEXT_PUBLIC_GQL_URL=https://api.myikas.com/api/sf/graphql\n";export{e as DEPENDENCIES,n as DEV_DEPENDENCIES,r as DEV_ENV,a as NEXT_CONFIG,l as PROD_ENV,t as RESOLUTIONS,s as SCRIPTS,i as TS_CONFIG};
1
+ var e={next:"12.0.7",react:"17.0.2","react-dom":"17.0.2",mobx:"^6.1.3","mobx-react-lite":"^3.1.5","next-transpile-modules":"^9.0.0","@ikas/storefront-utils":"^3.0.0-alpha.29"},n={"@types/node":"^14.14.6","@types/react":"^17.0.2","@types/react-dom":"^17.0.2","@typescript-eslint/eslint-plugin":"^2.10.0","@typescript-eslint/parser":"^2.10.0",eslint:"^6.6.0","eslint-config-react-app":"^5.2.1","eslint-loader":"3.0.3","eslint-plugin-flowtype":"4.6.0","eslint-plugin-import":"2.20.1","eslint-plugin-jsx-a11y":"6.2.3","eslint-plugin-react":"7.19.0","eslint-plugin-react-hooks":"^1.6.1",sass:"^1.43.4",typescript:"^4.5.2"},t={"@types/react":"17.0.2","@types/react-dom":"17.0.2"},s={upgradeDependencies:"yarn upgrade @ikas/storefront @ikas/storefront-utils",dev:"next dev -p 3333",build:"next build",start:"next start",generate:"ikas --generate","prettier:all":"npx prettier@^2.1 './**/src/**/*.(ts|tsx|css|scss)' --write"},i='{\n "compilerOptions": {\n "target": "esnext",\n "lib": [\n "dom",\n "dom.iterable",\n "esnext"\n ],\n "allowJs": true,\n "skipLibCheck": true,\n "strict": true,\n "forceConsistentCasingInFileNames": true,\n "experimentalDecorators": true,\n "noEmit": true,\n "esModuleInterop": true,\n "module": "esnext",\n "moduleResolution": "node",\n "resolveJsonModule": true,\n "isolatedModules": true,\n "jsx": "preserve",\n "baseUrl": ".",\n "useUnknownInCatchVariables": false,\n "incremental": true\n },\n "typeRoots": [\n "./node_modules/@types"\n ],\n "include": [\n "next-env.d.ts",\n "**/*.ts",\n "**/*.tsx",\n "**/typings/global.d.ts",\n ],\n "exclude": [\n "node_modules",\n "./src/pages/api",\n ]\n}',a='const withTM = require("next-transpile-modules")(["@ikas/storefront"]);\n\nconst config = {\n i18n: {\n defaultLocale: "en",\n locales: ["en"],\n localeDetection: false,\n },\n basePath: process.env.NEXTJS_BASE_PATH || "",\n\n images: {\n deviceSizes: [\n 180,\n 360,\n 540,\n 720,\n 900,\n 1080,\n 1296,\n 1512,\n 1728,\n 1950,\n 2560,\n 3840,\n ],\n },\n\n webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {\n if (!isServer) {\n config.resolve.fallback.fs = false;\n }\n return config;\n },\n};\n\nmodule.exports = withTM(config);',r="NEXT_PUBLIC_ENV=local\nNEXT_PUBLIC_BASE_URL=https://api.myikas.dev/api/sf\nNEXT_PUBLIC_IMG_BASE_URL=https://cdn.myikas.dev/\nNEXT_PUBLIC_UPLOAD_GQL_URL=https://api.myikas.dev/api/admin/graphql\nNEXT_PUBLIC_GQL_URL=https://api.myikas.dev/api/sf/graphql\n",l="NEXT_PUBLIC_ENV=local\nNEXT_PUBLIC_BASE_URL=https://api.myikas.com/api/sf\nNEXT_PUBLIC_IMG_BASE_URL=https://cdn.myikas.com/\nNEXT_PUBLIC_UPLOAD_GQL_URL=https://api.myikas.com/api/admin/graphql\nNEXT_PUBLIC_GQL_URL=https://api.myikas.com/api/sf/graphql\n";export{e as DEPENDENCIES,n as DEV_DEPENDENCIES,r as DEV_ENV,a as NEXT_CONFIG,l as PROD_ENV,t as RESOLUTIONS,s as SCRIPTS,i as TS_CONFIG};
@@ -6,11 +6,13 @@ import { QueryParams as ListCheckoutSettingsQueryParams } from "src/__api/querie
6
6
  import { QueryParams as GetAvailableShippingCountriesQueryParams } from "src/__api/queries/getAvailableShippingCountries";
7
7
  import { QueryParams as ListStockLocationQueryParams } from "src/__api/queries/listStockLocation";
8
8
  import { QueryParams as GetAvailableStockLocationQueryParams } from "src/__api/queries/getAvailableStockLocations";
9
+ import { QueryParams as CreateStripePaymentIntentParams } from "src/__api/mutations/createStripePaymentIntent";
9
10
  import { APIResponse } from "@ikas/fe-api-client";
10
11
  import { IkasCheckoutSettings } from "src/models/data/checkout-settings";
11
12
  import { IkasPaymentGateway } from "src/models/data/payment-gateway";
12
13
  import { StockLocation } from "../../__api/models/StockLocation";
13
14
  import { GetAvailableStockLocation } from "../../__api/models/GetAvailableStockLocation";
15
+ import { CreateStripePaymentIntentResponse } from "../../__api/models/CreateStripePaymentIntentResponse";
14
16
  export default class CheckoutStore {
15
17
  static createSaleTransactionWithCart(params: CreateSaleTransaction): Promise<APIResponse<undefined> | APIResponse<import("../../__api/types").TransactionResponse>>;
16
18
  static listPaymentGateway(params: ListPaymentGatewayQueryParams): Promise<APIResponse<IkasPaymentGateway[]>>;
@@ -20,4 +22,5 @@ export default class CheckoutStore {
20
22
  static getAvailableShippingCountries(params: GetAvailableShippingCountriesQueryParams): Promise<APIResponse<undefined> | APIResponse<string[]>>;
21
23
  static listStockLocation(params: ListStockLocationQueryParams): Promise<APIResponse<StockLocation[]>>;
22
24
  static getAvailableStockLocations(params: GetAvailableStockLocationQueryParams): Promise<APIResponse<GetAvailableStockLocation[]>>;
25
+ static createStripePaymentIntent(params: CreateStripePaymentIntentParams): Promise<APIResponse<CreateStripePaymentIntentResponse | null>>;
23
26
  }
@@ -1 +1 @@
1
- import{__awaiter as t,__generator as i}from'../../ext/tslib/tslib.es6.js';import e from"../../__api/mutations/createSaleTransactionWithCart.js";import n from"../../__api/queries/listPaymentGateway.js";import r from"../../__api/mutations/retrieveInstallmentInfo.js";import o from"../../__api/queries/checkStocks.js";import s from"../../__api/queries/listCheckoutSettings.js";import a from"../../__api/queries/getAvailableShippingCountries.js";import u from"../../__api/queries/listStockLocation.js";import c from"../../__api/queries/getAvailableStockLocations.js";import{APIResponse as l}from'../../ext/@ikas/fe-api-client/build/utils/api.js';import'../../ext/axios/lib/axios.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{IkasCheckoutSettings as d}from"../../models/data/checkout-settings/index.js";import{IkasPaymentGateway as m}from"../../models/data/payment-gateway/index.js";import{StockLocation as f}from"../../__api/models/StockLocation.js";import{GetAvailableStockLocation as p}from"../../__api/models/GetAvailableStockLocation.js";var h=function(){function h(){}return h.createSaleTransactionWithCart=function(n){return t(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,e(n)];case 1:return[2,t.sent()]}}))}))},h.listPaymentGateway=function(e){var r;return t(this,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,n(e)];case 1:return t=i.sent(),[2,new l(null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new m(t)})),t.graphQLErrors)]}}))}))},h.retrieveInstallmentInfo=function(e){return t(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,r(e)];case 1:return[2,t.sent()]}}))}))},h.checkStocks=function(e){return t(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,o(e)];case 1:return[2,t.sent()]}}))}))},h.listCheckoutSettings=function(e){var n;return t(this,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,s(e)];case 1:return t=i.sent(),[2,new l(null===(n=t.data)||void 0===n?void 0:n.map((function(t){return new d(t)})),t.graphQLErrors)]}}))}))},h.getAvailableShippingCountries=function(e){return t(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,a(e)];case 1:return[2,t.sent()]}}))}))},h.listStockLocation=function(e){var n;return t(this,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,u(e)];case 1:return t=i.sent(),[2,new l(null===(n=t.data)||void 0===n?void 0:n.map((function(t){return new f(t)})),t.graphQLErrors)]}}))}))},h.getAvailableStockLocations=function(e){var n;return t(this,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,c(e)];case 1:return t=i.sent(),[2,new l(null===(n=t.data)||void 0===n?void 0:n.stockLocations.map((function(t){return new p(t)})),t.graphQLErrors)]}}))}))},h}();export{h as default};
1
+ import{__awaiter as t,__generator as e}from'../../ext/tslib/tslib.es6.js';import i from"../../__api/mutations/createSaleTransactionWithCart.js";import n from"../../__api/queries/listPaymentGateway.js";import r from"../../__api/mutations/retrieveInstallmentInfo.js";import o from"../../__api/queries/checkStocks.js";import s from"../../__api/queries/listCheckoutSettings.js";import a from"../../__api/queries/getAvailableShippingCountries.js";import u from"../../__api/queries/listStockLocation.js";import c from"../../__api/queries/getAvailableStockLocations.js";import l from"../../__api/mutations/createStripePaymentIntent.js";import{APIResponse as d}from'../../ext/@ikas/fe-api-client/build/utils/api.js';import'../../ext/axios/lib/axios.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{IkasCheckoutSettings as m}from"../../models/data/checkout-settings/index.js";import{IkasPaymentGateway as p}from"../../models/data/payment-gateway/index.js";import{StockLocation as f}from"../../__api/models/StockLocation.js";import{GetAvailableStockLocation as h}from"../../__api/models/GetAvailableStockLocation.js";import{CreateStripePaymentIntentResponse as v}from"../../__api/models/CreateStripePaymentIntentResponse.js";var _=function(){function _(){}return _.createSaleTransactionWithCart=function(n){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,i(n)];case 1:return[2,t.sent()]}}))}))},_.listPaymentGateway=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(i)];case 1:return t=e.sent(),[2,new d(null===(r=t.data)||void 0===r?void 0:r.map((function(t){return new p(t)})),t.graphQLErrors)]}}))}))},_.retrieveInstallmentInfo=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,r(i)];case 1:return[2,t.sent()]}}))}))},_.checkStocks=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,o(i)];case 1:return[2,t.sent()]}}))}))},_.listCheckoutSettings=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,s(i)];case 1:return t=e.sent(),[2,new d(null===(n=t.data)||void 0===n?void 0:n.map((function(t){return new m(t)})),t.graphQLErrors)]}}))}))},_.getAvailableShippingCountries=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,a(i)];case 1:return[2,t.sent()]}}))}))},_.listStockLocation=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,u(i)];case 1:return t=e.sent(),[2,new d(null===(n=t.data)||void 0===n?void 0:n.map((function(t){return new f(t)})),t.graphQLErrors)]}}))}))},_.getAvailableStockLocations=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,c(i)];case 1:return t=e.sent(),[2,new d(null===(n=t.data)||void 0===n?void 0:n.stockLocations.map((function(t){return new h(t)})),t.graphQLErrors)]}}))}))},_.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,l(i)];case 1:return t=e.sent(),[2,new d(t.data?new v(t.data):null,t.graphQLErrors)]}}))}))},_}();export{_ as default};
@@ -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'../../ext/lodash/uniqBy.js';import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import{IkasCustomer as s}from"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/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/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/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{Analytics as n}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as a}from"../../storefront/index.js";import{populateRaffleProducts as d}from"../../providers/helpers/raffles.js";import u from"./api.js";import{SaveMyCustomerInput as c}from"../../__api/models/SaveMyCustomerInput.js";import l from"../raffle/index.js";import'../../ext/@ikas/fe-api-client/build/utils/api.js';import'../../ext/axios/lib/axios.js';import m from'../../ext/@ikas/fe-api-client/build/config/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 p from"../product/index.js";import{CustomerEmailSubscriptionStatusesEnum as h}from"../../__api/types/index.js";var f="undefined"==typeof localStorage,v=function(){function v(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(i,r){return t(s,void 0,void 0,(function(){var t,o,s,a;return e(this,(function(e){switch(e.label){case 0:return[4,u.login({email:i,password:r})];case 1:return(t=e.sent())&&t.isSuccess&&t.data?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer&&n.customerLogin(),(s=null===(a=this.baseStore)||void 0===a?void 0:a.cartStore.cart)?[4,this.baseStore.cartStore.changeItemQuantity(s.orderLineItems[0],s.orderLineItems[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(i,r,o,n,a,d){return t(s,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return[4,u.register({email:o,password:n,firstName:i,lastName:r,isAcceptMarketing:a,attributes:d})];case 1:return(t=e.sent())&&t.isSuccess&&(null===(s=t.data)||void 0===s?void 0:s.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.saveContactForm=function(i){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return n.contactForm(i),[4,u.sendContactFormToMerchant(i)];case 1:return[2,t.sent().isSuccess]}}))}))},this.checkEmail=function(i){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.checkEmail({email:i})];case 1:return[2,t.sent().isSuccess]}}))}))},this.forgotPassword=function(i){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.forgotPassword({email:i})];case 1:return[2,t.sent().isSuccess]}}))}))},this.recoverPassword=function(i,r,o){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.recoverPassword({password:i,passwordAgain:r,token:o})];case 1:return[2,t.sent().isSuccess]}}))}))},this.logout=function(){var t;s.clearLocalData(),null===(t=s.baseStore)||void 0===t||t.cartStore.removeCart(),n.customerLogout()},this.saveCustomer=function(i){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,u.saveCustomer({input:new c(i)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[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,u.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(i){return t(s,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,u.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])._refundSettings=this._refundSettings,[2,r]):[2,null]}}))}))},this.getOrderTransactions=function(i){return void 0===i&&(i={}),t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.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(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.listFavoriteProducts()];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(s,void 0,void 0,(function(){var t,i,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,u.listFavoriteProducts()];case 1:return(t=e.sent()).isSuccess||!(null===(r=t.data)||void 0===r?void 0:r.length)?[2,[]]:[4,p.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:a.priceListId,salesChannelId:a.salesChannelId}})];case 2:return i=e.sent(),[2,(null===(o=null==i?void 0:i.data)||void 0===o?void 0:o.data)||[]]}}))}))},this.addProductToFavorites=function(i){return t(s,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,u.saveFavoriteProduct({isFavorite:!0,productId:i})];case 1:return t=e.sent(),n.addToWishlist(i),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(i){return t(s,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,u.saveFavoriteProduct({isFavorite:!1,productId:i})];case 1:return t=e.sent(),n.addToWishlist(i),[2,t.data||!1]}}))}))},this.isProductFavorite=function(i){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,u.isFavoriteProduct({productId:i})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(i){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,u.createCustomerEmailSubscription({input:{email:i}})];case 1:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,h.SUBSCRIBED):this._visitorSubscribedEmail=!0,n.createEmailSubscripition(i)),[2,t.isSuccess]}}))}))},this.sendReview=function(r){return t(s,void 0,void 0,(function(){var t,o,s,n;return e(this,(function(e){switch(e.label){case 0:if(t=a.customerReviewSettings,o=a.salesChannelId,!t)return[2];if(!(s=null===(n=this.customer)||void 0===n?void 0:n.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,u.createCustomerReview({input:i(i({},r),{customerId:t.customerLoginRequired?s:void 0,salesChannelId:o||""})})];case 1:return[2,e.sent().data]}}))}))},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,i,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,l.getRafflesByCustomerId({winnerFilter:!1})];case 1:return t=e.sent(),[4,l.getRafflesByCustomerId({winnerFilter:!0})];case 2:return i=e.sent(),r=t.data,o=i.data,null==r||r.forEach((function(t){(null==o?void 0:o.find((function(e){return e.id===t.id})))&&(t.isCustomerWinner=!0)})),r?[4,d(r)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2,r||[]]}}))}))},this.getCustomerAttributes=function(){return t(s,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,u.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(i=this.customer.attributes)||void 0===i||i.forEach((function(e){var i,r,o;e.customerAttribute=(null===(i=t.data)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(o=null===(r=e.customerAttribute)||void 0===r?void 0:r.options)||void 0===o?void 0:o.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderByEmail=function(i,r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.getOrderByEmail({email:i,orderNumber:r})];case 1:return[2,t.sent().data||null]}}))}))},this.getOrderRefundSettings=function(){return t(s,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,u.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)&&(this._refundSettings=t.data[0]),e.label=2;case 2:return[2]}}))}))},this.baseStore=o,r(this)}return Object.defineProperty(v.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||f||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),v.prototype.socialLogin=function(i){return t(this,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",r="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(i,"/login/authenticate?redirect=").concat(t),[4,fetch(r,{headers:{"x-api-key":a.config.apiKey||"","x-sfid":a.storefrontId||"","x-sfrid":a.storefrontRoutingId||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),a.router?a.router.replace(o.redirectUrl):window.location.href=o.redirectUrl,[2]}}))}))},v.prototype.socialLoginToken=function(i){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,u.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&&n.customerLogin(),[2,!0]):[2,!1]}}))}))},v.prototype.init=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.loadToken(),this.loadLastViewedProducts(),this.loadCustomerConsent(),[4,this.refreshToken()];case 1:return t.sent(),[4,this.getCustomer()];case 2:return t.sent(),[4,this.getOrderRefundSettings()];case 3:return t.sent(),this._initialized=!0,this.customer&&n.customerVisit(),[2]}}))}))},v.prototype.routeChangeInit=function(){this.customer||(this.loadToken(),this.getCustomer())},v.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return f||!this.token?[2]:[4,u.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},v.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,u.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},v.prototype.setCustomer=function(t){this.customer=new s(t)},v.prototype.getLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,u.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=t.data||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},v.prototype.saveLastViewedProducts=function(){f||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},v.prototype.loadLastViewedProducts=function(){if(!f)try{var t=window.localStorage.getItem("lastViewedProducts");t&&(this._lastViewedProducts=JSON.parse(t),this._lastViewedProducts=this._lastViewedProducts.reverse(),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"))}catch(t){}},v.prototype.removeLastViewedProducts=function(){f||window.localStorage.removeItem("lastViewedProducts")},v.prototype.onProductView=function(i,r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?this._lastViewedProducts.find((function(t){return t.productId===i}))?[2]:[4,u.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:i,variantId:r}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:i,variantId:r}),[3,3];case 2:this._lastViewedProducts.push({productId:i,variantId:r}),this._lastViewedProducts=this._lastViewedProducts.slice(0,20),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},v.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:if(f)return[2];t.label=1;case 1:return t.trys.push([1,4,,5]),this.loadLastViewedProducts(),this._lastViewedProducts.length?[4,u.saveLastViewedProducts({input:{customerId:this.customer.id,products:this._lastViewedProducts}})]:[3,3];case 2:t.sent()&&this.removeLastViewedProducts(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},v.prototype.saveCustomerConsent=function(){f||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},v.prototype.loadCustomerConsent=function(){f||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},v.prototype.removeCustomerConsent=function(){f||window.localStorage.removeItem("customerConsent")},v.prototype.setToken=function(t,e){f||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),m.TOKEN=t)},v.prototype.loadToken=function(){if(!f){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e&&this.setToken(t,parseInt(e))}},v.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},v.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,m.TOKEN=""},v}();export{v as IkasCustomerStore};
1
+ import{__awaiter as t,__generator as e,__assign as i}from'../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import o from'../../ext/lodash/uniqBy.js';import"../../models/data/blog/index.js";import"../../models/data/brand/index.js";import"../../models/data/cart/campaign-offer/index.js";import"../../models/data/cart/index.js";import"../../models/data/category/index.js";import"../../models/data/city/index.js";import"../../models/data/country/index.js";import"../../models/data/customer/address/index.js";import"../../models/data/customer/attribute-value/index.js";import{IkasCustomer as s}from"../../models/data/customer/index.js";import"../../models/data/customer-attribute/customer-attribute-option/index.js";import"../../models/data/customer-attribute/customer-attribute-sales-channel/index.js";import"../../models/data/customer-attribute/index.js";import"../../models/data/customer-review/index.js";import"../../models/data/customer-review-summary/index.js";import"../../models/data/district/index.js";import"../../models/data/favorite-product/index.js";import"../../models/data/html-meta-data/index.js";import"../../models/data/image/index.js";import"../../models/data/merchant-settings/index.js";import"../../models/data/order/address/index.js";import"../../models/data/order/adjustment/index.js";import"../../models/data/order/gift-line/index.js";import"../../models/data/order/invoice/index.js";import"../../models/data/order/line-item/discount/index.js";import"../../models/data/order/line-item/option/value/index.js";import"../../models/data/order/line-item/option/index.js";import"../../models/data/order/line-item/variant/index.js";import"../../models/data/order/line-item/index.js";import"../../models/data/order/package/tracking-info/index.js";import"../../models/data/order/package/index.js";import"../../models/data/order/payment-method/index.js";import"../../models/data/order/refund/line-item/index.js";import"../../models/data/order/shipping-line/index.js";import"../../models/data/order/tax-line/index.js";import"../../models/data/order/transaction/index.js";import"../../models/data/order/index.js";import"../../models/data/product/attribute-value/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/product-attribute/index.js";import"../../models/data/product-filter/index.js";import"../../models/data/product-campaign/campaign/index.js";import"../../models/data/product-campaign/filter/index.js";import"../../models/data/product-option-set/index.js";import"../../models/data/raffle/index.js";import"../../models/data/state/index.js";import"../../models/data/variant-type/variant-value/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{Analytics as n}from"../../analytics/analytics.js";import"../../analytics/head/index.js";import{IkasStorefrontConfig as a}from"../../storefront/index.js";import{populateRaffleProducts as d}from"../../providers/helpers/raffles.js";import u from"./api.js";import{SaveMyCustomerInput as c}from"../../__api/models/SaveMyCustomerInput.js";import l from"../raffle/index.js";import'../../ext/@ikas/fe-api-client/build/utils/api.js';import'../../ext/axios/lib/axios.js';import m from'../../ext/@ikas/fe-api-client/build/config/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 p from"../product/index.js";import{CustomerEmailSubscriptionStatusesEnum as h}from"../../__api/types/index.js";var f="undefined"==typeof localStorage,v=function(){function v(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(i,r){return t(s,void 0,void 0,(function(){var t,o,s,a;return e(this,(function(e){switch(e.label){case 0:return[4,u.login({email:i,password:r})];case 1:return(t=e.sent())&&t.isSuccess&&t.data?(o=t.data,this.setToken(o.token,o.tokenExpiry),o.customer&&this.setCustomer(o.customer),this.customer&&n.customerLogin(),(s=null===(a=this.baseStore)||void 0===a?void 0:a.cartStore.cart)?[4,this.baseStore.cartStore.changeItemQuantity(s.orderLineItems[0],s.orderLineItems[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(i,r,o,n,a,d){return t(s,void 0,void 0,(function(){var t,s;return e(this,(function(e){switch(e.label){case 0:return[4,u.register({email:o,password:n,firstName:i,lastName:r,isAcceptMarketing:a,attributes:d})];case 1:return(t=e.sent())&&t.isSuccess&&(null===(s=t.data)||void 0===s?void 0:s.customer)?(this.setToken(t.data.token,t.data.tokenExpiry),this.setCustomer(t.data.customer),this.saveLocalLastViewedProducts(),[2,!0]):[2,!1]}}))}))},this.saveContactForm=function(i){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return n.contactForm(i),[4,u.sendContactFormToMerchant(i)];case 1:return[2,t.sent().isSuccess]}}))}))},this.checkEmail=function(i){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.checkEmail({email:i})];case 1:return[2,t.sent().isSuccess]}}))}))},this.forgotPassword=function(i){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.forgotPassword({email:i})];case 1:return[2,t.sent().isSuccess]}}))}))},this.recoverPassword=function(i,r,o){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.recoverPassword({password:i,passwordAgain:r,token:o})];case 1:return[2,t.sent().isSuccess]}}))}))},this.logout=function(){var t;s.clearLocalData(),null===(t=s.baseStore)||void 0===t||t.cartStore.removeCart(),n.customerLogout()},this.saveCustomer=function(i){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,u.saveCustomer({input:new c(i)})];case 1:return(t=e.sent()).isSuccess&&t.data?(this.setCustomer(t.data),[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,u.getOrders({})];case 1:return[2,t.sent().data||[]]}}))}))},this.getOrder=function(i){return t(s,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,u.getOrders({orderId:i})];case 1:return(t=e.sent()).isSuccess&&(null===(o=t.data)||void 0===o?void 0:o.length)?(r=t.data[0],[4,this.getOrderRefundSettings()]):[2,null];case 2:return e.sent(),r._refundSettings=this._refundSettings,[2,r]}}))}))},this.getOrderTransactions=function(i){return void 0===i&&(i={}),t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.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(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.listFavoriteProducts()];case 1:return[2,t.sent().data||[]]}}))}))},this.getFavoriteProducts=function(){return t(s,void 0,void 0,(function(){var t,i,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,u.listFavoriteProducts()];case 1:return(t=e.sent()).isSuccess||!(null===(r=t.data)||void 0===r?void 0:r.length)?[2,[]]:[4,p.searchProducts({input:{productIdList:t.data.map((function(t){return t.productId})),priceListId:a.priceListId,salesChannelId:a.salesChannelId}})];case 2:return i=e.sent(),[2,(null===(o=null==i?void 0:i.data)||void 0===o?void 0:o.data)||[]]}}))}))},this.addProductToFavorites=function(i){return t(s,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,u.saveFavoriteProduct({isFavorite:!0,productId:i})];case 1:return t=e.sent(),n.addToWishlist(i),[2,t.data||!1]}}))}))},this.removeProductFromFavorites=function(i){return t(s,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,u.saveFavoriteProduct({isFavorite:!1,productId:i})];case 1:return t=e.sent(),n.addToWishlist(i),[2,t.data||!1]}}))}))},this.isProductFavorite=function(i){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,u.isFavoriteProduct({productId:i})];case 1:return[2,e.sent().data||!1]}}))}))},this.createEmailSubscription=function(i){return t(s,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,u.createCustomerEmailSubscription({input:{email:i}})];case 1:return(t=e.sent()).isSuccess&&(window.localStorage.setItem("customerEmailSubscription","true"),this.customer?(this.customer.subscriptionStatus,h.SUBSCRIBED):this._visitorSubscribedEmail=!0,n.createEmailSubscripition(i)),[2,t.isSuccess]}}))}))},this.sendReview=function(r){return t(s,void 0,void 0,(function(){var t,o,s,n;return e(this,(function(e){switch(e.label){case 0:if(t=a.customerReviewSettings,o=a.salesChannelId,!t)return[2];if(!(s=null===(n=this.customer)||void 0===n?void 0:n.id)&&t.customerLoginRequired)throw Error("Unauthorized");return[4,u.createCustomerReview({input:i(i({},r),{customerId:t.customerLoginRequired?s:void 0,salesChannelId:o||""})})];case 1:return[2,e.sent().data]}}))}))},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,i,r,o;return e(this,(function(e){switch(e.label){case 0:return[4,l.getRafflesByCustomerId({winnerFilter:!1})];case 1:return t=e.sent(),[4,l.getRafflesByCustomerId({winnerFilter:!0})];case 2:return i=e.sent(),r=t.data,o=i.data,null==r||r.forEach((function(t){(null==o?void 0:o.find((function(e){return e.id===t.id})))&&(t.isCustomerWinner=!0)})),r?[4,d(r)]:[3,4];case 3:e.sent(),e.label=4;case 4:return[2,r||[]]}}))}))},this.getCustomerAttributes=function(){return t(s,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,u.listCustomerAttribute()];case 1:return t=e.sent(),this.customer&&(null===(i=this.customer.attributes)||void 0===i||i.forEach((function(e){var i,r,o;e.customerAttribute=(null===(i=t.data)||void 0===i?void 0:i.find((function(t){return t.id===e.customerAttributeId})))||null,e.customerAttributeOptionId&&(e.customerAttributeOption=(null===(o=null===(r=e.customerAttribute)||void 0===r?void 0:r.options)||void 0===o?void 0:o.find((function(t){return t.id===e.customerAttributeOptionId})))||null)}))),[2,t.data||[]]}}))}))},this.getOrderByEmail=function(i,r){return t(s,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return[4,u.getOrderByEmail({email:i,orderNumber:r})];case 1:return[2,t.sent().data||null]}}))}))},this.getOrderRefundSettings=function(){return t(s,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return this._refundSettings?[3,2]:[4,u.listOrderRefundSettings({})];case 1:(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)&&(this._refundSettings=t.data[0]),e.label=2;case 2:return[2]}}))}))},this.baseStore=o,r(this)}return Object.defineProperty(v.prototype,"initialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"canCreateEmailSubscription",{get:function(){var t;return!((null===(t=this.customer)||void 0===t?void 0:t.isSubscribed)||f||this._visitorSubscribedEmail)&&!window.localStorage.getItem("customerEmailSubscription")},enumerable:!1,configurable:!0}),Object.defineProperty(v.prototype,"customerConsentGranted",{get:function(){return this._customerConsentGranted},enumerable:!1,configurable:!0}),v.prototype.socialLogin=function(i){return t(this,void 0,void 0,(function(){var t,r,o;return e(this,(function(e){switch(e.label){case 0:return"undefined"==typeof window?[2]:(t=new URLSearchParams(window.location.search).get("redirect")||"",r="".concat(process.env.NEXT_PUBLIC_BASE_URL,"/ms/").concat(i,"/login/authenticate?redirect=").concat(t),[4,fetch(r,{headers:{"x-api-key":a.config.apiKey||"","x-sfid":a.storefrontId||"","x-sfrid":a.storefrontRoutingId||""}})]);case 1:return[4,e.sent().json()];case 2:return o=e.sent(),a.router?a.router.replace(o.redirectUrl):window.location.href=o.redirectUrl,[2]}}))}))},v.prototype.socialLoginToken=function(i){var r;return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,u.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&&n.customerLogin(),[2,!0]):[2,!1]}}))}))},v.prototype.init=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.loadToken(),this.loadLastViewedProducts(),this.loadCustomerConsent(),[4,this.refreshToken()];case 1:return t.sent(),[4,this.getCustomer()];case 2:return t.sent(),this._initialized=!0,this.customer&&n.customerVisit(),[2]}}))}))},v.prototype.routeChangeInit=function(){this.customer||(this.loadToken(),this.getCustomer())},v.prototype.getCustomer=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return f||!this.token?[2]:[4,u.getCustomer()];case 1:return(t=e.sent()).data&&this.setCustomer(t.data),[2]}}))}))},v.prototype.refreshToken=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.token?[4,u.refreshToken({token:this.token})]:[2];case 1:return(t=e.sent()).isSuccess&&t.data?this.setToken(t.data.token,t.data.tokenExpiry):(this.token=null,this.tokenExpiry=null,this.clearLocalData()),[2]}}))}))},v.prototype.setCustomer=function(t){this.customer=new s(t)},v.prototype.getLastViewedProducts=function(){return t(this,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return this.customer?[4,u.getLastViewedProducts({customerId:this.customer.id})]:[3,2];case 1:return t=e.sent(),this._lastViewedProducts=t.data||[],[3,3];case 2:this.loadLastViewedProducts(),e.label=3;case 3:return[2,this._lastViewedProducts]}}))}))},v.prototype.saveLastViewedProducts=function(){f||window.localStorage.setItem("lastViewedProducts",JSON.stringify(this._lastViewedProducts))},v.prototype.loadLastViewedProducts=function(){if(!f)try{var t=window.localStorage.getItem("lastViewedProducts");t&&(this._lastViewedProducts=JSON.parse(t),this._lastViewedProducts=this._lastViewedProducts.reverse(),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"))}catch(t){}},v.prototype.removeLastViewedProducts=function(){f||window.localStorage.removeItem("lastViewedProducts")},v.prototype.onProductView=function(i,r){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this.customer?this._lastViewedProducts.find((function(t){return t.productId===i}))?[2]:[4,u.saveLastViewedProducts({input:{customerId:this.customer.id,products:[{productId:i,variantId:r}]}})]:[3,2];case 1:return t.sent()&&this._lastViewedProducts.push({productId:i,variantId:r}),[3,3];case 2:this._lastViewedProducts.push({productId:i,variantId:r}),this._lastViewedProducts=this._lastViewedProducts.slice(0,20),this._lastViewedProducts=o(this._lastViewedProducts,"variantId"),this.saveLastViewedProducts(),t.label=3;case 3:return[2]}}))}))},v.prototype.saveLocalLastViewedProducts=function(){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:if(f)return[2];t.label=1;case 1:return t.trys.push([1,4,,5]),this.loadLastViewedProducts(),this._lastViewedProducts.length?[4,u.saveLastViewedProducts({input:{customerId:this.customer.id,products:this._lastViewedProducts}})]:[3,3];case 2:t.sent()&&this.removeLastViewedProducts(),t.label=3;case 3:return[3,5];case 4:return t.sent(),[3,5];case 5:return[2]}}))}))},v.prototype.saveCustomerConsent=function(){f||(this._customerConsentGranted=!0,window.localStorage.setItem("customerConsent","true"))},v.prototype.loadCustomerConsent=function(){f||(this._customerConsentGranted=!!window.localStorage.getItem("customerConsent"))},v.prototype.removeCustomerConsent=function(){f||window.localStorage.removeItem("customerConsent")},v.prototype.setToken=function(t,e){f||(this.token=t,this.tokenExpiry=e,localStorage.setItem("customerToken",t),localStorage.setItem("customerTokenExpiry",e+""),m.TOKEN=t)},v.prototype.loadToken=function(){if(!f){var t=localStorage.getItem("customerToken"),e=localStorage.getItem("customerTokenExpiry");t&&e&&this.setToken(t,parseInt(e))}},v.prototype.clearLocalTokenData=function(){localStorage.removeItem("customerToken"),localStorage.removeItem("customerTokenExpiry"),this.token=void 0,this.tokenExpiry=void 0},v.prototype.clearLocalData=function(){this.clearLocalTokenData(),this.customer=void 0,m.TOKEN=""},v}();export{v as IkasCustomerStore};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "3.0.0-alpha.28",
3
+ "version": "3.0.0-alpha.29",
4
4
  "main": "./build/index.js",
5
5
  "module": "./build/index.js",
6
6
  "author": "Umut Ozan Yıldırım",
@@ -30,6 +30,8 @@
30
30
  "dependencies": {
31
31
  "@ikas/fe-api-client": "^1.0.12",
32
32
  "@ikas/react-phone-number-input": "^3.1.25-alpha.2",
33
+ "@stripe/react-stripe-js": "^1.7.2",
34
+ "@stripe/stripe-js": "^1.29.0",
33
35
  "archiver": "^5.3.0",
34
36
  "axios": "^0.21.0",
35
37
  "command-line-args": "^5.2.0",