@ikas/storefront 4.5.2 → 4.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/analytics/analytics.js +1 -1
- package/build/analytics/googleAnalytics.js +1 -1
- package/build/analytics/googleTagManager.js +1 -1
- package/build/analytics/googleUniversal.js +1 -1
- package/build/analytics/ikas.js +1 -1
- package/build/components/checkout/components/address-form/model.js +1 -1
- package/build/components/checkout/components/cart-summary/cart-item/index.js +1 -1
- package/build/components/checkout/components/customer-addresses/model.js +1 -1
- package/build/components/checkout/components/quick-registration/model.js +1 -1
- package/build/components/checkout/index.js +1 -1
- package/build/components/checkout/model.js +1 -1
- package/build/components/checkout/steps/step-payment/payment-gateways/index.js +1 -1
- package/build/components/checkout/steps/step-success/index.js +1 -1
- package/build/components/page/head.js +1 -1
- package/build/components/page/index.js +1 -1
- package/build/components/page-editor/ThemeComponentEditor.js +1 -1
- package/build/components/page-editor/model.js +1 -1
- package/build/hooks/useCustomerReviews.js +1 -1
- package/build/hooks/useStore.js +1 -1
- package/build/models/data/theme-json/component/index.d.ts +1 -0
- package/build/models/data/theme-json/component/index.js +1 -1
- package/build/models/ui/blog-category-list/index.js +1 -1
- package/build/models/ui/brand-list/index.js +1 -1
- package/build/models/ui/category-list/index.js +1 -1
- package/build/models/ui/customer-review-list/index.js +1 -1
- package/build/models/ui/customer-review-summary-list/index.js +1 -1
- package/build/models/ui/product-list/index.js +1 -1
- package/build/models/ui/raffle-list/index.js +1 -1
- package/build/models/ui/validator/form/account-info.js +1 -1
- package/build/models/ui/validator/form/address.js +1 -1
- package/build/models/ui/validator/form/ikas-address.js +1 -1
- package/build/models/ui/validator/form/register.js +1 -1
- package/build/page-data-init/index.js +1 -1
- package/build/pages/checkout.js +1 -1
- package/build/store/blog/index.js +1 -1
- package/build/store/brand/index.js +1 -1
- package/build/store/category/index.js +1 -1
- package/build/store/checkout/index.js +1 -1
- package/build/store/customer/api.js +1 -1
- package/build/store/customer/index.js +1 -1
- package/build/store/html-meta-data/index.js +1 -1
- package/build/store/location/index.js +1 -1
- package/package.json +11 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as i,__assign as e}from'./../../../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as a}from"@ikas/storefront-config";import{makeAutoObservable as
|
|
1
|
+
import{__awaiter as t,__generator as i,__assign as e}from'./../../../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as a}from"@ikas/storefront-config";import{makeAutoObservable as n}from"mobx";import r from"../../../store/customer/api.js";import o from"../../../store/product/index.js";import"../../data/blog/category/index.js";import"../../data/blog/content/index.js";import"../../data/blog/meta-data/index.js";import"../../data/blog/tag/index.js";import"../../data/blog/index.js";import"../../data/brand/index.js";import"@ikas/storefront-models";import"../../data/campaign-offer/index.js";import"../../data/cart/campaign-offer/index.js";import"../../data/cart/index.js";import"../../data/category/path-item/index.js";import"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/checkout-settings/index.js";import"../../data/city/index.js";import"../../data/country/index.js";import"../../data/customer/address/index.js";import"../../data/customer/address/ikas-localized-customer-address.js";import"../../data/customer/attribute/index.js";import"../../data/customer/review/summary/index.js";import{IkasCustomerReview as s}from"../../data/customer/review/index.js";import"../../data/customer/index.js";import"../../data/district/index.js";import"../../data/favorite-product/index.js";import"../../data/filter-category/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/order/address/index.js";import"../../data/order/line-item/option/value/index.js";import"../../data/order/line-item/variant/value/index.js";import"../../data/order/line-item/variant/index.js";import"../../data/order/line-item/index.js";import"../../data/order/package/index.js";import"../../data/order/transaction/index.js";import"../../data/order/index.js";import"../../data/payment-gateway/index.js";import"../../data/product/attribute-value/index.js";import"../../data/product/filter/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/stock-location/index.js";import"../../data/product/variant/price/index.js";import"../../data/product/variant/index.js";import"../../data/variant-type/index.js";import"../../data/product/index.js";import"../../data/raffle/index.js";import"../../data/state/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/component/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var d=function(){function d(e){var a=this;this._initialized=!1,this._minPage=null,this._productId=null,this._isLoading=!1,this.getInitial=function(){return t(a,void 0,void 0,(function(){var t,e,a,n;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviews(this.page,this.limit)];case 2:return t=i.sent(),this.data=(null===(a=t.data)||void 0===a?void 0:a.data)||[],this._count=(null===(n=t.data)||void 0===n?void 0:n.count)||0,this._initialized=!0,this._minPage=this.page,[3,5];case 3:return e=i.sent(),console.log(e),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPrev=function(){return t(a,void 0,void 0,(function(){var t,e,a,n,r;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.listCustomerReviews(t,this.limit)];case 2:return e=i.sent(),this.data=(null===(n=e.data)||void 0===n?void 0:n.data.concat(this.data))||this.data,this._count=(null===(r=e.data)||void 0===r?void 0:r.count)||this._count,this._minPage=t,[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(a,void 0,void 0,(function(){var t,e,a,n;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasNext)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviews(this.page+1,this.limit)];case 2:return t=i.sent(),this.data=this.data.concat((null===(a=t.data)||void 0===a?void 0:a.data)||[]),this._count=(null===(n=t.data)||void 0===n?void 0:n.count)||this._count,this._page=this.page+1,[3,5];case 3:return e=i.sent(),console.log(e),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(e){return t(a,void 0,void 0,(function(){var t,a,n,r;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviews(e,this.limit)];case 2:return t=i.sent(),this.data=(null===(n=t.data)||void 0===n?void 0:n.data)||[],this._count=(null===(r=t.data)||void 0===r?void 0:r.count)||0,this._page=e,this._minPage=e,[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.data=e.data?e.data.map((function(t){return new s(t)})):[],this._limit=e.limit||5,this._page=e.page||1,this._count=e.count||0,this._initialized=e.initialized||!1,this._minPage=e.minPage,this._productId=e.productId||null,n(this)}return Object.defineProperty(d.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"hasPrev",{get:function(){return!!this._minPage&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"hasNext",{get:function(){return this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),d.prototype.listCustomerReviews=function(n,s){var d,u,c;return t(this,void 0,void 0,(function(){var t,p,l;return i(this,(function(i){switch(i.label){case 0:return[4,r.listCustomerReviews({productId:this._productId,input:{salesChannelId:a.getSalesChannelId()||""},pagination:{page:n,limit:s}})];case 1:return t=i.sent(),!(null===(d=t.data)||void 0===d?void 0:d.data)||this._productId?[3,3]:(p=null===(u=null==t?void 0:t.data)||void 0===u?void 0:u.data.map((function(t){return null==t?void 0:t.productId})),[4,o.searchProducts({input:{productIdList:p}})]);case 2:l=i.sent(),t.data.data=null===(c=null==t?void 0:t.data)||void 0===c?void 0:c.data.map((function(t){var i,a,n=null===(a=null===(i=null==l?void 0:l.data)||void 0===i?void 0:i.data)||void 0===a?void 0:a.find((function(i){return i.id===t.productId}));return e(e({},t),{product:n})})).filter((function(t){return t.product&&!t.product.deleted})),i.label=3;case 3:return[2,t]}}))}))},d.prototype.toJSON=function(){return{data:this.data,limit:this._limit,page:this._page,count:this._count,initialized:this._initialized,minPage:this._minPage,productId:this._productId}},d}();export{d as IkasCustomerReviewList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as i}from'./../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as e}from"mobx";import a from"../../../store/customer/api.js";import"../../data/blog/category/index.js";import"../../data/blog/content/index.js";import"../../data/blog/meta-data/index.js";import"../../data/blog/tag/index.js";import"../../data/blog/index.js";import"../../data/brand/index.js";import"@ikas/storefront-models";import"../../data/campaign-offer/index.js";import"../../data/cart/campaign-offer/index.js";import"../../data/cart/index.js";import"../../data/category/path-item/index.js";import"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/checkout-settings/index.js";import"../../data/city/index.js";import"../../data/country/index.js";import"../../data/customer/address/index.js";import"../../data/customer/address/ikas-localized-customer-address.js";import"../../data/customer/attribute/index.js";import{IkasCustomerReviewSummary as r}from"../../data/customer/review/summary/index.js";import"../../data/customer/review/index.js";import"../../data/customer/index.js";import"../../data/district/index.js";import"../../data/favorite-product/index.js";import"../../data/filter-category/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/order/address/index.js";import"../../data/order/line-item/option/value/index.js";import"../../data/order/line-item/variant/value/index.js";import"../../data/order/line-item/variant/index.js";import"../../data/order/line-item/index.js";import"../../data/order/package/index.js";import"../../data/order/transaction/index.js";import"../../data/order/index.js";import"../../data/payment-gateway/index.js";import"../../data/product/attribute-value/index.js";import"../../data/product/filter/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/stock-location/index.js";import"../../data/product/variant/price/index.js";import"../../data/product/variant/index.js";import"../../data/variant-type/index.js";import"../../data/product/index.js";import"../../data/raffle/index.js";import"../../data/state/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var n=function(){function n(a){var n=this;this._initialized=!1,this._minPage=null,this._isLoading=!1,this.getInitial=function(){return t(n,void 0,void 0,(function(){var t,e,a,r;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviewSummary(this.page,this.limit)];case 2:return t=i.sent(),this.data=(null===(a=t.data)||void 0===a?void 0:a.data)||[],this._count=(null===(r=t.data)||void 0===r?void 0:r.count)||0,this._initialized=!0,this._minPage=this.page,[3,5];case 3:return e=i.sent(),console.log(e),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPrev=function(){return t(n,void 0,void 0,(function(){var t,e,a,r,n,o;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.listCustomerReviewSummary(t,this.limit)];case 2:return e=i.sent(),this.data=(null===(n=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===n?void 0:n.concat(this.data))||this.data,this._count=(null===(o=e.data)||void 0===o?void 0:o.count)||this._count,this._minPage=t,[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(n,void 0,void 0,(function(){var t,e,a,r;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasNext)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviewSummary(this.page+1,this.limit)];case 2:return t=i.sent(),this.data=this.data.concat((null===(a=t.data)||void 0===a?void 0:a.data)||[]),this._count=(null===(r=t.data)||void 0===r?void 0:r.count)||this._count,this._page=this.page+1,[3,5];case 3:return e=i.sent(),console.log(e),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(e){return t(n,void 0,void 0,(function(){var t,a,r,n;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviewSummary(e,this.limit)];case 2:return t=i.sent(),this.data=(null===(r=t.data)||void 0===r?void 0:r.data)||[],this._count=(null===(n=t.data)||void 0===n?void 0:n.count)||0,this._page=e,this._minPage=e,[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.data=a.data?a.data.map((function(t){return new r(t)})):[],this._limit=a.limit||5,this._page=a.page||1,this._count=a.count||0,this._initialized=a.initialized||!1,this._minPage=a.minPage,this._productId=a.productId,e(this)}return Object.defineProperty(n.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasPrev",{get:function(){return!!this._minPage&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasNext",{get:function(){return this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),n.prototype.listCustomerReviewSummary=function(e,r){return t(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,a.listCustomerReviewSummary({productId:{eq:this._productId},pagination:{page:e,limit:r}})];case 1:return[2,t.sent()]}}))}))},n.prototype.toJSON=function(){return{data:this.data,limit:this._limit,page:this._page,count:this._count,initialized:this._initialized,minPage:this._minPage,productId:this._productId}},n}();export{n as IkasCustomerReviewSummaryList};
|
|
1
|
+
import{__awaiter as t,__generator as i}from'./../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as e}from"mobx";import a from"../../../store/customer/api.js";import"../../data/blog/category/index.js";import"../../data/blog/content/index.js";import"../../data/blog/meta-data/index.js";import"../../data/blog/tag/index.js";import"../../data/blog/index.js";import"../../data/brand/index.js";import"@ikas/storefront-models";import"../../data/campaign-offer/index.js";import"../../data/cart/campaign-offer/index.js";import"../../data/cart/index.js";import"../../data/category/path-item/index.js";import"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/checkout-settings/index.js";import"../../data/city/index.js";import"../../data/country/index.js";import"../../data/customer/address/index.js";import"../../data/customer/address/ikas-localized-customer-address.js";import"../../data/customer/attribute/index.js";import{IkasCustomerReviewSummary as r}from"../../data/customer/review/summary/index.js";import"../../data/customer/review/index.js";import"../../data/customer/index.js";import"../../data/district/index.js";import"../../data/favorite-product/index.js";import"../../data/filter-category/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/order/address/index.js";import"../../data/order/line-item/option/value/index.js";import"../../data/order/line-item/variant/value/index.js";import"../../data/order/line-item/variant/index.js";import"../../data/order/line-item/index.js";import"../../data/order/package/index.js";import"../../data/order/transaction/index.js";import"../../data/order/index.js";import"../../data/payment-gateway/index.js";import"../../data/product/attribute-value/index.js";import"../../data/product/filter/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/stock-location/index.js";import"../../data/product/variant/price/index.js";import"../../data/product/variant/index.js";import"../../data/variant-type/index.js";import"../../data/product/index.js";import"../../data/raffle/index.js";import"../../data/state/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/component/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var n=function(){function n(a){var n=this;this._initialized=!1,this._minPage=null,this._isLoading=!1,this.getInitial=function(){return t(n,void 0,void 0,(function(){var t,e,a,r;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviewSummary(this.page,this.limit)];case 2:return t=i.sent(),this.data=(null===(a=t.data)||void 0===a?void 0:a.data)||[],this._count=(null===(r=t.data)||void 0===r?void 0:r.count)||0,this._initialized=!0,this._minPage=this.page,[3,5];case 3:return e=i.sent(),console.log(e),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPrev=function(){return t(n,void 0,void 0,(function(){var t,e,a,r,n,o;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.listCustomerReviewSummary(t,this.limit)];case 2:return e=i.sent(),this.data=(null===(n=null===(r=e.data)||void 0===r?void 0:r.data)||void 0===n?void 0:n.concat(this.data))||this.data,this._count=(null===(o=e.data)||void 0===o?void 0:o.count)||this._count,this._minPage=t,[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(n,void 0,void 0,(function(){var t,e,a,r;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasNext)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviewSummary(this.page+1,this.limit)];case 2:return t=i.sent(),this.data=this.data.concat((null===(a=t.data)||void 0===a?void 0:a.data)||[]),this._count=(null===(r=t.data)||void 0===r?void 0:r.count)||this._count,this._page=this.page+1,[3,5];case 3:return e=i.sent(),console.log(e),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(e){return t(n,void 0,void 0,(function(){var t,a,r,n;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviewSummary(e,this.limit)];case 2:return t=i.sent(),this.data=(null===(r=t.data)||void 0===r?void 0:r.data)||[],this._count=(null===(n=t.data)||void 0===n?void 0:n.count)||0,this._page=e,this._minPage=e,[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.data=a.data?a.data.map((function(t){return new r(t)})):[],this._limit=a.limit||5,this._page=a.page||1,this._count=a.count||0,this._initialized=a.initialized||!1,this._minPage=a.minPage,this._productId=a.productId,e(this)}return Object.defineProperty(n.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasPrev",{get:function(){return!!this._minPage&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"hasNext",{get:function(){return this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),n.prototype.listCustomerReviewSummary=function(e,r){return t(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,a.listCustomerReviewSummary({productId:{eq:this._productId},pagination:{page:e,limit:r}})];case 1:return[2,t.sent()]}}))}))},n.prototype.toJSON=function(){return{data:this.data,limit:this._limit,page:this._page,count:this._count,initialized:this._initialized,minPage:this._minPage,productId:this._productId}},n}();export{n as IkasCustomerReviewSummaryList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e,__assign as i}from'./../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import s from"lodash/debounce";import"../../data/blog/category/index.js";import"../../data/blog/content/index.js";import"../../data/blog/meta-data/index.js";import"../../data/blog/tag/index.js";import"../../data/blog/index.js";import"../../data/brand/index.js";import{IkasCategoryProductsOrderType as o,IkasThemeJsonPageType as a,IkasThemeJsonStockPreference as n}from"@ikas/storefront-models";import"../../data/campaign-offer/index.js";import"../../data/cart/campaign-offer/index.js";import"../../data/cart/index.js";import"../../data/category/path-item/index.js";import"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/checkout-settings/index.js";import"../../data/city/index.js";import"../../data/country/index.js";import"../../data/customer/address/index.js";import"../../data/customer/address/ikas-localized-customer-address.js";import"../../data/customer/attribute/index.js";import"../../data/customer/review/summary/index.js";import"../../data/customer/review/index.js";import"../../data/customer/index.js";import"../../data/district/index.js";import"../../data/favorite-product/index.js";import{IkasFilterCategory as d}from"../../data/filter-category/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/order/address/index.js";import"../../data/order/line-item/option/value/index.js";import"../../data/order/line-item/variant/value/index.js";import"../../data/order/line-item/variant/index.js";import"../../data/order/line-item/index.js";import"../../data/order/package/index.js";import"../../data/order/transaction/index.js";import"../../data/order/index.js";import"../../data/payment-gateway/index.js";import"../../data/product/attribute-value/index.js";import{IkasProductFilter as c,IkasProductFilterValue as u}from"../../data/product/filter/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/stock-location/index.js";import"../../data/product/variant/price/index.js";import"../../data/product/variant/index.js";import"../../data/variant-type/index.js";import{IkasProduct as l}from"../../data/product/index.js";import"../../data/raffle/index.js";import"../../data/state/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";import p from"../../../store/product/index.js";import h from"query-string";import{SortByDirectionEnum as f,SortByTypeEnum as g,GetSuggestedProductsMethodEnum as m}from"@ikas/storefront-api";import{IkasStorefrontConfig as v}from"@ikas/storefront-config";import{Analytics as _}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import"../../../components/page/index.js";import"../../../components/page/head.js";import"react";import"next/image.js";import"@ikas/storefront-model-functions";import"../../../components/link/index.js";import"../../../components/page-editor/loader/style.module.scss.js";import"../../../components/google-captcha/index.js";import"../blog-list/index.js";import"../blog-category-list/index.js";import"../brand-list/index.js";import"../category-list/index.js";import"../product-attribute-detail/index.js";import"../product-attribute-list/index.js";import"../customer-review-list/index.js";import"../customer-review-summary-list/index.js";import"../validator/index.js";import"../validator/rules/index.js";import"../validator/form/login.js";import"../validator/form/address.js";import"../validator/form/ikas-address.js";import"../validator/form/register.js";import"../validator/form/contact-form.js";import"../validator/form/forgot-password.js";import"../validator/form/recover-password.js";import"../validator/form/account-info.js";import"../validator/form/raffle-form.js";import"../validator/form/customer-review.js";import"../raffle-list/index.js";import"../../../pages/home.js";import"../../../pages/_slug_/index.js";import"../../../pages/pages/_slug_.js";import"../../../pages/checkout.js";import"../../../pages/account/index.js";import"../../../pages/account/addresses.js";import"../../../pages/account/orders/index.js";import"../../../pages/account/orders/_id_.js";import"../../../pages/account/login.js";import"../../../pages/account/register.js";import"../../../pages/account/forgot-password.js";import"../../../pages/account/recover-password.js";import"../../../pages/cart.js";import"../../../pages/editor.js";import"../../../pages/account/favorite-products.js";import"../../../pages/search.js";import"next/error.js";import"../../../pages/blog/index.js";import"../../../pages/blog/_slug_.js";import"../../../pages/raffle/_slug_.js";import"../../../pages/raffle/index.js";import"../../../pages/account/raffles.js";import"../../../pages/account/activate.js";import{IkasBaseStore as y}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import"lodash/get";var I,E,S,P,C=function(){function I(o,n){var u=this;this.filters=null,this._filterCategories=null,this._infiniteScrollPage=null,this._initialized=!1,this._minPage=null,this._filterBrandId=null,this._filterCategoryId=null,this._relatedProductData=null,this._viewedTogetherProductData=null,this.pageSpecificData=null,this._recommendFor=null,this._isLoading=!1,this._fetchRequestTime=0,this.router=null,this.applyFilters=function(){return t(u,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getInitial()];case 1:return t=e.sent(),[a.CATEGORY,a.BRAND,a.SEARCH].includes(this._pageType)?(t&&this.setQueryParams(),[2]):[2]}}))}))},this.getInitial=function(r,s){return t(u,void 0,void 0,(function(){var t,o,a,n,d,c,u,p,h,f,g,m,v,_,I;return e(this,(function(e){switch(e.label){case 0:this._isLoading=!0,t=Date.now(),this._fetchRequestTime=t,e.label=1;case 1:return e.trys.push([1,14,15,16]),o=s?this._page:1,a=this._limit,!this.isFilterable||this.filters?[3,3]:[4,this.getFilters()];case 2:e.sent(),e.label=3;case 3:return this.applyQueryParamFilters(r),this.isSearch&&!this.hasAppliedfilter?(this.data=[],this._page=1,this._minPage=1,this._count=0,this._initialized=!0,[2,!0]):(n=void 0,d=!1,this.isStatic?(o=void 0,a=200,[3,10]):[3,4]);case 4:return this.isDiscounted?(o=1,a=10,[3,10]):[3,5];case 5:return this.isRecommended?(o=1,a=10,[3,10]):[3,6];case 6:return this.isLastViewed?this.isBrowser()?[4,this.waitForCustomerStoreInit()]:[3,9]:[3,10];case 7:return e.sent(),[4,y.getInstance().customerStore.getLastViewedProducts()];case 8:return(c=e.sent())&&c.length?(n=c.map((function(t){return t.productId})),d=y.getInstance().customerStore.useLastViewedProductResponse,[3,10]):[2];case 9:return[2];case 10:return d?(p=y.getInstance().customerStore._savedLastViewedProductsResponse,[3,13]):[3,11];case 11:return[4,this.searchProducts(o||1,a||10,n)];case 12:p=e.sent(),e.label=13;case 13:return(u=p)&&this._fetchRequestTime===t?(h=[],!d&&this.isLastViewed&&y.getInstance().customerStore.setSavedLastViewedProductsResponse(u),this.isStatic||this.isLastViewed?(f=this.isStatic?this._productListPropValue.productIds:y.getInstance().customerStore._lastViewedProducts,h=(null==f?void 0:f.map((function(t){var e,r,s=null===(r=null===(e=u.data)||void 0===e?void 0:e.data)||void 0===r?void 0:r.find((function(e){return e.id===t.productId})),o=null==s?void 0:s.variants.find((function(e){return e.id===t.variantId}));if((null==o?void 0:o.isActive)||(o=null==s?void 0:s.variants.find((function(t){return t.isActive}))),s&&o)return new l(i(i({},s),{selectedVariantValues:o.variantValues}))})).filter((function(t){return!!t})))||[]):h=(null===(v=null===(m=u.data)||void 0===m?void 0:m.data)||void 0===v?void 0:v.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})))||[],this.applyFacets(null===(_=u.data)||void 0===_?void 0:_.facets),this.data=h,this._count=(null===(I=u.data)||void 0===I?void 0:I.count)||0,this._initialized=!0,this._page=o||1,this._minPage=this.page,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),s||(this._infiniteScrollPage=null),this.handleListingEvent(),[2,!0]):[2];case 14:return g=e.sent(),console.log(g),[3,16];case 15:return t===this._fetchRequestTime&&(this._isLoading=!1),[7];case 16:return[2]}}))}))},this.getPrev=function(){return t(u,void 0,void 0,(function(){var t,r,s,o,a,n,d;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.searchProducts(t,this.limit)];case 2:return(r=e.sent())?(s=null===(n=null===(a=r.data)||void 0===a?void 0:a.data)||void 0===n?void 0:n.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=(null==s?void 0:s.concat(this.data))||this.data,this._count=(null===(d=r.data)||void 0===d?void 0:d.count)||this._count,this._minPage=t,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),[3,5]):[2];case 3:return o=e.sent(),console.log(o),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(u,void 0,void 0,(function(){var t,r,s,o,a,n;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasNext)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(this.page+1,this.limit)];case 2:return(t=e.sent())?(r=null===(a=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===a?void 0:a.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=this.data.concat(r||[]),this._count=(null===(n=t.data)||void 0===n?void 0:n.count)||this._count,this._page=this.page+1,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),[3,5]):[2];case 3:return s=e.sent(),console.log(s),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(r){return t(u,void 0,void 0,(function(){var t,s,o,a,n,d;return e(this,(function(e){switch(e.label){case 0:if(this._isLoading||this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(r,this.limit)];case 2:return(t=e.sent())?(s=null===(n=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===n?void 0:n.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=s||[],this._count=(null===(d=t.data)||void 0===d?void 0:d.count)||0,this._page=r,this._minPage=r,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),[3,5]):[2];case 3:return o=e.sent(),console.log(o),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.setVisibleInfiniteScrollPage=function(t){var e;u._infiniteScrollPage!==t&&(u._infiniteScrollPage=t,v.getIsEditor()||null===(e=u.router)||void 0===e||e.replace("".concat(location.pathname).concat(u.queryParams?"?"+u.queryParams:""),void 0,{shallow:!0}))},this.searchDebouncer=s((function(){u.applyFilters()}),500),this.searchAnalyticsDebouncer=s((function(){_.search(u._searchKeyword)}),1e3);var p=o,h=o;if(this.data=o.data?o.data.map((function(t){return new l(t)})):[],this._type=p.type||h._type||p.productListPropValue.productListType||h._productListPropValue.productListType||E.ALL,this._pageType=o.pageType,this._sort=o.sort||o.productListPropValue.initialSort||S.LAST_ADDED,this._limit=o.limit||p.productListPropValue.initialLimit||h._productListPropValue.initialLimit||20,this._page=o.page||1,this._minPage=o.minPage||null,this._count=o.count||0,this._searchKeyword=o.searchKeyword||"",this._productListPropValue=p.productListPropValue||h._productListPropValue,this._filterBrandId=p.filterBrandId||h._filterBrandId||null,this._filterCategoryId=p.filterCategoryId||h._filterCategoryId||null,this._relatedProductData=p.relatedProductData||h._relatedProductData||null,this._viewedTogetherProductData=p.viewedTogetherProductData||h._viewedTogetherProductData||null,this._recommendFor=p.recommendFor||h._recommendFor,this.filters=o.filters?o.filters.map((function(t){return new c(t,u)})):null,this._filterCategories=o.filterCategories?o.filterCategories.map((function(t){return new d(t)})):null,this.pageSpecificData=p.pageSpecificData||h.pageSpecificData||null,this.router=n,r(this,{router:!1}),this.setPageSpecificSort(),this.setIsFilteredForProducts(),this.setIsStaticForProducts(),this.isBrowser())if(this.restoreInfiniteScrollPage(),location.search&&(this.isFilterable||this._type===E.SEARCH)){var f=this.getQueryParams();this.getInitial(f,this._page>1)}else this._page>1?this.getInitial(void 0,!0):this.isLastViewed?this.getInitial():this.handleListingEvent()}return Object.defineProperty(I.prototype,"sort",{get:function(){return this._sort},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"pageType",{get:function(){return this._pageType},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"minPage",{get:function(){return this._minPage||1},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"searchKeyword",{get:function(){return this._searchKeyword},set:function(t){t!==this._searchKeyword&&(this._searchKeyword=t,this.searchDebouncer(),this.searchAnalyticsDebouncer())},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isFilterable",{get:function(){return this._type===E.ALL||this._type===E.CATEGORY},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isFiltered",{get:function(){var t,e;return(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))||!!this._searchKeyword||this._pageType!==a.CATEGORY&&(!!this._filterCategoryId||(null===(e=this._filterCategories)||void 0===e?void 0:e.some((function(t){return t.isSelected}))))},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isStatic",{get:function(){return this._type===E.STATIC},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isDiscounted",{get:function(){return this._type===E.DISCOUNTED},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isRecommended",{get:function(){return this._type===E.RECOMMENDED},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isLastViewed",{get:function(){return this._type===E.LAST_VIEWED},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isRelatedProducts",{get:function(){return this._type===E.RELATED_PRODUCTS},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isViewedTogetherProducts",{get:function(){return this._type===E.VIEWED_TOGETHER},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isSearch",{get:function(){return this._type===E.SEARCH},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"hasPrev",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended||!this._minPage)&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"hasNext",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended)&&this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"queryParams",{get:function(){var t,e,i,r,s=this,o={};if(null===(t=this.filters)||void 0===t||t.forEach((function(t){t.keyList.length&&(o[t.key]=t.keyList)})),this._searchKeyword&&(o.s=this._searchKeyword),this._sort&&(o.o=b[this._sort]),this._infiniteScrollPage&&(o.page=this._infiniteScrollPage),this._pageType!==a.CATEGORY){var n=null===(e=this.filterCategories)||void 0===e?void 0:e.filter((function(t){return t.isSelected}));if(!!(null==n?void 0:n.length))o.c=null==n?void 0:n.map((function(t){return t.slug}));else if(this._filterCategoryId){var d=null===(r=null===(i=this.filterCategories)||void 0===i?void 0:i.find((function(t){return t.id===s._filterCategoryId})))||void 0===r?void 0:r.slug;d&&(o.c=d)}}return h.stringify(o,{arrayFormat:"comma"})},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"filterCategories",{get:function(){var t;return null===(t=this._filterCategories)||void 0===t?void 0:t.filter((function(t){return 0!==t.resultCount}))},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"hasAppliedfilter",{get:function(){var t;return!!this._searchKeyword||(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isFeaturedSortEnabled",{get:function(){var t;return(null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)===o.MANUALLY&&[E.ALL,E.CATEGORY].includes(this._type)},enumerable:!1,configurable:!0}),I.prototype.setIsFilteredForProducts=function(){var t=this;this.data.forEach((function(e){return e.isFiltered=t.isFiltered||!1}))},I.prototype.setIsStaticForProducts=function(){var t=this;this.data.forEach((function(e){return e.isStatic=t.isStatic||!1}))},I.prototype.setPageSpecificSort=function(){var t;if((null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)&&[E.ALL].includes(this._type))switch(this.pageSpecificData.orderType){case o.HIGHEST_DISCOUNT_RATIO:this._sort=S.DECRASING_DISCOUNT;break;case o.LOWEST_DISCOUNT_RATIO:this._sort=S.INCREASING_DISCOUNT;break;case o.HIGHEST_PRICE:this._sort=S.DECREASING_PRICE;break;case o.LOWEST_PRICE:this._sort=S.INCREASING_PRICE;break;case o.NEWEST:this._sort=S.LAST_ADDED;break;case o.OLDEST:this._sort=S.FIRST_ADDED;break;case o.MANUALLY:this._sort=S.FEATURED}},I.prototype.getSortParams=function(){var t,e;switch(this._sort){case S.INCREASING_PRICE:t=f.ASC,e=g.PRICE;break;case S.DECREASING_PRICE:t=f.DESC,e=g.PRICE;break;case S.FIRST_ADDED:t=f.ASC,e=g.CREATED_AT;break;case S.LAST_ADDED:t=f.DESC,e=g.CREATED_AT;break;case S.INCREASING_DISCOUNT:t=f.ASC,e=g.DISCOUNT_RATIO;break;case S.DECRASING_DISCOUNT:t=f.DESC,e=g.DISCOUNT_RATIO;break;case S.FEATURED:if(this.isSearch)return;t=f.ASC,e=g.MANUAL_SORT;break;case S.DEFAULT:t=void 0,e=void 0}if(t&&e)return{direction:t,type:e}},I.prototype.searchProducts=function(i,r,s){var o,d,c;return t(this,void 0,void 0,(function(){var t,l,h,f;return e(this,(function(e){switch(e.label){case 0:return t=[],l=[],null===(o=this.filters)||void 0===o||o.forEach((function(e){e.valueList.length&&t.push(new u({id:e.id,type:e.type,displayType:e.displayType,valueList:e.valueList})),e.isFacetFilter&&l.push({id:e.id,type:e.type,displayType:e.displayType})})),h=null===(d=this._filterCategories)||void 0===d?void 0:d.filter((function(t){return t.isSelected})).map((function(t){return t.id})),f=this.getSortParams(),this.isRelatedProducts&&this._relatedProductData?[4,p.getSuggestedProducts({priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId(),productId:this._relatedProductData.productId,brandIds:this._relatedProductData.brandIds,categoryIds:this._relatedProductData.categoryIds,locale:v.getCurrentLocale()})]:[3,2];case 1:case 3:case 5:return[2,e.sent()];case 2:return this.isViewedTogetherProducts&&this._viewedTogetherProductData?[4,p.getSuggestedProducts({priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId(),method:m.VIEWED_TOGETHER,productIds:this._viewedTogetherProductData.productIds,locale:v.getCurrentLocale()})]:[3,4];case 4:return[4,p.searchProducts({input:{page:i,perPage:r,productIdList:this.isStatic?null===(c=this._productListPropValue.productIds)||void 0===c?void 0:c.map((function(t){return t.productId})):s,filterList:t,facetList:l,brandId:this._pageType===a.BRAND&&this._type!==E.SEARCH?this._filterBrandId:void 0,categoryIdList:h&&h.length?h:this._filterCategoryId?[this._filterCategoryId]:void 0,priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId(),query:this._searchKeyword,order:this._type===E.SEARCH?[]:f?[f]:[],showStockOption:v.getStockPreference()||n.SHOW_ALL}})]}}))}))},I.prototype.getFilters=function(){var i,r,s;return t(this,void 0,void 0,(function(){var t,o,n=this;return e(this,(function(e){switch(e.label){case 0:return[4,p.getProductFilterData({categoryId:this._filterCategoryId?this._filterCategoryId:void 0,locale:v.getCurrentLocale()})];case 1:return t=e.sent(),this.filters=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.filters.map((function(t){return new c(t,n)})),this._filterCategories=null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.categories,this.pageType!==a.CATEGORY&&this._filterCategoryId&&(o=null===(s=this._filterCategories)||void 0===s?void 0:s.find((function(t){return t.id===n._filterCategoryId})))&&(o.isSelected=!0),this.filters&&this.filters.sort((function(t,e){return t.order>e.order?1:-1})),[2]}}))}))},I.prototype.applyQueryParamFilters=function(t){var e,i=this;try{null==t||t.forEach((function(t,e){var r,s=null===(r=i.filters)||void 0===r?void 0:r.find((function(t){return t.key===e}));s&&s.applyQueryParam(t)}));var r=null==t?void 0:t.get("s");r&&(this._searchKeyword=r);var s=null==t?void 0:t.get("o");if(s){var o=parseInt(s),n=Object.entries(b).find((function(t){return t[1]===o}));n&&(this._sort=n[0])}if(this._pageType!==a.CATEGORY){var d=null==t?void 0:t.get("c"),c=null==d?void 0:d.split(",");c&&c.length&&(null===(e=this.filterCategories)||void 0===e||e.forEach((function(t){t.isSelected=c.some((function(e){return e===t.slug}))})))}}catch(t){console.log(t)}},I.prototype.applyFacets=function(t){var e,i;null===(e=this.filters)||void 0===e||e.forEach((function(e){var i,r,s,o=null==t?void 0:t.find((function(t){return t.id===e.id}));o?null===(i=e.values)||void 0===i||i.forEach((function(t){var i=o.values.find((function(e){return e.id===t.id}));i?t.resultCount=i.count:e.isCustomValueFilter?t.resultCount=null:t.resultCount=0})):e.isCustomValueFilter?null===(r=e.values)||void 0===r||r.forEach((function(t){return t.resultCount=null})):null===(s=e.values)||void 0===s||s.forEach((function(t){return t.resultCount=0}))}));var r=null==t?void 0:t.find((function(t){return"category"===t.id}));r&&(null===(i=this._filterCategories)||void 0===i||i.forEach((function(t){var e=r.values.find((function(e){return e.id===t.id}));t.resultCount=e?e.count:0})))},I.prototype.setQueryParams=function(){var t;!this.isBrowser()||this.isSearch||v.getIsEditor()||null===(t=this.router)||void 0===t||t.replace("".concat(location.pathname).concat(this.queryParams?"?"+this.queryParams:""),void 0,{shallow:!0})},I.prototype.clearFilters=function(){var t,e;null===(t=this.filters)||void 0===t||t.forEach((function(t){return t.clear()})),this._searchKeyword="",this._pageType!==a.CATEGORY&&(this._filterCategoryId=void 0),null===(e=this._filterCategories)||void 0===e||e.forEach((function(t){return t.isSelected=!1})),this.applyFilters()},I.prototype.setSortType=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this._sort=i,[4,this.getInitial()];case 1:return t.sent()&&this.setQueryParams(),[2]}}))}))},I.prototype.onFilterCategoryClick=function(i,r){var s,o;return void 0===r&&(r=!1),t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r?(null===(s=this._filterCategories)||void 0===s||s.forEach((function(t){t.id===i.id&&(t.isSelected=!t.isSelected)})),[4,this.applyFilters()]):[3,2];case 1:return t.sent(),[3,3];case 2:v.getIsEditor()||null===(o=y.getInstance().router)||void 0===o||o.push(i.href+(this.queryParams?"?"+this.queryParams:"")),t.label=3;case 3:return[2]}}))}))},I.prototype.toJSON=function(){return{data:this.data,type:this._type,pageType:this._pageType,sort:this._sort,limit:this._limit,page:this._page,count:this._count,searchKeyword:this._searchKeyword,initialized:this._initialized,minPage:this._minPage,filterBrandId:this._filterBrandId,filterCategoryId:this._filterCategoryId,filterCategories:this._filterCategories,filters:this.filters,recommendFor:this._recommendFor,productListPropValue:this._productListPropValue,pageSpecificData:this.pageSpecificData}},I.prototype.restoreInfiniteScrollPage=function(){var t=this.getQueryParams(),e=null==t?void 0:t.get("page");if(e){var i=parseInt(e);isNaN(i)||(this._page=i,this._infiniteScrollPage=i)}},I.prototype.getQueryParams=function(){if(this.isBrowser())return new URLSearchParams(location.search)},I.prototype.isBrowser=function(){return"undefined"!=typeof window},I.prototype.waitForCustomerStoreInit=function(){return new Promise((function(t){var e=setInterval((function(){y.getInstance().customerStore.initialized&&(clearInterval(e),t(null))}),1e3)}))},I.prototype.handleListingEvent=function(){this.searchKeyword&&this.data.length?_.viewSearchResults(this._searchKeyword,this.data):this.data.length&&this._type===E.ALL&&_.viewListing(this.data)},I}();!function(t){t.ALL="ALL",t.STATIC="STATIC",t.DISCOUNTED="DISCOUNTED",t.RECOMMENDED="RECOMMENDED",t.CATEGORY="CATEGORY",t.SEARCH="SEARCH",t.LAST_VIEWED="LAST_VIEWED",t.RELATED_PRODUCTS="RELATED_PRODUCTS",t.VIEWED_TOGETHER="VIEWED_TOGETHER"}(E||(E={})),function(t){t.INCREASING_PRICE="INCREASING_PRICE",t.DECREASING_PRICE="DECREASING_PRICE",t.LAST_ADDED="LAST_ADDED",t.FIRST_ADDED="FIRST_ADDED",t.INCREASING_DISCOUNT="INCREASING_DISCOUNT",t.DECRASING_DISCOUNT="DECRASING_DISCOUNT",t.FEATURED="FEATURED",t.DEFAULT="DEFAULT"}(S||(S={})),function(t){t.CATEGORY="CATEGORY",t.BRAND="BRAND"}(P||(P={}));var b=((I={})[S.INCREASING_PRICE]=1,I[S.DECREASING_PRICE]=2,I[S.LAST_ADDED]=3,I[S.FIRST_ADDED]=4,I[S.INCREASING_DISCOUNT]=5,I[S.DECRASING_DISCOUNT]=6,I[S.FEATURED]=7,I[S.DEFAULT]=8,I);export{C as IkasProductList,S as IkasProductListSortType,E as IkasProductListType,P as IkasRelatedProductsType};
|
|
1
|
+
import{__awaiter as t,__generator as e,__assign as i}from'./../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as r}from"mobx";import s from"lodash/debounce";import"../../data/blog/category/index.js";import"../../data/blog/content/index.js";import"../../data/blog/meta-data/index.js";import"../../data/blog/tag/index.js";import"../../data/blog/index.js";import"../../data/brand/index.js";import{IkasCategoryProductsOrderType as o,IkasThemeJsonPageType as a,IkasThemeJsonStockPreference as n}from"@ikas/storefront-models";import"../../data/campaign-offer/index.js";import"../../data/cart/campaign-offer/index.js";import"../../data/cart/index.js";import"../../data/category/path-item/index.js";import"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/checkout-settings/index.js";import"../../data/city/index.js";import"../../data/country/index.js";import"../../data/customer/address/index.js";import"../../data/customer/address/ikas-localized-customer-address.js";import"../../data/customer/attribute/index.js";import"../../data/customer/review/summary/index.js";import"../../data/customer/review/index.js";import"../../data/customer/index.js";import"../../data/district/index.js";import"../../data/favorite-product/index.js";import{IkasFilterCategory as d}from"../../data/filter-category/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/order/address/index.js";import"../../data/order/line-item/option/value/index.js";import"../../data/order/line-item/variant/value/index.js";import"../../data/order/line-item/variant/index.js";import"../../data/order/line-item/index.js";import"../../data/order/package/index.js";import"../../data/order/transaction/index.js";import"../../data/order/index.js";import"../../data/payment-gateway/index.js";import"../../data/product/attribute-value/index.js";import{IkasProductFilter as c,IkasProductFilterValue as u}from"../../data/product/filter/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/stock-location/index.js";import"../../data/product/variant/price/index.js";import"../../data/product/variant/index.js";import"../../data/variant-type/index.js";import{IkasProduct as l}from"../../data/product/index.js";import"../../data/raffle/index.js";import"../../data/state/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/component/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";import p from"../../../store/product/index.js";import h from"query-string";import{SortByDirectionEnum as f,SortByTypeEnum as m,GetSuggestedProductsMethodEnum as g}from"@ikas/storefront-api";import{IkasStorefrontConfig as v}from"@ikas/storefront-config";import{Analytics as _}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import"../../../components/page/index.js";import"../../../components/page/head.js";import"react";import"next/image.js";import"@ikas/storefront-model-functions";import"../../../components/link/index.js";import"../../../components/page-editor/loader/style.module.scss.js";import"../../../components/google-captcha/index.js";import"../blog-list/index.js";import"../blog-category-list/index.js";import"../brand-list/index.js";import"../category-list/index.js";import"../product-attribute-detail/index.js";import"../product-attribute-list/index.js";import"../customer-review-list/index.js";import"../customer-review-summary-list/index.js";import"../validator/index.js";import"../validator/rules/index.js";import"../validator/form/login.js";import"../validator/form/address.js";import"../validator/form/ikas-address.js";import"../validator/form/register.js";import"../validator/form/contact-form.js";import"../validator/form/forgot-password.js";import"../validator/form/recover-password.js";import"../validator/form/account-info.js";import"../validator/form/raffle-form.js";import"../validator/form/customer-review.js";import"../raffle-list/index.js";import"../../../pages/home.js";import"../../../pages/_slug_/index.js";import"../../../pages/pages/_slug_.js";import"../../../pages/checkout.js";import"../../../pages/account/index.js";import"../../../pages/account/addresses.js";import"../../../pages/account/orders/index.js";import"../../../pages/account/orders/_id_.js";import"../../../pages/account/login.js";import"../../../pages/account/register.js";import"../../../pages/account/forgot-password.js";import"../../../pages/account/recover-password.js";import"../../../pages/cart.js";import"../../../pages/editor.js";import"../../../pages/account/favorite-products.js";import"../../../pages/search.js";import"next/error.js";import"../../../pages/blog/index.js";import"../../../pages/blog/_slug_.js";import"../../../pages/raffle/_slug_.js";import"../../../pages/raffle/index.js";import"../../../pages/account/raffles.js";import"../../../pages/account/activate.js";import{IkasBaseStore as y}from"../../../store/base.js";import"../../../store/customer/index.js";import"../../../store/cart/index.js";import"lodash/get";var I,E,S,P,C=function(){function I(o,n){var u=this;this.filters=null,this._filterCategories=null,this._infiniteScrollPage=null,this._initialized=!1,this._minPage=null,this._filterBrandId=null,this._filterCategoryId=null,this._relatedProductData=null,this._viewedTogetherProductData=null,this.pageSpecificData=null,this._recommendFor=null,this._isLoading=!1,this._fetchRequestTime=0,this.router=null,this.applyFilters=function(){return t(u,void 0,void 0,(function(){var t;return e(this,(function(e){switch(e.label){case 0:return[4,this.getInitial()];case 1:return t=e.sent(),[a.CATEGORY,a.BRAND,a.SEARCH].includes(this._pageType)?(t&&this.setQueryParams(),[2]):[2]}}))}))},this.getInitial=function(r,s){return t(u,void 0,void 0,(function(){var t,o,a,n,d,c,u,p,h,f,m,g,v,_,I;return e(this,(function(e){switch(e.label){case 0:this._isLoading=!0,t=Date.now(),this._fetchRequestTime=t,e.label=1;case 1:return e.trys.push([1,14,15,16]),o=s?this._page:1,a=this._limit,!this.isFilterable||this.filters?[3,3]:[4,this.getFilters()];case 2:e.sent(),e.label=3;case 3:return this.applyQueryParamFilters(r),this.isSearch&&!this.hasAppliedfilter?(this.data=[],this._page=1,this._minPage=1,this._count=0,this._initialized=!0,[2,!0]):(n=void 0,d=!1,this.isStatic?(o=void 0,a=200,[3,10]):[3,4]);case 4:return this.isDiscounted?(o=1,a=10,[3,10]):[3,5];case 5:return this.isRecommended?(o=1,a=10,[3,10]):[3,6];case 6:return this.isLastViewed?this.isBrowser()?[4,this.waitForCustomerStoreInit()]:[3,9]:[3,10];case 7:return e.sent(),[4,y.getInstance().customerStore.getLastViewedProducts()];case 8:return(c=e.sent())&&c.length?(n=c.map((function(t){return t.productId})),d=y.getInstance().customerStore.useLastViewedProductResponse,[3,10]):[2];case 9:return[2];case 10:return d?(p=y.getInstance().customerStore._savedLastViewedProductsResponse,[3,13]):[3,11];case 11:return[4,this.searchProducts(o||1,a||10,n)];case 12:p=e.sent(),e.label=13;case 13:return(u=p)&&this._fetchRequestTime===t?(h=[],!d&&this.isLastViewed&&y.getInstance().customerStore.setSavedLastViewedProductsResponse(u),this.isStatic||this.isLastViewed?(f=this.isStatic?this._productListPropValue.productIds:y.getInstance().customerStore._lastViewedProducts,h=(null==f?void 0:f.map((function(t){var e,r,s=null===(r=null===(e=u.data)||void 0===e?void 0:e.data)||void 0===r?void 0:r.find((function(e){return e.id===t.productId})),o=null==s?void 0:s.variants.find((function(e){return e.id===t.variantId}));if((null==o?void 0:o.isActive)||(o=null==s?void 0:s.variants.find((function(t){return t.isActive}))),s&&o)return new l(i(i({},s),{selectedVariantValues:o.variantValues}))})).filter((function(t){return!!t})))||[]):h=(null===(v=null===(g=u.data)||void 0===g?void 0:g.data)||void 0===v?void 0:v.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})))||[],this.applyFacets(null===(_=u.data)||void 0===_?void 0:_.facets),this.data=h,this._count=(null===(I=u.data)||void 0===I?void 0:I.count)||0,this._initialized=!0,this._page=o||1,this._minPage=this.page,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),s||(this._infiniteScrollPage=null),this.handleListingEvent(),[2,!0]):[2];case 14:return m=e.sent(),console.log(m),[3,16];case 15:return t===this._fetchRequestTime&&(this._isLoading=!1),[7];case 16:return[2]}}))}))},this.getPrev=function(){return t(u,void 0,void 0,(function(){var t,r,s,o,a,n,d;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.searchProducts(t,this.limit)];case 2:return(r=e.sent())?(s=null===(n=null===(a=r.data)||void 0===a?void 0:a.data)||void 0===n?void 0:n.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=(null==s?void 0:s.concat(this.data))||this.data,this._count=(null===(d=r.data)||void 0===d?void 0:d.count)||this._count,this._minPage=t,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),[3,5]):[2];case 3:return o=e.sent(),console.log(o),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(u,void 0,void 0,(function(){var t,r,s,o,a,n;return e(this,(function(e){switch(e.label){case 0:if(this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed||this._isLoading||!this.hasNext)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(this.page+1,this.limit)];case 2:return(t=e.sent())?(r=null===(a=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===a?void 0:a.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=this.data.concat(r||[]),this._count=(null===(n=t.data)||void 0===n?void 0:n.count)||this._count,this._page=this.page+1,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),[3,5]):[2];case 3:return s=e.sent(),console.log(s),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(r){return t(u,void 0,void 0,(function(){var t,s,o,a,n,d;return e(this,(function(e){switch(e.label){case 0:if(this._isLoading||this.isStatic||this.isDiscounted||this.isRecommended||this.isLastViewed)return[2];this._isLoading=!0,e.label=1;case 1:return e.trys.push([1,3,4,5]),[4,this.searchProducts(r,this.limit)];case 2:return(t=e.sent())?(s=null===(n=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===n?void 0:n.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new l(i(i({},t),{selectedVariantValues:(e||t.variants[0]).variantValues}))})),this.data=s||[],this._count=(null===(d=t.data)||void 0===d?void 0:d.count)||0,this._page=r,this._minPage=r,this.setIsFilteredForProducts(),this.setIsStaticForProducts(),[3,5]):[2];case 3:return o=e.sent(),console.log(o),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.setVisibleInfiniteScrollPage=function(t){var e;u._infiniteScrollPage!==t&&(u._infiniteScrollPage=t,v.getIsEditor()||null===(e=u.router)||void 0===e||e.replace("".concat(location.pathname).concat(u.queryParams?"?"+u.queryParams:""),void 0,{shallow:!0}))},this.searchDebouncer=s((function(){u.applyFilters()}),500),this.searchAnalyticsDebouncer=s((function(){_.search(u._searchKeyword)}),1e3);var p=o,h=o;if(this.data=o.data?o.data.map((function(t){return new l(t)})):[],this._type=p.type||h._type||p.productListPropValue.productListType||h._productListPropValue.productListType||E.ALL,this._pageType=o.pageType,this._sort=o.sort||o.productListPropValue.initialSort||S.LAST_ADDED,this._limit=o.limit||p.productListPropValue.initialLimit||h._productListPropValue.initialLimit||20,this._page=o.page||1,this._minPage=o.minPage||null,this._count=o.count||0,this._searchKeyword=o.searchKeyword||"",this._productListPropValue=p.productListPropValue||h._productListPropValue,this._filterBrandId=p.filterBrandId||h._filterBrandId||null,this._filterCategoryId=p.filterCategoryId||h._filterCategoryId||null,this._relatedProductData=p.relatedProductData||h._relatedProductData||null,this._viewedTogetherProductData=p.viewedTogetherProductData||h._viewedTogetherProductData||null,this._recommendFor=p.recommendFor||h._recommendFor,this.filters=o.filters?o.filters.map((function(t){return new c(t,u)})):null,this._filterCategories=o.filterCategories?o.filterCategories.map((function(t){return new d(t)})):null,this.pageSpecificData=p.pageSpecificData||h.pageSpecificData||null,this.router=n,r(this,{router:!1}),this.setPageSpecificSort(),this.setIsFilteredForProducts(),this.setIsStaticForProducts(),this.isBrowser())if(this.restoreInfiniteScrollPage(),location.search&&(this.isFilterable||this._type===E.SEARCH)){var f=this.getQueryParams();this.getInitial(f,this._page>1)}else this._page>1?this.getInitial(void 0,!0):this.isLastViewed?this.getInitial():this.handleListingEvent()}return Object.defineProperty(I.prototype,"sort",{get:function(){return this._sort},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"pageType",{get:function(){return this._pageType},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"minPage",{get:function(){return this._minPage||1},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"searchKeyword",{get:function(){return this._searchKeyword},set:function(t){t!==this._searchKeyword&&(this._searchKeyword=t,this.searchDebouncer(),this.searchAnalyticsDebouncer())},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isFilterable",{get:function(){return this._type===E.ALL||this._type===E.CATEGORY},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isFiltered",{get:function(){var t,e;return(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))||!!this._searchKeyword||this._pageType!==a.CATEGORY&&(!!this._filterCategoryId||(null===(e=this._filterCategories)||void 0===e?void 0:e.some((function(t){return t.isSelected}))))},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isStatic",{get:function(){return this._type===E.STATIC},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isDiscounted",{get:function(){return this._type===E.DISCOUNTED},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isRecommended",{get:function(){return this._type===E.RECOMMENDED},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isLastViewed",{get:function(){return this._type===E.LAST_VIEWED},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isRelatedProducts",{get:function(){return this._type===E.RELATED_PRODUCTS},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isViewedTogetherProducts",{get:function(){return this._type===E.VIEWED_TOGETHER},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isSearch",{get:function(){return this._type===E.SEARCH},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"hasPrev",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended||!this._minPage)&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"hasNext",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended)&&this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"queryParams",{get:function(){var t,e,i,r,s=this,o={};if(null===(t=this.filters)||void 0===t||t.forEach((function(t){t.keyList.length&&(o[t.key]=t.keyList)})),this._searchKeyword&&(o.s=this._searchKeyword),this._sort&&(o.o=b[this._sort]),this._infiniteScrollPage&&(o.page=this._infiniteScrollPage),this._pageType!==a.CATEGORY){var n=null===(e=this.filterCategories)||void 0===e?void 0:e.filter((function(t){return t.isSelected}));if(!!(null==n?void 0:n.length))o.c=null==n?void 0:n.map((function(t){return t.slug}));else if(this._filterCategoryId){var d=null===(r=null===(i=this.filterCategories)||void 0===i?void 0:i.find((function(t){return t.id===s._filterCategoryId})))||void 0===r?void 0:r.slug;d&&(o.c=d)}}return h.stringify(o,{arrayFormat:"comma"})},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"filterCategories",{get:function(){var t;return null===(t=this._filterCategories)||void 0===t?void 0:t.filter((function(t){return 0!==t.resultCount}))},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"hasAppliedfilter",{get:function(){var t;return!!this._searchKeyword||(null===(t=this.filters)||void 0===t?void 0:t.some((function(t){return!!t.valueList.length})))},enumerable:!1,configurable:!0}),Object.defineProperty(I.prototype,"isFeaturedSortEnabled",{get:function(){var t;return(null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)===o.MANUALLY&&[E.ALL,E.CATEGORY].includes(this._type)},enumerable:!1,configurable:!0}),I.prototype.setIsFilteredForProducts=function(){var t=this;this.data.forEach((function(e){return e.isFiltered=t.isFiltered||!1}))},I.prototype.setIsStaticForProducts=function(){var t=this;this.data.forEach((function(e){return e.isStatic=t.isStatic||!1}))},I.prototype.setPageSpecificSort=function(){var t;if((null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)&&[E.ALL].includes(this._type))switch(this.pageSpecificData.orderType){case o.HIGHEST_DISCOUNT_RATIO:this._sort=S.DECRASING_DISCOUNT;break;case o.LOWEST_DISCOUNT_RATIO:this._sort=S.INCREASING_DISCOUNT;break;case o.HIGHEST_PRICE:this._sort=S.DECREASING_PRICE;break;case o.LOWEST_PRICE:this._sort=S.INCREASING_PRICE;break;case o.NEWEST:this._sort=S.LAST_ADDED;break;case o.OLDEST:this._sort=S.FIRST_ADDED;break;case o.MANUALLY:this._sort=S.FEATURED}},I.prototype.getSortParams=function(){var t,e;switch(this._sort){case S.INCREASING_PRICE:t=f.ASC,e=m.PRICE;break;case S.DECREASING_PRICE:t=f.DESC,e=m.PRICE;break;case S.FIRST_ADDED:t=f.ASC,e=m.CREATED_AT;break;case S.LAST_ADDED:t=f.DESC,e=m.CREATED_AT;break;case S.INCREASING_DISCOUNT:t=f.ASC,e=m.DISCOUNT_RATIO;break;case S.DECRASING_DISCOUNT:t=f.DESC,e=m.DISCOUNT_RATIO;break;case S.FEATURED:if(this.isSearch)return;t=f.ASC,e=m.MANUAL_SORT;break;case S.DEFAULT:t=void 0,e=void 0}if(t&&e)return{direction:t,type:e}},I.prototype.searchProducts=function(i,r,s){var o,d,c;return t(this,void 0,void 0,(function(){var t,l,h,f;return e(this,(function(e){switch(e.label){case 0:return t=[],l=[],null===(o=this.filters)||void 0===o||o.forEach((function(e){e.valueList.length&&t.push(new u({id:e.id,type:e.type,displayType:e.displayType,valueList:e.valueList})),e.isFacetFilter&&l.push({id:e.id,type:e.type,displayType:e.displayType})})),h=null===(d=this._filterCategories)||void 0===d?void 0:d.filter((function(t){return t.isSelected})).map((function(t){return t.id})),f=this.getSortParams(),this.isRelatedProducts&&this._relatedProductData?[4,p.getSuggestedProducts({priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId(),productId:this._relatedProductData.productId,brandIds:this._relatedProductData.brandIds,categoryIds:this._relatedProductData.categoryIds,locale:v.getCurrentLocale()})]:[3,2];case 1:case 3:case 5:return[2,e.sent()];case 2:return this.isViewedTogetherProducts&&this._viewedTogetherProductData?[4,p.getSuggestedProducts({priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId(),method:g.VIEWED_TOGETHER,productIds:this._viewedTogetherProductData.productIds,locale:v.getCurrentLocale()})]:[3,4];case 4:return[4,p.searchProducts({input:{page:i,perPage:r,productIdList:this.isStatic?null===(c=this._productListPropValue.productIds)||void 0===c?void 0:c.map((function(t){return t.productId})):s,filterList:t,facetList:l,brandId:this._pageType===a.BRAND&&this._type!==E.SEARCH?this._filterBrandId:void 0,categoryIdList:h&&h.length?h:this._filterCategoryId?[this._filterCategoryId]:void 0,priceListId:v.getPriceListId(),salesChannelId:v.getSalesChannelId(),query:this._searchKeyword,order:this._type===E.SEARCH?[]:f?[f]:[],showStockOption:v.getStockPreference()||n.SHOW_ALL}})]}}))}))},I.prototype.getFilters=function(){var i,r,s;return t(this,void 0,void 0,(function(){var t,o,n=this;return e(this,(function(e){switch(e.label){case 0:return[4,p.getProductFilterData({categoryId:this._filterCategoryId?this._filterCategoryId:void 0,locale:v.getCurrentLocale()})];case 1:return t=e.sent(),this.filters=null===(i=null==t?void 0:t.data)||void 0===i?void 0:i.filters.map((function(t){return new c(t,n)})),this._filterCategories=null===(r=null==t?void 0:t.data)||void 0===r?void 0:r.categories,this.pageType!==a.CATEGORY&&this._filterCategoryId&&(o=null===(s=this._filterCategories)||void 0===s?void 0:s.find((function(t){return t.id===n._filterCategoryId})))&&(o.isSelected=!0),this.filters&&this.filters.sort((function(t,e){return t.order>e.order?1:-1})),[2]}}))}))},I.prototype.applyQueryParamFilters=function(t){var e,i=this;try{null==t||t.forEach((function(t,e){var r,s=null===(r=i.filters)||void 0===r?void 0:r.find((function(t){return t.key===e}));s&&s.applyQueryParam(t)}));var r=null==t?void 0:t.get("s");r&&(this._searchKeyword=r);var s=null==t?void 0:t.get("o");if(s){var o=parseInt(s),n=Object.entries(b).find((function(t){return t[1]===o}));n&&(this._sort=n[0])}if(this._pageType!==a.CATEGORY){var d=null==t?void 0:t.get("c"),c=null==d?void 0:d.split(",");c&&c.length&&(null===(e=this.filterCategories)||void 0===e||e.forEach((function(t){t.isSelected=c.some((function(e){return e===t.slug}))})))}}catch(t){console.log(t)}},I.prototype.applyFacets=function(t){var e,i;null===(e=this.filters)||void 0===e||e.forEach((function(e){var i,r,s,o=null==t?void 0:t.find((function(t){return t.id===e.id}));o?null===(i=e.values)||void 0===i||i.forEach((function(t){var i=o.values.find((function(e){return e.id===t.id}));i?t.resultCount=i.count:e.isCustomValueFilter?t.resultCount=null:t.resultCount=0})):e.isCustomValueFilter?null===(r=e.values)||void 0===r||r.forEach((function(t){return t.resultCount=null})):null===(s=e.values)||void 0===s||s.forEach((function(t){return t.resultCount=0}))}));var r=null==t?void 0:t.find((function(t){return"category"===t.id}));r&&(null===(i=this._filterCategories)||void 0===i||i.forEach((function(t){var e=r.values.find((function(e){return e.id===t.id}));t.resultCount=e?e.count:0})))},I.prototype.setQueryParams=function(){var t;!this.isBrowser()||this.isSearch||v.getIsEditor()||null===(t=this.router)||void 0===t||t.replace("".concat(location.pathname).concat(this.queryParams?"?"+this.queryParams:""),void 0,{shallow:!0})},I.prototype.clearFilters=function(){var t,e;null===(t=this.filters)||void 0===t||t.forEach((function(t){return t.clear()})),this._searchKeyword="",this._pageType!==a.CATEGORY&&(this._filterCategoryId=void 0),null===(e=this._filterCategories)||void 0===e||e.forEach((function(t){return t.isSelected=!1})),this.applyFilters()},I.prototype.setSortType=function(i){return t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return this._sort=i,[4,this.getInitial()];case 1:return t.sent()&&this.setQueryParams(),[2]}}))}))},I.prototype.onFilterCategoryClick=function(i,r){var s,o;return void 0===r&&(r=!1),t(this,void 0,void 0,(function(){return e(this,(function(t){switch(t.label){case 0:return r?(null===(s=this._filterCategories)||void 0===s||s.forEach((function(t){t.id===i.id&&(t.isSelected=!t.isSelected)})),[4,this.applyFilters()]):[3,2];case 1:return t.sent(),[3,3];case 2:v.getIsEditor()||null===(o=y.getInstance().router)||void 0===o||o.push(i.href+(this.queryParams?"?"+this.queryParams:"")),t.label=3;case 3:return[2]}}))}))},I.prototype.toJSON=function(){return{data:this.data,type:this._type,pageType:this._pageType,sort:this._sort,limit:this._limit,page:this._page,count:this._count,searchKeyword:this._searchKeyword,initialized:this._initialized,minPage:this._minPage,filterBrandId:this._filterBrandId,filterCategoryId:this._filterCategoryId,filterCategories:this._filterCategories,filters:this.filters,recommendFor:this._recommendFor,productListPropValue:this._productListPropValue,pageSpecificData:this.pageSpecificData}},I.prototype.restoreInfiniteScrollPage=function(){var t=this.getQueryParams(),e=null==t?void 0:t.get("page");if(e){var i=parseInt(e);isNaN(i)||(this._page=i,this._infiniteScrollPage=i)}},I.prototype.getQueryParams=function(){if(this.isBrowser())return new URLSearchParams(location.search)},I.prototype.isBrowser=function(){return"undefined"!=typeof window},I.prototype.waitForCustomerStoreInit=function(){return new Promise((function(t){var e=setInterval((function(){y.getInstance().customerStore.initialized&&(clearInterval(e),t(null))}),1e3)}))},I.prototype.handleListingEvent=function(){this.searchKeyword&&this.data.length?_.viewSearchResults(this._searchKeyword,this.data):this.data.length&&this._type===E.ALL&&_.viewListing(this.data)},I}();!function(t){t.ALL="ALL",t.STATIC="STATIC",t.DISCOUNTED="DISCOUNTED",t.RECOMMENDED="RECOMMENDED",t.CATEGORY="CATEGORY",t.SEARCH="SEARCH",t.LAST_VIEWED="LAST_VIEWED",t.RELATED_PRODUCTS="RELATED_PRODUCTS",t.VIEWED_TOGETHER="VIEWED_TOGETHER"}(E||(E={})),function(t){t.INCREASING_PRICE="INCREASING_PRICE",t.DECREASING_PRICE="DECREASING_PRICE",t.LAST_ADDED="LAST_ADDED",t.FIRST_ADDED="FIRST_ADDED",t.INCREASING_DISCOUNT="INCREASING_DISCOUNT",t.DECRASING_DISCOUNT="DECRASING_DISCOUNT",t.FEATURED="FEATURED",t.DEFAULT="DEFAULT"}(S||(S={})),function(t){t.CATEGORY="CATEGORY",t.BRAND="BRAND"}(P||(P={}));var b=((I={})[S.INCREASING_PRICE]=1,I[S.DECREASING_PRICE]=2,I[S.LAST_ADDED]=3,I[S.FIRST_ADDED]=4,I[S.INCREASING_DISCOUNT]=5,I[S.DECRASING_DISCOUNT]=6,I[S.FEATURED]=7,I[S.DEFAULT]=8,I);export{C as IkasProductList,S as IkasProductListSortType,E as IkasProductListType,P as IkasRelatedProductsType};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as i}from'./../../../ext/tslib/tslib.es6.js';import{populateRaffleProducts as e}from"@ikas/storefront-providers";import{makeAutoObservable as a,runInAction as n}from"mobx";import r from"../../../store/raffle/index.js";import"../../data/blog/category/index.js";import"../../data/blog/content/index.js";import"../../data/blog/meta-data/index.js";import"../../data/blog/tag/index.js";import"../../data/blog/index.js";import"../../data/brand/index.js";import"@ikas/storefront-models";import"../../data/campaign-offer/index.js";import"../../data/cart/campaign-offer/index.js";import"../../data/cart/index.js";import"../../data/category/path-item/index.js";import"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/checkout-settings/index.js";import"../../data/city/index.js";import"../../data/country/index.js";import"../../data/customer/address/index.js";import"../../data/customer/address/ikas-localized-customer-address.js";import"../../data/customer/attribute/index.js";import"../../data/customer/review/summary/index.js";import"../../data/customer/review/index.js";import"../../data/customer/index.js";import"../../data/district/index.js";import"../../data/favorite-product/index.js";import"../../data/filter-category/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/order/address/index.js";import"../../data/order/line-item/option/value/index.js";import"../../data/order/line-item/variant/value/index.js";import"../../data/order/line-item/variant/index.js";import"../../data/order/line-item/index.js";import"../../data/order/package/index.js";import"../../data/order/transaction/index.js";import"../../data/order/index.js";import"../../data/payment-gateway/index.js";import"../../data/product/attribute-value/index.js";import"../../data/product/filter/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/stock-location/index.js";import"../../data/product/variant/price/index.js";import"../../data/product/variant/index.js";import"../../data/variant-type/index.js";import"../../data/product/index.js";import{IkasRaffle as o}from"../../data/raffle/index.js";import"../../data/state/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var s=function(){function s(e){void 0===e&&(e={});var r=this;this._initialized=!1,this._minPage=null,this._isLoading=!1,this.getPrev=function(){return t(r,void 0,void 0,(function(){var t,e,a,n,r,o;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.getRaffleList(t,this.limit)];case 2:return e=i.sent(),this.data=(null===(r=null===(n=e.data)||void 0===n?void 0:n.data)||void 0===r?void 0:r.concat(this.data))||this.data,this._count=(null===(o=e.data)||void 0===o?void 0:o.count)||this._count,this._minPage=t,[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(r,void 0,void 0,(function(){var t,e,a,n;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasNext)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.getRaffleList(this.page+1,this.limit)];case 2:return t=i.sent(),this.data=this.data.concat((null===(a=t.data)||void 0===a?void 0:a.data)||[]),this._count=(null===(n=t.data)||void 0===n?void 0:n.count)||this._count,this._page=this.page+1,[3,5];case 3:return e=i.sent(),console.log(e),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(e){return t(r,void 0,void 0,(function(){var t,a,r=this;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.getRaffleList(e,this.limit)];case 2:return t=i.sent(),n((function(){var i,a;r.data=(null===(i=t.data)||void 0===i?void 0:i.data)||[],r._count=(null===(a=t.data)||void 0===a?void 0:a.count)||0,r._page=e,r._minPage=e})),[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.data=e.data?e.data.map((function(t){return new o(t)})):[],this._limit=e.limit||20,this._page=e.page||1,this._count=e.count||0,this._initialized=e.initialized||!1,this._minPage=e.minPage||null,this._start=e.start||null,this._end=e.end||null,this._includeDeleted=e.includeDeleted||null,this._name=e.name||null,this._search=e.search||null,this._id=e.id||null,a(this)}return Object.defineProperty(s.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"hasPrev",{get:function(){return!!this._minPage&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"hasNext",{get:function(){return this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"minPage",{get:function(){return this._minPage||1},enumerable:!1,configurable:!0}),s.prototype.getRaffleList=function(a,n){var o;return t(this,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,r.listStorefrontRaffle({start:this._start?{eq:this._start}:void 0,end:this._end?{eq:this._end}:void 0,includeDeleted:this._includeDeleted||!1,name:this._name?{eq:this._name}:void 0,id:this._id?{eq:this._id}:void 0,search:this._search||void 0,pagination:{limit:n,page:a}})];case 1:return t=i.sent(),[4,e((null===(o=t.data)||void 0===o?void 0:o.data)||[])];case 2:return i.sent(),[2,t]}}))}))},s.prototype.toJSON=function(){return{data:this.data,limit:this._limit,page:this._page,count:this._count,initialized:this._initialized,minPage:this._minPage}},s}();export{s as IkasRaffleList};
|
|
1
|
+
import{__awaiter as t,__generator as i}from'./../../../ext/tslib/tslib.es6.js';import{populateRaffleProducts as e}from"@ikas/storefront-providers";import{makeAutoObservable as a,runInAction as n}from"mobx";import r from"../../../store/raffle/index.js";import"../../data/blog/category/index.js";import"../../data/blog/content/index.js";import"../../data/blog/meta-data/index.js";import"../../data/blog/tag/index.js";import"../../data/blog/index.js";import"../../data/brand/index.js";import"@ikas/storefront-models";import"../../data/campaign-offer/index.js";import"../../data/cart/campaign-offer/index.js";import"../../data/cart/index.js";import"../../data/category/path-item/index.js";import"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/checkout-settings/index.js";import"../../data/city/index.js";import"../../data/country/index.js";import"../../data/customer/address/index.js";import"../../data/customer/address/ikas-localized-customer-address.js";import"../../data/customer/attribute/index.js";import"../../data/customer/review/summary/index.js";import"../../data/customer/review/index.js";import"../../data/customer/index.js";import"../../data/district/index.js";import"../../data/favorite-product/index.js";import"../../data/filter-category/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/order/address/index.js";import"../../data/order/line-item/option/value/index.js";import"../../data/order/line-item/variant/value/index.js";import"../../data/order/line-item/variant/index.js";import"../../data/order/line-item/index.js";import"../../data/order/package/index.js";import"../../data/order/transaction/index.js";import"../../data/order/index.js";import"../../data/payment-gateway/index.js";import"../../data/product/attribute-value/index.js";import"../../data/product/filter/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/stock-location/index.js";import"../../data/product/variant/price/index.js";import"../../data/product/variant/index.js";import"../../data/variant-type/index.js";import"../../data/product/index.js";import{IkasRaffle as o}from"../../data/raffle/index.js";import"../../data/state/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/component/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var s=function(){function s(e){void 0===e&&(e={});var r=this;this._initialized=!1,this._minPage=null,this._isLoading=!1,this.getPrev=function(){return t(r,void 0,void 0,(function(){var t,e,a,n,r,o;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.getRaffleList(t,this.limit)];case 2:return e=i.sent(),this.data=(null===(r=null===(n=e.data)||void 0===n?void 0:n.data)||void 0===r?void 0:r.concat(this.data))||this.data,this._count=(null===(o=e.data)||void 0===o?void 0:o.count)||this._count,this._minPage=t,[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(r,void 0,void 0,(function(){var t,e,a,n;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasNext)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.getRaffleList(this.page+1,this.limit)];case 2:return t=i.sent(),this.data=this.data.concat((null===(a=t.data)||void 0===a?void 0:a.data)||[]),this._count=(null===(n=t.data)||void 0===n?void 0:n.count)||this._count,this._page=this.page+1,[3,5];case 3:return e=i.sent(),console.log(e),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(e){return t(r,void 0,void 0,(function(){var t,a,r=this;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.getRaffleList(e,this.limit)];case 2:return t=i.sent(),n((function(){var i,a;r.data=(null===(i=t.data)||void 0===i?void 0:i.data)||[],r._count=(null===(a=t.data)||void 0===a?void 0:a.count)||0,r._page=e,r._minPage=e})),[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.data=e.data?e.data.map((function(t){return new o(t)})):[],this._limit=e.limit||20,this._page=e.page||1,this._count=e.count||0,this._initialized=e.initialized||!1,this._minPage=e.minPage||null,this._start=e.start||null,this._end=e.end||null,this._includeDeleted=e.includeDeleted||null,this._name=e.name||null,this._search=e.search||null,this._id=e.id||null,a(this)}return Object.defineProperty(s.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"hasPrev",{get:function(){return!!this._minPage&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"hasNext",{get:function(){return this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"minPage",{get:function(){return this._minPage||1},enumerable:!1,configurable:!0}),s.prototype.getRaffleList=function(a,n){var o;return t(this,void 0,void 0,(function(){var t;return i(this,(function(i){switch(i.label){case 0:return[4,r.listStorefrontRaffle({start:this._start?{eq:this._start}:void 0,end:this._end?{eq:this._end}:void 0,includeDeleted:this._includeDeleted||!1,name:this._name?{eq:this._name}:void 0,id:this._id?{eq:this._id}:void 0,search:this._search||void 0,pagination:{limit:n,page:a}})];case 1:return t=i.sent(),[4,e((null===(o=t.data)||void 0===o?void 0:o.data)||[])];case 2:return i.sent(),[2,t]}}))}))},s.prototype.toJSON=function(){return{data:this.data,limit:this._limit,page:this._page,count:this._count,initialized:this._initialized,minPage:this._minPage}},s}();export{s as IkasRaffleList};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__spreadArray as r}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as a,computed as i,action as o}from"mobx";import{Validator as s}from"../index.js";import{IkasBaseStore as n}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{PhoneRule as d,RequiredRule as m}from"../rules/index.js";import"../../../data/blog/category/index.js";import"../../../data/blog/content/index.js";import"../../../data/blog/meta-data/index.js";import"../../../data/blog/tag/index.js";import"../../../data/blog/index.js";import"../../../data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as u}from"@ikas/storefront-models";import"../../../data/campaign-offer/index.js";import"../../../data/cart/campaign-offer/index.js";import"../../../data/cart/index.js";import"../../../data/category/path-item/index.js";import"../../../data/category/index.js";import"../../../data/checkout/index.js";import"../../../data/checkout-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import"../../../data/customer/address/index.js";import"../../../data/customer/address/ikas-localized-customer-address.js";import"../../../data/customer/attribute/index.js";import"../../../data/customer/review/summary/index.js";import"../../../data/customer/review/index.js";import"../../../data/customer/index.js";import"../../../data/district/index.js";import"../../../data/favorite-product/index.js";import"../../../data/filter-category/index.js";import"../../../data/html-meta-data/index.js";import"../../../data/image/index.js";import"../../../data/order/address/index.js";import"../../../data/order/line-item/option/value/index.js";import"../../../data/order/line-item/variant/value/index.js";import"../../../data/order/line-item/variant/index.js";import"../../../data/order/line-item/index.js";import"../../../data/order/package/index.js";import"../../../data/order/transaction/index.js";import"../../../data/order/index.js";import"../../../data/payment-gateway/index.js";import"../../../data/product/attribute-value/index.js";import"../../../data/product/filter/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/stock-location/index.js";import"../../../data/product/variant/price/index.js";import"../../../data/product/variant/index.js";import"../../../data/variant-type/index.js";import"../../../data/product/index.js";import"../../../data/raffle/index.js";import"../../../data/state/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var p=function(){function p(e){var t=this;this.validatorRules=function(e){return void 0===e&&(e=!1),r([new m({model:t.customer,fieldKey:"firstName",valuePath:"firstName",message:t.message.requiredRule}),new m({model:t.customer,fieldKey:"lastName",valuePath:"lastName",message:t.message.requiredRule})],e?[new d({model:t.customer,fieldKey:"phone",valuePath:"phone",message:t.message.phoneRule})]:[],!0)},this.onFirstNameChange=function(e){t.customer.firstName=e},this.onLastNameChange=function(e){t.customer.lastName=e},this.onPhoneChange=function(e){t.customer.phone=e||null,e||t.validator.setRules(t.validatorRules())},a(this,{firstNameErrorMessage:i,lastNameErrorMessage:i,phoneErrorMessage:i,isMarketingAccepted:i,hasError:i,firstName:i,lastName:i,phone:i,validateAll:o,submit:o}),this.customer=e.customer,this.message=e.message,this.validator=new s(this.customer,this.validatorRules())}return Object.defineProperty(p.prototype,"hasError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"email",{get:function(){return this.customer.email},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"firstName",{get:function(){return this.customer.firstName},set:function(e){this.customer.firstName=e},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"lastName",{get:function(){return this.customer.lastName||""},set:function(e){this.customer.lastName=e},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"phone",{get:function(){return this.customer.phone||""},set:function(e){this.customer.phone=e},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isMarketingAccepted",{get:function(){return this.customer.isSubscribed},set:function(e){this.customer.subscriptionStatus=e?u.SUBSCRIBED:u.NOT_SUBSCRIBED},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"firstNameErrorMessage",{get:function(){var e,t;return null===(t=null===(e=this.validator.results)||void 0===e?void 0:e.firstName)||void 0===t?void 0:t.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"lastNameErrorMessage",{get:function(){var e,t;return null===(t=null===(e=this.validator.results)||void 0===e?void 0:e.lastName)||void 0===t?void 0:t.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"phoneErrorMessage",{get:function(){var e,t;return null===(t=null===(e=this.validator.results)||void 0===e?void 0:e.phone)||void 0===t?void 0:t.errorMessage},enumerable:!1,configurable:!0}),p.prototype.validateAll=function(){return this.validator.validateAll()},p.prototype.submit=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e={isFormError:!1,isSuccess:!1},this.phone&&this.validator.setRules(this.validatorRules(!0)),[4,this.validateAll()];case 1:if(t.sent())return e.isFormError=!0,[2,e];t.label=2;case 2:return t.trys.push([2,4,,5]),[4,n.getInstance().customerStore.saveCustomer(this.customer)];case 3:return t.sent()&&(e.isSuccess=!0),[2,e];case 4:return t.sent(),[2,e];case 5:return[2]}}))}))},p}();export{p as AccountInfoForm};
|
|
1
|
+
import{__awaiter as e,__generator as t,__spreadArray as r}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as a,computed as i,action as o}from"mobx";import{Validator as s}from"../index.js";import{IkasBaseStore as n}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{PhoneRule as d,RequiredRule as m}from"../rules/index.js";import"../../../data/blog/category/index.js";import"../../../data/blog/content/index.js";import"../../../data/blog/meta-data/index.js";import"../../../data/blog/tag/index.js";import"../../../data/blog/index.js";import"../../../data/brand/index.js";import{IkasCustomerEmailSubscriptionStatus as u}from"@ikas/storefront-models";import"../../../data/campaign-offer/index.js";import"../../../data/cart/campaign-offer/index.js";import"../../../data/cart/index.js";import"../../../data/category/path-item/index.js";import"../../../data/category/index.js";import"../../../data/checkout/index.js";import"../../../data/checkout-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import"../../../data/customer/address/index.js";import"../../../data/customer/address/ikas-localized-customer-address.js";import"../../../data/customer/attribute/index.js";import"../../../data/customer/review/summary/index.js";import"../../../data/customer/review/index.js";import"../../../data/customer/index.js";import"../../../data/district/index.js";import"../../../data/favorite-product/index.js";import"../../../data/filter-category/index.js";import"../../../data/html-meta-data/index.js";import"../../../data/image/index.js";import"../../../data/order/address/index.js";import"../../../data/order/line-item/option/value/index.js";import"../../../data/order/line-item/variant/value/index.js";import"../../../data/order/line-item/variant/index.js";import"../../../data/order/line-item/index.js";import"../../../data/order/package/index.js";import"../../../data/order/transaction/index.js";import"../../../data/order/index.js";import"../../../data/payment-gateway/index.js";import"../../../data/product/attribute-value/index.js";import"../../../data/product/filter/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/stock-location/index.js";import"../../../data/product/variant/price/index.js";import"../../../data/product/variant/index.js";import"../../../data/variant-type/index.js";import"../../../data/product/index.js";import"../../../data/raffle/index.js";import"../../../data/state/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/component/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var p=function(){function p(e){var t=this;this.validatorRules=function(e){return void 0===e&&(e=!1),r([new m({model:t.customer,fieldKey:"firstName",valuePath:"firstName",message:t.message.requiredRule}),new m({model:t.customer,fieldKey:"lastName",valuePath:"lastName",message:t.message.requiredRule})],e?[new d({model:t.customer,fieldKey:"phone",valuePath:"phone",message:t.message.phoneRule})]:[],!0)},this.onFirstNameChange=function(e){t.customer.firstName=e},this.onLastNameChange=function(e){t.customer.lastName=e},this.onPhoneChange=function(e){t.customer.phone=e||null,e||t.validator.setRules(t.validatorRules())},a(this,{firstNameErrorMessage:i,lastNameErrorMessage:i,phoneErrorMessage:i,isMarketingAccepted:i,hasError:i,firstName:i,lastName:i,phone:i,validateAll:o,submit:o}),this.customer=e.customer,this.message=e.message,this.validator=new s(this.customer,this.validatorRules())}return Object.defineProperty(p.prototype,"hasError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"email",{get:function(){return this.customer.email},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"firstName",{get:function(){return this.customer.firstName},set:function(e){this.customer.firstName=e},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"lastName",{get:function(){return this.customer.lastName||""},set:function(e){this.customer.lastName=e},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"phone",{get:function(){return this.customer.phone||""},set:function(e){this.customer.phone=e},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"isMarketingAccepted",{get:function(){return this.customer.isSubscribed},set:function(e){this.customer.subscriptionStatus=e?u.SUBSCRIBED:u.NOT_SUBSCRIBED},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"firstNameErrorMessage",{get:function(){var e,t;return null===(t=null===(e=this.validator.results)||void 0===e?void 0:e.firstName)||void 0===t?void 0:t.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"lastNameErrorMessage",{get:function(){var e,t;return null===(t=null===(e=this.validator.results)||void 0===e?void 0:e.lastName)||void 0===t?void 0:t.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"phoneErrorMessage",{get:function(){var e,t;return null===(t=null===(e=this.validator.results)||void 0===e?void 0:e.phone)||void 0===t?void 0:t.errorMessage},enumerable:!1,configurable:!0}),p.prototype.validateAll=function(){return this.validator.validateAll()},p.prototype.submit=function(){return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return e={isFormError:!1,isSuccess:!1},this.phone&&this.validator.setRules(this.validatorRules(!0)),[4,this.validateAll()];case 1:if(t.sent())return e.isFormError=!0,[2,e];t.label=2;case 2:return t.trys.push([2,4,,5]),[4,n.getInstance().customerStore.saveCustomer(this.customer)];case 3:return t.sent()&&(e.isSuccess=!0),[2,e];case 4:return t.sent(),[2,e];case 5:return[2]}}))}))},p}();export{p as AccountInfoForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__spreadArray as t,__awaiter as e,__generator as i}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as s,computed as r,observable as n,action as d}from"mobx";import a from"lodash/cloneDeep";import{Validator as o}from"../index.js";import{PhoneRule as u,RequiredRule as l}from"../rules/index.js";import{listCountry as c,listState as m,listCity as h,listDistrict as p}from"@ikas/storefront-api";import{IkasStorefrontConfig as f}from"@ikas/storefront-config";import{FREE_TEXT_CITY_COUNTRY_LIST as g}from"../../../../utils/constants.js";import{IkasBaseStore as v}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import"../../../data/blog/category/index.js";import"../../../data/blog/content/index.js";import"../../../data/blog/meta-data/index.js";import"../../../data/blog/tag/index.js";import"../../../data/blog/index.js";import"../../../data/brand/index.js";import"@ikas/storefront-models";import"../../../data/campaign-offer/index.js";import"../../../data/cart/campaign-offer/index.js";import"../../../data/cart/index.js";import"../../../data/category/path-item/index.js";import"../../../data/category/index.js";import"../../../data/checkout/index.js";import"../../../data/checkout-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import{IkasCustomerAddress as y}from"../../../data/customer/address/index.js";import"../../../data/customer/address/ikas-localized-customer-address.js";import"../../../data/customer/attribute/index.js";import"../../../data/customer/review/summary/index.js";import"../../../data/customer/review/index.js";import"../../../data/customer/index.js";import"../../../data/district/index.js";import"../../../data/favorite-product/index.js";import"../../../data/filter-category/index.js";import"../../../data/html-meta-data/index.js";import"../../../data/image/index.js";import"../../../data/order/address/index.js";import"../../../data/order/line-item/option/value/index.js";import"../../../data/order/line-item/variant/value/index.js";import"../../../data/order/line-item/variant/index.js";import"../../../data/order/line-item/index.js";import"../../../data/order/package/index.js";import"../../../data/order/transaction/index.js";import"../../../data/order/index.js";import"../../../data/payment-gateway/index.js";import"../../../data/product/attribute-value/index.js";import"../../../data/product/filter/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/stock-location/index.js";import"../../../data/product/variant/price/index.js";import"../../../data/product/variant/index.js";import"../../../data/variant-type/index.js";import"../../../data/product/index.js";import"../../../data/raffle/index.js";import"../../../data/state/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var b=function(t){return t.sort((function(t,e){return t.label.localeCompare(e.label)}))},j=function(t){return{label:t.name,value:t.id+""}},x=function(){function x(g){var b=this;this.countries=[],this.states=[],this.cities=[],this.districts=[],this._isCountriesPending=!0,this._isStatesPending=!1,this._isCitiesPending=!1,this._isDistrictsPending=!1,this.validatorRules=function(e){return void 0===e&&(e=!1),t([new l({model:b.address,fieldKey:"firstName",valuePath:"firstName",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"lastName",valuePath:"lastName",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"addressLine1",valuePath:"addressLine1",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"country",valuePath:"country",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"state",valuePath:"state",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"city",valuePath:"city",message:b.message.requiredRule}),new l({model:b.address,fieldKey:"title",valuePath:"title",message:b.message.requiredRule})],e?[new u({model:b.address,fieldKey:"phone",valuePath:"phone",message:b.message.phoneRule})]:[],!0)},this.onTitleChange=function(t){b.address.title=t},this.onFirstNameChange=function(t){b.address.firstName=t},this.onLastNameChange=function(t){b.address.lastName=t},this.onPhoneChange=function(t){b.address.phone=t,t||b.validator.setRules(b.validatorRules())},this.onAddressLine1Change=function(t){b.address.addressLine1=t},this.onAddressLine2Change=function(t){b.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){b.address.postalCode=t},this.onCountryChange=function(t){var e;if((null===(e=b.address.country)||void 0===e?void 0:e.id)!==t){var i=b.countries.find((function(e){return e.id===t}));b.address.country={id:(null==i?void 0:i.id)||null,name:(null==i?void 0:i.name)||"",code:(null==i?void 0:i.iso3)||null,iso2:(null==i?void 0:i.iso2)||null,iso3:(null==i?void 0:i.iso3)||null},b.address.state=null,b.address.city=null,b.address.district=null,b.states=[],b.cities=[],b.districts=[],b.listStates()}},this.onStateChange=function(t){var e;if((null===(e=b.address.state)||void 0===e?void 0:e.id)!==t){var i=b.states.find((function(e){return e.id===t}));b.address.state={id:i.id,name:null==i?void 0:i.name,code:null==i?void 0:i.stateCode},b.address.city=null,b.address.district=null,b.cities=[],b.districts=[],b.listCities()}},this.onCityChange=function(t){var e;if((null===(e=b.address.city)||void 0===e?void 0:e.id)!==t){var i=b.cities.find((function(e){return e.id===t}));b.address.city={id:i.id,name:i.name,code:null},b.address.district=null,b.districts=[],b.listDistricts()}},this.onCityInputChange=function(t){b.districts=[],b.address.city={id:null,name:t,code:null}},this.onDistrictChange=function(t){var e;if((null===(e=b.address.district)||void 0===e?void 0:e.id)!==t){var i=b.districts.find((function(e){return e.id===t}));b.address.district={id:i.id,name:i.name,code:null}}},this.onDistrictInputChange=function(t){b.address.district={id:null,name:t,code:null}},this.listCountries=function(){return e(b,void 0,void 0,(function(){var t,e,s,r;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),this._isCountriesPending=!0,[4,c({})];case 1:return t=i.sent(),e=f.getCurrentRouting(),s=t.data||[],(null===(r=null==e?void 0:e.countryCodes)||void 0===r?void 0:r.length)&&(s=s.filter((function(t){var i;return t.iso2&&(null===(i=e.countryCodes)||void 0===i?void 0:i.includes(t.iso2))}))),this.countries=s,1!==this.countries.length||this.address.country||this.onCountryChange(this.countries[0].id),this.countries=s,[3,4];case 2:return i.sent(),[3,4];case 3:return this._isCountriesPending=!1,[7];case 4:return[2]}}))}))},this.listStates=function(){return e(b,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.address.country)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,4,5]),this._isStatesPending=!0,[4,m({countryId:{eq:this.address.country.id}})];case 2:return t=i.sent(),this.states=t.data||[],this.hasState||this.onStateChange(this.states[0].id),[3,5];case 3:return i.sent(),[3,5];case 4:return this._isStatesPending=!1,[7];case 5:return[2]}}))}))},this.listCities=function(){return e(b,void 0,void 0,(function(){var t,e,s,r;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.address.state)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,4,5]),this._isCitiesPending=!0,[4,h({stateId:{eq:this.address.state.id},countryId:(null===(s=this.address.country)||void 0===s?void 0:s.id)?{eq:null===(r=this.address.country)||void 0===r?void 0:r.id}:void 0})];case 2:return t=i.sent(),this.cities=t.data||[],[3,5];case 3:return i.sent(),[3,5];case 4:return this._isCitiesPending=!1,[7];case 5:return[2]}}))}))},this.listDistricts=function(){return e(b,void 0,void 0,(function(){var t,e,s,r;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.address.city)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,4,5]),this._isDistrictsPending=!0,[4,p({cityId:{eq:this.address.city.id},stateId:(null===(s=this.address.state)||void 0===s?void 0:s.id)?{eq:null===(r=this.address.state)||void 0===r?void 0:r.id}:void 0})];case 2:return t=i.sent(),this.districts=t.data||[],[3,5];case 3:return i.sent(),[3,5];case 4:return this._isDistrictsPending=!1,[7];case 5:return[2]}}))}))},this.validateAll=function(){return b.validator.validateAll()},this.submit=function(){return e(b,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:return t={isFormError:!1,isSuccess:!1},this.address.phone&&this.validator.setRules(this.validatorRules(!0)),[4,this.validateAll()];case 1:if(i.sent())return t.isFormError=!0,[2,t];if(!(e=a(v.getInstance().customerStore.customer))||!this.address)return[2,t];(null==e?void 0:e.addresses)||(e.addresses=[]),this.isEdit?e.addresses[this.editingAddressIndex]=this.address:e.addresses.push(this.address),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,v.getInstance().customerStore.saveCustomer(e)];case 3:return i.sent()&&(t.isSuccess=!0),[2,t];case 4:return i.sent(),[2,t];case 5:return[2]}}))}))},s(this,{hasValidatorError:r,isEdit:r,results:r,editingAddressIndex:r,isFreeTextCity:r,isFreeTextDistrict:r,countries:n,states:n,cities:n,districts:n,_isCountriesPending:n,_isStatesPending:n,_isCitiesPending:n,_isDistrictsPending:n,isCountriesPending:r,isStatesPending:r,isCitiesPending:r,isDistrictsPending:r,onCountryChange:d,validateAll:d,submit:d}),this.address=g.address||new y({addressLine1:"",addressLine2:null,attributes:null,company:null,firstName:"",identityNumber:null,isDefault:null,lastName:"",phone:null,postalCode:null,taxNumber:null,taxOffice:null,title:"",country:null,state:null,city:null,district:null,id:"",createdAt:0,updatedAt:0}),this.message=g.message,this.validator=new o(this.address,this.validatorRules()),this.listCountries(),this.address.state&&this.listStates(),this.address.country&&this.listCities(),this.address.city&&this.listDistricts()}return Object.defineProperty(x.prototype,"isFreeTextCity",{get:function(){var t=this;return g.some((function(e){var i,s;return(null===(s=null===(i=t.address.country)||void 0===i?void 0:i.iso2)||void 0===s?void 0:s.toLowerCase())===e.toLowerCase()}))},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isFreeTextDistrict",{get:function(){return!this.districtOptions.length},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isEdit",{get:function(){return-1!==this.editingAddressIndex},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"editingAddressIndex",{get:function(){var t,e,i,s=this;return null!==(i=null===(e=null===(t=v.getInstance().customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.findIndex((function(t){return t.id===s.address.id})))&&void 0!==i?i:-1},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"countryOptions",{get:function(){var t=this.countries.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"stateOptions",{get:function(){var t=this.states.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"cityOptions",{get:function(){var t=this.cities.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"districtOptions",{get:function(){var t=this.districts.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasState",{get:function(){return this.states.length>1},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCountriesPending",{get:function(){return this._isCountriesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isStatesPending",{get:function(){return this.isCountriesPending||this._isStatesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCitiesPending",{get:function(){return this.isStatesPending||this._isCitiesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isDistrictsPending",{get:function(){return this.isCitiesPending||this._isDistrictsPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasValidatorError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"results",{get:function(){return this.validator.results},enumerable:!1,configurable:!0}),x}();export{x as AddressForm};
|
|
1
|
+
import{__spreadArray as t,__awaiter as e,__generator as i}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as s,computed as r,observable as n,action as d}from"mobx";import a from"lodash/cloneDeep";import{Validator as o}from"../index.js";import{PhoneRule as u,RequiredRule as l}from"../rules/index.js";import{listCountry as c,listState as m,listCity as h,listDistrict as p}from"@ikas/storefront-api";import{IkasStorefrontConfig as f}from"@ikas/storefront-config";import{FREE_TEXT_CITY_COUNTRY_LIST as g}from"../../../../utils/constants.js";import{IkasBaseStore as v}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import"../../../data/blog/category/index.js";import"../../../data/blog/content/index.js";import"../../../data/blog/meta-data/index.js";import"../../../data/blog/tag/index.js";import"../../../data/blog/index.js";import"../../../data/brand/index.js";import"@ikas/storefront-models";import"../../../data/campaign-offer/index.js";import"../../../data/cart/campaign-offer/index.js";import"../../../data/cart/index.js";import"../../../data/category/path-item/index.js";import"../../../data/category/index.js";import"../../../data/checkout/index.js";import"../../../data/checkout-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import{IkasCustomerAddress as y}from"../../../data/customer/address/index.js";import"../../../data/customer/address/ikas-localized-customer-address.js";import"../../../data/customer/attribute/index.js";import"../../../data/customer/review/summary/index.js";import"../../../data/customer/review/index.js";import"../../../data/customer/index.js";import"../../../data/district/index.js";import"../../../data/favorite-product/index.js";import"../../../data/filter-category/index.js";import"../../../data/html-meta-data/index.js";import"../../../data/image/index.js";import"../../../data/order/address/index.js";import"../../../data/order/line-item/option/value/index.js";import"../../../data/order/line-item/variant/value/index.js";import"../../../data/order/line-item/variant/index.js";import"../../../data/order/line-item/index.js";import"../../../data/order/package/index.js";import"../../../data/order/transaction/index.js";import"../../../data/order/index.js";import"../../../data/payment-gateway/index.js";import"../../../data/product/attribute-value/index.js";import"../../../data/product/filter/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/stock-location/index.js";import"../../../data/product/variant/price/index.js";import"../../../data/product/variant/index.js";import"../../../data/variant-type/index.js";import"../../../data/product/index.js";import"../../../data/raffle/index.js";import"../../../data/state/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/component/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var j=function(t){return t.sort((function(t,e){return t.label.localeCompare(e.label)}))},b=function(t){return{label:t.name,value:t.id+""}},x=function(){function x(g){var j=this;this.countries=[],this.states=[],this.cities=[],this.districts=[],this._isCountriesPending=!0,this._isStatesPending=!1,this._isCitiesPending=!1,this._isDistrictsPending=!1,this.validatorRules=function(e){return void 0===e&&(e=!1),t([new l({model:j.address,fieldKey:"firstName",valuePath:"firstName",message:j.message.requiredRule}),new l({model:j.address,fieldKey:"lastName",valuePath:"lastName",message:j.message.requiredRule}),new l({model:j.address,fieldKey:"addressLine1",valuePath:"addressLine1",message:j.message.requiredRule}),new l({model:j.address,fieldKey:"country",valuePath:"country",message:j.message.requiredRule}),new l({model:j.address,fieldKey:"state",valuePath:"state",message:j.message.requiredRule}),new l({model:j.address,fieldKey:"city",valuePath:"city",message:j.message.requiredRule}),new l({model:j.address,fieldKey:"title",valuePath:"title",message:j.message.requiredRule})],e?[new u({model:j.address,fieldKey:"phone",valuePath:"phone",message:j.message.phoneRule})]:[],!0)},this.onTitleChange=function(t){j.address.title=t},this.onFirstNameChange=function(t){j.address.firstName=t},this.onLastNameChange=function(t){j.address.lastName=t},this.onPhoneChange=function(t){j.address.phone=t,t||j.validator.setRules(j.validatorRules())},this.onAddressLine1Change=function(t){j.address.addressLine1=t},this.onAddressLine2Change=function(t){j.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){j.address.postalCode=t},this.onCountryChange=function(t){var e;if((null===(e=j.address.country)||void 0===e?void 0:e.id)!==t){var i=j.countries.find((function(e){return e.id===t}));j.address.country={id:(null==i?void 0:i.id)||null,name:(null==i?void 0:i.name)||"",code:(null==i?void 0:i.iso3)||null,iso2:(null==i?void 0:i.iso2)||null,iso3:(null==i?void 0:i.iso3)||null},j.address.state=null,j.address.city=null,j.address.district=null,j.states=[],j.cities=[],j.districts=[],j.listStates()}},this.onStateChange=function(t){var e;if((null===(e=j.address.state)||void 0===e?void 0:e.id)!==t){var i=j.states.find((function(e){return e.id===t}));j.address.state={id:i.id,name:null==i?void 0:i.name,code:null==i?void 0:i.stateCode},j.address.city=null,j.address.district=null,j.cities=[],j.districts=[],j.listCities()}},this.onCityChange=function(t){var e;if((null===(e=j.address.city)||void 0===e?void 0:e.id)!==t){var i=j.cities.find((function(e){return e.id===t}));j.address.city={id:i.id,name:i.name,code:null},j.address.district=null,j.districts=[],j.listDistricts()}},this.onCityInputChange=function(t){j.districts=[],j.address.city={id:null,name:t,code:null}},this.onDistrictChange=function(t){var e;if((null===(e=j.address.district)||void 0===e?void 0:e.id)!==t){var i=j.districts.find((function(e){return e.id===t}));j.address.district={id:i.id,name:i.name,code:null}}},this.onDistrictInputChange=function(t){j.address.district={id:null,name:t,code:null}},this.listCountries=function(){return e(j,void 0,void 0,(function(){var t,e,s,r;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,3,4]),this._isCountriesPending=!0,[4,c({})];case 1:return t=i.sent(),e=f.getCurrentRouting(),s=t.data||[],(null===(r=null==e?void 0:e.countryCodes)||void 0===r?void 0:r.length)&&(s=s.filter((function(t){var i;return t.iso2&&(null===(i=e.countryCodes)||void 0===i?void 0:i.includes(t.iso2))}))),this.countries=s,1!==this.countries.length||this.address.country||this.onCountryChange(this.countries[0].id),this.countries=s,[3,4];case 2:return i.sent(),[3,4];case 3:return this._isCountriesPending=!1,[7];case 4:return[2]}}))}))},this.listStates=function(){return e(j,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.address.country)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,4,5]),this._isStatesPending=!0,[4,m({countryId:{eq:this.address.country.id}})];case 2:return t=i.sent(),this.states=t.data||[],this.hasState||this.onStateChange(this.states[0].id),[3,5];case 3:return i.sent(),[3,5];case 4:return this._isStatesPending=!1,[7];case 5:return[2]}}))}))},this.listCities=function(){return e(j,void 0,void 0,(function(){var t,e,s,r;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.address.state)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,4,5]),this._isCitiesPending=!0,[4,h({stateId:{eq:this.address.state.id},countryId:(null===(s=this.address.country)||void 0===s?void 0:s.id)?{eq:null===(r=this.address.country)||void 0===r?void 0:r.id}:void 0})];case 2:return t=i.sent(),this.cities=t.data||[],[3,5];case 3:return i.sent(),[3,5];case 4:return this._isCitiesPending=!1,[7];case 5:return[2]}}))}))},this.listDistricts=function(){return e(j,void 0,void 0,(function(){var t,e,s,r;return i(this,(function(i){switch(i.label){case 0:if(!(null===(e=this.address.city)||void 0===e?void 0:e.id))return[2];i.label=1;case 1:return i.trys.push([1,3,4,5]),this._isDistrictsPending=!0,[4,p({cityId:{eq:this.address.city.id},stateId:(null===(s=this.address.state)||void 0===s?void 0:s.id)?{eq:null===(r=this.address.state)||void 0===r?void 0:r.id}:void 0})];case 2:return t=i.sent(),this.districts=t.data||[],[3,5];case 3:return i.sent(),[3,5];case 4:return this._isDistrictsPending=!1,[7];case 5:return[2]}}))}))},this.validateAll=function(){return j.validator.validateAll()},this.submit=function(){return e(j,void 0,void 0,(function(){var t,e;return i(this,(function(i){switch(i.label){case 0:return t={isFormError:!1,isSuccess:!1},this.address.phone&&this.validator.setRules(this.validatorRules(!0)),[4,this.validateAll()];case 1:if(i.sent())return t.isFormError=!0,[2,t];if(!(e=a(v.getInstance().customerStore.customer))||!this.address)return[2,t];(null==e?void 0:e.addresses)||(e.addresses=[]),this.isEdit?e.addresses[this.editingAddressIndex]=this.address:e.addresses.push(this.address),i.label=2;case 2:return i.trys.push([2,4,,5]),[4,v.getInstance().customerStore.saveCustomer(e)];case 3:return i.sent()&&(t.isSuccess=!0),[2,t];case 4:return i.sent(),[2,t];case 5:return[2]}}))}))},s(this,{hasValidatorError:r,isEdit:r,results:r,editingAddressIndex:r,isFreeTextCity:r,isFreeTextDistrict:r,countries:n,states:n,cities:n,districts:n,_isCountriesPending:n,_isStatesPending:n,_isCitiesPending:n,_isDistrictsPending:n,isCountriesPending:r,isStatesPending:r,isCitiesPending:r,isDistrictsPending:r,onCountryChange:d,validateAll:d,submit:d}),this.address=g.address||new y({addressLine1:"",addressLine2:null,attributes:null,company:null,firstName:"",identityNumber:null,isDefault:null,lastName:"",phone:null,postalCode:null,taxNumber:null,taxOffice:null,title:"",country:null,state:null,city:null,district:null,id:"",createdAt:0,updatedAt:0}),this.message=g.message,this.validator=new o(this.address,this.validatorRules()),this.listCountries(),this.address.state&&this.listStates(),this.address.country&&this.listCities(),this.address.city&&this.listDistricts()}return Object.defineProperty(x.prototype,"isFreeTextCity",{get:function(){var t=this;return g.some((function(e){var i,s;return(null===(s=null===(i=t.address.country)||void 0===i?void 0:i.iso2)||void 0===s?void 0:s.toLowerCase())===e.toLowerCase()}))},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isFreeTextDistrict",{get:function(){return!this.districtOptions.length},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isEdit",{get:function(){return-1!==this.editingAddressIndex},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"editingAddressIndex",{get:function(){var t,e,i,s=this;return null!==(i=null===(e=null===(t=v.getInstance().customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.findIndex((function(t){return t.id===s.address.id})))&&void 0!==i?i:-1},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"countryOptions",{get:function(){var t=this.countries.map(b);return j(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"stateOptions",{get:function(){var t=this.states.map(b);return j(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"cityOptions",{get:function(){var t=this.cities.map(b);return j(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"districtOptions",{get:function(){var t=this.districts.map(b);return j(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasState",{get:function(){return this.states.length>1},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCountriesPending",{get:function(){return this._isCountriesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isStatesPending",{get:function(){return this.isCountriesPending||this._isStatesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCitiesPending",{get:function(){return this.isStatesPending||this._isCitiesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isDistrictsPending",{get:function(){return this.isCitiesPending||this._isDistrictsPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasValidatorError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"results",{get:function(){return this.validator.results},enumerable:!1,configurable:!0}),x}();export{x as AddressForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as i,observable as s,computed as r,action as n}from"mobx";import d from"lodash/cloneDeep";import{listCheckoutSettings as a,listCountry as o,listState as u,listCity as c,listDistrict as l}from"@ikas/storefront-api";import{IkasStorefrontConfig as m}from"@ikas/storefront-config";import{IkasBaseStore as h}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import"../../../data/blog/category/index.js";import"../../../data/blog/content/index.js";import"../../../data/blog/meta-data/index.js";import"../../../data/blog/tag/index.js";import"../../../data/blog/index.js";import"../../../data/brand/index.js";import"@ikas/storefront-models";import"../../../data/campaign-offer/index.js";import"../../../data/cart/campaign-offer/index.js";import"../../../data/cart/index.js";import"../../../data/category/path-item/index.js";import"../../../data/category/index.js";import"../../../data/checkout/index.js";import"../../../data/checkout-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import"../../../data/customer/address/index.js";import{IkasLocalizedCustomerAddress as p}from"../../../data/customer/address/ikas-localized-customer-address.js";import"../../../data/customer/attribute/index.js";import"../../../data/customer/review/summary/index.js";import"../../../data/customer/review/index.js";import"../../../data/customer/index.js";import"../../../data/district/index.js";import"../../../data/favorite-product/index.js";import"../../../data/filter-category/index.js";import"../../../data/html-meta-data/index.js";import"../../../data/image/index.js";import"../../../data/order/address/index.js";import"../../../data/order/line-item/option/value/index.js";import"../../../data/order/line-item/variant/value/index.js";import"../../../data/order/line-item/variant/index.js";import"../../../data/order/line-item/index.js";import"../../../data/order/package/index.js";import"../../../data/order/transaction/index.js";import"../../../data/order/index.js";import"../../../data/payment-gateway/index.js";import"../../../data/product/attribute-value/index.js";import"../../../data/product/filter/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/stock-location/index.js";import"../../../data/product/variant/price/index.js";import"../../../data/product/variant/index.js";import"../../../data/variant-type/index.js";import"../../../data/product/index.js";import"../../../data/raffle/index.js";import"../../../data/state/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";import{AddressFormItem as f,LocalizedAddressModel as g}from"@ikas/localized-address";import v from"lodash/mapValues";import y from"../../../../store/location/index.js";var b=function(t){return t.sort((function(t,e){return t.label.localeCompare(e.label)}))},j=function(t){return{label:t.name,value:t.id+""}},x=function(){function x(f){var v=this;this.countries=[],this.states=[],this.cities=[],this.districts=[],this.isLoaded=!1,this.isFormSubmit=!1,this._isCountriesPending=!0,this._isStatesPending=!1,this._isCitiesPending=!1,this._isDistrictsPending=!1,this.init=function(){return t(v,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,a({})];case 1:return(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)&&(this.address.checkoutSettings=t.data[0]),this.address.countrySettings=new g({currentLocale:m.getCurrentLocale()}),[4,this.address.countrySettings.waitUntilInitialized()];case 2:return e.sent(),this.isLoaded=!0,[2]}}))}))},this.onTitleChange=function(t){v.address.title=t},this.onFirstNameChange=function(t){v.address.firstName=t},this.onLastNameChange=function(t){v.address.lastName=t},this.onIdentityNumberChange=function(t){v.address.identityNumber=t},this.onPhoneChange=function(t){v.address.phone=t},this.onAddressLine1Change=function(t){v.address.addressLine1=t},this.onAddressLine2Change=function(t){v.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){v.address.postalCode=t},this.onCountryChange=function(t){var e;if((null===(e=v.address.country)||void 0===e?void 0:e.id)!==t){var i=v.countries.find((function(e){return e.id===t}));v.address.country={id:(null==i?void 0:i.id)||null,name:(null==i?void 0:i.name)||"",code:(null==i?void 0:i.iso3)||null,iso2:(null==i?void 0:i.iso2)||null,iso3:(null==i?void 0:i.iso3)||null},v.address.state=null,v.address.city=null,v.address.district=null,v.states=[],v.cities=[],v.districts=[],v.listStates()}},this.onStateChange=function(t){var e;if((null===(e=v.address.state)||void 0===e?void 0:e.id)!==t){var i=v.states.find((function(e){return e.id===t}));v.address.state={id:i.id,name:null==i?void 0:i.name,code:null==i?void 0:i.stateCode},v.address.isFreeTextCity||(v.address.city=null,v.cities=[],v.listCities()),v.address.isFreeTextDistrict||(v.address.district=null,v.districts=[])}},this.onCityChange=function(t){var e;if((null===(e=v.address.city)||void 0===e?void 0:e.id)!==t){var i=v.cities.find((function(e){return e.id===t}));v.address.city={id:i.id,name:i.name,code:null},v.address.isFreeTextDistrict||(v.address.district=null,v.districts=[],v.listDistricts())}},this.onCityInputChange=function(t){v.districts=[],v.address.city={id:null,name:t,code:null}},this.onDistrictChange=function(t){var e;if((null===(e=v.address.district)||void 0===e?void 0:e.id)!==t){var i=v.districts.find((function(e){return e.id===t}));v.address.district={id:i.id,name:i.name,code:null}}},this.onDistrictInputChange=function(t){v.address.district={id:null,name:t,code:null}},this.listCountries=function(){return t(v,void 0,void 0,(function(){var t,i,s,r,n,d,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,6,7]),this._isCountriesPending=!0,[4,o({})];case 1:return t=e.sent(),i=m.getCurrentRouting(),s=t.data||[],(null===(a=null==i?void 0:i.countryCodes)||void 0===a?void 0:a.length)&&(s=s.filter((function(t){var e;return t.iso2&&(null===(e=i.countryCodes)||void 0===e?void 0:e.includes(t.iso2))}))),this.countries=s,1!==this.countries.length||this.address.country?[3,2]:(this.onCountryChange(this.countries[0].id),[3,4]);case 2:return!this.countries.length||this.address.country?[3,4]:[4,y.getMyCountry()];case 3:r=e.sent(),n=r.data,(d=this.countries.find((function(t){return t.iso2===n})))?this.onCountryChange(d.id):this.onCountryChange(this.countries[0].id),e.label=4;case 4:return this.countries=s,[3,7];case 5:return e.sent(),[3,7];case 6:return this._isCountriesPending=!1,[7];case 7:return[2]}}))}))},this.listStates=function(){return t(v,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.address.country)||void 0===i?void 0:i.id))return[2];e.label=1;case 1:return e.trys.push([1,3,4,5]),this._isStatesPending=!0,[4,u({countryId:{eq:this.address.country.id}})];case 2:return t=e.sent(),this.states=t.data||[],this.hasState||this.onStateChange(this.states[0].id),[3,5];case 3:return e.sent(),[3,5];case 4:return this._isStatesPending=!1,[7];case 5:return[2]}}))}))},this.listCities=function(){return t(v,void 0,void 0,(function(){var t,i,s,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.address.state)||void 0===i?void 0:i.id))return[2];e.label=1;case 1:return e.trys.push([1,3,4,5]),this._isCitiesPending=!0,[4,c({stateId:{eq:this.address.state.id},countryId:(null===(s=this.address.country)||void 0===s?void 0:s.id)?{eq:null===(r=this.address.country)||void 0===r?void 0:r.id}:void 0})];case 2:return t=e.sent(),this.cities=t.data||[],[3,5];case 3:return e.sent(),[3,5];case 4:return this._isCitiesPending=!1,[7];case 5:return[2]}}))}))},this.listDistricts=function(){return t(v,void 0,void 0,(function(){var t,i,s,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.address.city)||void 0===i?void 0:i.id))return[2];e.label=1;case 1:return e.trys.push([1,3,4,5]),this._isDistrictsPending=!0,[4,l({cityId:{eq:this.address.city.id},stateId:(null===(s=this.address.state)||void 0===s?void 0:s.id)?{eq:null===(r=this.address.state)||void 0===r?void 0:r.id}:void 0})];case 2:return t=e.sent(),this.districts=t.data||[],[3,5];case 3:return e.sent(),[3,5];case 4:return this._isDistrictsPending=!1,[7];case 5:return[2]}}))}))},this.submit=function(){return t(v,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(t={isFormError:!1,isSuccess:!1},this.isFormSubmit=!0,!this.address.isValidAddress)return t.isFormError=!0,[2,t];if(!(i=d(h.getInstance().customerStore.customer))||!this.address)return[2,t];(null==i?void 0:i.addresses)||(i.addresses=[]),this.isEdit?i.addresses[this.editingAddressIndex]=this.address:i.addresses.push(this.address),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,h.getInstance().customerStore.saveCustomer(i)];case 2:return e.sent()&&(t.isSuccess=!0),[2,t];case 3:return e.sent(),[2,t];case 4:return[2]}}))}))},i(this,{isLoaded:s,isEdit:r,editingAddressIndex:r,isFreeTextCity:r,isFreeTextDistrict:r,countries:s,states:s,cities:s,districts:s,_isCountriesPending:s,_isStatesPending:s,_isCitiesPending:s,_isDistrictsPending:s,isCountriesPending:r,isStatesPending:r,isCitiesPending:r,isDistrictsPending:r,onCountryChange:n,submit:n}),this.address=f.address||new p({addressLine1:"",addressLine2:null,attributes:null,company:null,firstName:"",identityNumber:null,isDefault:null,lastName:"",phone:null,postalCode:null,taxNumber:null,taxOffice:null,title:"",country:null,state:null,city:null,district:null,id:"",createdAt:0,updatedAt:0}),this.message=f.message,this.listCountries(),this.address.state&&this.listStates(),this.address.country&&this.listCities(),this.address.city&&this.listDistricts(),this.init()}return Object.defineProperty(x.prototype,"isFreeTextCity",{get:function(){return this.address.isFreeTextCity},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isFreeTextDistrict",{get:function(){return this.address.isFreeTextDistrict},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isEdit",{get:function(){return-1!==this.editingAddressIndex},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"editingAddressIndex",{get:function(){var t,e,i,s=this;return null!==(i=null===(e=null===(t=h.getInstance().customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.findIndex((function(t){return t.id===s.address.id})))&&void 0!==i?i:-1},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"countryOptions",{get:function(){var t=this.countries.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"stateOptions",{get:function(){var t=this.states.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"cityOptions",{get:function(){var t=this.cities.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"districtOptions",{get:function(){var t=this.districts.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasState",{get:function(){return this.states.length>1},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCountriesPending",{get:function(){return this._isCountriesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isStatesPending",{get:function(){return this.isCountriesPending||this._isStatesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCitiesPending",{get:function(){return this.isStatesPending||this._isCitiesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isDistrictsPending",{get:function(){return this.isCitiesPending||this._isDistrictsPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"fieldSettings",{get:function(){return this.address.fieldSettings},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"fieldLabels",{get:function(){return this.address.fieldLabels},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"addressFormat",{get:function(){return this.countryOptions.length<=1?this.address.addressFormatIgnoreCountry:this.address.addressFormat},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"validationResult",{get:function(){var t=this;if(this.address.validationResults)return v(this.address.validationResults,(function(e,i){return{hasError:t.isFormSubmit&&e.hasError,message:t.isFormSubmit&&e.hasError?i===f.PHONE?t.message.phoneRule?"string"==typeof t.message.phoneRule?t.message.phoneRule:t.message.phoneRule(t.address):"":e.isInvalid?"string"==typeof t.message.invalidRule?t.message.invalidRule:t.message.invalidRule(t.address):"string"==typeof t.message.requiredRule?t.message.requiredRule:t.message.requiredRule(t.address):""}}))},enumerable:!1,configurable:!0}),x}();export{x as IkasAddressForm};
|
|
1
|
+
import{__awaiter as t,__generator as e}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as i,observable as s,computed as r,action as n}from"mobx";import d from"lodash/cloneDeep";import{listCheckoutSettings as a,listCountry as o,listState as u,listCity as c,listDistrict as l}from"@ikas/storefront-api";import{IkasStorefrontConfig as m}from"@ikas/storefront-config";import{IkasBaseStore as h}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import"../../../data/blog/category/index.js";import"../../../data/blog/content/index.js";import"../../../data/blog/meta-data/index.js";import"../../../data/blog/tag/index.js";import"../../../data/blog/index.js";import"../../../data/brand/index.js";import"@ikas/storefront-models";import"../../../data/campaign-offer/index.js";import"../../../data/cart/campaign-offer/index.js";import"../../../data/cart/index.js";import"../../../data/category/path-item/index.js";import"../../../data/category/index.js";import"../../../data/checkout/index.js";import"../../../data/checkout-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import"../../../data/customer/address/index.js";import{IkasLocalizedCustomerAddress as p}from"../../../data/customer/address/ikas-localized-customer-address.js";import"../../../data/customer/attribute/index.js";import"../../../data/customer/review/summary/index.js";import"../../../data/customer/review/index.js";import"../../../data/customer/index.js";import"../../../data/district/index.js";import"../../../data/favorite-product/index.js";import"../../../data/filter-category/index.js";import"../../../data/html-meta-data/index.js";import"../../../data/image/index.js";import"../../../data/order/address/index.js";import"../../../data/order/line-item/option/value/index.js";import"../../../data/order/line-item/variant/value/index.js";import"../../../data/order/line-item/variant/index.js";import"../../../data/order/line-item/index.js";import"../../../data/order/package/index.js";import"../../../data/order/transaction/index.js";import"../../../data/order/index.js";import"../../../data/payment-gateway/index.js";import"../../../data/product/attribute-value/index.js";import"../../../data/product/filter/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/stock-location/index.js";import"../../../data/product/variant/price/index.js";import"../../../data/product/variant/index.js";import"../../../data/variant-type/index.js";import"../../../data/product/index.js";import"../../../data/raffle/index.js";import"../../../data/state/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/component/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";import{AddressFormItem as f,LocalizedAddressModel as g}from"@ikas/localized-address";import v from"lodash/mapValues";import y from"../../../../store/location/index.js";var b=function(t){return t.sort((function(t,e){return t.label.localeCompare(e.label)}))},j=function(t){return{label:t.name,value:t.id+""}},x=function(){function x(f){var v=this;this.countries=[],this.states=[],this.cities=[],this.districts=[],this.isLoaded=!1,this.isFormSubmit=!1,this._isCountriesPending=!0,this._isStatesPending=!1,this._isCitiesPending=!1,this._isDistrictsPending=!1,this.init=function(){return t(v,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,a({})];case 1:return(t=e.sent()).isSuccess&&(null===(i=t.data)||void 0===i?void 0:i.length)&&(this.address.checkoutSettings=t.data[0]),this.address.countrySettings=new g({currentLocale:m.getCurrentLocale()}),[4,this.address.countrySettings.waitUntilInitialized()];case 2:return e.sent(),this.isLoaded=!0,[2]}}))}))},this.onTitleChange=function(t){v.address.title=t},this.onFirstNameChange=function(t){v.address.firstName=t},this.onLastNameChange=function(t){v.address.lastName=t},this.onIdentityNumberChange=function(t){v.address.identityNumber=t},this.onPhoneChange=function(t){v.address.phone=t},this.onAddressLine1Change=function(t){v.address.addressLine1=t},this.onAddressLine2Change=function(t){v.address.addressLine2=t},this.onAddressPostalCodeChange=function(t){v.address.postalCode=t},this.onCountryChange=function(t){var e;if((null===(e=v.address.country)||void 0===e?void 0:e.id)!==t){var i=v.countries.find((function(e){return e.id===t}));v.address.country={id:(null==i?void 0:i.id)||null,name:(null==i?void 0:i.name)||"",code:(null==i?void 0:i.iso3)||null,iso2:(null==i?void 0:i.iso2)||null,iso3:(null==i?void 0:i.iso3)||null},v.address.state=null,v.address.city=null,v.address.district=null,v.states=[],v.cities=[],v.districts=[],v.listStates()}},this.onStateChange=function(t){var e;if((null===(e=v.address.state)||void 0===e?void 0:e.id)!==t){var i=v.states.find((function(e){return e.id===t}));v.address.state={id:i.id,name:null==i?void 0:i.name,code:null==i?void 0:i.stateCode},v.address.isFreeTextCity||(v.address.city=null,v.cities=[],v.listCities()),v.address.isFreeTextDistrict||(v.address.district=null,v.districts=[])}},this.onCityChange=function(t){var e;if((null===(e=v.address.city)||void 0===e?void 0:e.id)!==t){var i=v.cities.find((function(e){return e.id===t}));v.address.city={id:i.id,name:i.name,code:null},v.address.isFreeTextDistrict||(v.address.district=null,v.districts=[],v.listDistricts())}},this.onCityInputChange=function(t){v.districts=[],v.address.city={id:null,name:t,code:null}},this.onDistrictChange=function(t){var e;if((null===(e=v.address.district)||void 0===e?void 0:e.id)!==t){var i=v.districts.find((function(e){return e.id===t}));v.address.district={id:i.id,name:i.name,code:null}}},this.onDistrictInputChange=function(t){v.address.district={id:null,name:t,code:null}},this.listCountries=function(){return t(v,void 0,void 0,(function(){var t,i,s,r,n,d,a;return e(this,(function(e){switch(e.label){case 0:return e.trys.push([0,5,6,7]),this._isCountriesPending=!0,[4,o({})];case 1:return t=e.sent(),i=m.getCurrentRouting(),s=t.data||[],(null===(a=null==i?void 0:i.countryCodes)||void 0===a?void 0:a.length)&&(s=s.filter((function(t){var e;return t.iso2&&(null===(e=i.countryCodes)||void 0===e?void 0:e.includes(t.iso2))}))),this.countries=s,1!==this.countries.length||this.address.country?[3,2]:(this.onCountryChange(this.countries[0].id),[3,4]);case 2:return!this.countries.length||this.address.country?[3,4]:[4,y.getMyCountry()];case 3:r=e.sent(),n=r.data,(d=this.countries.find((function(t){return t.iso2===n})))?this.onCountryChange(d.id):this.onCountryChange(this.countries[0].id),e.label=4;case 4:return this.countries=s,[3,7];case 5:return e.sent(),[3,7];case 6:return this._isCountriesPending=!1,[7];case 7:return[2]}}))}))},this.listStates=function(){return t(v,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.address.country)||void 0===i?void 0:i.id))return[2];e.label=1;case 1:return e.trys.push([1,3,4,5]),this._isStatesPending=!0,[4,u({countryId:{eq:this.address.country.id}})];case 2:return t=e.sent(),this.states=t.data||[],this.hasState||this.onStateChange(this.states[0].id),[3,5];case 3:return e.sent(),[3,5];case 4:return this._isStatesPending=!1,[7];case 5:return[2]}}))}))},this.listCities=function(){return t(v,void 0,void 0,(function(){var t,i,s,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.address.state)||void 0===i?void 0:i.id))return[2];e.label=1;case 1:return e.trys.push([1,3,4,5]),this._isCitiesPending=!0,[4,c({stateId:{eq:this.address.state.id},countryId:(null===(s=this.address.country)||void 0===s?void 0:s.id)?{eq:null===(r=this.address.country)||void 0===r?void 0:r.id}:void 0})];case 2:return t=e.sent(),this.cities=t.data||[],[3,5];case 3:return e.sent(),[3,5];case 4:return this._isCitiesPending=!1,[7];case 5:return[2]}}))}))},this.listDistricts=function(){return t(v,void 0,void 0,(function(){var t,i,s,r;return e(this,(function(e){switch(e.label){case 0:if(!(null===(i=this.address.city)||void 0===i?void 0:i.id))return[2];e.label=1;case 1:return e.trys.push([1,3,4,5]),this._isDistrictsPending=!0,[4,l({cityId:{eq:this.address.city.id},stateId:(null===(s=this.address.state)||void 0===s?void 0:s.id)?{eq:null===(r=this.address.state)||void 0===r?void 0:r.id}:void 0})];case 2:return t=e.sent(),this.districts=t.data||[],[3,5];case 3:return e.sent(),[3,5];case 4:return this._isDistrictsPending=!1,[7];case 5:return[2]}}))}))},this.submit=function(){return t(v,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:if(t={isFormError:!1,isSuccess:!1},this.isFormSubmit=!0,!this.address.isValidAddress)return t.isFormError=!0,[2,t];if(!(i=d(h.getInstance().customerStore.customer))||!this.address)return[2,t];(null==i?void 0:i.addresses)||(i.addresses=[]),this.isEdit?i.addresses[this.editingAddressIndex]=this.address:i.addresses.push(this.address),e.label=1;case 1:return e.trys.push([1,3,,4]),[4,h.getInstance().customerStore.saveCustomer(i)];case 2:return e.sent()&&(t.isSuccess=!0),[2,t];case 3:return e.sent(),[2,t];case 4:return[2]}}))}))},i(this,{isLoaded:s,isEdit:r,editingAddressIndex:r,isFreeTextCity:r,isFreeTextDistrict:r,countries:s,states:s,cities:s,districts:s,_isCountriesPending:s,_isStatesPending:s,_isCitiesPending:s,_isDistrictsPending:s,isCountriesPending:r,isStatesPending:r,isCitiesPending:r,isDistrictsPending:r,onCountryChange:n,submit:n}),this.address=f.address||new p({addressLine1:"",addressLine2:null,attributes:null,company:null,firstName:"",identityNumber:null,isDefault:null,lastName:"",phone:null,postalCode:null,taxNumber:null,taxOffice:null,title:"",country:null,state:null,city:null,district:null,id:"",createdAt:0,updatedAt:0}),this.message=f.message,this.listCountries(),this.address.state&&this.listStates(),this.address.country&&this.listCities(),this.address.city&&this.listDistricts(),this.init()}return Object.defineProperty(x.prototype,"isFreeTextCity",{get:function(){return this.address.isFreeTextCity},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isFreeTextDistrict",{get:function(){return this.address.isFreeTextDistrict},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isEdit",{get:function(){return-1!==this.editingAddressIndex},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"editingAddressIndex",{get:function(){var t,e,i,s=this;return null!==(i=null===(e=null===(t=h.getInstance().customerStore.customer)||void 0===t?void 0:t.addresses)||void 0===e?void 0:e.findIndex((function(t){return t.id===s.address.id})))&&void 0!==i?i:-1},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"countryOptions",{get:function(){var t=this.countries.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"stateOptions",{get:function(){var t=this.states.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"cityOptions",{get:function(){var t=this.cities.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"districtOptions",{get:function(){var t=this.districts.map(j);return b(t)},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"hasState",{get:function(){return this.states.length>1},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCountriesPending",{get:function(){return this._isCountriesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isStatesPending",{get:function(){return this.isCountriesPending||this._isStatesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isCitiesPending",{get:function(){return this.isStatesPending||this._isCitiesPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"isDistrictsPending",{get:function(){return this.isCitiesPending||this._isDistrictsPending},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"fieldSettings",{get:function(){return this.address.fieldSettings},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"fieldLabels",{get:function(){return this.address.fieldLabels},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"addressFormat",{get:function(){return this.countryOptions.length<=1?this.address.addressFormatIgnoreCountry:this.address.addressFormat},enumerable:!1,configurable:!0}),Object.defineProperty(x.prototype,"validationResult",{get:function(){var t=this;if(this.address.validationResults)return v(this.address.validationResults,(function(e,i){return{hasError:t.isFormSubmit&&e.hasError,message:t.isFormSubmit&&e.hasError?i===f.PHONE?t.message.phoneRule?"string"==typeof t.message.phoneRule?t.message.phoneRule:t.message.phoneRule(t.address):"":e.isInvalid?"string"==typeof t.message.invalidRule?t.message.invalidRule:t.message.invalidRule(t.address):"string"==typeof t.message.requiredRule?t.message.requiredRule:t.message.requiredRule(t.address):""}}))},enumerable:!1,configurable:!0}),x}();export{x as IkasAddressForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__spreadArray as r,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as a,computed as o,observable as s,action as n}from"mobx";import{Validator as u}from"../index.js";import{IkasBaseStore as d}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{PhoneRule as l,RequiredRule as m,EmailRule as p,MinRule as c}from"../rules/index.js";import"../../../data/blog/category/index.js";import"../../../data/blog/content/index.js";import"../../../data/blog/meta-data/index.js";import"../../../data/blog/tag/index.js";import"../../../data/blog/index.js";import"../../../data/brand/index.js";import{IkasCustomerAttributeType as f,IkasCustomerAttributeRegisterPageRequirement as b}from"@ikas/storefront-models";import"../../../data/campaign-offer/index.js";import"../../../data/cart/campaign-offer/index.js";import"../../../data/cart/index.js";import"../../../data/category/path-item/index.js";import"../../../data/category/index.js";import"../../../data/checkout/index.js";import"../../../data/checkout-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import"../../../data/customer/address/index.js";import"../../../data/customer/address/ikas-localized-customer-address.js";import"../../../data/customer/attribute/index.js";import"../../../data/customer/review/summary/index.js";import"../../../data/customer/review/index.js";import"../../../data/customer/index.js";import"../../../data/district/index.js";import"../../../data/favorite-product/index.js";import"../../../data/filter-category/index.js";import"../../../data/html-meta-data/index.js";import"../../../data/image/index.js";import"../../../data/order/address/index.js";import"../../../data/order/line-item/option/value/index.js";import"../../../data/order/line-item/variant/value/index.js";import"../../../data/order/line-item/variant/index.js";import"../../../data/order/line-item/index.js";import"../../../data/order/package/index.js";import"../../../data/order/transaction/index.js";import"../../../data/order/index.js";import"../../../data/payment-gateway/index.js";import"../../../data/product/attribute-value/index.js";import"../../../data/product/filter/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/stock-location/index.js";import"../../../data/product/variant/price/index.js";import"../../../data/product/variant/index.js";import"../../../data/variant-type/index.js";import"../../../data/product/index.js";import"../../../data/raffle/index.js";import"../../../data/state/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var h=function(){function h(e){var t=this;this.model={firstName:"",lastName:"",email:"",password:"",attributes:void 0,isMarketingAccepted:!1,phone:null},this.isFormSubmit=!1,this._customerAttributes=void 0,this.validatorRules=function(e){return void 0===e&&(e=!1),r([new m({fieldKey:"firstName",valuePath:"firstName",message:t.message.requiredRule}),new m({fieldKey:"lastName",valuePath:"lastName",message:t.message.requiredRule}),new m({fieldKey:"email",valuePath:"email",message:t.message.requiredRule}),new m({fieldKey:"password",valuePath:"password",message:t.message.requiredRule}),new p({fieldKey:"email",valuePath:"email",message:t.message.emailRule}),new c({fieldKey:"password",valuePath:"password",minValue:6,message:t.message.minRule})],e?[new l({fieldKey:"phone",valuePath:"phone",message:t.message.phoneRule})]:[],!0)},this.onFirstNameChange=function(e){t.firstName=e},this.onLastNameChange=function(e){t.lastName=e},this.onEmailChange=function(e){t.email=e},this.onPasswordChange=function(e){t.password=e},this.onPhoneChange=function(e){t.phone=e},this.setCustomerAttributes=function(e){t._customerAttributes=(null==e?void 0:e.filter((function(e){return e.registerPageRequirement!==b.INVISIBLE})).map((function(e){return{attribute:e,attributeValue:{isChecked:void 0,value:void 0,selectedIdList:void 0},validator:{isRequired:e.registerPageRequirement===b.MANDATORY,hasError:!1,message:""}}})))||[]},this.onAttributeChange=function(e,r){var i;if(t._customerAttributes){var a=t._customerAttributes.find((function(t){return t.attribute.id===e}));if(a){var o=null===(i=t._customerAttributes)||void 0===i?void 0:i.findIndex((function(t){return t.attribute.id===e}));void 0!==o&&-1!==o&&(t._customerAttributes[o].attributeValue=t.getAttributeValue(a.attribute,r),t.validateCustomerAttribute())}}},a(this,{emailErrorMessage:o,passwordErrorMessage:o,firstNameErrorMessage:o,lastNameErrorMessage:o,phoneErrorMessage:o,hasError:o,redirect:o,model:s,validateAll:n,register:n,customerAttributes:o,_customerAttributes:s}),this.message=e.message,this.validator=new u(this.model,this.validatorRules())}return Object.defineProperty(h.prototype,"firstName",{get:function(){return this.model.firstName},set:function(e){this.model.firstName=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"lastName",{get:function(){return this.model.lastName},set:function(e){this.model.lastName=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"email",{get:function(){return this.model.email},set:function(e){this.model.email=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"password",{get:function(){return this.model.password},set:function(e){this.model.password=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isMarketingAccepted",{get:function(){return this.model.isMarketingAccepted},set:function(e){this.model.isMarketingAccepted=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"phone",{get:function(){return this.model.phone},set:function(e){this.model.phone=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"hasError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"firstNameErrorMessage",{get:function(){return this.validator.results.firstName.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"lastNameErrorMessage",{get:function(){return this.validator.results.lastName.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"emailErrorMessage",{get:function(){return this.validator.results.email.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"passwordErrorMessage",{get:function(){return this.validator.results.password.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"phoneErrorMessage",{get:function(){var e;return null===(e=this.validator.results.phone)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"attributes",{get:function(){return this.model.attributes},set:function(e){this.model.attributes=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"redirect",{get:function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("redirect")},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"customerAttributes",{get:function(){return this._customerAttributes},enumerable:!1,configurable:!0}),h.prototype.getAttributeValue=function(e,t){var r={isChecked:void 0,value:void 0,selectedIdList:void 0};if("string"!=typeof t||e.type!==f.TEXT&&e.type!==f.DATETIME&&e.type!==f.CHOICE||(r.value=t),"string"==typeof t&&e.type===f.NUMERIC){var i=parseInt(t);isNaN(i)?r.value=r.value||"":r.value=t}return"boolean"==typeof t&&e.type===f.BOOLEAN&&(r.isChecked=t),"object"==typeof t&&e.type===f.MULTIPLE_CHOICE&&(r.selectedIdList=t),r},Object.defineProperty(h.prototype,"formattedAttributesInput",{get:function(){if(!this._customerAttributes)return null;if(!this._customerAttributes.some((function(e){return void 0!==e.attributeValue.value||void 0!==e.attributeValue.isChecked||void 0!==e.attributeValue.selectedIdList})))return null;var e=[];return this._customerAttributes.map((function(t){var r=t.attributeValue,i=r.selectedIdList,a=r.isChecked,o=r.value;void 0!==i&&f.MULTIPLE_CHOICE&&i.map((function(r){e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:r,value:null})})),t.attribute.type===f.BOOLEAN&&e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:null,value:a?a.toString():"false"}),void 0!==o&&(t.attribute.type!==f.TEXT&&t.attribute.type!==f.NUMERIC||e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:null,value:o.toString()}),t.attribute.type===f.CHOICE&&e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:o,value:null}),t.attribute.type===f.DATETIME&&e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:null,value:new Date(o).getTime().toString()}))})),e},enumerable:!1,configurable:!0}),h.prototype.validateCustomerAttribute=function(){var e,t=this;this._customerAttributes=null===(e=this._customerAttributes)||void 0===e?void 0:e.map((function(e){var r;return e.validator.isRequired&&t.isFormSubmit&&(e.attribute.type===f.BOOLEAN||e.attributeValue.value||(null===(r=e.attributeValue.selectedIdList)||void 0===r?void 0:r.length)?(e.validator.hasError=!1,e.validator.message=""):(e.validator.hasError=!0,e.validator.message="string"==typeof t.message.requiredRule?t.message.requiredRule:t.message.requiredRule(t.model))),e}))},h.prototype.validateAll=function(){var r;return e(this,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return this.validateCustomerAttribute(),[4,this.validator.validateAll()];case 1:return e=t.sent(),i=null===(r=this._customerAttributes)||void 0===r?void 0:r.some((function(e){return e.validator.hasError})),[2,e||i]}}))}))},h.prototype.register=function(){return e(this,void 0,void 0,(function(){var e,r;return t(this,(function(t){switch(t.label){case 0:return this.isFormSubmit=!0,e={isFormError:!1,isSuccess:!1,errorCodes:[]},this.phone&&this.validator.setRules(this.validatorRules(!0)),[4,this.validateAll()];case 1:if(t.sent())return e.isFormError=!0,[2,e];t.label=2;case 2:return t.trys.push([2,4,,5]),[4,d.getInstance().customerStore.register(this.model.firstName,this.model.lastName,this.model.email,this.model.password,this.model.isMarketingAccepted,this.model.attributes||this.formattedAttributesInput||void 0,this.model.phone)];case 3:return r=t.sent(),[2,i(i({},e),r)];case 4:return t.sent(),[2,e];case 5:return[2]}}))}))},h}();export{h as RegisterForm};
|
|
1
|
+
import{__awaiter as e,__generator as t,__spreadArray as r,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{makeObservable as a,computed as o,observable as s,action as n}from"mobx";import{Validator as u}from"../index.js";import{IkasBaseStore as d}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{PhoneRule as m,RequiredRule as l,EmailRule as p,MinRule as c}from"../rules/index.js";import"../../../data/blog/category/index.js";import"../../../data/blog/content/index.js";import"../../../data/blog/meta-data/index.js";import"../../../data/blog/tag/index.js";import"../../../data/blog/index.js";import"../../../data/brand/index.js";import{IkasCustomerAttributeType as f,IkasCustomerAttributeRegisterPageRequirement as b}from"@ikas/storefront-models";import"../../../data/campaign-offer/index.js";import"../../../data/cart/campaign-offer/index.js";import"../../../data/cart/index.js";import"../../../data/category/path-item/index.js";import"../../../data/category/index.js";import"../../../data/checkout/index.js";import"../../../data/checkout-settings/index.js";import"../../../data/city/index.js";import"../../../data/country/index.js";import"../../../data/customer/address/index.js";import"../../../data/customer/address/ikas-localized-customer-address.js";import"../../../data/customer/attribute/index.js";import"../../../data/customer/review/summary/index.js";import"../../../data/customer/review/index.js";import"../../../data/customer/index.js";import"../../../data/district/index.js";import"../../../data/favorite-product/index.js";import"../../../data/filter-category/index.js";import"../../../data/html-meta-data/index.js";import"../../../data/image/index.js";import"../../../data/order/address/index.js";import"../../../data/order/line-item/option/value/index.js";import"../../../data/order/line-item/variant/value/index.js";import"../../../data/order/line-item/variant/index.js";import"../../../data/order/line-item/index.js";import"../../../data/order/package/index.js";import"../../../data/order/transaction/index.js";import"../../../data/order/index.js";import"../../../data/payment-gateway/index.js";import"../../../data/product/attribute-value/index.js";import"../../../data/product/filter/index.js";import"../../../data/product/option-set/option/index.js";import"../../../data/product/option-set/index.js";import"../../../data/product/stock-location/index.js";import"../../../data/product/variant/price/index.js";import"../../../data/product/variant/index.js";import"../../../data/variant-type/index.js";import"../../../data/product/index.js";import"../../../data/raffle/index.js";import"../../../data/state/index.js";import"../../../data/theme-json/index.js";import"../../../data/theme-json/component/index.js";import"../../../data/theme-json/custom-data/index.js";import"../../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var h=function(){function h(e){var t=this;this.model={firstName:"",lastName:"",email:"",password:"",attributes:void 0,isMarketingAccepted:!1,phone:null},this.isFormSubmit=!1,this._customerAttributes=void 0,this.validatorRules=function(e){return void 0===e&&(e=!1),r([new l({fieldKey:"firstName",valuePath:"firstName",message:t.message.requiredRule}),new l({fieldKey:"lastName",valuePath:"lastName",message:t.message.requiredRule}),new l({fieldKey:"email",valuePath:"email",message:t.message.requiredRule}),new l({fieldKey:"password",valuePath:"password",message:t.message.requiredRule}),new p({fieldKey:"email",valuePath:"email",message:t.message.emailRule}),new c({fieldKey:"password",valuePath:"password",minValue:6,message:t.message.minRule})],e?[new m({fieldKey:"phone",valuePath:"phone",message:t.message.phoneRule})]:[],!0)},this.onFirstNameChange=function(e){t.firstName=e},this.onLastNameChange=function(e){t.lastName=e},this.onEmailChange=function(e){t.email=e},this.onPasswordChange=function(e){t.password=e},this.onPhoneChange=function(e){t.phone=e},this.setCustomerAttributes=function(e){t._customerAttributes=(null==e?void 0:e.filter((function(e){return e.registerPageRequirement!==b.INVISIBLE})).map((function(e){return{attribute:e,attributeValue:{isChecked:void 0,value:void 0,selectedIdList:void 0},validator:{isRequired:e.registerPageRequirement===b.MANDATORY,hasError:!1,message:""}}})))||[]},this.onAttributeChange=function(e,r){var i;if(t._customerAttributes){var a=t._customerAttributes.find((function(t){return t.attribute.id===e}));if(a){var o=null===(i=t._customerAttributes)||void 0===i?void 0:i.findIndex((function(t){return t.attribute.id===e}));void 0!==o&&-1!==o&&(t._customerAttributes[o].attributeValue=t.getAttributeValue(a.attribute,r),t.validateCustomerAttribute())}}},a(this,{emailErrorMessage:o,passwordErrorMessage:o,firstNameErrorMessage:o,lastNameErrorMessage:o,phoneErrorMessage:o,hasError:o,redirect:o,model:s,validateAll:n,register:n,customerAttributes:o,_customerAttributes:s}),this.message=e.message,this.validator=new u(this.model,this.validatorRules())}return Object.defineProperty(h.prototype,"firstName",{get:function(){return this.model.firstName},set:function(e){this.model.firstName=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"lastName",{get:function(){return this.model.lastName},set:function(e){this.model.lastName=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"email",{get:function(){return this.model.email},set:function(e){this.model.email=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"password",{get:function(){return this.model.password},set:function(e){this.model.password=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"isMarketingAccepted",{get:function(){return this.model.isMarketingAccepted},set:function(e){this.model.isMarketingAccepted=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"phone",{get:function(){return this.model.phone},set:function(e){this.model.phone=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"hasError",{get:function(){return this.validator.hasError},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"firstNameErrorMessage",{get:function(){return this.validator.results.firstName.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"lastNameErrorMessage",{get:function(){return this.validator.results.lastName.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"emailErrorMessage",{get:function(){return this.validator.results.email.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"passwordErrorMessage",{get:function(){return this.validator.results.password.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"phoneErrorMessage",{get:function(){var e;return null===(e=this.validator.results.phone)||void 0===e?void 0:e.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"attributes",{get:function(){return this.model.attributes},set:function(e){this.model.attributes=e},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"redirect",{get:function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("redirect")},enumerable:!1,configurable:!0}),Object.defineProperty(h.prototype,"customerAttributes",{get:function(){return this._customerAttributes},enumerable:!1,configurable:!0}),h.prototype.getAttributeValue=function(e,t){var r={isChecked:void 0,value:void 0,selectedIdList:void 0};if("string"!=typeof t||e.type!==f.TEXT&&e.type!==f.DATETIME&&e.type!==f.CHOICE||(r.value=t),"string"==typeof t&&e.type===f.NUMERIC){var i=parseInt(t);isNaN(i)?r.value=r.value||"":r.value=t}return"boolean"==typeof t&&e.type===f.BOOLEAN&&(r.isChecked=t),"object"==typeof t&&e.type===f.MULTIPLE_CHOICE&&(r.selectedIdList=t),r},Object.defineProperty(h.prototype,"formattedAttributesInput",{get:function(){if(!this._customerAttributes)return null;if(!this._customerAttributes.some((function(e){return void 0!==e.attributeValue.value||void 0!==e.attributeValue.isChecked||void 0!==e.attributeValue.selectedIdList})))return null;var e=[];return this._customerAttributes.map((function(t){var r=t.attributeValue,i=r.selectedIdList,a=r.isChecked,o=r.value;void 0!==i&&f.MULTIPLE_CHOICE&&i.map((function(r){e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:r,value:null})})),t.attribute.type===f.BOOLEAN&&e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:null,value:a?a.toString():"false"}),void 0!==o&&(t.attribute.type!==f.TEXT&&t.attribute.type!==f.NUMERIC||e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:null,value:o.toString()}),t.attribute.type===f.CHOICE&&e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:o,value:null}),t.attribute.type===f.DATETIME&&e.push({customerAttributeId:t.attribute.id,customerAttributeOptionId:null,value:new Date(o).getTime().toString()}))})),e},enumerable:!1,configurable:!0}),h.prototype.validateCustomerAttribute=function(){var e,t=this;this._customerAttributes=null===(e=this._customerAttributes)||void 0===e?void 0:e.map((function(e){var r;return e.validator.isRequired&&t.isFormSubmit&&(e.attribute.type===f.BOOLEAN||e.attributeValue.value||(null===(r=e.attributeValue.selectedIdList)||void 0===r?void 0:r.length)?(e.validator.hasError=!1,e.validator.message=""):(e.validator.hasError=!0,e.validator.message="string"==typeof t.message.requiredRule?t.message.requiredRule:t.message.requiredRule(t.model))),e}))},h.prototype.validateAll=function(){var r;return e(this,void 0,void 0,(function(){var e,i;return t(this,(function(t){switch(t.label){case 0:return this.validateCustomerAttribute(),[4,this.validator.validateAll()];case 1:return e=t.sent(),i=null===(r=this._customerAttributes)||void 0===r?void 0:r.some((function(e){return e.validator.hasError})),[2,e||i]}}))}))},h.prototype.register=function(){return e(this,void 0,void 0,(function(){var e,r;return t(this,(function(t){switch(t.label){case 0:return this.isFormSubmit=!0,e={isFormError:!1,isSuccess:!1,errorCodes:[]},this.phone&&this.validator.setRules(this.validatorRules(!0)),[4,this.validateAll()];case 1:if(t.sent())return e.isFormError=!0,[2,e];t.label=2;case 2:return t.trys.push([2,4,,5]),[4,d.getInstance().customerStore.register(this.model.firstName,this.model.lastName,this.model.email,this.model.password,this.model.isMarketingAccepted,this.model.attributes||this.formattedAttributesInput||void 0,this.model.phone)];case 3:return r=t.sent(),[2,i(i({},e),r)];case 4:return t.sent(),[2,e];case 5:return[2]}}))}))},h}();export{h as RegisterForm};
|