@ikas/storefront 2.0.34 → 2.0.35-alpha.2
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/_virtual/index.js_commonjs-proxy3.js +1 -1
- package/build/_virtual/index.js_commonjs-proxy4.js +1 -1
- package/build/analytics/analytics.js +1 -1
- package/build/analytics/googleAnalytics.d.ts +13 -0
- package/build/analytics/googleAnalytics.js +1 -0
- package/build/analytics/googleTagManager.d.ts +2 -0
- package/build/analytics/googleTagManager.js +1 -1
- package/build/analytics/googleUniversal.d.ts +8 -0
- package/build/analytics/googleUniversal.js +1 -0
- package/build/analytics/head/index.js +1 -1
- package/build/api/storefront/__generated__/getStorefront.d.ts +2 -0
- package/build/api/storefront/index.js +1 -1
- package/build/ikas.js +7 -7
- package/build/models/data/storefront/index.d.ts +2 -0
- package/build/models/data/storefront/index.js +1 -1
- package/build/models/ui/product-list/index.js +1 -1
- package/build/models/ui/validator/form/raffle-form.js +1 -1
- package/build/providers/page-data-get.d.ts +2 -0
- package/build/providers/page-data-next.d.ts +12 -0
- package/build/providers/page-data-next.js +1 -1
- package/build/storefront/index.d.ts +4 -0
- package/build/storefront/index.js +1 -1
- package/package.json +1 -1
|
@@ -15,6 +15,8 @@ export declare class IkasStorefront {
|
|
|
15
15
|
salesChannelId: string | null;
|
|
16
16
|
fbpId: string | null;
|
|
17
17
|
gtmId: string | null;
|
|
18
|
+
analytics4Id: string | null;
|
|
19
|
+
universalAnalyticsId: string | null;
|
|
18
20
|
localizations: IkasStorefrontLocalization[];
|
|
19
21
|
routings: IkasStorefrontRouting[];
|
|
20
22
|
domains: IkasStorefrontDomain[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IkasStorefrontLocalization as n}from"./localization/index.js";import{IkasStorefrontDomain as
|
|
1
|
+
import{IkasStorefrontLocalization as n}from"./localization/index.js";import{IkasStorefrontDomain as i}from"./domain/index.js";import{IkasStorefrontRouting as t}from"./routing/index.js";import{IkasStorefrontTheme as s}from"./theme/index.js";var e;!function(n){n.WAITING="WAITING",n.READY="READY"}(e||(e={}));var a=function(a){void 0===a&&(a={}),this.id=a.id||"",this.name=a.name||"",this.status=a.status||e.WAITING,this.mainStorefrontThemeId=a.mainStorefrontThemeId||null,this.emailSettingsId=a.emailSettingsId||null,this.salesChannelId=a.salesChannelId||null,this.gtmId=a.gtmId||null,this.fbpId=a.fbpId||null,this.analytics4Id=a.analytics4Id||null,this.universalAnalyticsId=a.universalAnalyticsId||null,this.localizations=a.localizations?a.localizations.map((function(i){return new n(i)})):[],this.routings=a.routings?a.routings.map((function(n){return new t(n)})):[],this.domains=a.domains?a.domains.map((function(n){return new i(n)})):[],this.themes=a.themes?a.themes.map((function(n){return new s(n)})):[]};export{a as IkasStorefront,e as StorefrontStatus};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as e}from'../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import"../../theme/theme.js";import{IkasThemePageType as r}from"../../theme/page/index.js";import"../../theme/component/prop/index.js";import"../../theme/page/component/prop-value/link.js";import"../brand-list/index.js";import"../blog-list/index.js";import"../blog-category-list/index.js";import"../category-list/index.js";import{IkasProductDetail as s}from"../product-detail/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/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"../../theme/settings/index.js";import"../../theme/custom-data/index.js";import"../../../api/blog/index.js";import"../../../api/brand/index.js";import"../../../api/cart/index.js";import"../../../api/category/index.js";import"../../../api/checkout/index.js";import"../../../api/city/index.js";import"../../../api/country/index.js";import"../../../api/customer/index.js";import"../../../api/customer-review/index.js";import"../../../api/customer-review-summary/index.js";import"../../../api/district/index.js";import"../../../api/html-meta-data/index.js";import"../../../api/merchant/index.js";import{IkasProductSearchAPI as n}from"../../../api/product-search/index.js";import"../../data/blog/index.js";import"../../data/brand/index.js";import{ModelOrder as a,IkasFilterCategory as o}from"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/customer/address/index.js";import"../../data/customer/index.js";import"../../data/customer-review/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/installment-info/index.js";import"../../data/order/index.js";import"../../data/order/line-item/index.js";import"../../../api/product-option-file/index.js";import"../../data/product/index.js";import"../../data/variant-type/index.js";import"../../data/product/variant/index.js";import"../../data/product/variant/price/index.js";import"../../data/product-attribute/index.js";import"../../data/product/attribute-value/index.js";import{IkasProductFilter as u,IkasProductFilterValue as c}from"../../data/product-filter/index.js";import"../../data/variant-type/variant-value/index.js";import"../../data/order-transaction/index.js";import"../../data/product-option-set/index.js";import"../../data/raffle/index.js";import"../../data/product-campaing/campaign/index.js";import"../../../api/apollo.js";import"../../../api/favorite-product/index.js";import"../../../api/contact-form/index.js";import"../../../api/state/index.js";import"../../../api/product-option-set/index.js";import"../../../api/raffle/index.js";import"../../../api/back-in-stock-reminder/index.js";import"../../../api/product-campaign/index.js";import l from'../../../ext/query-string/index.js';import d from'../../../ext/lodash/debounce.js';import{Analytics as p}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasStorefrontConfig as h}from"../../../storefront/index.js";import{SortByDirectionEnum as f,SortByTypeEnum as m}from"../../../__generated__/global-types.js";var g,_,y,v=function(){function y(n,a){var c=this;if(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.pageSpecificData=null,this._recommendFor=null,this._isLoading=!1,this._fetchRequestTime=0,this.router=null,this.applyFilters=function(){return t(c,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,this.getInitial()];case 1:return t=e.sent(),[r.CATEGORY,r.BRAND,r.SEARCH].includes(this._pageType)?(t&&this.isBrowser()&&!this.isSearch&&!h.isEditor&&(null===(i=this.router)||void 0===i||i.replace("".concat(location.pathname).concat(this.filterQueryParams?"?"+this.filterQueryParams:""),void 0,{shallow:!0})),[2]):[2]}}))}))},this.getInitial=function(i,r){return t(c,void 0,void 0,(function(){var t,n,a,o,u,c,l,d,p;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,12,13,14]),n=r?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(i),this.isSearch&&!this.hasAppliedfilter?(this.data=[],this._page=1,this._minPage=1,this._count=0,this._initialized=!0,[2,!0]):(o=void 0,this.isStatic?(n=void 0,a=200,[3,10]):[3,4]);case 4:return this.isDiscounted?(n=1,a=10,[3,10]):[3,5];case 5:return this.isRecommended?(n=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,h.store.customerStore.getLastViewedProducts()];case 8:return(u=e.sent())&&u.length&&(o=u.map((function(t){return t.productId}))),[3,10];case 9:return[2];case 10:return[4,this.searchProducts(n||1,a||10,o)];case 11:return(c=e.sent())&&this._fetchRequestTime===t?(l=[],this.isStatic||this.isLastViewed?(d=this.isStatic?this._productListPropValue.productIds:h.store.customerStore._lastViewedProducts,l=(null==d?void 0:d.map((function(t){var e=c.data.find((function(e){return e.id===t.productId})),i=null==e?void 0:e.variants.find((function(e){return e.id===t.variantId}));if((null==i?void 0:i.isActive)||(i=null==e?void 0:e.variants.find((function(t){return t.isActive}))),e&&i)return new s(e,i.variantValues)})).filter((function(t){return!!t})))||[]):l=c.data.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new s(t,(e||t.variants[0]).variantValues)})),this.applyFacets(c.facets),this.data=l,this._count=c.count,this._initialized=!0,this._page=n||1,this._minPage=this.page,r||(this._infiniteScrollPage=null),this.handleListingEvent(),[2,!0]):[2];case 12:return p=e.sent(),console.log(p),[3,14];case 13:return t===this._fetchRequestTime&&(this._isLoading=!1),[7];case 14:return[2]}}))}))},this.getPrev=function(){return t(c,void 0,void 0,(function(){var t,i,r,n;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(i=e.sent())?(r=i.data.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new s(t,(e||t.variants[0]).variantValues)})),this.data=r.concat(this.data),this._count=i.count,this._minPage=t,[3,5]):[2];case 3:return n=e.sent(),console.log(n),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(c,void 0,void 0,(function(){var t,i,r;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())?(i=t.data.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new s(t,(e||t.variants[0]).variantValues)})),this.data=this.data.concat(i),this._count=t.count,this._page=this.page+1,[3,5]):[2];case 3:return r=e.sent(),console.log(r),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(i){return t(c,void 0,void 0,(function(){var t,r,n;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(i,this.limit)];case 2:return(t=e.sent())?(r=t.data.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new s(t,(e||t.variants[0]).variantValues)})),this.data=r,this._count=t.count,this._page=i,this._minPage=i,[3,5]):[2];case 3:return n=e.sent(),console.log(n),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.setVisibleInfiniteScrollPage=function(t){var e;c._infiniteScrollPage!==t&&(c._infiniteScrollPage=t,h.isEditor||null===(e=c.router)||void 0===e||e.replace("".concat(location.pathname).concat(c.filterQueryParams?"?"+c.filterQueryParams:""),void 0,{shallow:!0}))},this.searchDebouncer=d((function(){c.applyFilters()}),100),this.searchAnalyticsDebouncer=d((function(){p.search(c._searchKeyword)}),1e3),this.data=n.data?n.data.map((function(t){return new s(t.product,t.selectedVariantValues)})):[],this._type=n.type||n.productListPropValue.productListType||g.ALL,this._pageType=n.pageType,this._sort=n.sort||n.productListPropValue.initialSort||_.LAST_ADDED,"A_Z"!==this.initialSort&&"Z_A"!==this.initialSort||(this._sort=_.LAST_ADDED),this._pageType===r.SEARCH&&(this._sort=_.FEATURED),this._limit=n.limit||n.productListPropValue.initialLimit||20,this._page=n.page||1,this._minPage=n.minPage||null,this._count=n.count||0,this._searchKeyword=n.searchKeyword||"",this._productListPropValue=n.productListPropValue,this._filterBrandId=n.filterBrandId||null,this._filterCategoryId=n.filterCategoryId||null,this._relatedProductData=n.relatedProductData||null,this._recommendFor=n.recommendFor,this.filters=n.filters?n.filters.map((function(t){return new u(t,c)})):null,this._filterCategories=n.filterCategories?n.filterCategories.map((function(t){return new o(t)})):null,this.pageSpecificData=n.pageSpecificData||null,this.router=a,i(this),this.setPageSpecificSort(),this.isBrowser())if(this.restoreInfiniteScrollPage(),location.search&&(this.isFilterable||this._type===g.SEARCH)){var l=this.getQueryParams();this.getInitial(l,this._page>1)}else this._page>1?this.getInitial(void 0,!0):this.isLastViewed?this.getInitial():this.handleListingEvent()}return Object.defineProperty(y.prototype,"sort",{get:function(){return this._sort},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"pageType",{get:function(){return this._pageType},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"minPage",{get:function(){return this._minPage||1},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(y.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(y.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isFilterable",{get:function(){return this._type===g.ALL||this._type===g.CATEGORY},enumerable:!1,configurable:!0}),Object.defineProperty(y.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!==r.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(y.prototype,"isStatic",{get:function(){return this._type===g.STATIC},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isDiscounted",{get:function(){return this._type===g.DISCOUNTED},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isRecommended",{get:function(){return this._type===g.RECOMMENDED},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isLastViewed",{get:function(){return this._type===g.LAST_VIEWED},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isRelatedProducts",{get:function(){return this._type===g.RELATED_PRODUCTS},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isSearch",{get:function(){return this._type===g.SEARCH},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"hasPrev",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended||!this._minPage)&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"hasNext",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended)&&this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"filterQueryParams",{get:function(){var t,e,i,s,n=this,a={};if(null===(t=this.filters)||void 0===t||t.forEach((function(t){t.keyList.length&&(a[t.key]=t.keyList)})),this._searchKeyword&&(a.s=this._searchKeyword),this._infiniteScrollPage&&(a.page=this._infiniteScrollPage),this._pageType!==r.CATEGORY){var o=null===(e=this.filterCategories)||void 0===e?void 0:e.filter((function(t){return t.isSelected}));if(!!(null==o?void 0:o.length))a.c=null==o?void 0:o.map((function(t){return t.slug}));else if(this._filterCategoryId){var u=null===(s=null===(i=this.filterCategories)||void 0===i?void 0:i.find((function(t){return t.id===n._filterCategoryId})))||void 0===s?void 0:s.slug;u&&(a.c=u)}}return l.stringify(a,{arrayFormat:"comma"})},enumerable:!1,configurable:!0}),Object.defineProperty(y.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(y.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(y.prototype,"isFeaturedSortEnabled",{get:function(){var t;return(null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)===a.MANUALLY&&[g.ALL,g.CATEGORY].includes(this._type)},enumerable:!1,configurable:!0}),y.prototype.setPageSpecificSort=function(){var t;if((null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)&&[g.ALL,g.CATEGORY].includes(this._type))switch(this.pageSpecificData.orderType){case a.HIGHEST_DISCOUNT_RATIO:this._sort=_.DECRASING_DISCOUNT;break;case a.LOWEST_DISCOUNT_RATIO:this._sort=_.INCREASING_DISCOUNT;break;case a.HIGHEST_PRICE:this._sort=_.DECREASING_PRICE;break;case a.LOWEST_PRICE:this._sort=_.INCREASING_PRICE;break;case a.NEWEST:this._sort=_.LAST_ADDED;break;case a.OLDEST:this._sort=_.FIRST_ADDED;break;case a.MANUALLY:this._sort=_.FEATURED}},y.prototype.getSortParams=function(){var t=f.DESC,e=m.CREATED_AT;switch(this._sort){case _.INCREASING_PRICE:t=f.ASC,e=m.PRICE;break;case _.DECREASING_PRICE:t=f.DESC,e=m.PRICE;break;case _.FIRST_ADDED:t=f.ASC,e=m.CREATED_AT;break;case _.LAST_ADDED:t=f.DESC,e=m.CREATED_AT;break;case _.INCREASING_DISCOUNT:t=f.ASC,e=m.DISCOUNT_RATIO;break;case _.DECRASING_DISCOUNT:t=f.DESC,e=m.DISCOUNT_RATIO;break;case _.FEATURED:if(this.isSearch)return;t=f.ASC,e=m.MANUAL_SORT}return{direction:t,type:e}},y.prototype.searchProducts=function(i,s,a){var o,u,l;return t(this,void 0,void 0,(function(){var t,d,p,f;return e(this,(function(e){switch(e.label){case 0:return t=[],d=[],null===(o=this.filters)||void 0===o||o.forEach((function(e){e.valueList.length&&t.push(new c({id:e.id,type:e.type,displayType:e.displayType,valueList:e.valueList})),e.isFacetFilter&&d.push({id:e.id,type:e.type,displayType:e.displayType})})),p=null===(u=this._filterCategories)||void 0===u?void 0:u.filter((function(t){return t.isSelected})).map((function(t){return t.id})),f=this.getSortParams(),this.isRelatedProducts&&this._relatedProductData?[4,n.getRelatedProducts({priceListId:h.priceListId,salesChannelId:h.salesChannelId,productId:this._relatedProductData.productId,brandIds:this._relatedProductData.brandIds,categoryIds:this._relatedProductData.categoryIds})]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return[4,n.searchProducts({page:i,perPage:s,productIdList:this.isStatic?null===(l=this._productListPropValue.productIds)||void 0===l?void 0:l.map((function(t){return t.productId})):a,filterList:t,facetList:d,brandId:this._pageType===r.BRAND&&this._type!==g.SEARCH?this._filterBrandId:void 0,categoryIdList:p&&p.length?p:this._filterCategoryId?[this._filterCategoryId]:void 0,priceListId:h.priceListId,salesChannelId:h.salesChannelId,query:this._searchKeyword,order:this._type===g.SEARCH?null:f?[f]:null},!0)]}}))}))},y.prototype.getFilters=function(){var i;return t(this,void 0,void 0,(function(){var t,s,a=this;return e(this,(function(e){switch(e.label){case 0:return[4,n.getProductFilterData(this._filterCategoryId?this._filterCategoryId:void 0)];case 1:return t=e.sent(),this.filters=null==t?void 0:t.filters.map((function(t){return new u(t,a)})),this._filterCategories=null==t?void 0:t.categories,this.pageType!==r.CATEGORY&&this._filterCategoryId&&(s=null===(i=this._filterCategories)||void 0===i?void 0:i.find((function(t){return t.id===a._filterCategoryId})))&&(s._isSelected=!0),this.filters&&this.filters.sort((function(t,e){return t.order>e.order?1:-1})),[2]}}))}))},y.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 s=null==t?void 0:t.get("s");if(s&&(this._searchKeyword=s),this._pageType!==r.CATEGORY){var n=null==t?void 0:t.get("c"),a=null==n?void 0:n.split(",");a&&a.length&&(null===(e=this.filterCategories)||void 0===e||e.forEach((function(t){t._isSelected=a.some((function(e){return e===t.slug}))})))}}catch(t){console.log(t)}},y.prototype.applyFacets=function(t){var e,i;null===(e=this.filters)||void 0===e||e.forEach((function(e){var i,r,s,n=null==t?void 0:t.find((function(t){return t.id===e.id}));n?null===(i=e.values)||void 0===i||i.forEach((function(t){var i=n.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})))},y.prototype.clearFilters=function(){var t,e;null===(t=this.filters)||void 0===t||t.forEach((function(t){return t.clear()})),this._searchKeyword="",this._pageType!==r.CATEGORY&&(this._filterCategoryId=void 0),null===(e=this._filterCategories)||void 0===e||e.forEach((function(t){return t._isSelected=!1})),this.applyFilters()},y.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(),[2]}}))}))},y.prototype.onFilterCategoryClick=function(i,r){var s,n;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:h.isEditor||null===(n=this.router)||void 0===n||n.push(i.href+(this.filterQueryParams?"?"+this.filterQueryParams:"")),t.label=3;case 3:return[2]}}))}))},y.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}},y.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)}},y.prototype.getQueryParams=function(){if(this.isBrowser())return new URLSearchParams(location.search)},y.prototype.isBrowser=function(){return"undefined"!=typeof window},y.prototype.waitForCustomerStoreInit=function(){return new Promise((function(t){var e=setInterval((function(){h.store.customerStore.initialized&&(clearInterval(e),t(null))}),1e3)}))},y.prototype.handleListingEvent=function(){this.searchKeyword&&this.data.length?p.viewSearchResults(this._searchKeyword,this.data):this.data.length&&this._type===g.ALL&&p.viewListing(this.data)},y}();!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"}(g||(g={})),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"}(_||(_={})),function(t){t.CATEGORY="CATEGORY",t.BRAND="BRAND"}(y||(y={}));export{v as IkasProductList,_ as IkasProductListSortType,g as IkasProductListType,y as IkasRelatedProductsType};
|
|
1
|
+
import{__awaiter as t,__generator as e}from'../../../ext/tslib/tslib.es6.js';import{makeAutoObservable as i}from"mobx";import"../../theme/theme.js";import{IkasThemePageType as r}from"../../theme/page/index.js";import"../../theme/component/prop/index.js";import"../../theme/page/component/prop-value/link.js";import"../brand-list/index.js";import"../blog-list/index.js";import"../blog-category-list/index.js";import"../category-list/index.js";import{IkasProductDetail as s}from"../product-detail/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/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"../../theme/settings/index.js";import"../../theme/custom-data/index.js";import"../../../api/blog/index.js";import"../../../api/brand/index.js";import"../../../api/cart/index.js";import"../../../api/category/index.js";import"../../../api/checkout/index.js";import"../../../api/city/index.js";import"../../../api/country/index.js";import"../../../api/customer/index.js";import"../../../api/customer-review/index.js";import"../../../api/customer-review-summary/index.js";import"../../../api/district/index.js";import"../../../api/html-meta-data/index.js";import"../../../api/merchant/index.js";import{IkasProductSearchAPI as n}from"../../../api/product-search/index.js";import"../../data/blog/index.js";import"../../data/brand/index.js";import{ModelOrder as a,IkasFilterCategory as o}from"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/customer/address/index.js";import"../../data/customer/index.js";import"../../data/customer-review/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/installment-info/index.js";import"../../data/order/index.js";import"../../data/order/line-item/index.js";import"../../../api/product-option-file/index.js";import"../../data/product/index.js";import"../../data/variant-type/index.js";import"../../data/product/variant/index.js";import"../../data/product/variant/price/index.js";import"../../data/product-attribute/index.js";import"../../data/product/attribute-value/index.js";import{IkasProductFilter as u,IkasProductFilterValue as c}from"../../data/product-filter/index.js";import"../../data/variant-type/variant-value/index.js";import"../../data/order-transaction/index.js";import"../../data/product-option-set/index.js";import"../../data/raffle/index.js";import"../../data/product-campaing/campaign/index.js";import"../../../api/apollo.js";import"../../../api/favorite-product/index.js";import"../../../api/contact-form/index.js";import"../../../api/state/index.js";import"../../../api/product-option-set/index.js";import"../../../api/raffle/index.js";import"../../../api/back-in-stock-reminder/index.js";import"../../../api/product-campaign/index.js";import l from'../../../ext/query-string/index.js';import d from'../../../ext/lodash/debounce.js';import{Analytics as p}from"../../../analytics/analytics.js";import"../../../analytics/head/index.js";import{IkasStorefrontConfig as h}from"../../../storefront/index.js";import{SortByDirectionEnum as f,SortByTypeEnum as m}from"../../../__generated__/global-types.js";var g,_,y,v=function(){function y(n,a){var c=this;if(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.pageSpecificData=null,this._recommendFor=null,this._isLoading=!1,this._fetchRequestTime=0,this.router=null,this.applyFilters=function(){return t(c,void 0,void 0,(function(){var t,i;return e(this,(function(e){switch(e.label){case 0:return[4,this.getInitial()];case 1:return t=e.sent(),[r.CATEGORY,r.BRAND,r.SEARCH].includes(this._pageType)?(t&&this.isBrowser()&&!this.isSearch&&!h.isEditor&&(null===(i=this.router)||void 0===i||i.replace("".concat(location.pathname).concat(this.filterQueryParams?"?"+this.filterQueryParams:""),void 0,{shallow:!0})),[2]):[2]}}))}))},this.getInitial=function(i,r){return t(c,void 0,void 0,(function(){var t,n,a,o,u,c,l,d,p;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,12,13,14]),n=r?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(i),this.isSearch&&!this.hasAppliedfilter?(this.data=[],this._page=1,this._minPage=1,this._count=0,this._initialized=!0,[2,!0]):(o=void 0,this.isStatic?(n=void 0,a=200,[3,10]):[3,4]);case 4:return this.isDiscounted?(n=1,a=10,[3,10]):[3,5];case 5:return this.isRecommended?(n=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,h.store.customerStore.getLastViewedProducts()];case 8:return(u=e.sent())&&u.length&&(o=u.map((function(t){return t.productId}))),[3,10];case 9:return[2];case 10:return[4,this.searchProducts(n||1,a||10,o)];case 11:return(c=e.sent())&&this._fetchRequestTime===t?(l=[],this.isStatic||this.isLastViewed?(d=this.isStatic?this._productListPropValue.productIds:h.store.customerStore._lastViewedProducts,l=(null==d?void 0:d.map((function(t){var e=c.data.find((function(e){return e.id===t.productId})),i=null==e?void 0:e.variants.find((function(e){return e.id===t.variantId}));if((null==i?void 0:i.isActive)||(i=null==e?void 0:e.variants.find((function(t){return t.isActive}))),e&&i)return new s(e,i.variantValues)})).filter((function(t){return!!t})))||[]):l=c.data.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new s(t,(e||t.variants[0]).variantValues)})),this.applyFacets(c.facets),this.data=l,this._count=c.count,this._initialized=!0,this._page=n||1,this._minPage=this.page,r||(this._infiniteScrollPage=null),this.handleListingEvent(),[2,!0]):[2];case 12:return p=e.sent(),console.log(p),[3,14];case 13:return t===this._fetchRequestTime&&(this._isLoading=!1),[7];case 14:return[2]}}))}))},this.getPrev=function(){return t(c,void 0,void 0,(function(){var t,i,r,n;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(i=e.sent())?(r=i.data.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new s(t,(e||t.variants[0]).variantValues)})),this.data=r.concat(this.data),this._count=i.count,this._minPage=t,[3,5]):[2];case 3:return n=e.sent(),console.log(n),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(c,void 0,void 0,(function(){var t,i,r;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())?(i=t.data.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new s(t,(e||t.variants[0]).variantValues)})),this.data=this.data.concat(i),this._count=t.count,this._page=this.page+1,[3,5]):[2];case 3:return r=e.sent(),console.log(r),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(i){return t(c,void 0,void 0,(function(){var t,r,n;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(i,this.limit)];case 2:return(t=e.sent())?(r=t.data.map((function(t){var e=t.variants.find((function(t){return t.isActive}));return new s(t,(e||t.variants[0]).variantValues)})),this.data=r,this._count=t.count,this._page=i,this._minPage=i,[3,5]):[2];case 3:return n=e.sent(),console.log(n),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.setVisibleInfiniteScrollPage=function(t){var e;c._infiniteScrollPage!==t&&(c._infiniteScrollPage=t,h.isEditor||null===(e=c.router)||void 0===e||e.replace("".concat(location.pathname).concat(c.filterQueryParams?"?"+c.filterQueryParams:""),void 0,{shallow:!0}))},this.searchDebouncer=d((function(){c.applyFilters()}),100),this.searchAnalyticsDebouncer=d((function(){p.search(c._searchKeyword)}),1e3),this.data=n.data?n.data.map((function(t){return new s(t.product,t.selectedVariantValues)})):[],this._type=n.type||n.productListPropValue.productListType||g.ALL,this._pageType=n.pageType,this._sort=n.sort||n.productListPropValue.initialSort||_.LAST_ADDED,"A_Z"!==this.initialSort&&"Z_A"!==this.initialSort||(this._sort=_.LAST_ADDED),this._limit=n.limit||n.productListPropValue.initialLimit||20,this._page=n.page||1,this._minPage=n.minPage||null,this._count=n.count||0,this._searchKeyword=n.searchKeyword||"",this._productListPropValue=n.productListPropValue,this._filterBrandId=n.filterBrandId||null,this._filterCategoryId=n.filterCategoryId||null,this._relatedProductData=n.relatedProductData||null,this._recommendFor=n.recommendFor,this.filters=n.filters?n.filters.map((function(t){return new u(t,c)})):null,this._filterCategories=n.filterCategories?n.filterCategories.map((function(t){return new o(t)})):null,this.pageSpecificData=n.pageSpecificData||null,this.router=a,i(this),this.setPageSpecificSort(),this.isBrowser())if(this.restoreInfiniteScrollPage(),location.search&&(this.isFilterable||this._type===g.SEARCH)){var l=this.getQueryParams();this.getInitial(l,this._page>1)}else this._page>1?this.getInitial(void 0,!0):this.isLastViewed?this.getInitial():this.handleListingEvent()}return Object.defineProperty(y.prototype,"sort",{get:function(){return this._sort},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"pageType",{get:function(){return this._pageType},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"minPage",{get:function(){return this._minPage||1},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(y.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(y.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isFilterable",{get:function(){return this._type===g.ALL||this._type===g.CATEGORY},enumerable:!1,configurable:!0}),Object.defineProperty(y.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!==r.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(y.prototype,"isStatic",{get:function(){return this._type===g.STATIC},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isDiscounted",{get:function(){return this._type===g.DISCOUNTED},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isRecommended",{get:function(){return this._type===g.RECOMMENDED},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isLastViewed",{get:function(){return this._type===g.LAST_VIEWED},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isRelatedProducts",{get:function(){return this._type===g.RELATED_PRODUCTS},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isSearch",{get:function(){return this._type===g.SEARCH},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"hasPrev",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended||!this._minPage)&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"hasNext",{get:function(){return!(this.isStatic||this.isDiscounted||this.isRecommended)&&this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),Object.defineProperty(y.prototype,"filterQueryParams",{get:function(){var t,e,i,s,n=this,a={};if(null===(t=this.filters)||void 0===t||t.forEach((function(t){t.keyList.length&&(a[t.key]=t.keyList)})),this._searchKeyword&&(a.s=this._searchKeyword),this._infiniteScrollPage&&(a.page=this._infiniteScrollPage),this._pageType!==r.CATEGORY){var o=null===(e=this.filterCategories)||void 0===e?void 0:e.filter((function(t){return t.isSelected}));if(!!(null==o?void 0:o.length))a.c=null==o?void 0:o.map((function(t){return t.slug}));else if(this._filterCategoryId){var u=null===(s=null===(i=this.filterCategories)||void 0===i?void 0:i.find((function(t){return t.id===n._filterCategoryId})))||void 0===s?void 0:s.slug;u&&(a.c=u)}}return l.stringify(a,{arrayFormat:"comma"})},enumerable:!1,configurable:!0}),Object.defineProperty(y.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(y.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(y.prototype,"isFeaturedSortEnabled",{get:function(){var t;return(null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)===a.MANUALLY&&[g.ALL,g.CATEGORY].includes(this._type)},enumerable:!1,configurable:!0}),y.prototype.setPageSpecificSort=function(){var t;if((null===(t=this.pageSpecificData)||void 0===t?void 0:t.orderType)&&[g.ALL,g.CATEGORY].includes(this._type))switch(this.pageSpecificData.orderType){case a.HIGHEST_DISCOUNT_RATIO:this._sort=_.DECRASING_DISCOUNT;break;case a.LOWEST_DISCOUNT_RATIO:this._sort=_.INCREASING_DISCOUNT;break;case a.HIGHEST_PRICE:this._sort=_.DECREASING_PRICE;break;case a.LOWEST_PRICE:this._sort=_.INCREASING_PRICE;break;case a.NEWEST:this._sort=_.LAST_ADDED;break;case a.OLDEST:this._sort=_.FIRST_ADDED;break;case a.MANUALLY:this._sort=_.FEATURED}},y.prototype.getSortParams=function(){var t=f.DESC,e=m.CREATED_AT;switch(this._sort){case _.INCREASING_PRICE:t=f.ASC,e=m.PRICE;break;case _.DECREASING_PRICE:t=f.DESC,e=m.PRICE;break;case _.FIRST_ADDED:t=f.ASC,e=m.CREATED_AT;break;case _.LAST_ADDED:t=f.DESC,e=m.CREATED_AT;break;case _.INCREASING_DISCOUNT:t=f.ASC,e=m.DISCOUNT_RATIO;break;case _.DECRASING_DISCOUNT:t=f.DESC,e=m.DISCOUNT_RATIO;break;case _.FEATURED:if(this.isSearch)return;t=f.ASC,e=m.MANUAL_SORT}return{direction:t,type:e}},y.prototype.searchProducts=function(i,s,a){var o,u,l;return t(this,void 0,void 0,(function(){var t,d,p,f;return e(this,(function(e){switch(e.label){case 0:return t=[],d=[],null===(o=this.filters)||void 0===o||o.forEach((function(e){e.valueList.length&&t.push(new c({id:e.id,type:e.type,displayType:e.displayType,valueList:e.valueList})),e.isFacetFilter&&d.push({id:e.id,type:e.type,displayType:e.displayType})})),p=null===(u=this._filterCategories)||void 0===u?void 0:u.filter((function(t){return t.isSelected})).map((function(t){return t.id})),f=this.getSortParams(),this.isRelatedProducts&&this._relatedProductData?[4,n.getRelatedProducts({priceListId:h.priceListId,salesChannelId:h.salesChannelId,productId:this._relatedProductData.productId,brandIds:this._relatedProductData.brandIds,categoryIds:this._relatedProductData.categoryIds})]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return[4,n.searchProducts({page:i,perPage:s,productIdList:this.isStatic?null===(l=this._productListPropValue.productIds)||void 0===l?void 0:l.map((function(t){return t.productId})):a,filterList:t,facetList:d,brandId:this._pageType===r.BRAND&&this._type!==g.SEARCH?this._filterBrandId:void 0,categoryIdList:p&&p.length?p:this._filterCategoryId?[this._filterCategoryId]:void 0,priceListId:h.priceListId,salesChannelId:h.salesChannelId,query:this._searchKeyword,order:this._type===g.SEARCH?null:f?[f]:null},!0)]}}))}))},y.prototype.getFilters=function(){var i;return t(this,void 0,void 0,(function(){var t,s,a=this;return e(this,(function(e){switch(e.label){case 0:return[4,n.getProductFilterData(this._filterCategoryId?this._filterCategoryId:void 0)];case 1:return t=e.sent(),this.filters=null==t?void 0:t.filters.map((function(t){return new u(t,a)})),this._filterCategories=null==t?void 0:t.categories,this.pageType!==r.CATEGORY&&this._filterCategoryId&&(s=null===(i=this._filterCategories)||void 0===i?void 0:i.find((function(t){return t.id===a._filterCategoryId})))&&(s._isSelected=!0),this.filters&&this.filters.sort((function(t,e){return t.order>e.order?1:-1})),[2]}}))}))},y.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 s=null==t?void 0:t.get("s");if(s&&(this._searchKeyword=s),this._pageType!==r.CATEGORY){var n=null==t?void 0:t.get("c"),a=null==n?void 0:n.split(",");a&&a.length&&(null===(e=this.filterCategories)||void 0===e||e.forEach((function(t){t._isSelected=a.some((function(e){return e===t.slug}))})))}}catch(t){console.log(t)}},y.prototype.applyFacets=function(t){var e,i;null===(e=this.filters)||void 0===e||e.forEach((function(e){var i,r,s,n=null==t?void 0:t.find((function(t){return t.id===e.id}));n?null===(i=e.values)||void 0===i||i.forEach((function(t){var i=n.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})))},y.prototype.clearFilters=function(){var t,e;null===(t=this.filters)||void 0===t||t.forEach((function(t){return t.clear()})),this._searchKeyword="",this._pageType!==r.CATEGORY&&(this._filterCategoryId=void 0),null===(e=this._filterCategories)||void 0===e||e.forEach((function(t){return t._isSelected=!1})),this.applyFilters()},y.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(),[2]}}))}))},y.prototype.onFilterCategoryClick=function(i,r){var s,n;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:h.isEditor||null===(n=this.router)||void 0===n||n.push(i.href+(this.filterQueryParams?"?"+this.filterQueryParams:"")),t.label=3;case 3:return[2]}}))}))},y.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}},y.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)}},y.prototype.getQueryParams=function(){if(this.isBrowser())return new URLSearchParams(location.search)},y.prototype.isBrowser=function(){return"undefined"!=typeof window},y.prototype.waitForCustomerStoreInit=function(){return new Promise((function(t){var e=setInterval((function(){h.store.customerStore.initialized&&(clearInterval(e),t(null))}),1e3)}))},y.prototype.handleListingEvent=function(){this.searchKeyword&&this.data.length?p.viewSearchResults(this._searchKeyword,this.data):this.data.length&&this._type===g.ALL&&p.viewListing(this.data)},y}();!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"}(g||(g={})),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"}(_||(_={})),function(t){t.CATEGORY="CATEGORY",t.BRAND="BRAND"}(y||(y={}));export{v as IkasProductList,_ as IkasProductListSortType,g as IkasProductListType,y as IkasRelatedProductsType};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t}from'../../../../ext/tslib/tslib.es6.js';import{makeObservable as r,computed as a,observable as i,action as s}from"mobx";import{Validator as n}from"../index.js";import{RequiredRule as o,EmailRule as l,PhoneRule as u,MinRule as m,MaxRule as
|
|
1
|
+
import{__awaiter as e,__generator as t}from'../../../../ext/tslib/tslib.es6.js';import{makeObservable as r,computed as a,observable as i,action as s}from"mobx";import{Validator as n}from"../index.js";import{RequiredRule as o,EmailRule as l,PhoneRule as u,MinRule as m,MaxRule as d,IdentityNumberRule as f}from"../rules/index.js";import{IkasRaffleParticipant as h,IkasRaffleAppliedProduct as c}from"../../../data/raffle/index.js";import{IkasStorefrontConfig as b}from"../../../../storefront/index.js";import{IkasRaffleAPI as p}from"../../../../api/raffle/index.js";var g=function(){function g(e){var t,h,c,p=this;this.model={firstName:(null===(t=b.store.customerStore.customer)||void 0===t?void 0:t.firstName)||"",lastName:(null===(h=b.store.customerStore.customer)||void 0===h?void 0:h.lastName)||"",email:(null===(c=b.store.customerStore.customer)||void 0===c?void 0:c.email)||"",extraData:{birthYear:null,identityNumber:null},phone:""},this.onFirstNameChange=function(e){p.firstName=e},this.onLastNameChange=function(e){p.lastName=e},this.onEmailChange=function(e){p.email=e},this.onBirthYearChange=function(e){p.birthYear=e},this.onIdentityNumberChange=function(e){p.identityNumber=e},this.onPhoneChange=function(e){p.phone=e},r(this,{emailErrorMessage:a,firstNameErrorMessage:a,lastNameErrorMessage:a,birthYearErrorMessage:a,identityNumberErrorMessage:a,hasValidatorError:a,results:a,redirect:a,model:i,validateAll:s}),this.raffle=e.raffle,this.validator=new n(this.model,[new o({fieldKey:"firstName",valuePath:"firstName",message:e.message.requiredRule}),new o({fieldKey:"lastName",valuePath:"lastName",message:e.message.requiredRule}),new o({fieldKey:"email",valuePath:"email",message:e.message.requiredRule}),new o({fieldKey:"birthYear",valuePath:"extraData.birthYear",message:e.message.requiredRule}),new o({fieldKey:"identityNumber",valuePath:"extraData.identityNumber",message:e.message.requiredRule}),new l({fieldKey:"email",valuePath:"email",message:e.message.emailRule}),new u({fieldKey:"phone",valuePath:"phone",message:e.message.phoneRule}),new m({fieldKey:"birthYear",valuePath:"extraData.birthYear",message:e.message.birthdayRule,minValue:1e3}),new d({fieldKey:"birthYear",valuePath:"extraData.birthYear",message:e.message.birthdayRule,maxValue:9999}),new f({fieldKey:"identityNumber",valuePath:"extraData.identityNumber",message:e.message.identityNumberRule})])}return Object.defineProperty(g.prototype,"firstName",{get:function(){return this.model.firstName},set:function(e){this.model.firstName=e},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"lastName",{get:function(){return this.model.lastName},set:function(e){this.model.lastName=e},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"email",{get:function(){return this.model.email},set:function(e){this.model.email=e},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"birthYear",{get:function(){return this.model.extraData.birthYear},set:function(e){this.model.extraData.birthYear=e},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"identityNumber",{get:function(){return this.model.extraData.identityNumber},set:function(e){this.model.extraData.identityNumber=e},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"phone",{get:function(){return this.model.phone},set:function(e){this.model.phone=e},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"firstNameErrorMessage",{get:function(){return this.validator.results.firstName.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"lastNameErrorMessage",{get:function(){return this.validator.results.lastName.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"emailErrorMessage",{get:function(){return this.validator.results.email.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"birthYearErrorMessage",{get:function(){return this.validator.results.birthYear.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"identityNumberErrorMessage",{get:function(){return this.validator.results.identityNumber.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"phoneErrorMessage",{get:function(){return this.validator.results.phone.errorMessage},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"redirect",{get:function(){if("undefined"!=typeof window)return new URLSearchParams(window.location.search).get("redirect")},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"hasValidatorError",{get:function(){var e;return this.validator.hasError||!(null===(e=this.raffle.variants)||void 0===e?void 0:e.length)},enumerable:!1,configurable:!0}),Object.defineProperty(g.prototype,"results",{get:function(){return this.validator.results},enumerable:!1,configurable:!0}),g.prototype.validateAll=function(){return this.validator.validateAll()},g.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},[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,p.saveRaffleParticipant(new h({appliedProduct:new c({productId:this.raffle.products[0].selectedVariant.productId,variantId:this.raffle.products[0].selectedVariant.id}),email:this.email,firstName:this.firstName,lastName:this.lastName,raffleId:this.raffle.id,extraData:{birthYear:this.birthYear,identityNumber:this.identityNumber},phone:this.phone}))];case 3:return t.sent()&&(e.isSuccess=!0),[2,e];case 4:return t.sent(),[2,e];case 5:return[2]}}))}))},g}();export{g as RaffleForm};
|
|
@@ -33,6 +33,8 @@ export declare class IkasPageDataProvider {
|
|
|
33
33
|
paymentGateways: any;
|
|
34
34
|
gtmId: string | null;
|
|
35
35
|
fbpId: string | null;
|
|
36
|
+
analytics4Id: string | null;
|
|
37
|
+
universalAnalyticsId: string | null;
|
|
36
38
|
favicon: any;
|
|
37
39
|
stockPreference: import("../models/theme/settings").IkasThemeStockPreference;
|
|
38
40
|
storefrontJSScripts: string[];
|
|
@@ -38,6 +38,8 @@ export declare class IkasNextPageDataProvider {
|
|
|
38
38
|
paymentGateways: any;
|
|
39
39
|
gtmId: string | null;
|
|
40
40
|
fbpId: string | null;
|
|
41
|
+
analytics4Id: string | null;
|
|
42
|
+
universalAnalyticsId: string | null;
|
|
41
43
|
favicon: any;
|
|
42
44
|
stockPreference: IkasThemeStockPreference;
|
|
43
45
|
storefrontJSScripts: string[];
|
|
@@ -69,6 +71,8 @@ export declare class IkasNextPageDataProvider {
|
|
|
69
71
|
paymentGateways: any;
|
|
70
72
|
gtmId: string | null;
|
|
71
73
|
fbpId: string | null;
|
|
74
|
+
analytics4Id: string | null;
|
|
75
|
+
universalAnalyticsId: string | null;
|
|
72
76
|
favicon: any;
|
|
73
77
|
stockPreference: IkasThemeStockPreference;
|
|
74
78
|
storefrontJSScripts: string[];
|
|
@@ -109,6 +113,8 @@ export declare class IkasNextPageDataProvider {
|
|
|
109
113
|
paymentGateways: any;
|
|
110
114
|
gtmId: string | null;
|
|
111
115
|
fbpId: string | null;
|
|
116
|
+
analytics4Id: string | null;
|
|
117
|
+
universalAnalyticsId: string | null;
|
|
112
118
|
favicon: any;
|
|
113
119
|
stockPreference: IkasThemeStockPreference;
|
|
114
120
|
storefrontJSScripts: string[];
|
|
@@ -140,6 +146,8 @@ export declare class IkasNextPageDataProvider {
|
|
|
140
146
|
paymentGateways: any;
|
|
141
147
|
gtmId: string | null;
|
|
142
148
|
fbpId: string | null;
|
|
149
|
+
analytics4Id: string | null;
|
|
150
|
+
universalAnalyticsId: string | null;
|
|
143
151
|
favicon: any;
|
|
144
152
|
stockPreference: IkasThemeStockPreference;
|
|
145
153
|
storefrontJSScripts: string[];
|
|
@@ -180,6 +188,8 @@ export declare class IkasNextPageDataProvider {
|
|
|
180
188
|
paymentGateways: any;
|
|
181
189
|
gtmId: string | null;
|
|
182
190
|
fbpId: string | null;
|
|
191
|
+
analytics4Id: string | null;
|
|
192
|
+
universalAnalyticsId: string | null;
|
|
183
193
|
favicon: any;
|
|
184
194
|
stockPreference: IkasThemeStockPreference;
|
|
185
195
|
storefrontJSScripts: string[];
|
|
@@ -211,6 +221,8 @@ export declare class IkasNextPageDataProvider {
|
|
|
211
221
|
paymentGateways: any;
|
|
212
222
|
gtmId: string | null;
|
|
213
223
|
fbpId: string | null;
|
|
224
|
+
analytics4Id: string | null;
|
|
225
|
+
universalAnalyticsId: string | null;
|
|
214
226
|
favicon: any;
|
|
215
227
|
stockPreference: IkasThemeStockPreference;
|
|
216
228
|
storefrontJSScripts: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__assign as o,__spreadArray as r}from'../ext/tslib/tslib.es6.js';import i from"fs";import n from"next/config.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/index.js";import"../models/data/customer-review/index.js";import"mobx";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/installment-info/index.js";import"../models/data/order/index.js";import"../models/data/order/line-item/index.js";import"../api/product-option-file/index.js";import"../models/data/product/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/variant/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product-filter/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/data/order-transaction/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/product-campaing/campaign/index.js";import{IkasTheme as s}from"../models/theme/theme.js";import{IkasThemePageType as a}from"../models/theme/page/index.js";import"../models/theme/component/prop/index.js";import"../models/theme/page/component/prop-value/link.js";import"../models/ui/brand-list/index.js";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-detail/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import"../models/theme/settings/index.js";import"../models/theme/custom-data/index.js";import{IkasStorefront as d}from"../models/data/storefront/index.js";import{IkasSalesChannel as l}from"../models/data/sales-channel/index.js";import{IkasStorefrontRouting as m}from"../models/data/storefront/routing/index.js";import{IkasStorefrontConfig as c}from"../storefront/index.js";import{IkasPageDataProvider as p}from"./page-data-get.js";import{IkasStorefrontThemeLocalization as u}from"../models/data/storefront/theme-localization/index.js";import{IkasStorefrontAPI as f}from"../api/storefront/index.js";import{I18NFileReader as g}from"../utils/i18n.js";import"../api/blog/index.js";import"../api/brand/index.js";import"../api/cart/index.js";import"../api/category/index.js";import{IkasCheckoutAPI as j}from"../api/checkout/index.js";import"../api/city/index.js";import"../api/country/index.js";import"../api/customer/index.js";import"../api/customer-review/index.js";import"../api/customer-review-summary/index.js";import"../api/district/index.js";import"../api/html-meta-data/index.js";import"../api/merchant/index.js";import"../api/product-search/index.js";import"../api/apollo.js";import"../api/favorite-product/index.js";import"../api/contact-form/index.js";import"../api/state/index.js";import"../api/product-option-set/index.js";import"../api/raffle/index.js";import"../api/back-in-stock-reminder/index.js";import"../api/product-campaign/index.js";import{getGoogleFontHref as x}from"../utils/google-fonts.js";var h=function(){function h(){}return h.readLocalTheme=function(){return new Promise((function(e,t){i.readFile("./src/theme.json",{flag:"a+"},(function(o,r){if(o)return t(o);var i=r.length?JSON.parse(r.toString()):{};e(new s(i))}))}))},h.readSettingsFile=function(){return new Promise((function(e){var t=n().serverRuntimeConfig.SETTINGS;i.readFile(t,{flag:"a+"},(function(t,o){if(t)return console.error("SETTINGS FILE READ ERROR!!!"),console.error(t),e(null);var r=o.length?JSON.parse(o.toString()):{};e(r)}))}))},h.getSettings=function(o){var r=this;return new Promise((function(n){return e(r,void 0,void 0,(function(){var e,r,s,a,p,g,j,x,v,S,C,y,b,I,w,k;return t(this,(function(t){switch(t.label){case 0:return"local"===process.env.NEXT_PUBLIC_ENV?c.storefrontId?[4,f.getStorefront(c.storefrontId)]:(console.error("Missing storefrontId in the config.json file!"),[2,n(null)]):[3,3];case 1:return(e=t.sent())?(r=e,[4,h.readLocalTheme()]):[2,n(null)];case 2:return s=t.sent(),a=h.createColorScript(s.settings),p=h.createFontScript(s.settings),g=[],a&&g.push(a),p&&g.push(p),n({storefront:r,themeLocalization:new u({themeJson:s}),salesChannel:new l({id:r.salesChannelId}),routing:r.routings.length?r.routings.find((function(e){return e.locale===o||e.id===o}))||r.routings[0]:new m({}),favicon:s.settings.favicon,stockPreference:s.settings.stockPreference,storefrontJSScripts:g,domain:"",productBackInStockSettings:{customerLoginRequired:!0},customerReviewSettings:{customerLoginRequired:!0,customerPurchaseRequired:!1}}),[3,5];case 3:return[4,h.readSettingsFile()];case 4:if(!(j=t.sent())||!j.localizationMap)return[2,n(null)];if(x=new d(j.storefront),v=new l(j.salesChannel),S=j.localizationMap,C=j.storefrontJSScripts||[],y=j.domain,b=j.productBackInStockSettings?{customerLoginRequired:j.productBackInStockSettings.customerLoginRequired}:null,I=j.customerReviewSettings?{customerLoginRequired:j.customerReviewSettings.customerLoginRequired||!1,customerPurchaseRequired:j.customerReviewSettings.customerPurchaseRequired||!1}:null,w=S[o],k=x.routings.find((function(e){return e.id===o||e.path===o})),!w||!k)return console.error("THEME LOCALIZATION PATH OR ROUTING MISSING!!!"),[2,n(null)];i.readFile(w,{flag:"a+"},(function(e,t){if(e)return console.error("THEME LOCALZIATION FILE READ ERROR!!!"),console.error(e),n(null);var o=t.length?JSON.parse(t.toString()):{},r=new u(o),i=r.themeJson.settings.favicon,s=r.themeJson.settings.stockPreference;if(r.themeJson.settings){var a=h.createColorScript(r.themeJson.settings),d=h.createFontScript(r.themeJson.settings);a&&C.push(a),d&&C.push(d)}n({storefront:x,themeLocalization:r,salesChannel:v,routing:k,favicon:i,stockPreference:s,storefrontJSScripts:C,domain:y,productBackInStockSettings:b,customerReviewSettings:I})})),t.label=5;case 5:return[2]}}))}))}))},h.getPageData=function(i,s,d,l,m){var u,f;return e(this,void 0,void 0,(function(){var e,x,v,S,C,y,b,I,w,k,P,R,L,T,B,E,V,J,F,O,N,D,q,A,z,M;return t(this,(function(t){switch(t.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,x=!e&&m,v=n().serverRuntimeConfig,x?[3,7]:(S=i.locale)?[4,h.getSettings(S)]:[2,{props:{},notFound:!0}];case 1:return(C=t.sent())&&C.storefront.mainStorefrontThemeId&&C.storefront.salesChannelId?(y=C.storefront,b=C.themeLocalization,I=C.salesChannel,w=C.routing,k=C.favicon,P=C.stockPreference,R=C.storefrontJSScripts,L=C.domain,T=C.productBackInStockSettings,B=C.customerReviewSettings,c.storefrontId=y.id,c.storefrontRoutingId=w.id,c.storefrontThemeId=y.mainStorefrontThemeId,c.salesChannelId=y.salesChannelId,c.priceListId=w.priceListId||void 0,c.stockLocationIds=null===(u=I.stockLocations)||void 0===u?void 0:u.map((function(e){return e.id})),c.routings=y.routings,c.paymentGateways=I.paymentGateways||[],c.gtmId=y.gtmId||void 0,c.fbpId=y.fbpId||void 0,c.favicon=k||null,c.stockPreference=P||null,c.storefrontJSScripts=R||[],c.domain=L,c.productBackInStockSettings=T,c.customerReviewSettings=B,(E=new p(b.themeJson,i.params,d)).possiblePageTypes=l||(d?[d]:[]),m?[3,3]:[4,E.getPageData()]):[2,{props:{},notFound:!0}];case 2:if(t.sent(),!E.page)return[2,{props:{},notFound:!0}];t.label=3;case 3:return V=m?E.theme.components.map((function(e){return e.id})):E.page.components.map((function(e){return e.componentId})),J=b.themeJson.components.filter((function(e){return m||V.includes(e.id)})),F=r(["common"],J.map((function(e){return e.dir})),!0),(d===a.CHECKOUT||m)&&F.push("checkout-page"),O=v.nextI18nConf,N=w.locale,[4,new g(N,F,e?void 0:O.localePath).read()];case 4:return D=t.sent(),c.translations=D,q={},d!==a.CHECKOUT?[3,6]:(A=null===(f=E.page)||void 0===f?void 0:f.components[0])?[4,j.listCheckoutSettings()]:[3,6];case 5:z=t.sent(),M={buttonBgColor:A.propValues.buttonBgColor,buttonTextColor:A.propValues.buttonTextColor,buttonDisabledBgColor:A.propValues.buttonDisabledBgColor,buttonDisabledTextColor:A.propValues.buttonDisabledTextColor,primaryTextColor:A.propValues.primaryTextColor,secondaryTextColor:A.propValues.secondaryTextColor,primaryBgColor:A.propValues.primaryBgColor,secondaryBgColor:A.propValues.secondaryBgColor,borderColor:A.propValues.borderColor,cardBgColor:A.propValues.cardBgColor,errorColor:A.propValues.errorColor,errorLightColor:A.propValues.errorLightColor,warningColor:A.propValues.warningColor,warningLightColor:A.propValues.warningLightColor,successColor:A.propValues.successColor,successLightColor:A.propValues.successLightColor},q.customizationProps=M,q.returnPolicy=b.returnPolicy,q.privacyPolicy=b.privacyPolicy,q.termsOfService=b.termsOfService,q.checkoutSettingsStr=(null==z?void 0:z.length)?JSON.stringify(z[0]):null,t.label=6;case 6:return s?[2,{props:o(o({},E.nextPageData.props),q)}]:[2,{props:o(o({},E.nextPageData.props),q),revalidate:60}];case 7:return[2,{props:{}}];case 8:return[2]}}))}))},h.getStaticProps=function(o,r,i,n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,h.getPageData(o,!1,r,i,n)];case 1:return[2,e.sent()]}}))}))},h.getServerSideProps=function(o,r){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,h.getPageData(o,!0,r)];case 1:return[2,e.sent()]}}))}))},h.createColorScript=function(e){if(e.colors)return"<script>".concat(e.colors.map((function(e){return'document.documentElement.style.setProperty("'.concat(e.key,'","').concat(e.color,'");')})).join("\r\n"),"<\/script> \n ")},h.createFontScript=function(e){var t=x(e.fontFamily);if(t)return'<link id="ikas-font" rel="stylesheet" href="'.concat(t,"\"> \n <style>\n body { \n font-family: '").concat(e.fontFamily.name,'\', -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;\n } \n </style>')},h}();export{h as IkasNextPageDataProvider};
|
|
1
|
+
import{__awaiter as e,__generator as t,__assign as o,__spreadArray as r}from'../ext/tslib/tslib.es6.js';import i from"fs";import n from"next/config.js";import"../models/data/blog/index.js";import"../models/data/brand/index.js";import"../models/data/category/index.js";import"../models/data/checkout/index.js";import"../models/data/customer/address/index.js";import"../models/data/customer/index.js";import"../models/data/customer-review/index.js";import"mobx";import"../models/data/html-meta-data/index.js";import"../models/data/image/index.js";import"../models/data/installment-info/index.js";import"../models/data/order/index.js";import"../models/data/order/line-item/index.js";import"../api/product-option-file/index.js";import"../models/data/product/index.js";import"../models/data/variant-type/index.js";import"../models/data/product/variant/index.js";import"../models/data/product/variant/price/index.js";import"../models/data/product-attribute/index.js";import"../models/data/product/attribute-value/index.js";import"../models/data/product-filter/index.js";import"../models/data/variant-type/variant-value/index.js";import"../models/data/order-transaction/index.js";import"../models/data/product-option-set/index.js";import"../models/data/raffle/index.js";import"../models/data/product-campaing/campaign/index.js";import{IkasTheme as s}from"../models/theme/theme.js";import{IkasThemePageType as a}from"../models/theme/page/index.js";import"../models/theme/component/prop/index.js";import"../models/theme/page/component/prop-value/link.js";import"../models/ui/brand-list/index.js";import"../models/ui/blog-list/index.js";import"../models/ui/blog-category-list/index.js";import"../models/ui/category-list/index.js";import"../models/ui/product-detail/index.js";import"../models/ui/product-list/index.js";import"../models/ui/product-attribute-detail/index.js";import"../models/ui/product-attribute-list/index.js";import"../models/ui/customer-review-list/index.js";import"../models/ui/customer-review-summary-list/index.js";import"../models/ui/validator/index.js";import"../models/ui/validator/rules/index.js";import"../models/ui/validator/form/login.js";import"../models/ui/validator/form/address.js";import"../models/ui/validator/form/register.js";import"../models/ui/validator/form/contact-form.js";import"../models/ui/validator/form/forgot-password.js";import"../models/ui/validator/form/recover-password.js";import"../models/ui/validator/form/account-info.js";import"../models/ui/validator/form/raffle-form.js";import"../models/ui/validator/form/customer-review.js";import"../models/ui/raffle-list/index.js";import"../models/theme/settings/index.js";import"../models/theme/custom-data/index.js";import{IkasStorefront as d}from"../models/data/storefront/index.js";import{IkasSalesChannel as l}from"../models/data/sales-channel/index.js";import{IkasStorefrontRouting as m}from"../models/data/storefront/routing/index.js";import{IkasStorefrontConfig as c}from"../storefront/index.js";import{IkasPageDataProvider as p}from"./page-data-get.js";import{IkasStorefrontThemeLocalization as u}from"../models/data/storefront/theme-localization/index.js";import{IkasStorefrontAPI as f}from"../api/storefront/index.js";import{I18NFileReader as g}from"../utils/i18n.js";import"../api/blog/index.js";import"../api/brand/index.js";import"../api/cart/index.js";import"../api/category/index.js";import{IkasCheckoutAPI as j}from"../api/checkout/index.js";import"../api/city/index.js";import"../api/country/index.js";import"../api/customer/index.js";import"../api/customer-review/index.js";import"../api/customer-review-summary/index.js";import"../api/district/index.js";import"../api/html-meta-data/index.js";import"../api/merchant/index.js";import"../api/product-search/index.js";import"../api/apollo.js";import"../api/favorite-product/index.js";import"../api/contact-form/index.js";import"../api/state/index.js";import"../api/product-option-set/index.js";import"../api/raffle/index.js";import"../api/back-in-stock-reminder/index.js";import"../api/product-campaign/index.js";import{getGoogleFontHref as v}from"../utils/google-fonts.js";var x=function(){function x(){}return x.readLocalTheme=function(){return new Promise((function(e,t){i.readFile("./src/theme.json",{flag:"a+"},(function(o,r){if(o)return t(o);var i=r.length?JSON.parse(r.toString()):{};e(new s(i))}))}))},x.readSettingsFile=function(){return new Promise((function(e){var t=n().serverRuntimeConfig.SETTINGS;i.readFile(t,{flag:"a+"},(function(t,o){if(t)return console.error("SETTINGS FILE READ ERROR!!!"),console.error(t),e(null);var r=o.length?JSON.parse(o.toString()):{};e(r)}))}))},x.getSettings=function(o){var r=this;return new Promise((function(n){return e(r,void 0,void 0,(function(){var e,r,s,a,p,g,j,v,h,S,C,y,I,b,w,k;return t(this,(function(t){switch(t.label){case 0:return"local"===process.env.NEXT_PUBLIC_ENV?c.storefrontId?[4,f.getStorefront(c.storefrontId)]:(console.error("Missing storefrontId in the config.json file!"),[2,n(null)]):[3,3];case 1:return(e=t.sent())?(r=e,[4,x.readLocalTheme()]):[2,n(null)];case 2:return s=t.sent(),a=x.createColorScript(s.settings),p=x.createFontScript(s.settings),g=[],a&&g.push(a),p&&g.push(p),n({storefront:r,themeLocalization:new u({themeJson:s}),salesChannel:new l({id:r.salesChannelId}),routing:r.routings.length?r.routings.find((function(e){return e.locale===o||e.id===o}))||r.routings[0]:new m({}),favicon:s.settings.favicon,stockPreference:s.settings.stockPreference,storefrontJSScripts:g,domain:"",productBackInStockSettings:{customerLoginRequired:!0},customerReviewSettings:{customerLoginRequired:!0,customerPurchaseRequired:!1}}),[3,5];case 3:return[4,x.readSettingsFile()];case 4:if(!(j=t.sent())||!j.localizationMap)return[2,n(null)];if(v=new d(j.storefront),h=new l(j.salesChannel),S=j.localizationMap,C=j.storefrontJSScripts||[],y=j.domain,I=j.productBackInStockSettings?{customerLoginRequired:j.productBackInStockSettings.customerLoginRequired}:null,b=j.customerReviewSettings?{customerLoginRequired:j.customerReviewSettings.customerLoginRequired||!1,customerPurchaseRequired:j.customerReviewSettings.customerPurchaseRequired||!1}:null,w=S[o],k=v.routings.find((function(e){return e.id===o||e.path===o})),!w||!k)return console.error("THEME LOCALIZATION PATH OR ROUTING MISSING!!!"),[2,n(null)];i.readFile(w,{flag:"a+"},(function(e,t){if(e)return console.error("THEME LOCALZIATION FILE READ ERROR!!!"),console.error(e),n(null);var o=t.length?JSON.parse(t.toString()):{},r=new u(o),i=r.themeJson.settings.favicon,s=r.themeJson.settings.stockPreference;if(r.themeJson.settings){var a=x.createColorScript(r.themeJson.settings),d=x.createFontScript(r.themeJson.settings);a&&C.push(a),d&&C.push(d)}n({storefront:v,themeLocalization:r,salesChannel:h,routing:k,favicon:i,stockPreference:s,storefrontJSScripts:C,domain:y,productBackInStockSettings:I,customerReviewSettings:b})})),t.label=5;case 5:return[2]}}))}))}))},x.getPageData=function(i,s,d,l,m){var u,f;return e(this,void 0,void 0,(function(){var e,v,h,S,C,y,I,b,w,k,P,R,L,T,B,E,V,J,F,O,N,D,A,q,z,M;return t(this,(function(t){switch(t.label){case 0:return e="local"===process.env.NEXT_PUBLIC_ENV,v=!e&&m,h=n().serverRuntimeConfig,v?[3,7]:(S=i.locale)?[4,x.getSettings(S)]:[2,{props:{},notFound:!0}];case 1:return(C=t.sent())&&C.storefront.mainStorefrontThemeId&&C.storefront.salesChannelId?(y=C.storefront,I=C.themeLocalization,b=C.salesChannel,w=C.routing,k=C.favicon,P=C.stockPreference,R=C.storefrontJSScripts,L=C.domain,T=C.productBackInStockSettings,B=C.customerReviewSettings,c.storefrontId=y.id,c.storefrontRoutingId=w.id,c.storefrontThemeId=y.mainStorefrontThemeId,c.salesChannelId=y.salesChannelId,c.priceListId=w.priceListId||void 0,c.stockLocationIds=null===(u=b.stockLocations)||void 0===u?void 0:u.map((function(e){return e.id})),c.routings=y.routings,c.paymentGateways=b.paymentGateways||[],c.gtmId=y.gtmId||void 0,c.fbpId=y.fbpId||void 0,c.analytics4Id=y.analytics4Id||void 0,c.universalAnalyticsId=y.universalAnalyticsId||void 0,c.favicon=k||null,c.stockPreference=P||null,c.storefrontJSScripts=R||[],c.domain=L,c.productBackInStockSettings=T,c.customerReviewSettings=B,(E=new p(I.themeJson,i.params,d)).possiblePageTypes=l||(d?[d]:[]),m?[3,3]:[4,E.getPageData()]):[2,{props:{},notFound:!0}];case 2:if(t.sent(),!E.page)return[2,{props:{},notFound:!0}];t.label=3;case 3:return V=m?E.theme.components.map((function(e){return e.id})):E.page.components.map((function(e){return e.componentId})),J=I.themeJson.components.filter((function(e){return m||V.includes(e.id)})),F=r(["common"],J.map((function(e){return e.dir})),!0),(d===a.CHECKOUT||m)&&F.push("checkout-page"),O=h.nextI18nConf,N=w.locale,[4,new g(N,F,e?void 0:O.localePath).read()];case 4:return D=t.sent(),c.translations=D,A={},d!==a.CHECKOUT?[3,6]:(q=null===(f=E.page)||void 0===f?void 0:f.components[0])?[4,j.listCheckoutSettings()]:[3,6];case 5:z=t.sent(),M={buttonBgColor:q.propValues.buttonBgColor,buttonTextColor:q.propValues.buttonTextColor,buttonDisabledBgColor:q.propValues.buttonDisabledBgColor,buttonDisabledTextColor:q.propValues.buttonDisabledTextColor,primaryTextColor:q.propValues.primaryTextColor,secondaryTextColor:q.propValues.secondaryTextColor,primaryBgColor:q.propValues.primaryBgColor,secondaryBgColor:q.propValues.secondaryBgColor,borderColor:q.propValues.borderColor,cardBgColor:q.propValues.cardBgColor,errorColor:q.propValues.errorColor,errorLightColor:q.propValues.errorLightColor,warningColor:q.propValues.warningColor,warningLightColor:q.propValues.warningLightColor,successColor:q.propValues.successColor,successLightColor:q.propValues.successLightColor},A.customizationProps=M,A.returnPolicy=I.returnPolicy,A.privacyPolicy=I.privacyPolicy,A.termsOfService=I.termsOfService,A.checkoutSettingsStr=(null==z?void 0:z.length)?JSON.stringify(z[0]):null,t.label=6;case 6:return s?[2,{props:o(o({},E.nextPageData.props),A)}]:[2,{props:o(o({},E.nextPageData.props),A),revalidate:60}];case 7:return[2,{props:{}}];case 8:return[2]}}))}))},x.getStaticProps=function(o,r,i,n){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,x.getPageData(o,!1,r,i,n)];case 1:return[2,e.sent()]}}))}))},x.getServerSideProps=function(o,r){return e(this,void 0,void 0,(function(){return t(this,(function(e){switch(e.label){case 0:return[4,x.getPageData(o,!0,r)];case 1:return[2,e.sent()]}}))}))},x.createColorScript=function(e){if(e.colors)return"<script>".concat(e.colors.map((function(e){return'document.documentElement.style.setProperty("'.concat(e.key,'","').concat(e.color,'");')})).join("\r\n"),"<\/script> \n ")},x.createFontScript=function(e){var t=v(e.fontFamily);if(t)return'<link id="ikas-font" rel="stylesheet" href="'.concat(t,"\"> \n <style>\n body { \n font-family: '").concat(e.fontFamily.name,'\', -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;\n } \n </style>')},x}();export{x as IkasNextPageDataProvider};
|
|
@@ -22,6 +22,8 @@ export declare class IkasStorefrontConfig {
|
|
|
22
22
|
static paymentGateways: IkasSalesChannelPaymentGateway[];
|
|
23
23
|
static gtmId?: string;
|
|
24
24
|
static fbpId?: string;
|
|
25
|
+
static analytics4Id?: string;
|
|
26
|
+
static universalAnalyticsId?: string;
|
|
25
27
|
static favicon: IkasThemeFavicon;
|
|
26
28
|
static stockPreference: IkasThemeStockPreference;
|
|
27
29
|
static translations: Record<string, any>;
|
|
@@ -46,6 +48,8 @@ export declare class IkasStorefrontConfig {
|
|
|
46
48
|
paymentGateways: any;
|
|
47
49
|
gtmId: string | null;
|
|
48
50
|
fbpId: string | null;
|
|
51
|
+
analytics4Id: string | null;
|
|
52
|
+
universalAnalyticsId: string | null;
|
|
49
53
|
favicon: any;
|
|
50
54
|
stockPreference: IkasThemeStockPreference;
|
|
51
55
|
storefrontJSScripts: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var t=function(){function t(){}return t.init=function(n,r,o){t.store=n,t.config=r,t.apiUrlOverride=o||null,"local"===process.env.NEXT_PUBLIC_ENV&&(this.storefrontId=r.storefrontId)},t.initWithJson=function(n,r){try{Object.entries(n).forEach((function(n){var r=n[0],o=n[1];t[r]=o})),t.router=r}catch(t){console.log(t)}},t.getCurrentRouting=function(){return t.routings.find((function(n){return n.id===t.storefrontRoutingId}))},t.getCurrentLocale=function(){var n=t.getCurrentRouting();return(null==n?void 0:n.locale)||"en"},t.getJson=function(){return{domain:t.domain,storefrontId:t.storefrontId||null,storefrontRoutingId:t.storefrontRoutingId||null,storefrontThemeId:t.storefrontThemeId||null,salesChannelId:t.salesChannelId||null,priceListId:t.priceListId||null,stockLocationIds:t.stockLocationIds||null,routings:JSON.parse(JSON.stringify(t.routings))||null,paymentGateways:JSON.parse(JSON.stringify(t.paymentGateways))||null,gtmId:t.gtmId||null,fbpId:t.fbpId||null,favicon:JSON.parse(JSON.stringify(t.favicon)),stockPreference:t.stockPreference||null,storefrontJSScripts:t.storefrontJSScripts||[],translations:this.translations,customerReviewSettings:t.customerReviewSettings,productBackInStockSettings:t.productBackInStockSettings?JSON.parse(JSON.stringify(t.productBackInStockSettings)):null}},t.config={},t.apiUrlOverride=null,t.routings=[],t.paymentGateways=[],t.translations={},t.storefrontJSScripts=[],t.isEditor=!1,t}();export{t as IkasStorefrontConfig};
|
|
1
|
+
var t=function(){function t(){}return t.init=function(n,r,o){t.store=n,t.config=r,t.apiUrlOverride=o||null,"local"===process.env.NEXT_PUBLIC_ENV&&(this.storefrontId=r.storefrontId)},t.initWithJson=function(n,r){try{Object.entries(n).forEach((function(n){var r=n[0],o=n[1];t[r]=o})),t.router=r}catch(t){console.log(t)}},t.getCurrentRouting=function(){return t.routings.find((function(n){return n.id===t.storefrontRoutingId}))},t.getCurrentLocale=function(){var n=t.getCurrentRouting();return(null==n?void 0:n.locale)||"en"},t.getJson=function(){return{domain:t.domain,storefrontId:t.storefrontId||null,storefrontRoutingId:t.storefrontRoutingId||null,storefrontThemeId:t.storefrontThemeId||null,salesChannelId:t.salesChannelId||null,priceListId:t.priceListId||null,stockLocationIds:t.stockLocationIds||null,routings:JSON.parse(JSON.stringify(t.routings))||null,paymentGateways:JSON.parse(JSON.stringify(t.paymentGateways))||null,gtmId:t.gtmId||null,fbpId:t.fbpId||null,analytics4Id:t.analytics4Id||null,universalAnalyticsId:t.universalAnalyticsId||null,favicon:JSON.parse(JSON.stringify(t.favicon)),stockPreference:t.stockPreference||null,storefrontJSScripts:t.storefrontJSScripts||[],translations:this.translations,customerReviewSettings:t.customerReviewSettings,productBackInStockSettings:t.productBackInStockSettings?JSON.parse(JSON.stringify(t.productBackInStockSettings)):null}},t.config={},t.apiUrlOverride=null,t.routings=[],t.paymentGateways=[],t.translations={},t.storefrontJSScripts=[],t.isEditor=!1,t}();export{t as IkasStorefrontConfig};
|