@ikas/bp-storefront 1.4.0-beta.13 → 1.4.0-beta.131
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/dist/analytics/analytics-functions/helpers.js +1 -1
- package/dist/analytics/analytics.js +1 -1
- package/dist/analytics/google-tag-manager/productView.js +1 -1
- package/dist/analytics/google-tag-manager/viewCategory.js +1 -1
- package/dist/analytics/ikas/analytics.js +1 -1
- package/dist/analytics/utils.js +1 -1
- package/dist/ext/lodash/flatten.js +1 -0
- package/dist/functions/api/cart/index.js +1 -1
- package/dist/functions/models/category/index.js +1 -1
- package/dist/functions/models/image/index.d.ts +65 -20
- package/dist/functions/models/image/index.js +1 -1
- package/dist/functions/models/product/variant/index.d.ts +72 -6
- package/dist/functions/models/product/variant/index.js +1 -1
- package/dist/functions/models/product-list/index.js +1 -1
- package/dist/functions/models/validator/account-info/index.js +1 -1
- package/dist/functions/models/validator/address/index.d.ts +70 -2
- package/dist/functions/models/validator/contact-form/index.js +1 -1
- package/dist/functions/models/validator/coupon-code-form/index.js +1 -1
- package/dist/functions/models/validator/customer-review/index.js +1 -1
- package/dist/functions/models/validator/forgot-password/index.js +1 -1
- package/dist/functions/models/validator/login/index.js +1 -1
- package/dist/functions/models/validator/newsletter-subscription/index.js +1 -1
- package/dist/functions/models/validator/order-tracking/index.js +1 -1
- package/dist/functions/models/validator/recover-password/index.js +1 -1
- package/dist/functions/models/validator/register/index.js +1 -1
- package/dist/functions/models/validator/sms-login/index.js +1 -1
- package/dist/functions/models/validator/verify-phone-number/index.js +1 -1
- package/dist/functions/stores/base/index.d.ts +38 -1
- package/dist/functions/stores/base/index.js +1 -1
- package/dist/functions/stores/cart/index.js +1 -1
- package/dist/functions/stores/customer/index.d.ts +29 -23
- package/dist/functions/stores/customer/index.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/dist/packages/storefront-config/src/index.js +1 -1
- package/dist/packages/storefront-config/src/theme-globals.js +1 -0
- package/dist/storefront-config/src/index.d.ts +4 -0
- package/dist/storefront-config/src/theme-globals.d.ts +305 -0
- package/dist/storefront-models/src/index.d.ts +1 -0
- package/dist/storefront-models/src/models/blueprint/prop-value/color.d.ts +2 -0
- package/dist/storefront-models/src/models/blueprint/prop-value/index.d.ts +2 -0
- package/dist/storefront-models/src/models/blueprint/prop-value/svg-list.d.ts +3 -0
- package/dist/storefront-models/src/models/blueprint/prop-value/svg.d.ts +3 -0
- package/dist/storefront-models/src/models/product/campaign/data/index.d.ts +2 -0
- package/dist/storefront-models/src/models/product/campaign/filter/index.d.ts +1 -1
- package/dist/storefront-models/src/models/product/campaign/product-tiered-discount/index.d.ts +13 -0
- package/dist/storefront-models/src/models/product/variant/index.d.ts +17 -0
- package/dist/theme/settings/index.d.ts +48 -0
- package/dist/theme/settings/index.js +1 -0
- package/dist/utils/component-renderer.d.ts +2 -1
- package/dist/utils/component-renderer.js +1 -1
- package/dist/utils/pay-with-ikas.d.ts +552 -0
- package/dist/utils/pay-with-ikas.js +1 -0
- package/dist/utils/svg.d.ts +15 -0
- package/dist/utils/svg.js +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as t,__generator as r}from'./../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as n}from"../../../packages/storefront-config/src/index.js";import i from'./../../../ext/lodash/cloneDeep.js';import{I18n as a}from"../../../i18n/index.js";import{Router as o,withRoutePrefix as s}from"../../../router/index.js";import{customerStore as u}from"../../../stores/customer/index.js";import{isClient as d,isBackNavigation as l,getQueryParams as c,debounce as f,stringToSlug as v,stringifyQueryParams as p}from"../../../utils/helper.js";import{setSavedLastViewedProductsResponse as g,getLastViewedProducts as I,waitForCustomerStoreInit as E}from"../../stores/customer/index.js";import{getIkasFilterCategorySlug as C,getIkasFilterCategoryHref as S}from"../filter-category/index.js";import{getFilterValueList as A,clearFilter as y,selectFilterValue as T,onNumberRangeFilterOptionClick as R,getFilterKeyList as D,applyQueryParamForFilter as h,initIkasProductFilter as _,isCustomValueFilter as m}from"../product/filter/index.js";import{getProductVariantPrice as b,hasProductVariantStock as N}from"../product/variant/index.js";var L;function O(t){var r=e({data:[],limit:10,page:1,count:0,isInitialized:!1,isLoading:!1,type:"ALL",sort:"DEFAULT",searchKeyword:"",pageType:"CATEGORY",category:null,brand:null,productListPropValue:{id:"",productIds:[],initialLimit:10,productListType:"ALL"}},t);return function(e){var t;if((null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&["ALL"].includes(e.type))switch(e.pageSpecificData.orderType){case"HIGHEST_DISCOUNT_RATIO":e.sort="DECRASING_DISCOUNT";break;case"LOWEST_DISCOUNT_RATIO":e.sort="INCREASING_DISCOUNT";break;case"HIGHEST_PRICE":e.sort="DECREASING_PRICE";break;case"LOWEST_PRICE":e.sort="INCREASING_PRICE";break;case"NEWEST":e.sort="LAST_ADDED";break;case"OLDEST":e.sort="FIRST_ADDED";break;case"MANUALLY":e.sort="FEATURED"}}(r),z(r),J(r),r}function P(e){var t;if(d()&&(!l()||!o.isFromBFCache)){!function(e){var t=c(),r=null==t?void 0:t.get("page");if(r){var n=parseInt(r);isNaN(n)||(e.page=n,e.infiniteScrollPage=n)}}(e);if(["CATEGORY","BRAND","SEARCH"].includes(e.pageType)&&location.search&&U(e)&&((null===(t=e.productListPropValue)||void 0===t?void 0:t.usePageFilter)||"SEARCH"===e.type))le(e,c(),e.page>1);else e.page>1?le(e,void 0,!0):k(e)?le(e):Re(e)}}function G(e,t){t!==e.searchKeyword&&(e.searchKeyword=t,_e(e),me(e))}function U(e){return"ALL"===e.type||"CATEGORY"===e.type}function V(e){var t,r;return(null===(t=e.filters)||void 0===t?void 0:t.some(function(e){return!!A(e).length}))||!!e.searchKeyword||"CATEGORY"!==e.pageType&&(!!e.filterCategoryId||!!(null===(r=e.filterCategories)||void 0===r?void 0:r.some(function(e){return e.isSelected})))}function w(e){return"STATIC"===e.type}function F(e){return"DISCOUNTED"===e.type}function j(e){return"RECOMMENDED"===e.type}function k(e){return"LAST_VIEWED"===e.type}function x(e){return"RELATED_PRODUCTS"===e.type}function H(e){return"VIEWED_TOGETHER"===e.type}function W(e){return"PURCHASED_TOGETHER"===e.type}function K(e){return"SEARCH"===e.type}function B(e){return!(w(e)||F(e)||j(e)||!e.minPage)&&e.minPage>1}function Y(e){return!(w(e)||F(e)||j(e))&&e.page*e.limit<e.count}function Z(e){var t;return(null===(t=e.filterCategories)||void 0===t?void 0:t.filter(function(e){return 0!==e.resultCount}))||[]}function M(e){var t;return!!e.searchKeyword||!!(null===(t=e.filters)||void 0===t?void 0:t.some(function(e){return!!A(e).length}))}function q(e){var t;return"MANUALLY"===(null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&["ALL","CATEGORY"].includes(e.type)}function z(e){var t=V(e);e.data.forEach(function(e){return e.isFiltered=t||!1})}function J(e){var t=w(e);e.data.forEach(function(e){return e.isFiltered=t||!1})}function X(e){e._enableSuggestions=!0}function Q(e){var t={};return e.categoryId&&(t.categoryId=e.categoryId),e.brandId&&(t.brandId=e.brandId),Object.keys(t).length?s("/search?suggestion=".concat(encodeURIComponent(JSON.stringify(t)))):s("/search")}function $(i,a,o,s){return t(this,void 0,void 0,function(){var t,u,d,l,f,v,p,g,I,E,C,S,y,T,R,D;return r(this,function(r){switch(r.label){case 0:return t=[],u=[],null===(S=i.filters)||void 0===S||S.forEach(function(e){var r=A(e);r.length&&t.push({id:e.id,type:e.type,displayType:e.displayType,valueList:r}),e.isFacetFilter&&u.push({id:e.id,type:e.type,displayType:e.displayType})}),d=c(),(l=null==d?void 0:d.get("suggestion"))&&(f=JSON.parse(decodeURIComponent(l)),(v=f.brandId)&&((p=null===(y=i.filters)||void 0===y?void 0:y.find(function(e){return"brand"===e.id&&"BRAND"===e.type}))&&(g=null===(T=p.values)||void 0===T?void 0:T.find(function(e){return e.id===v}))&&h(p,g.name),t.push({id:"brand",type:"BRAND",displayType:"BOX",valueList:[v]})),f.categoryId&&(i.filterCategoryId=f.categoryId),i.searchKeyword=f.term),I=null===(R=i.filterCategories)||void 0===R?void 0:R.filter(function(e){return e.isSelected}).map(function(e){return e.id}),E=function(e){var t,r;switch(e.sort){case"INCREASING_PRICE":t="ASC",r="PRICE";break;case"DECREASING_PRICE":t="DESC",r="PRICE";break;case"FIRST_ADDED":t="ASC",r="CREATED_AT";break;case"LAST_ADDED":t="DESC",r="CREATED_AT";break;case"INCREASING_DISCOUNT":t="ASC",r="DISCOUNT_RATIO";break;case"DECRASING_DISCOUNT":t="DESC",r="DISCOUNT_RATIO";break;case"FEATURED":if(K(e))return;t="ASC",r="MANUAL_SORT";break;case"DEFAULT":t=void 0,r=void 0;break;case"AVERAGE_RATING":t="DESC",r="AVERAGE_RATING";break;case"REVIEW_COUNT":t="DESC",r="REVIEW_COUNT";break;case"SALE_COUNT":t="DESC",r="SALE_COUNT";break;case"A_Z":t="ASC",r="NAME";break;case"Z_A":t="DESC",r="NAME"}if(t&&r)return{direction:t,type:r}}(i),j(i)&&i.recommendedProductData?[4,import("../../api/product/index.js")]:[3,3];case 1:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,brandIds:i.recommendedProductData.brandIds,categoryIds:i.recommendedProductData.categoryIds,locale:n.getCurrentLocale()})];case 2:case 5:case 8:case 11:case 14:return[2,r.sent()];case 3:return x(i)&&i.relatedProductData?[4,import("../../api/product/index.js")]:[3,6];case 4:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,productId:i.relatedProductData.productId,brandIds:i.relatedProductData.brandIds,categoryIds:i.relatedProductData.categoryIds,locale:n.getCurrentLocale()})];case 6:return H(i)&&i.viewedTogetherProductData?[4,import("../../api/product/index.js")]:[3,9];case 7:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,method:"VIEWED_TOGETHER",productIds:i.viewedTogetherProductData.productIds,locale:n.getCurrentLocale()})];case 9:return W(i)&&i.purchasedTogetherProductData?[4,import("../../api/product/index.js")]:[3,12];case 10:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,method:"PURCHASED_TOGETHER",productIds:i.purchasedTogetherProductData.productIds,locale:n.getCurrentLocale()})];case 12:return C={input:e(e(e(e({page:a,perPage:o},i._enableSuggestions?{enableSuggestions:i._enableSuggestions}:{}),{productIdList:w(i)?null===(D=i.productListPropValue.productIds)||void 0===D?void 0:D.map(function(e){return e.productId}):s,filterList:t,facetList:u}),i.baseCategoryIdList?{baseCategoryIdList:i.baseCategoryIdList}:{}),{brandId:"BRAND"===i.pageType&&"SEARCH"!==i.type?i.filterBrandId:void 0,categoryIdList:I&&I.length?I:i.filterCategoryId?[i.filterCategoryId]:void 0,priceListId:n.priceListId,salesChannelId:n.salesChannelId,query:i.searchKeyword,order:E?[E]:[],showStockOption:n.stockPreference||"SHOW_ALL"})},[4,import("../../api/product/index.js")];case 13:return[4,(0,r.sent().apiSearchProducts)(C,i.excludedFields||[])]}})})}function ee(e){return t(this,void 0,void 0,function(){var t,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:return[4,import("../../api/product/index.js")];case 1:return[4,(0,r.sent().apiGetProductFilterData)({categoryId:e.filterCategoryId?e.filterCategoryId:void 0,locale:n.getCurrentLocale()})];case 2:return t=r.sent(),e.filters=null===(a=null==t?void 0:t.data)||void 0===a?void 0:a.filters.map(function(e){return _(e)}),e.filterCategories=null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.categories,ye(e),e.disabledSortTypes=null===(s=t.data)||void 0===s?void 0:s.disabledSortTypes,"CATEGORY"!==e.pageType&&e.filterCategoryId&&(i=null===(u=e.filterCategories)||void 0===u?void 0:u.find(function(t){return t.id===e.filterCategoryId}))&&(i.isSelected=!0),e.filters&&e.filters.sort(function(e,t){return e.order>t.order?1:-1}),[2]}})})}function te(e){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,le(e)];case 1:return t=r.sent(),["CATEGORY","BRAND","SEARCH"].includes(e.pageType)?(t&&ne(e),[2]):[2]}})})}function re(e){var t,r,n,i={};if(null===(t=e.filters)||void 0===t||t.forEach(function(e){var t=D(e);t.length&&(i[v(e.name)]=t)}),e.searchKeyword&&(i.s=e.searchKeyword),e.sort&&(i.o=be[e.sort]),e.baseCategoryIdList&&(i.bc=e.baseCategoryIdList),e.suggestionCategoryId&&(i.suggestionCategoryId=e.suggestionCategoryId),e.infiniteScrollPage?i.page=e.infiniteScrollPage:i.page=e.page,"CATEGORY"!==e.pageType){var a=null===(r=e.filterCategories)||void 0===r?void 0:r.filter(function(e){return e.isSelected});if(!!(null==a?void 0:a.length))i.c=null==a?void 0:a.map(function(e){return C(e)});else if(e.filterCategoryId){var o=null===(n=e.filterCategories)||void 0===n?void 0:n.find(function(t){return t.id===e.filterCategoryId}),s=o?C(o):void 0;s&&(i.c=s)}}return p(i,{arrayFormat:"comma"})}function ne(e){if(d()&&!K(e)&&!n.isEditor){var t=re(e),r=s("".concat(location.pathname).concat(t?"?"+t:""));o.navigate(r,!0)}}function ie(e){var t,r;null===(t=e.filters)||void 0===t||t.forEach(function(e){return y(e)}),e.searchKeyword="","CATEGORY"!==e.pageType&&(e.filterCategoryId=void 0),null===(r=e.filterCategories)||void 0===r||r.forEach(function(e){return e.isSelected=!1}),te(e)}function ae(e,t){y(t),te(e)}function oe(e,t,r){T(t,r),te(e)}function se(e,t,r){R(t,r),te(e)}function ue(e){var t,r=null===(t=e.filters)||void 0===t?void 0:t.filter(function(e){var t;return null===(t=e.values)||void 0===t?void 0:t.some(function(e){return e.isSelected})});return null==r?void 0:r.map(function(e){var t,r;return e.numberRange?{filter:e,values:[e.numberRange.from+"-"+e.numberRange.to],commaSeperatedValues:e.numberRange.from+"-"+e.numberRange.to}:e.numberRangeListOptions?{filter:e,values:e.numberRangeListOptions.filter(function(e){return e.isSelected}).map(function(e){return e.from+"-"+e.to}),commaSeperatedValues:e.numberRangeListOptions.filter(function(e){return e.isSelected}).map(function(e){return e.from+"-"+e.to}).join(",")}:{filter:e,values:(null===(t=e.values)||void 0===t?void 0:t.filter(function(e){return e.isSelected}).map(function(e){return e.name}))||[],commaSeperatedValues:(null===(r=e.values)||void 0===r?void 0:r.filter(function(e){return e.isSelected}).map(function(e){return e.name}).join(","))||""}})}function de(e){return e.variants[0]}function le(e,n,a){return t(this,void 0,void 0,function(){var t,o,s,l,c,f,v,p,S,A,y,T,R,D,_,b;return r(this,function(r){switch(r.label){case 0:e.isLoading=!0,t=Date.now(),e.fetchRequestTime=t,r.label=1;case 1:return r.trys.push([1,14,15,16]),o=a?e.page:1,s=e.limit,!U(e)||e.filters?[3,3]:[4,ee(e)];case 2:r.sent(),r.label=3;case 3:return function(e,t){var r;try{null==t||t.forEach(function(t,r){var n,i=null===(n=e.filters)||void 0===n?void 0:n.find(function(e){return e.key===r});i&&h(i,t)});var n=null==t?void 0:t.get("s");n&&(e.searchKeyword=n);var i=null==t?void 0:t.get("o");if(i){var a=parseInt(i),o=Object.entries(be).find(function(e){return e[1]===a});o&&(e.sort=o[0])}if("CATEGORY"!==e.pageType){var s=null==t?void 0:t.get("c"),u=null==s?void 0:s.split(",");u&&u.length&&(null===(r=e.filterCategories)||void 0===r||r.forEach(function(e){e.isSelected=u.some(function(t){return t===C(e)})}))}if("SEARCH"===e.pageType){var d=null==t?void 0:t.get("bc"),l=null==d?void 0:d.split(",");l&&(e.baseCategoryIdList=l);var c=null==t?void 0:t.get("suggestion");if(c){var f=JSON.parse(decodeURIComponent(c)).categoryId;f&&(e.suggestionCategoryId=f)}var v=null==t?void 0:t.get("suggestionCategoryId");v&&(e.suggestionCategoryId=v,e.filterCategoryId=v)}}catch(e){console.log(e)}}(e,n),[4,fe(e)];case 4:return r.sent(),K(e)&&!M(e)?(e.data=[],e.page=1,e.minPage=1,e.count=0,e.isInitialized=!0,[2,!0]):(l=void 0,c=!1,w(e)?(o=void 0,s=200,[3,10]):[3,5]);case 5:return F(e)||j(e)?(o=1,s=10,[3,10]):[3,6];case 6:return k(e)?d()?[4,E(u)]:[3,9]:[3,10];case 7:return r.sent(),[4,I(u)];case 8:return(f=r.sent())&&f.length?(l=f.map(function(e){return e.productId}),c=u.useLastViewedProductResponse,[3,10]):[2];case 9:return[2];case 10:return c?(p=u._savedLastViewedProductsResponse,[3,13]):[3,11];case 11:return[4,$(e,o||1,s||10,l)];case 12:p=r.sent(),r.label=13;case 13:return(v=p)&&e.fetchRequestTime===t?(S=[],!c&&k(e)&&g(u,v),w(e)||k(e)?(A=w(e)?e.productListPropValue.productIds:u._lastViewedProducts,S=(null==A?void 0:A.map(function(e){var t,r,n=null===(r=null===(t=v.data)||void 0===t?void 0:t.data)||void 0===r?void 0:r.find(function(t){return t.id===e.productId}),i=null==n?void 0:n.variants.find(function(t){return t.id===e.variantId});if((null==i?void 0:i.isActive)&&N(i)||(i=null==n?void 0:n.variants.find(function(e){return e.isActive&&N(e)})),n&&i)return n.selectedVariantValues=i.variantValues,n}).filter(function(e){return!!e}))||[]):S=(null===(R=null===(T=v.data)||void 0===T?void 0:T.data)||void 0===R?void 0:R.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}))||[],null===(D=e.filters)||void 0===D||D.forEach(function(e){var t,r;if(void 0===e.isCollapsed){var n=!1;(!1===(null===(t=e.settings)||void 0===t?void 0:t.showCollapsedOnMobile)&&d()&&window.innerWidth<768||!1===(null===(r=e.settings)||void 0===r?void 0:r.showCollapsedOnDesktop))&&(n=!0),e.isCollapsed=!n}}),function(e,t){var r,n,a=i(e);null===(r=a.filters)||void 0===r||r.forEach(function(e){var r,n,i,a=null==t?void 0:t.find(function(t){return t.id===e.id});a?null===(r=e.values)||void 0===r||r.forEach(function(t){var r=a.values.find(function(e){return e.id===t.id});r?t.resultCount=r.count:m(e)?t.resultCount=null:t.resultCount=0}):m(e)?null===(n=e.values)||void 0===n||n.forEach(function(e){return e.resultCount=null}):null===(i=e.values)||void 0===i||i.forEach(function(e){return e.resultCount=0})});var o=null==t?void 0:t.find(function(e){return"category"===e.id});o&&(null===(n=a.filterCategories)||void 0===n||n.forEach(function(e){var t=o.values.find(function(t){return t.id===e.id});e.resultCount=t?t.count:0})),e.filters=a.filters,e.filterCategories=a.filterCategories,ye(e)}(e,null===(_=v.data)||void 0===_?void 0:_.facets),e.data=S,e.count=(null===(b=v.data)||void 0===b?void 0:b.count)||0,e.isInitialized=!0,e.page=o||1,e.minPage=e.page,v.data&&"suggestions"in v.data&&(e.suggestions=v.data.suggestions),z(e),J(e),a||(e.infiniteScrollPage=null),Re(e),[2,!0]):[2];case 14:return y=r.sent(),console.log(y),[3,16];case 15:return t===e.fetchRequestTime&&(e.isLoading=!1),[7];case 16:return[2]}})})}function ce(e){e.isCollapsed=!e.isCollapsed}function fe(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s,u,d,l,c;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,13,,14]),e.productListPropValue.category?[4,import("../../api/category/index.js")]:[3,3];case 1:return[4,(0,r.sent().apiListCategory)({id:{eq:e.productListPropValue.category}})];case 2:return t=r.sent(),e.category=(null===(o=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===o?void 0:o[0])||null,[3,7];case 3:return e.productListPropValue.usePageFilter&&"CATEGORY"===e.pageType&&e.pageSpecificData?(e.category=e.pageSpecificData,[3,7]):[3,4];case 4:return e.filterCategoryId?[4,import("../../api/category/index.js")]:[3,7];case 5:return[4,(0,r.sent().apiListCategory)({id:{eq:e.filterCategoryId}})];case 6:t=r.sent(),e.category=(null===(u=null===(s=t.data)||void 0===s?void 0:s.data)||void 0===u?void 0:u[0])||null,r.label=7;case 7:return e.productListPropValue.usePageFilter&&"BRAND"===e.pageType&&e.pageSpecificData?(e.brand=e.pageSpecificData,[3,12]):[3,8];case 8:return e.filterBrandId?e.filterBrandId!==(null===(d=e.pageSpecificData)||void 0===d?void 0:d.id)?[3,9]:(e.brand=e.pageSpecificData,[3,12]):[3,12];case 9:return[4,import("../../api/brand/index.js")];case 10:return[4,(0,r.sent().apiListProductBrand)({id:{eq:e.filterBrandId}})];case 11:n=r.sent(),e.brand=(null===(c=null===(l=n.data)||void 0===l?void 0:l.data)||void 0===c?void 0:c[0])||null,r.label=12;case 12:return[3,14];case 13:return i=r.sent(),console.error(i),[3,14];case 14:return[2]}})})}function ve(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:if(w(e)||F(e)||j(e)||x(e)||H(e)||W(e)||k(e)||e.isLoading||!B(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),t=e.minPage-1,[4,$(e,t,e.limit)];case 2:return(n=r.sent())?(i=null===(s=null===(o=n.data)||void 0===o?void 0:o.data)||void 0===s?void 0:s.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=(null==i?void 0:i.concat(e.data))||e.data,e.count=(null===(u=n.data)||void 0===u?void 0:u.count)||e.count,e.minPage=t,z(e),J(e),ne(e),[3,5]):[2];case 3:return a=r.sent(),console.log(a),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function pe(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s;return r(this,function(r){switch(r.label){case 0:if(w(e)||F(e)||j(e)||x(e)||H(e)||W(e)||k(e)||e.isLoading||!Y(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,$(e,e.page+1,e.limit)];case 2:return(t=r.sent())?(n=null===(o=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===o?void 0:o.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=e.data.concat(n||[]),e.count=(null===(s=t.data)||void 0===s?void 0:s.count)||e.count,e.page=e.page+1,z(e),J(e),ne(e),[3,5]):[2];case 3:return i=r.sent(),console.log(i),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function ge(e,n){return t(this,void 0,void 0,function(){var t,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:if(e.isLoading||w(e)||F(e)||j(e)||k(e)||x(e)||H(e)||W(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,$(e,n,e.limit)];case 2:return(t=r.sent())?(i=null===(s=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===s?void 0:s.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=i||[],e.count=(null===(u=t.data)||void 0===u?void 0:u.count)||0,e.page=n,e.minPage=n,z(e),J(e),ne(e),[3,5]):[2];case 3:return a=r.sent(),console.log(a),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function Ie(e,n){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.sort=n,[4,le(e)];case 1:return t.sent()&&ne(e),[2]}})})}function Ee(e){return Ce(e,e.sort)}function Ce(e,t){switch(t){case"INCREASING_PRICE":return a.translate("sort_type.increasing_price");case"DECREASING_PRICE":return a.translate("sort_type.decreasing_price");case"LAST_ADDED":return a.translate("sort_type.last_added");case"FIRST_ADDED":return a.translate("sort_type.first_added");case"INCREASING_DISCOUNT":return a.translate("sort_type.increasing_discount");case"DECRASING_DISCOUNT":return a.translate("sort_type.decreasing_discount");case"FEATURED":return a.translate("sort_type.featured");case"DEFAULT":return a.translate("sort_type.default");case"AVERAGE_RATING":return a.translate("sort_type.average_rating");case"REVIEW_COUNT":return a.translate("sort_type.review_count");case"SALE_COUNT":return a.translate("sort_type.sale_count");case"A_Z":return a.translate("sort_type.a_z");case"Z_A":return a.translate("sort_type.z_a")}}function Se(e){var t,r,n,i,a,o,s,u,d=[];return(null===(t=e.disabledSortTypes)||void 0===t?void 0:t.includes("NAME"))||(d.push({label:Ce(0,"A_Z"),value:"A_Z",isSelected:"A_Z"===e.sort}),d.push({label:Ce(0,"Z_A"),value:"Z_A",isSelected:"Z_A"===e.sort})),(null===(r=e.disabledSortTypes)||void 0===r?void 0:r.includes("PRICE"))||(d.push({label:Ce(0,"INCREASING_PRICE"),value:"INCREASING_PRICE",isSelected:"INCREASING_PRICE"===e.sort}),d.push({label:Ce(0,"DECREASING_PRICE"),value:"DECREASING_PRICE",isSelected:"DECREASING_PRICE"===e.sort})),(null===(n=e.disabledSortTypes)||void 0===n?void 0:n.includes("CREATED_AT"))||(d.push({label:Ce(0,"LAST_ADDED"),value:"LAST_ADDED",isSelected:"LAST_ADDED"===e.sort}),d.push({label:Ce(0,"FIRST_ADDED"),value:"FIRST_ADDED",isSelected:"FIRST_ADDED"===e.sort})),(null===(i=e.disabledSortTypes)||void 0===i?void 0:i.includes("DISCOUNT_RATIO"))||(d.push({label:Ce(0,"INCREASING_DISCOUNT"),value:"INCREASING_DISCOUNT",isSelected:"INCREASING_DISCOUNT"===e.sort}),d.push({label:Ce(0,"DECRASING_DISCOUNT"),value:"DECRASING_DISCOUNT",isSelected:"DECRASING_DISCOUNT"===e.sort})),(null===(a=e.disabledSortTypes)||void 0===a?void 0:a.includes("MANUAL_SORT"))||d.push({label:Ce(0,"FEATURED"),value:"FEATURED",isSelected:"FEATURED"===e.sort}),(null===(o=e.disabledSortTypes)||void 0===o?void 0:o.includes("AVERAGE_RATING"))||d.push({label:Ce(0,"AVERAGE_RATING"),value:"AVERAGE_RATING",isSelected:"AVERAGE_RATING"===e.sort}),(null===(s=e.disabledSortTypes)||void 0===s?void 0:s.includes("REVIEW_COUNT"))||d.push({label:Ce(0,"REVIEW_COUNT"),value:"REVIEW_COUNT",isSelected:"REVIEW_COUNT"===e.sort}),(null===(u=e.disabledSortTypes)||void 0===u?void 0:u.includes("SALE_COUNT"))||d.push({label:Ce(0,"SALE_COUNT"),value:"SALE_COUNT",isSelected:"SALE_COUNT"===e.sort}),d}function Ae(e,i,a){return t(this,void 0,void 0,function(){var t,s,u;return r(this,function(r){switch(r.label){case 0:return a?(null===(u=e.filterCategories)||void 0===u||u.forEach(function(e){e.id===i.id&&(e.isSelected=!e.isSelected)}),[4,te(e)]):[3,2];case 1:return r.sent(),[3,3];case 2:n.isEditor||(t=re(e),s=S(i)+(t?"?"+t:""),o.navigate(s)),r.label=3;case 3:return[2]}})})}function ye(e){var t;null===(t=e.filterCategories)||void 0===t||t.forEach(function(e){e.image=e.imageId?{id:e.imageId,isVideo:!1}:null})}function Te(e,t){if(e.infiniteScrollPage!==t){e.infiniteScrollPage=t;var r=re(e);o.navigate("".concat(location.pathname).concat(r?"?"+r:""),!0)}}function Re(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.searchKeyword&&e.data.length?[4,import("../../../analytics/analytics-functions/viewSearchResults.js")]:[3,2];case 1:return(0,t.sent().anl_viewSearchResults)(e.searchKeyword,e.data),[3,4];case 2:return e.data.length&&"ALL"===e.type?[4,import("../../../analytics/analytics-functions/viewListing.js")]:[3,4];case 3:(0,t.sent().anl_viewListing)(e.data),t.label=4;case 4:return[2]}})})}function De(e){var t=e.data[0];if(!t)return n.getDefaultCurrencyCode()||"";var r=de(t),i=b(r);return(null==i?void 0:i.currency)||n.getDefaultCurrencyCode()||""}function he(e){var t=e.data[0];if(!t)return n.getDefaultCurrencySymbol()||"";var r=de(t),i=b(r);return(null==i?void 0:i.currencySymbol)||n.getDefaultCurrencySymbol()||""}var _e=f(function(e){te(e)},500),me=f(function(e){return t(void 0,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../../analytics/analytics-functions/search.js")];case 1:return(0,t.sent().anl_search)(e.searchKeyword),[2]}})})},1e3),be=((L={}).INCREASING_PRICE=1,L.DECREASING_PRICE=2,L.LAST_ADDED=3,L.FIRST_ADDED=4,L.INCREASING_DISCOUNT=5,L.DECRASING_DISCOUNT=6,L.FEATURED=7,L.DEFAULT=8,L.AVERAGE_RATING=9,L.REVIEW_COUNT=10,L.SALE_COUNT=11,L.A_Z=12,L.Z_A=13,L);export{ae as clearProductListFilter,ie as clearProductListFilters,X as enableProductListSuggestions,De as getProductListCurrencyCode,he as getProductListCurrencySymbol,Z as getProductListFilterCategories,le as getProductListInitialData,pe as getProductListNextPage,ge as getProductListPage,ve as getProductListPrevPage,Se as getProductListSortOptions,Ee as getProductListSortTypeTranslation,Q as getProductListSuggestionHref,ue as getSelectedFilterValues,oe as handleFilterValueClick,se as handleNumberRangeOptionClick,M as hasProductListAppliedFilters,q as hasProductListFeaturedSortEnabled,Y as hasProductListNextPage,B as hasProductListPrevPage,O as initProductList,ye as initProductListFilterCategories,P as initProductListOnBrowser,F as isProductListDiscounted,U as isProductListFilterable,V as isProductListFiltered,k as isProductListLastViewed,W as isProductListPurchasedTogether,j as isProductListRecommended,x as isProductListRelatedProducts,K as isProductListSearch,w as isProductListStatic,H as isProductListViewedTogether,Ae as onFilterCategoryClick,ce as productListToggleFilterCollapsed,G as searchProductList,z as setProductListIsFilteredForProducts,J as setProductListIsStaticForProducts,Te as setProductListVisiblePage,Ie as setSortType,Ce as translateProductListSortType};
|
|
1
|
+
import{__assign as e,__awaiter as t,__generator as r}from'./../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as n}from"../../../packages/storefront-config/src/index.js";import i from'./../../../ext/lodash/cloneDeep.js';import{I18n as a}from"../../../i18n/index.js";import{Router as o,withRoutePrefix as s}from"../../../router/index.js";import{customerStore as u}from"../../../stores/customer/index.js";import{isClient as d,isBackNavigation as l,getQueryParams as c,debounce as f,stringToSlug as v,stringifyQueryParams as p}from"../../../utils/helper.js";import{setSavedLastViewedProductsResponse as g,getLastViewedProducts as I,waitForCustomerStoreInit as E}from"../../stores/customer/index.js";import{getIkasFilterCategorySlug as C,getIkasFilterCategoryHref as S}from"../filter-category/index.js";import{getFilterValueList as A,clearFilter as y,selectFilterValue as T,onNumberRangeFilterOptionClick as R,getFilterKeyList as D,applyQueryParamForFilter as h,initIkasProductFilter as _,isCustomValueFilter as m}from"../product/filter/index.js";import{getProductVariantPrice as b,hasProductVariantStock as N}from"../product/variant/index.js";var L;function O(t){var r=e({data:[],limit:10,page:1,count:0,isInitialized:!1,isLoading:!1,type:"ALL",sort:"DEFAULT",searchKeyword:"",pageType:"CATEGORY",category:null,brand:null,productListPropValue:{id:"",productIds:[],initialLimit:10,productListType:"ALL"}},t);return function(e){var t;if((null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&["ALL"].includes(e.type))switch(e.pageSpecificData.orderType){case"HIGHEST_DISCOUNT_RATIO":e.sort="DECRASING_DISCOUNT";break;case"LOWEST_DISCOUNT_RATIO":e.sort="INCREASING_DISCOUNT";break;case"HIGHEST_PRICE":e.sort="DECREASING_PRICE";break;case"LOWEST_PRICE":e.sort="INCREASING_PRICE";break;case"NEWEST":e.sort="LAST_ADDED";break;case"OLDEST":e.sort="FIRST_ADDED";break;case"MANUALLY":e.sort="FEATURED"}}(r),z(r),J(r),r}function P(e){var t;if(d()&&(!l()||!o.isFromBFCache)){!function(e){var t=c(),r=null==t?void 0:t.get("page");if(r){var n=parseInt(r);isNaN(n)||(e.page=n,e.infiniteScrollPage=n)}}(e);if(["CATEGORY","BRAND","SEARCH"].includes(e.pageType)&&location.search&&U(e)&&((null===(t=e.productListPropValue)||void 0===t?void 0:t.usePageFilter)||"SEARCH"===e.type))le(e,c(),e.page>1);else e.page>1?le(e,void 0,!0):k(e)?le(e):Re(e)}}function G(e,t){t!==e.searchKeyword&&(e.searchKeyword=t,_e(e),me(e))}function U(e){return"ALL"===e.type||"CATEGORY"===e.type}function V(e){var t,r;return(null===(t=e.filters)||void 0===t?void 0:t.some(function(e){return!!A(e).length}))||!!e.searchKeyword||"CATEGORY"!==e.pageType&&(!!e.filterCategoryId||!!(null===(r=e.filterCategories)||void 0===r?void 0:r.some(function(e){return e.isSelected})))}function w(e){return"STATIC"===e.type}function F(e){return"DISCOUNTED"===e.type}function j(e){return"RECOMMENDED"===e.type}function k(e){return"LAST_VIEWED"===e.type}function x(e){return"RELATED_PRODUCTS"===e.type}function H(e){return"VIEWED_TOGETHER"===e.type}function W(e){return"PURCHASED_TOGETHER"===e.type}function K(e){return"SEARCH"===e.type}function B(e){return!(w(e)||F(e)||j(e)||!e.minPage)&&e.minPage>1}function Y(e){return!(w(e)||F(e)||j(e))&&e.page*e.limit<e.count}function Z(e){var t;return(null===(t=e.filterCategories)||void 0===t?void 0:t.filter(function(e){return 0!==e.resultCount}))||[]}function M(e){var t;return!!e.searchKeyword||!!(null===(t=e.filters)||void 0===t?void 0:t.some(function(e){return!!A(e).length}))}function q(e){var t;return"MANUALLY"===(null===(t=e.pageSpecificData)||void 0===t?void 0:t.orderType)&&["ALL","CATEGORY"].includes(e.type)}function z(e){var t=V(e);e.data.forEach(function(e){return e.isFiltered=t||!1})}function J(e){var t=w(e);e.data.forEach(function(e){return e.isFiltered=t||!1})}function X(e){e._enableSuggestions=!0}function Q(e){var t={};return e.categoryId&&(t.categoryId=e.categoryId),e.brandId&&(t.brandId=e.brandId),Object.keys(t).length?s("/search?suggestion=".concat(encodeURIComponent(JSON.stringify(t)))):s("/search")}function $(i,a,o,s){return t(this,void 0,void 0,function(){var t,u,d,l,f,v,p,g,I,E,C,S,y,T,R,D;return r(this,function(r){switch(r.label){case 0:return t=[],u=[],null===(S=i.filters)||void 0===S||S.forEach(function(e){var r=A(e);r.length&&t.push({id:e.id,type:e.type,displayType:e.displayType,valueList:r}),e.isFacetFilter&&u.push({id:e.id,type:e.type,displayType:e.displayType})}),d=c(),(l=null==d?void 0:d.get("suggestion"))&&(f=JSON.parse(decodeURIComponent(l)),(v=f.brandId)&&((p=null===(y=i.filters)||void 0===y?void 0:y.find(function(e){return"brand"===e.id&&"BRAND"===e.type}))&&(g=null===(T=p.values)||void 0===T?void 0:T.find(function(e){return e.id===v}))&&h(p,g.name),t.push({id:"brand",type:"BRAND",displayType:"BOX",valueList:[v]})),f.categoryId&&(i.filterCategoryId=f.categoryId),i.searchKeyword=f.term),I=null===(R=i.filterCategories)||void 0===R?void 0:R.filter(function(e){return e.isSelected}).map(function(e){return e.id}),E=function(e){var t,r;switch(e.sort){case"INCREASING_PRICE":t="ASC",r="PRICE";break;case"DECREASING_PRICE":t="DESC",r="PRICE";break;case"FIRST_ADDED":t="ASC",r="CREATED_AT";break;case"LAST_ADDED":t="DESC",r="CREATED_AT";break;case"INCREASING_DISCOUNT":t="ASC",r="DISCOUNT_RATIO";break;case"DECRASING_DISCOUNT":t="DESC",r="DISCOUNT_RATIO";break;case"FEATURED":if(K(e))return;t="ASC",r="MANUAL_SORT";break;case"DEFAULT":t=void 0,r=void 0;break;case"AVERAGE_RATING":t="DESC",r="AVERAGE_RATING";break;case"REVIEW_COUNT":t="DESC",r="REVIEW_COUNT";break;case"SALE_COUNT":t="DESC",r="SALE_COUNT";break;case"A_Z":t="ASC",r="NAME";break;case"Z_A":t="DESC",r="NAME"}if(t&&r)return{direction:t,type:r}}(i),j(i)&&i.recommendedProductData?[4,import("../../api/product/index.js")]:[3,3];case 1:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,brandIds:i.recommendedProductData.brandIds,categoryIds:i.recommendedProductData.categoryIds,locale:n.getCurrentLocale()})];case 2:case 5:case 8:case 11:case 14:return[2,r.sent()];case 3:return x(i)&&i.relatedProductData?[4,import("../../api/product/index.js")]:[3,6];case 4:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,productId:i.relatedProductData.productId,brandIds:i.relatedProductData.brandIds,categoryIds:i.relatedProductData.categoryIds,locale:n.getCurrentLocale()})];case 6:return H(i)&&i.viewedTogetherProductData?[4,import("../../api/product/index.js")]:[3,9];case 7:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,method:"VIEWED_TOGETHER",productIds:i.viewedTogetherProductData.productIds,locale:n.getCurrentLocale()})];case 9:return W(i)&&i.purchasedTogetherProductData?[4,import("../../api/product/index.js")]:[3,12];case 10:return[4,(0,r.sent().apiGetSuggestedProducts)({priceListId:n.priceListId,salesChannelId:n.salesChannelId,method:"PURCHASED_TOGETHER",productIds:i.purchasedTogetherProductData.productIds,locale:n.getCurrentLocale()})];case 12:return C={input:e(e(e(e({page:a,perPage:o},i._enableSuggestions?{enableSuggestions:i._enableSuggestions}:{}),{productIdList:w(i)?null===(D=i.productListPropValue.productIds)||void 0===D?void 0:D.map(function(e){return e.productId}):s,filterList:t,facetList:u}),i.baseCategoryIdList?{baseCategoryIdList:i.baseCategoryIdList}:{}),{brandId:"BRAND"===i.pageType&&"SEARCH"!==i.type?i.filterBrandId:void 0,categoryIdList:I&&I.length?I:i.filterCategoryId?[i.filterCategoryId]:void 0,priceListId:n.priceListId,salesChannelId:n.salesChannelId,query:i.searchKeyword,order:E?[E]:[],showStockOption:n.stockPreference||"SHOW_ALL"})},[4,import("../../api/product/index.js")];case 13:return[4,(0,r.sent().apiSearchProducts)(C,i.excludedFields||[])]}})})}function ee(e){return t(this,void 0,void 0,function(){var t,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:return[4,import("../../api/product/index.js")];case 1:return[4,(0,r.sent().apiGetProductFilterData)({categoryId:e.filterCategoryId?e.filterCategoryId:void 0,locale:n.getCurrentLocale()})];case 2:return t=r.sent(),e.filters=null===(a=null==t?void 0:t.data)||void 0===a?void 0:a.filters.map(function(e){return _(e)}),e.filterCategories=null===(o=null==t?void 0:t.data)||void 0===o?void 0:o.categories,ye(e),e.disabledSortTypes=null===(s=t.data)||void 0===s?void 0:s.disabledSortTypes,"CATEGORY"!==e.pageType&&e.filterCategoryId&&(i=null===(u=e.filterCategories)||void 0===u?void 0:u.find(function(t){return t.id===e.filterCategoryId}))&&(i.isSelected=!0),e.filters&&e.filters.sort(function(e,t){return e.order>t.order?1:-1}),[2]}})})}function te(e){return t(this,void 0,void 0,function(){var t;return r(this,function(r){switch(r.label){case 0:return[4,le(e)];case 1:return t=r.sent(),["CATEGORY","BRAND","SEARCH"].includes(e.pageType)?(t&&ne(e),[2]):[2]}})})}function re(e){var t,r,n,i={};if(null===(t=e.filters)||void 0===t||t.forEach(function(e){var t=D(e);t.length&&(i[v(e.name)]=t)}),e.searchKeyword&&(i.s=e.searchKeyword),e.sort&&(i.o=be[e.sort]),e.baseCategoryIdList&&(i.bc=e.baseCategoryIdList),e.suggestionCategoryId&&(i.suggestionCategoryId=e.suggestionCategoryId),e.infiniteScrollPage?i.page=e.infiniteScrollPage:i.page=e.page,"CATEGORY"!==e.pageType){var a=null===(r=e.filterCategories)||void 0===r?void 0:r.filter(function(e){return e.isSelected});if(!!(null==a?void 0:a.length))i.c=null==a?void 0:a.map(function(e){return C(e)});else if(e.filterCategoryId){var o=null===(n=e.filterCategories)||void 0===n?void 0:n.find(function(t){return t.id===e.filterCategoryId}),s=o?C(o):void 0;s&&(i.c=s)}}return p(i,{arrayFormat:"comma"})}function ne(e){if(d()&&!K(e)&&!n.isEditor){var t=re(e),r=s("".concat(location.pathname).concat(t?"?"+t:""));o.navigate(r,!0)}}function ie(e){var t,r;null===(t=e.filters)||void 0===t||t.forEach(function(e){return y(e)}),e.searchKeyword="","CATEGORY"!==e.pageType&&(e.filterCategoryId=void 0),null===(r=e.filterCategories)||void 0===r||r.forEach(function(e){return e.isSelected=!1}),te(e)}function ae(e,t){y(t),te(e)}function oe(e,t,r){T(t,r),te(e)}function se(e,t,r){R(t,r),te(e)}function ue(e){var t,r=null===(t=e.filters)||void 0===t?void 0:t.filter(function(e){var t;return null===(t=e.values)||void 0===t?void 0:t.some(function(e){return e.isSelected})});return null==r?void 0:r.map(function(e){var t,r;return e.numberRange?{filter:e,values:[e.numberRange.from+"-"+e.numberRange.to],commaSeperatedValues:e.numberRange.from+"-"+e.numberRange.to}:e.numberRangeListOptions?{filter:e,values:e.numberRangeListOptions.filter(function(e){return e.isSelected}).map(function(e){return e.from+"-"+e.to}),commaSeperatedValues:e.numberRangeListOptions.filter(function(e){return e.isSelected}).map(function(e){return e.from+"-"+e.to}).join(",")}:{filter:e,values:(null===(t=e.values)||void 0===t?void 0:t.filter(function(e){return e.isSelected}).map(function(e){return e.name}))||[],commaSeperatedValues:(null===(r=e.values)||void 0===r?void 0:r.filter(function(e){return e.isSelected}).map(function(e){return e.name}).join(","))||""}})}function de(e){return e.variants[0]}function le(e,n,a){return t(this,void 0,void 0,function(){var t,o,s,l,c,f,v,p,S,A,y,T,R,D,_,b;return r(this,function(r){switch(r.label){case 0:e.isLoading=!0,t=Date.now(),e.fetchRequestTime=t,r.label=1;case 1:return r.trys.push([1,14,15,16]),o=a?e.page:1,s=e.limit,!U(e)||e.filters?[3,3]:[4,ee(e)];case 2:r.sent(),r.label=3;case 3:return function(e,t){var r;try{null==t||t.forEach(function(t,r){var n,i=null===(n=e.filters)||void 0===n?void 0:n.find(function(e){return e.key===r});i&&h(i,t)});var n=null==t?void 0:t.get("s");n&&(e.searchKeyword=n);var i=null==t?void 0:t.get("o");if(i){var a=parseInt(i),o=Object.entries(be).find(function(e){return e[1]===a});o&&(e.sort=o[0])}if("CATEGORY"!==e.pageType){var s=null==t?void 0:t.get("c"),u=null==s?void 0:s.split(",");u&&u.length&&(null===(r=e.filterCategories)||void 0===r||r.forEach(function(e){e.isSelected=u.some(function(t){return t===C(e)})}))}if("SEARCH"===e.pageType){var d=null==t?void 0:t.get("bc"),l=null==d?void 0:d.split(",");l&&(e.baseCategoryIdList=l);var c=null==t?void 0:t.get("suggestion");if(c){var f=JSON.parse(decodeURIComponent(c)).categoryId;f&&(e.suggestionCategoryId=f)}var v=null==t?void 0:t.get("suggestionCategoryId");v&&(e.suggestionCategoryId=v,e.filterCategoryId=v)}}catch(e){console.log(e)}}(e,n),[4,fe(e)];case 4:return r.sent(),K(e)&&!M(e)?(e.data=[],e.page=1,e.minPage=1,e.count=0,e.isInitialized=!0,[2,!0]):(l=void 0,c=!1,w(e)?(o=void 0,s=200,[3,10]):[3,5]);case 5:return F(e)||j(e)?(o=1,s=10,[3,10]):[3,6];case 6:return k(e)?d()?[4,E(u)]:[3,9]:[3,10];case 7:return r.sent(),[4,I(u)];case 8:return(f=r.sent())&&f.length?(l=f.map(function(e){return e.productId}),c=u.useLastViewedProductResponse,[3,10]):[2];case 9:return[2];case 10:return c?(p=u._savedLastViewedProductsResponse,[3,13]):[3,11];case 11:return[4,$(e,o||1,s||10,l)];case 12:p=r.sent(),r.label=13;case 13:return(v=p)&&e.fetchRequestTime===t?(S=[],!c&&k(e)&&g(u,v),w(e)||k(e)?(A=w(e)?e.productListPropValue.productIds:u._lastViewedProducts,S=(null==A?void 0:A.map(function(e){var t,r,n=null===(r=null===(t=v.data)||void 0===t?void 0:t.data)||void 0===r?void 0:r.find(function(t){return t.id===e.productId}),i=null==n?void 0:n.variants.find(function(t){return t.id===e.variantId});if((null==i?void 0:i.isActive)&&N(i)||(i=null==n?void 0:n.variants.find(function(e){return e.isActive&&N(e)})),n&&i)return n.selectedVariantValues=i.variantValues,n}).filter(function(e){return!!e}))||[]):S=(null===(R=null===(T=v.data)||void 0===T?void 0:T.data)||void 0===R?void 0:R.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}))||[],null===(D=e.filters)||void 0===D||D.forEach(function(e){var t,r;if(void 0===e.isCollapsed){var n=!1;(!1===(null===(t=e.settings)||void 0===t?void 0:t.showCollapsedOnMobile)&&d()&&window.innerWidth<768||!1===(null===(r=e.settings)||void 0===r?void 0:r.showCollapsedOnDesktop))&&(n=!0),e.isCollapsed=!n}}),function(e,t){var r,n,a=i(e);null===(r=a.filters)||void 0===r||r.forEach(function(e){var r,n,i,a=null==t?void 0:t.find(function(t){return t.id===e.id});a?null===(r=e.values)||void 0===r||r.forEach(function(t){var r=a.values.find(function(e){return e.id===t.id});r?t.resultCount=r.count:m(e)?t.resultCount=null:t.resultCount=0}):m(e)?null===(n=e.values)||void 0===n||n.forEach(function(e){return e.resultCount=null}):null===(i=e.values)||void 0===i||i.forEach(function(e){return e.resultCount=0})});var o=null==t?void 0:t.find(function(e){return"category"===e.id});o&&(null===(n=a.filterCategories)||void 0===n||n.forEach(function(e){var t=o.values.find(function(t){return t.id===e.id});e.resultCount=t?t.count:0})),e.filters=a.filters,e.filterCategories=a.filterCategories,ye(e)}(e,null===(_=v.data)||void 0===_?void 0:_.facets),e.data=S,e.count=(null===(b=v.data)||void 0===b?void 0:b.count)||0,e.isInitialized=!0,e.page=o||1,e.minPage=e.page,v.data&&"suggestions"in v.data&&(e.suggestions=v.data.suggestions),z(e),J(e),a||(e.infiniteScrollPage=null),Re(e),[2,!0]):[2];case 14:return y=r.sent(),console.log(y),[3,16];case 15:return t===e.fetchRequestTime&&(e.isLoading=!1),[7];case 16:return[2]}})})}function ce(e){e.isCollapsed=!e.isCollapsed}function fe(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s,u,d,l,c;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,13,,14]),e.productListPropValue.category?[4,import("../../api/category/index.js")]:[3,3];case 1:return[4,(0,r.sent().apiListCategory)({id:{eq:e.productListPropValue.category}})];case 2:return t=r.sent(),e.category=(null===(o=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===o?void 0:o[0])||null,[3,7];case 3:return e.productListPropValue.usePageFilter&&"CATEGORY"===e.pageType&&e.pageSpecificData?(e.category=e.pageSpecificData,[3,7]):[3,4];case 4:return e.filterCategoryId?[4,import("../../api/category/index.js")]:[3,7];case 5:return[4,(0,r.sent().apiListCategory)({id:{eq:e.filterCategoryId}})];case 6:t=r.sent(),e.category=(null===(u=null===(s=t.data)||void 0===s?void 0:s.data)||void 0===u?void 0:u[0])||null,r.label=7;case 7:return e.productListPropValue.usePageFilter&&"BRAND"===e.pageType&&e.pageSpecificData?(e.brand=e.pageSpecificData,[3,12]):[3,8];case 8:return e.filterBrandId?e.filterBrandId!==(null===(d=e.pageSpecificData)||void 0===d?void 0:d.id)?[3,9]:(e.brand=e.pageSpecificData,[3,12]):[3,12];case 9:return[4,import("../../api/brand/index.js")];case 10:return[4,(0,r.sent().apiListProductBrand)({id:{eq:e.filterBrandId}})];case 11:n=r.sent(),e.brand=(null===(c=null===(l=n.data)||void 0===l?void 0:l.data)||void 0===c?void 0:c[0])||null,r.label=12;case 12:return[3,14];case 13:return i=r.sent(),console.error(i),[3,14];case 14:return[2]}})})}function ve(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:if(w(e)||F(e)||j(e)||x(e)||H(e)||W(e)||k(e)||e.isLoading||!B(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),t=e.minPage-1,[4,$(e,t,e.limit)];case 2:return(n=r.sent())?(i=null===(s=null===(o=n.data)||void 0===o?void 0:o.data)||void 0===s?void 0:s.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=(null==i?void 0:i.concat(e.data))||e.data,e.count=(null===(u=n.data)||void 0===u?void 0:u.count)||e.count,e.minPage=t,z(e),J(e),ne(e),[3,5]):[2];case 3:return a=r.sent(),console.log(a),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function pe(e){return t(this,void 0,void 0,function(){var t,n,i,a,o,s;return r(this,function(r){switch(r.label){case 0:if(w(e)||F(e)||j(e)||x(e)||H(e)||W(e)||k(e)||e.isLoading||!Y(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,$(e,e.page+1,e.limit)];case 2:return(t=r.sent())?(n=null===(o=null===(a=t.data)||void 0===a?void 0:a.data)||void 0===o?void 0:o.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=e.data.concat(n||[]),e.count=(null===(s=t.data)||void 0===s?void 0:s.count)||e.count,e.page=e.page+1,z(e),J(e),ne(e),[3,5]):[2];case 3:return i=r.sent(),console.log(i),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function ge(e,n){return t(this,void 0,void 0,function(){var t,i,a,o,s,u;return r(this,function(r){switch(r.label){case 0:if(e.isLoading||w(e)||F(e)||j(e)||k(e)||x(e)||H(e)||W(e))return[2];e.isLoading=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,$(e,n,e.limit)];case 2:return(t=r.sent())?(i=null===(s=null===(o=t.data)||void 0===o?void 0:o.data)||void 0===s?void 0:s.map(function(e){var t=de(e);return e.selectedVariantValues=t.variantValues,e}),e.data=i||[],e.count=(null===(u=t.data)||void 0===u?void 0:u.count)||0,e.page=n,e.minPage=n,z(e),J(e),ne(e),[3,5]):[2];case 3:return a=r.sent(),console.log(a),[3,5];case 4:return e.isLoading=!1,[7];case 5:return[2]}})})}function Ie(e,n){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.sort=n,[4,le(e)];case 1:return t.sent()&&ne(e),[2]}})})}function Ee(e){return Ce(e,e.sort)}function Ce(e,t){switch(t){case"INCREASING_PRICE":return a.translate("sort_type.increasing_price");case"DECREASING_PRICE":return a.translate("sort_type.decreasing_price");case"LAST_ADDED":return a.translate("sort_type.last_added");case"FIRST_ADDED":return a.translate("sort_type.first_added");case"INCREASING_DISCOUNT":return a.translate("sort_type.increasing_discount");case"DECRASING_DISCOUNT":return a.translate("sort_type.decreasing_discount");case"FEATURED":return a.translate("sort_type.featured");case"DEFAULT":return a.translate("sort_type.default");case"AVERAGE_RATING":return a.translate("sort_type.average_rating");case"REVIEW_COUNT":return a.translate("sort_type.review_count");case"SALE_COUNT":return a.translate("sort_type.sale_count");case"A_Z":return a.translate("sort_type.a_z");case"Z_A":return a.translate("sort_type.z_a")}}function Se(e){var t,r,n,i,a,o,s,u;if(!e)return[];var d=[];return(null===(t=e.disabledSortTypes)||void 0===t?void 0:t.includes("NAME"))||(d.push({label:Ce(0,"A_Z"),value:"A_Z",isSelected:"A_Z"===e.sort}),d.push({label:Ce(0,"Z_A"),value:"Z_A",isSelected:"Z_A"===e.sort})),(null===(r=e.disabledSortTypes)||void 0===r?void 0:r.includes("PRICE"))||(d.push({label:Ce(0,"INCREASING_PRICE"),value:"INCREASING_PRICE",isSelected:"INCREASING_PRICE"===e.sort}),d.push({label:Ce(0,"DECREASING_PRICE"),value:"DECREASING_PRICE",isSelected:"DECREASING_PRICE"===e.sort})),(null===(n=e.disabledSortTypes)||void 0===n?void 0:n.includes("CREATED_AT"))||(d.push({label:Ce(0,"LAST_ADDED"),value:"LAST_ADDED",isSelected:"LAST_ADDED"===e.sort}),d.push({label:Ce(0,"FIRST_ADDED"),value:"FIRST_ADDED",isSelected:"FIRST_ADDED"===e.sort})),(null===(i=e.disabledSortTypes)||void 0===i?void 0:i.includes("DISCOUNT_RATIO"))||(d.push({label:Ce(0,"INCREASING_DISCOUNT"),value:"INCREASING_DISCOUNT",isSelected:"INCREASING_DISCOUNT"===e.sort}),d.push({label:Ce(0,"DECRASING_DISCOUNT"),value:"DECRASING_DISCOUNT",isSelected:"DECRASING_DISCOUNT"===e.sort})),(null===(a=e.disabledSortTypes)||void 0===a?void 0:a.includes("MANUAL_SORT"))||d.push({label:Ce(0,"FEATURED"),value:"FEATURED",isSelected:"FEATURED"===e.sort}),(null===(o=e.disabledSortTypes)||void 0===o?void 0:o.includes("AVERAGE_RATING"))||d.push({label:Ce(0,"AVERAGE_RATING"),value:"AVERAGE_RATING",isSelected:"AVERAGE_RATING"===e.sort}),(null===(s=e.disabledSortTypes)||void 0===s?void 0:s.includes("REVIEW_COUNT"))||d.push({label:Ce(0,"REVIEW_COUNT"),value:"REVIEW_COUNT",isSelected:"REVIEW_COUNT"===e.sort}),(null===(u=e.disabledSortTypes)||void 0===u?void 0:u.includes("SALE_COUNT"))||d.push({label:Ce(0,"SALE_COUNT"),value:"SALE_COUNT",isSelected:"SALE_COUNT"===e.sort}),d}function Ae(e,i,a){return t(this,void 0,void 0,function(){var t,s,u;return r(this,function(r){switch(r.label){case 0:return a?(null===(u=e.filterCategories)||void 0===u||u.forEach(function(e){e.id===i.id&&(e.isSelected=!e.isSelected)}),[4,te(e)]):[3,2];case 1:return r.sent(),[3,3];case 2:n.isEditor||(t=re(e),s=S(i)+(t?"?"+t:""),o.navigate(s)),r.label=3;case 3:return[2]}})})}function ye(e){var t;null===(t=e.filterCategories)||void 0===t||t.forEach(function(e){e.image=e.imageId?{id:e.imageId,isVideo:!1}:null})}function Te(e,t){if(e.infiniteScrollPage!==t){e.infiniteScrollPage=t;var r=re(e);o.navigate("".concat(location.pathname).concat(r?"?"+r:""),!0)}}function Re(e){return t(this,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return e.searchKeyword&&e.data.length?[4,import("../../../analytics/analytics-functions/viewSearchResults.js")]:[3,2];case 1:return(0,t.sent().anl_viewSearchResults)(e.searchKeyword,e.data),[3,4];case 2:return e.data.length&&"ALL"===e.type?[4,import("../../../analytics/analytics-functions/viewListing.js")]:[3,4];case 3:(0,t.sent().anl_viewListing)(e.data),t.label=4;case 4:return[2]}})})}function De(e){var t=e.data[0];if(!t)return n.getDefaultCurrencyCode()||"";var r=de(t),i=b(r);return(null==i?void 0:i.currency)||n.getDefaultCurrencyCode()||""}function he(e){var t=e.data[0];if(!t)return n.getDefaultCurrencySymbol()||"";var r=de(t),i=b(r);return(null==i?void 0:i.currencySymbol)||n.getDefaultCurrencySymbol()||""}var _e=f(function(e){te(e)},500),me=f(function(e){return t(void 0,void 0,void 0,function(){return r(this,function(t){switch(t.label){case 0:return[4,import("../../../analytics/analytics-functions/search.js")];case 1:return(0,t.sent().anl_search)(e.searchKeyword),[2]}})})},1e3),be=((L={}).INCREASING_PRICE=1,L.DECREASING_PRICE=2,L.LAST_ADDED=3,L.FIRST_ADDED=4,L.INCREASING_DISCOUNT=5,L.DECRASING_DISCOUNT=6,L.FEATURED=7,L.DEFAULT=8,L.AVERAGE_RATING=9,L.REVIEW_COUNT=10,L.SALE_COUNT=11,L.A_Z=12,L.Z_A=13,L);export{ae as clearProductListFilter,ie as clearProductListFilters,X as enableProductListSuggestions,De as getProductListCurrencyCode,he as getProductListCurrencySymbol,Z as getProductListFilterCategories,le as getProductListInitialData,pe as getProductListNextPage,ge as getProductListPage,ve as getProductListPrevPage,Se as getProductListSortOptions,Ee as getProductListSortTypeTranslation,Q as getProductListSuggestionHref,ue as getSelectedFilterValues,oe as handleFilterValueClick,se as handleNumberRangeOptionClick,M as hasProductListAppliedFilters,q as hasProductListFeaturedSortEnabled,Y as hasProductListNextPage,B as hasProductListPrevPage,O as initProductList,ye as initProductListFilterCategories,P as initProductListOnBrowser,F as isProductListDiscounted,U as isProductListFilterable,V as isProductListFiltered,k as isProductListLastViewed,W as isProductListPurchasedTogether,j as isProductListRecommended,x as isProductListRelatedProducts,K as isProductListSearch,w as isProductListStatic,H as isProductListViewedTogether,Ae as onFilterCategoryClick,ce as productListToggleFilterCollapsed,G as searchProductList,z as setProductListIsFilteredForProducts,J as setProductListIsStaticForProducts,Te as setProductListVisiblePage,Ie as setSortType,Ce as translateProductListSortType};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as s,__assign as r}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as i}from"../../../../i18n/index.js";import{customerStore as a}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{waitForCustomerStoreInit as t,saveCustomer as o}from"../../../stores/customer/index.js";import{validateValue as n,FORM_ITEM_DEFAULT_VALUE as l}from"../index.js";import{isCustomerSubscribed as
|
|
1
|
+
import{__awaiter as e,__generator as s,__assign as r}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as i}from"../../../../i18n/index.js";import{customerStore as a}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{waitForCustomerStoreInit as t,saveCustomer as o}from"../../../stores/customer/index.js";import{validateValue as n,FORM_ITEM_DEFAULT_VALUE as l}from"../index.js";import{isCustomerSubscribed as m}from"../../customer/index.js";function u(o){return e(this,void 0,void 0,function(){var e;return s(this,function(s){switch(s.label){case 0:return[4,t(a)];case 1:return s.sent(),e=a.customer,o.firstName=r(r({},l),{value:(null==e?void 0:e.firstName)||"",isRequired:!0,label:i.translate("label.first_name"),placeholder:i.translate("placeholder.first_name")}),o.lastName=r(r({},l),{value:(null==e?void 0:e.lastName)||"",isRequired:!0,label:i.translate("label.last_name"),placeholder:i.translate("placeholder.last_name")}),o.phone=r(r({},l),{value:(null==e?void 0:e.phone)||"",isRequired:!1,label:i.translate("label.phone"),placeholder:i.translate("placeholder.phone")}),o.isMarketingAccepted={value:!!e&&m(e),hasError:!1,message:void 0},o.isInitialized=!0,o.isSubmitted=!1,o.isSubmitting=!1,o.isSuccess=void 0,o.isFailure=void 0,o.responseMessage=void 0,[2]}})})}function d(e,s){e.firstName&&(e.firstName.value=s),e.isSubmitted&&f(e)}function c(e,s){e.lastName&&(e.lastName.value=s),e.isSubmitted&&f(e)}function p(e,s){e.phone&&(e.phone.value=s),e.isSubmitted&&f(e)}function v(e,s){e.isMarketingAccepted&&(e.isMarketingAccepted.value=s,e.isSubmitted&&f(e))}function h(t){return e(this,void 0,void 0,function(){var e,n,l,m,u;return s(this,function(s){switch(s.label){case 0:return t.isSubmitted=!0,t.isSuccess=void 0,t.isFailure=void 0,t.responseMessage=void 0,f(t)?[2,!1]:(t.isSubmitting=!0,[4,o(a,r(r({},a.customer),{firstName:null===(n=t.firstName)||void 0===n?void 0:n.value,lastName:null===(l=t.lastName)||void 0===l?void 0:l.value,phone:null===(m=t.phone)||void 0===m?void 0:m.value,subscriptionStatus:(null===(u=t.isMarketingAccepted)||void 0===u?void 0:u.value)?"SUBSCRIBED":"NOT_SUBSCRIBED"}))]);case 1:return e=s.sent(),t.isSubmitting=!1,e?(t.isSuccess=!0,t.responseMessage=i.translate("notification.success.account_info"),[2,!0]):(t.isFailure=!0,t.responseMessage=i.translate("notification.failure.account_info"),[2,!1])}})})}function f(e){if(!e.firstName||!e.lastName||!e.phone)return!1;var s=n(e.firstName.value,{required:!0});s.hasError?(e.firstName.hasError=!0,e.firstName.message=s.message):(e.firstName.hasError=!1,e.firstName.message=void 0);var r=n(e.lastName.value,{required:!0});r.hasError?(e.lastName.hasError=!0,e.lastName.message=r.message):(e.lastName.hasError=!1,e.lastName.message=void 0);var i=n(e.phone.value,{phone:!0});return i.hasError?(e.phone.hasError=!0,e.phone.message=i.message):(e.phone.hasError=!1,e.phone.message=void 0),s.hasError||r.hasError||i.hasError}export{u as initAccountInfoForm,d as setAccountInfoFormFirstName,v as setAccountInfoFormIsMarketingAccepted,c as setAccountInfoFormLastName,p as setAccountInfoFormPhone,h as submitAccountInfoForm};
|
|
@@ -2,6 +2,13 @@ import { AddressForm, IkasCustomerAddress } from "../../../../storefront-models/
|
|
|
2
2
|
/**
|
|
3
3
|
* Initializes an address form with default or existing address values, loads location data, and configures field settings.
|
|
4
4
|
*
|
|
5
|
+
* Also resolves `addressForm.addressFormat` for the selected country. That is an
|
|
6
|
+
* `AddressFormItem[][]` describing which fields the country uses and how they group into rows
|
|
7
|
+
* (outer array = rows, inner array = fields sharing a row), and it is the only correct source
|
|
8
|
+
* for laying out an address form -- a hardcoded field list will be wrong for most countries.
|
|
9
|
+
* It is empty until this promise resolves, and `setAddressFormCountry` re-resolves it, so
|
|
10
|
+
* render from it rather than copying it into local state.
|
|
11
|
+
*
|
|
5
12
|
* @ai-category Address, Form, Initialization, Checkout
|
|
6
13
|
* @ai-related submitAddressForm, setAddressFormCountry, setAddressFormState, setAddressFormCity
|
|
7
14
|
*
|
|
@@ -10,14 +17,75 @@ import { AddressForm, IkasCustomerAddress } from "../../../../storefront-models/
|
|
|
10
17
|
* @returns A promise that resolves once the form is fully initialized, including country/state/city lists, field settings, checkout settings, and shipping zones.
|
|
11
18
|
*
|
|
12
19
|
* @example
|
|
13
|
-
* ```
|
|
14
|
-
* import {
|
|
20
|
+
* ```tsx
|
|
21
|
+
* import { useEffect, useState } from "preact/hooks";
|
|
22
|
+
* import {
|
|
23
|
+
* type AddressForm,
|
|
24
|
+
* type AddressFormItem,
|
|
25
|
+
* initAddressForm,
|
|
26
|
+
* setAddressFormFirstName,
|
|
27
|
+
* setAddressFormLastName,
|
|
28
|
+
* setAddressFormIdentityNumber,
|
|
29
|
+
* setAddressFormAddressLine1,
|
|
30
|
+
* setAddressFormAddressLine2,
|
|
31
|
+
* setAddressFormPostalCode,
|
|
32
|
+
* setAddressFormPhone,
|
|
33
|
+
* } from "@ikas/bp-storefront";
|
|
15
34
|
*
|
|
16
35
|
* // Initialize an empty address form
|
|
17
36
|
* await initAddressForm(addressForm);
|
|
18
37
|
*
|
|
19
38
|
* // Initialize with an existing customer address for editing
|
|
20
39
|
* await initAddressForm(addressForm, existingAddress);
|
|
40
|
+
*
|
|
41
|
+
* // addressFormat is empty until init resolves, so gate the render on it.
|
|
42
|
+
* const [isLoading, setIsLoading] = useState(true);
|
|
43
|
+
* useEffect(() => {
|
|
44
|
+
* initAddressForm(addressForm, address).then(() => setIsLoading(false));
|
|
45
|
+
* }, []);
|
|
46
|
+
*
|
|
47
|
+
* // Every addressFormat key has a matching setter, each taking (addressForm, value).
|
|
48
|
+
* // The location keys (country, state, city, district, region) are omitted here: they
|
|
49
|
+
* // render as selects fed by addressForm.countryOptions / stateOptions / cityOptions /
|
|
50
|
+
* // districtOptions / regionOptions, and must fall back to a text input when the field
|
|
51
|
+
* // isFreeText or has no options.
|
|
52
|
+
* const SETTERS: Partial<Record<AddressFormItem, (form: AddressForm, value: string) => void>> = {
|
|
53
|
+
* firstName: setAddressFormFirstName,
|
|
54
|
+
* lastName: setAddressFormLastName,
|
|
55
|
+
* identityNumber: setAddressFormIdentityNumber,
|
|
56
|
+
* addressLine1: setAddressFormAddressLine1,
|
|
57
|
+
* addressLine2: setAddressFormAddressLine2,
|
|
58
|
+
* postalCode: setAddressFormPostalCode,
|
|
59
|
+
* phone: setAddressFormPhone,
|
|
60
|
+
* };
|
|
61
|
+
*
|
|
62
|
+
* // Render the country's own layout: outer array = rows, inner array = fields in that row.
|
|
63
|
+
* (addressForm.addressFormat ?? []).map((row) => {
|
|
64
|
+
* // A field the country does not use is absent from the form object entirely.
|
|
65
|
+
* const keys = row.filter((key) => addressForm[key] != null);
|
|
66
|
+
* if (!keys.length) return null;
|
|
67
|
+
*
|
|
68
|
+
* return (
|
|
69
|
+
* <div className="address-row" key={keys.join("-")}>
|
|
70
|
+
* {keys.map((key) => {
|
|
71
|
+
* // Each entry is an IkasFormItem: value, label, placeholder, hasError, message.
|
|
72
|
+
* const field = addressForm[key];
|
|
73
|
+
* if (!field) return null; // already guaranteed by the filter above; narrows the type
|
|
74
|
+
* return (
|
|
75
|
+
* <label key={key}>
|
|
76
|
+
* {field.label}
|
|
77
|
+
* <input
|
|
78
|
+
* value={field.value ?? ""}
|
|
79
|
+
* placeholder={field.placeholder}
|
|
80
|
+
* onInput={(e) => SETTERS[key]?.(addressForm, e.currentTarget.value)}
|
|
81
|
+
* />
|
|
82
|
+
* {field.hasError && <small>{field.message}</small>}
|
|
83
|
+
* </label>
|
|
84
|
+
* );
|
|
85
|
+
* })}
|
|
86
|
+
* </div>
|
|
87
|
+
* );
|
|
88
|
+
* })
|
|
21
89
|
* ```
|
|
22
90
|
*/
|
|
23
91
|
export declare function initAddressForm(addressForm: AddressForm, address?: IkasCustomerAddress): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as s,__generator as a}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as r}from"../../../../i18n/index.js";import{customerStore as t}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{saveContactForm as i}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as o,validateValue as l}from"../index.js";function m(s){s.firstName=e(e({},o),{label:r.translate("label.first_name"),placeholder:r.translate("placeholder.first_name")}),s.lastName=e(e({},o),{label:r.translate("label.last_name"),placeholder:r.translate("placeholder.last_name")}),s.email=e(e({},o),{label:r.translate("label.email"),placeholder:r.translate("placeholder.email")}),s.phone=e(e({},o),{label:r.translate("label.phone"),placeholder:r.translate("placeholder.phone")}),s.message=e(e({},o),{label:r.translate("label.message"),placeholder:r.translate("placeholder.message")}),s.isSubmitted=!1,s.isSubmitting=!1,s.isSuccess=void 0,s.isFailure=void 0,s.responseMessage=void 0}function n(e,s){e.firstName.value=s,e.isSubmitted&&p(e)}function u(e,s){e.lastName.value=s,e.isSubmitted&&p(e)}function d(e,s){e.email.value=s,e.isSubmitted&&p(e)}function c(e,s){e.phone.value=s,e.isSubmitted&&p(e)}function h(e,s){e.message.value=s,e.isSubmitted&&p(e)}function f(e){return s(this,void 0,void 0,function(){var s;return a(this,function(a){switch(a.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,p(e)?[2,!1]:(e.isSubmitting=!0,[4,i(t,{firstName:e.firstName.value,lastName:e.lastName.value,email:e.email.value,message:e.message.value,referer:window.location.href,phone:e.phone.value})]);case 1:return s=a.sent(),e.isSubmitting=!1,s?(e.isSuccess=!0,e.responseMessage=r.translate("notification.success.contact_form"),[2,!0]):(e.isFailure=!0,e.responseMessage=r.translate("notification.failure.contact_form"),[2,!1])}})})}function p(e){var s=l(e.firstName.value,{required:!0});s.hasError?(e.firstName.hasError=!0,e.firstName.message=s.message):(e.firstName.hasError=!1,e.firstName.message=void 0);var a=l(e.lastName.value,{required:!0});a.hasError?(e.lastName.hasError=!0,e.lastName.message=a.message):(e.lastName.hasError=!1,e.lastName.message=void 0);var r=l(e.email.value,{required:!0,email:!0});r.hasError?(e.email.hasError=!0,e.email.message=r.message):(e.email.hasError=!1,e.email.message=void 0);var t=l(e.message.value,{required:!0});return t.hasError?(e.message.hasError=!0,e.message.message=t.message):(e.message.hasError=!1,e.message.message=void 0),s.hasError||a.hasError||r.hasError||t.hasError}export{m as initContactForm,d as setContactFormEmail,n as setContactFormFirstName,u as setContactFormLastName,h as setContactFormMessage,c as setContactFormPhone,f as submitContactForm};
|
|
1
|
+
import{__assign as e,__awaiter as s,__generator as a}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as r}from"../../../../i18n/index.js";import{customerStore as t}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{saveContactForm as i}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as o,validateValue as l}from"../index.js";function m(s){s.firstName=e(e({},o),{label:r.translate("label.first_name"),placeholder:r.translate("placeholder.first_name")}),s.lastName=e(e({},o),{label:r.translate("label.last_name"),placeholder:r.translate("placeholder.last_name")}),s.email=e(e({},o),{label:r.translate("label.email"),placeholder:r.translate("placeholder.email")}),s.phone=e(e({},o),{label:r.translate("label.phone"),placeholder:r.translate("placeholder.phone")}),s.message=e(e({},o),{label:r.translate("label.message"),placeholder:r.translate("placeholder.message")}),s.isSubmitted=!1,s.isSubmitting=!1,s.isSuccess=void 0,s.isFailure=void 0,s.responseMessage=void 0}function n(e,s){e.firstName.value=s,e.isSubmitted&&p(e)}function u(e,s){e.lastName.value=s,e.isSubmitted&&p(e)}function d(e,s){e.email.value=s,e.isSubmitted&&p(e)}function c(e,s){e.phone.value=s,e.isSubmitted&&p(e)}function h(e,s){e.message.value=s,e.isSubmitted&&p(e)}function f(e){return s(this,void 0,void 0,function(){var s;return a(this,function(a){switch(a.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,p(e)?[2,!1]:(e.isSubmitting=!0,[4,i(t,{firstName:e.firstName.value,lastName:e.lastName.value,email:e.email.value,message:e.message.value,referer:window.location.href,phone:e.phone.value})]);case 1:return s=a.sent(),e.isSubmitting=!1,s?(e.isSuccess=!0,e.responseMessage=r.translate("notification.success.contact_form"),[2,!0]):(e.isFailure=!0,e.responseMessage=r.translate("notification.failure.contact_form"),[2,!1])}})})}function p(e){var s=l(e.firstName.value,{required:!0});s.hasError?(e.firstName.hasError=!0,e.firstName.message=s.message):(e.firstName.hasError=!1,e.firstName.message=void 0);var a=l(e.lastName.value,{required:!0});a.hasError?(e.lastName.hasError=!0,e.lastName.message=a.message):(e.lastName.hasError=!1,e.lastName.message=void 0);var r=l(e.email.value,{required:!0,email:!0});r.hasError?(e.email.hasError=!0,e.email.message=r.message):(e.email.hasError=!1,e.email.message=void 0);var t=l(e.message.value,{required:!0});return t.hasError?(e.message.hasError=!0,e.message.message=t.message):(e.message.hasError=!1,e.message.message=void 0),s.hasError||a.hasError||r.hasError||t.hasError}export{m as initContactForm,d as setContactFormEmail,n as setContactFormFirstName,u as setContactFormLastName,h as setContactFormMessage,c as setContactFormPhone,f as submitContactForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as s,__awaiter as e,__generator as o}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as i}from"../../../../i18n/index.js";import{cartStore as t}from"../../../../stores/cart/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import{saveCouponCode as r}from"../../../stores/cart/index.js";import"../../../../packages/storefront-api-client/src/utils/api.js";import'./../../../../ext/isomorphic-fetch/fetch-npm-node.js';import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import"../../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as n,validateValue as
|
|
1
|
+
import{__assign as s,__awaiter as e,__generator as o}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as i}from"../../../../i18n/index.js";import{cartStore as t}from"../../../../stores/cart/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import{saveCouponCode as r}from"../../../stores/cart/index.js";import"../../../../packages/storefront-api-client/src/utils/api.js";import'./../../../../ext/isomorphic-fetch/fetch-npm-node.js';import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import"../../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as n,validateValue as a}from"../index.js";import'./../../../../ext/uuid/dist/esm-browser/stringify.js';import'./../../../../ext/uuid/dist/esm-browser/v3.js';import'./../../../../ext/uuid/dist/esm-browser/native.js';import'./../../../../ext/uuid/dist/esm-browser/v5.js';import"../../product-list/index.js";import"../../../../analytics/analytics.js";import'./../../../../ext/animejs/lib/anime.esm.js';import"../../../../packages/storefront-api/src/index.js";import"../../../../theme/styles/index.js";import'./../../../../ext/preact/dist/preact.mjs.js';import'./../../../../ext/preact/hooks/dist/hooks.mjs.js';import"../../../../utils/fetch.js";import"../../../../packages/storefront-models/src/models/merchant-settings/index.js";function u(e){e.couponCode=s(s({},n),{label:i.translate("label.coupon_code"),placeholder:i.translate("placeholder.coupon_code")}),e.isSubmitted=!1,e.isSubmitting=!1,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0}function c(s,e){s.couponCode.value=e,s.isSubmitted&&l(s)}function d(s){return e(this,void 0,void 0,function(){var e,n,a,u,c,d;return o(this,function(o){switch(o.label){case 0:return t.cart?(s.isSubmitted=!0,s.isSuccess=void 0,s.isFailure=void 0,s.responseMessage=void 0,l(s)?[2,!1]:(s.isSubmitting=!0,[4,r(t.cart,s.couponCode.value)])):[2,!1];case 1:return e=o.sent(),n=e.success,a=e.response,s.isSubmitting=!1,n?(s.isSuccess=!0,s.responseMessage=i.translate("notification.success.coupon_code_form"),[2,!0]):(s.isFailure=!0,u=function(s){switch(s){case"COUPON_CODE_NOT_EXIST":return i.translate("notification.failure.coupon_code_not_exist");case"COUPON_CODE_USAGE_LIMIT_ERROR":return i.translate("notification.failure.coupon_code_usage_limit_error");case"COUPON_CODE_CANNOT_USE_THIS_CART":return i.translate("notification.failure.coupon_code_cannot_use_this_cart");default:return i.translate("notification.failure.coupon_code_form")}}(null!==(d=null===(c=null==a?void 0:a.errorCodes)||void 0===c?void 0:c[0])&&void 0!==d?d:""),s.responseMessage=u,[2,!1])}})})}function m(s){return e(this,void 0,void 0,function(){var e;return o(this,function(o){switch(o.label){case 0:return t.cart?(s.isSubmitted=!0,s.isSuccess=void 0,s.isFailure=void 0,s.responseMessage=void 0,s.isSubmitting=!0,[4,r(t.cart,null)]):[2,!1];case 1:return e=o.sent().success,s.isSubmitting=!1,e?(s.isSuccess=!0,s.responseMessage=i.translate("notification.success.coupon_code_form_remove"),[2,!0]):(s.isFailure=!0,s.responseMessage=i.translate("notification.failure.coupon_code_form_remove"),[2,!1])}})})}function l(s){var e=a(s.couponCode.value,{required:!0});return e.hasError?(s.couponCode.hasError=!0,s.couponCode.message=e.message):(s.couponCode.hasError=!1,s.couponCode.message=void 0),e.hasError}export{u as initCouponCodeForm,m as removeCouponCodeForm,c as setCouponCodeFormCouponCode,d as submitCouponCodeForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as t,__generator as s}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as r}from"../../../../i18n/index.js";import{customerStore as
|
|
1
|
+
import{__assign as e,__awaiter as t,__generator as s}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as r}from"../../../../i18n/index.js";import{customerStore as o}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{sendReview as i}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as a,validateValue as n}from"../index.js";function m(t,s){t.title=e(e({},a),{label:r.translate("label.comment_title"),placeholder:r.translate("placeholder.comment_title")}),t.comment=e(e({},a),{label:r.translate("label.comment"),placeholder:r.translate("placeholder.comment")}),t.star=e(e({},a),{label:r.translate("label.comment_star"),placeholder:r.translate("placeholder.comment_star")}),t.productId=s,t.isSubmitted=!1,t.isSubmitting=!1,t.isSuccess=void 0,t.isFailure=void 0,t.responseMessage=void 0}function l(e,t){e.title.value=t,e.isSubmitted&&p(e)}function c(e,t){e.comment.value=t,e.isSubmitted&&p(e)}function u(e,t){e.star.value=t,e.isSubmitted&&p(e)}function d(e){return t(this,void 0,void 0,function(){var t;return s(this,function(s){switch(s.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,p(e)?[2,!1]:(e.isSubmitting=!0,[4,i(o,{title:e.title.value,comment:e.comment.value,star:parseInt(e.star.value),productId:e.productId})]);case 1:return t=s.sent(),e.isSubmitting=!1,t?(e.isSuccess=!0,e.responseMessage=r.translate("notification.success.customer_review"),[2,!0]):(e.isFailure=!0,e.responseMessage=r.translate("notification.failure.customer_review"),[2,!1])}})})}function p(e){e.title.hasError=!1,e.title.message=void 0,e.comment.hasError=!1,e.comment.message=void 0;var t=n(e.star.value,{required:!0,min:1,max:5,integer:!0});return t.hasError?(e.star.hasError=!0,e.star.message=t.message):(e.star.hasError=!1,e.star.message=void 0),t.hasError}export{m as initCustomerReviewForm,c as setCustomerReviewFormComment,u as setCustomerReviewFormStar,l as setCustomerReviewFormTitle,d as submitCustomerReviewForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as s,__awaiter as e,__generator as i}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as
|
|
1
|
+
import{__assign as s,__awaiter as e,__generator as i}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as o}from"../../../../i18n/index.js";import{customerStore as r}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{forgotPassword as t}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as a,validateValue as n}from"../index.js";function m(e){e.email=s(s({},a),{label:o.translate("label.email"),placeholder:o.translate("placeholder.email")}),e.isSubmitted=!1,e.isSubmitting=!1,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0}function l(s,e){s.email.value=e,s.isSubmitted&&u(s)}function d(s){return e(this,void 0,void 0,function(){var e;return i(this,function(i){switch(i.label){case 0:return s.isSubmitted=!0,s.isSuccess=void 0,s.isFailure=void 0,s.responseMessage=void 0,u(s)?[2,!1]:(s.isSubmitting=!0,[4,t(r,s.email.value)]);case 1:return e=i.sent(),s.isSubmitting=!1,e?(s.isSuccess=!0,s.responseMessage=o.translate("notification.success.forgot_password"),[2,!0]):(s.isFailure=!0,s.responseMessage=o.translate("notification.failure.forgot_password"),[2,!1])}})})}function u(s){var e=n(s.email.value,{required:!0,email:!0});return e.hasError?(s.email.hasError=!0,s.email.message=e.message):(s.email.hasError=!1,s.email.message=void 0),e.hasError}export{m as initForgotPasswordForm,l as setForgotPasswordFormEmail,d as submitForgotPasswordForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as s,__awaiter as e,__generator as r}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as i}from"../../../../i18n/index.js";import{customerStore as o}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{customerLogin as a}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as t,validateValue as
|
|
1
|
+
import{__assign as s,__awaiter as e,__generator as r}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as i}from"../../../../i18n/index.js";import{customerStore as o}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{customerLogin as a}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as t,validateValue as l}from"../index.js";function n(e){e.email=s(s({},t),{label:i.translate("label.email"),placeholder:i.translate("placeholder.email")}),e.password=s(s({},t),{label:i.translate("label.password"),placeholder:i.translate("placeholder.password")}),e.isSubmitted=!1,e.isSubmitting=!1,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0}function m(s,e){s.email.value=e,s.isSubmitted&&c(s)}function d(s,e){s.password.value=e,s.isSubmitted&&c(s)}function u(s){return e(this,void 0,void 0,function(){var e;return r(this,function(r){switch(r.label){case 0:return s.isSubmitted=!0,s.isSuccess=void 0,s.isFailure=void 0,s.responseMessage=void 0,c(s)?[2,!1]:(s.isSubmitting=!0,[4,a(o,s.email.value,s.password.value)]);case 1:return e=r.sent(),s.isSubmitting=!1,e.isSuccess?(s.isSuccess=!0,s.responseMessage=i.translate("notification.success.login"),[2,!0]):(s.isFailure=!0,s.responseMessage=i.translate("notification.failure.login"),[2,!1])}})})}function c(s){var e=l(s.email.value,{required:!0,email:!0});e.hasError?(s.email.hasError=!0,s.email.message=e.message):(s.email.hasError=!1,s.email.message=void 0);var r=l(s.password.value,{required:!0,min:6});return r.hasError?(s.password.hasError=!0,s.password.message=r.message):(s.password.hasError=!1,s.password.message=void 0),e.hasError||r.hasError}export{n as initLoginForm,m as setLoginFormEmail,d as setLoginFormPassword,u as submitLoginForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as s,__generator as i}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as r}from"../../../../i18n/index.js";import{customerStore as t}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{createEmailSubscription as o}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as a,validateValue as n}from"../index.js";function l(s){s.email=e(e({},a),{label:r.translate("label.email"),placeholder:r.translate("placeholder.email")}),s.isMarketingAccepted={value:!1,hasError:!1,message:void 0},s.isSubmitted=!1,s.isSubmitting=!1,s.isSuccess=void 0,s.isFailure=void 0,s.responseMessage=void 0}function m(e,s){e.email.value=s,e.isSubmitted&&
|
|
1
|
+
import{__assign as e,__awaiter as s,__generator as i}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as r}from"../../../../i18n/index.js";import{customerStore as t}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{createEmailSubscription as o}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as a,validateValue as n}from"../index.js";function l(s){s.email=e(e({},a),{label:r.translate("label.email"),placeholder:r.translate("placeholder.email")}),s.isMarketingAccepted={value:!1,hasError:!1,message:void 0},s.isSubmitted=!1,s.isSubmitting=!1,s.isSuccess=void 0,s.isFailure=void 0,s.responseMessage=void 0}function m(e,s){e.email.value=s,e.isSubmitted&&c(e)}function u(e,s){e.isMarketingAccepted.value=s,e.isSubmitted&&c(e)}function d(e){return s(this,void 0,void 0,function(){var s;return i(this,function(i){switch(i.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,c(e)?[2,!1]:(e.isSubmitting=!0,[4,o(t,e.email.value)]);case 1:return s=i.sent(),e.isSubmitting=!1,s.isSuccess?(e.isSuccess=!0,e.responseMessage=r.translate("notification.success.newsletter_subscription"),[2,!0]):(e.isFailure=!0,s.errorCodes.includes("CUSTOMER_ALREADY_SUBSCRIBED")?e.responseMessage=r.translate("notification.failure.newsletter_subscription_already_subscribed"):e.responseMessage=r.translate("notification.failure.newsletter_subscription"),[2,!1])}})})}function c(e){var s=n(e.email.value,{required:!0,email:!0});return s.hasError?(e.email.hasError=!0,e.email.message=s.message):(e.email.hasError=!1,e.email.message=void 0),s.hasError}export{l as initNewsletterSubscriptionForm,m as setNewsletterSubscriptionFormEmail,u as setNewsletterSubscriptionFormIsMarketingAccepted,d as submitNewsletterSubscriptionForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as r,__generator as s}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as i}from"../../../../i18n/index.js";import{customerStore as o}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{getOrderByEmail as a}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as t,validateValue as m}from"../index.js";function
|
|
1
|
+
import{__assign as e,__awaiter as r,__generator as s}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as i}from"../../../../i18n/index.js";import{customerStore as o}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{getOrderByEmail as a}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as t,validateValue as m}from"../index.js";function l(r){r.email=e(e({},t),{label:i.translate("label.email"),placeholder:i.translate("placeholder.email")}),r.orderNumber=e(e({},t),{label:i.translate("label.order_number"),placeholder:i.translate("placeholder.order_number")}),r.isSubmitted=!1,r.isSubmitting=!1,r.isSuccess=void 0,r.isFailure=void 0,r.responseMessage=void 0}function n(e,r){e.email.value=r,e.isSubmitted&&c(e)}function u(e,r){e.orderNumber.value=r,e.isSubmitted&&c(e)}function d(e){return r(this,void 0,void 0,function(){var r;return s(this,function(s){switch(s.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,c(e)?[2,null]:(e.isSubmitting=!0,[4,a(o,e.email.value,e.orderNumber.value)]);case 1:return r=s.sent(),e.isSubmitting=!1,r?(e.isSuccess=!0,e.responseMessage=i.translate("notification.success.order_tracking"),[2,r]):(e.isFailure=!0,e.responseMessage=i.translate("notification.failure.order_tracking"),[2,null])}})})}function c(e){var r=m(e.email.value,{required:!0,email:!0});r.hasError?(e.email.hasError=!0,e.email.message=r.message):(e.email.hasError=!1,e.email.message=void 0);var s=m(e.orderNumber.value,{required:!0});return s.hasError?(e.orderNumber.hasError=!0,e.orderNumber.message=s.message):(e.orderNumber.hasError=!1,e.orderNumber.message=void 0),r.hasError||s.hasError}export{l as initOrderTrackingForm,n as setOrderTrackingFormEmail,u as setOrderTrackingFormOrderNumber,d as submitOrderTrackingForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as s,__awaiter as
|
|
1
|
+
import{__assign as s,__awaiter as e,__generator as r}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as o}from"../../../../i18n/index.js";import{customerStore as a}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{recoverPassword as i}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as t,validateValue as n}from"../index.js";function d(e){e.password=s(s({},t),{label:o.translate("label.password"),placeholder:o.translate("placeholder.password")}),e.passwordAgain=s(s({},t),{label:o.translate("label.password_again"),placeholder:o.translate("placeholder.password_again")}),e.isSubmitted=!1,e.isSubmitting=!1,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0}function l(s,e){s.password.value=e,s.isSubmitted&&m(s)}function p(s,e){s.passwordAgain.value=e,s.isSubmitted&&m(s)}function u(s){return e(this,void 0,void 0,function(){var e,t,n;return r(this,function(r){switch(r.label){case 0:return s.isSubmitted=!0,s.isSuccess=void 0,s.isFailure=void 0,s.responseMessage=void 0,m(s)?[2,!1]:(e="","undefined"!=typeof window&&(t=new URLSearchParams(window.location.search),e=t.get("token")||""),s.isSubmitting=!0,[4,i(a,s.password.value,s.passwordAgain.value,e)]);case 1:return n=r.sent(),s.isSubmitting=!1,n?(s.isSuccess=!0,s.responseMessage=o.translate("notification.success.recover_password"),[2,!0]):(s.isFailure=!0,s.responseMessage=o.translate("notification.failure.recover_password"),[2,!1])}})})}function m(s){var e=n(s.password.value,{required:!0,min:6});e.hasError?(s.password.hasError=!0,s.password.message=e.message):(s.password.hasError=!1,s.password.message=void 0);var r=n(s.passwordAgain.value,{required:!0,equals:s.password.value});return r.hasError?(s.passwordAgain.hasError=!0,s.passwordAgain.message=r.message):(s.passwordAgain.hasError=!1,s.passwordAgain.message=void 0),e.hasError||r.hasError}export{d as initRecoverPasswordForm,l as setRecoverPasswordFormPassword,p as setRecoverPasswordFormPasswordAgain,u as submitRecoverPasswordForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as s,__generator as r}from'./../../../../ext/tslib/tslib.es6.mjs.js';import"../../../../analytics/analytics.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import'./../../../../ext/animejs/lib/anime.esm.js';import"../../../../packages/storefront-api-client/src/utils/api.js";import'./../../../../ext/isomorphic-fetch/fetch-npm-node.js';import"../../../../packages/storefront-api/src/index.js";import{customerStore as t}from"../../../../stores/customer/index.js";import{I18n as i}from"../../../../i18n/index.js";import{FORM_ITEM_DEFAULT_VALUE as a,validateValue as o}from"../index.js";import'./../../../../ext/lodash/sortBy.js';import"../../../../router/index.js";import"../../../../stores/cart/index.js";import{getCustomerAttributes as n,register as l}from"../../../stores/customer/index.js";import"../../../../stores/base/index.js";import'./../../../../ext/uuid/dist/esm-browser/stringify.js';import'./../../../../ext/uuid/dist/esm-browser/v3.js';import'./../../../../ext/uuid/dist/esm-browser/native.js';import'./../../../../ext/uuid/dist/esm-browser/v5.js';import{getCustomerAttributeRegisterPageRequirement as d}from"../../customer/attribute/index.js";import"../../product-list/index.js";import"../../../../theme/styles/index.js";import'./../../../../ext/preact/dist/preact.mjs.js';import'./../../../../ext/preact/hooks/dist/hooks.mjs.js';import"../../../../utils/fetch.js";import"../../../../packages/storefront-models/src/models/merchant-settings/index.js";function u(o){o.firstName=e(e({},a),{isRequired:!0,label:i.translate("label.first_name"),placeholder:i.translate("placeholder.first_name")}),o.lastName=e(e({},a),{isRequired:!0,label:i.translate("label.last_name"),placeholder:i.translate("placeholder.last_name")}),o.email=e(e({},a),{isRequired:!0,label:i.translate("label.email"),placeholder:i.translate("placeholder.email")}),o.password=e(e({},a),{isRequired:!0,label:i.translate("label.password"),placeholder:i.translate("placeholder.password")}),o.phone=e(e({},a),{label:i.translate("label.phone"),placeholder:i.translate("placeholder.phone")}),o.isMarketingAccepted=T,o.isMembershipAgreementAccepted=e(e({},T),{isRequired:!0}),function(i){s(this,void 0,void 0,function(){var s;return r(this,function(r){switch(r.label){case 0:return i.attributes=[],i.isInitialized=!1,[4,n(t)];case 1:return s=r.sent(),i.isInitialized=!0,s.length?(i.attributes=s.filter(function(e){return"INVISIBLE"!==d(e)}).map(function(s){var r;return e(e({},a),{id:s.id,label:s.name,placeholder:s.description||"",isRequired:"MANDATORY"===d(s),type:s.type,options:"CHOICE"===s.type||"MULTIPLE_CHOICE"===s.type?(null===(r=s.options)||void 0===r?void 0:r.map(function(e){return{value:e.id,label:e.name}}))||[]:void 0,isChecked:void 0,value:void 0,selectedIdList:void 0})}),[2]):[2]}})})}(o),o.isSubmitted=!1,o.isSubmitting=!1,o.isSuccess=void 0,o.isFailure=void 0,o.responseMessage=void 0}function m(e,s,r){"string"!=typeof r&&"TEXT"!==s.type||(s.value=r)}function p(e,s,r){"string"!=typeof r&&"DATETIME"!==s.type||(s.value=r)}function c(e,s,r){"string"!=typeof r&&"DATE"!==s.type||(s.value=r)}function h(e,s,r){"string"!=typeof r&&"CHOICE"!==s.type||(s.value=r)}function v(e,s,r){"string"!=typeof r&&"NUMERIC"!==s.type||(Number.isInteger(Number(r))?s.value=r:s.value=r.slice(0,-1))}function f(e,s,r){"boolean"!=typeof r&&"CHOICE"!==s.type||(s.isChecked=r)}function g(e,s,r){"object"!=typeof r&&"MULTIPLE_CHOICE"!==s.type||(s.selectedIdList=r)}function E(e,s){e.firstName.value=s,e.isSubmitted&&N(e)}function b(e,s){e.lastName.value=s,e.isSubmitted&&N(e)}function y(e,s){e.email.value=s,e.isSubmitted&&N(e)}function I(e,s){e.password.value=s,e.isSubmitted&&N(e)}function A(e,s){e.phone.value=s,e.isSubmitted&&N(e)}function j(e,s){e.isMarketingAccepted.value=s,e.isSubmitted&&N(e)}function C(e,s){e.isMembershipAgreementAccepted.value=s,e.isSubmitted&&N(e)}function M(e){return s(this,void 0,void 0,function(){var s,a;return r(this,function(r){switch(r.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,N(e)?[2,!1]:(s=function(e){for(var s=[],r=0,t=e.attributes;r<t.length;r++){var i=t[r];if(!i.hasError)if(i.selectedIdList&&"MULTIPLE_CHOICE"===i.type)for(var a=0,o=i.selectedIdList;a<o.length;a++){var n=o[a];s.push({customerAttributeId:i.id,customerAttributeOptionId:n})}else"BOOLEAN"!==i.type?!i.value||"TEXT"!==i.type&&"NUMERIC"!==i.type?i.value&&"CHOICE"===i.type?s.push({customerAttributeId:i.id,customerAttributeOptionId:i.value}):!i.value||"DATE"!==i.type&&"DATETIME"!==i.type||s.push({customerAttributeId:i.id,value:new Date(i.value).getTime().toString()}):s.push({customerAttributeId:i.id,value:i.value}):s.push({customerAttributeId:i.id,value:i.isChecked?i.isChecked.toString():"false"})}return s}(e),e.isSubmitting=!0,[4,l(t,e.firstName.value,e.lastName.value,e.email.value,e.password.value,e.isMarketingAccepted.value,s,e.phone.value)]);case 1:return a=r.sent(),e.isSubmitting=!1,a.isSuccess?(e.isSuccess=!0,e.responseMessage=i.translate("notification.success.register"),[2,!0]):(e.isFailure=!0,e.responseMessage=i.translate("notification.failure.register"),[2,!1])}})})}function N(e){var s=o(e.firstName.value,{required:!0});s.hasError?(e.firstName.hasError=!0,e.firstName.message=s.message):(e.firstName.hasError=!1,e.firstName.message=void 0);var r=o(e.lastName.value,{required:!0});r.hasError?(e.lastName.hasError=!0,e.lastName.message=r.message):(e.lastName.hasError=!1,e.lastName.message=void 0);var t=o(e.email.value,{required:!0,email:!0});t.hasError?(e.email.hasError=!0,e.email.message=t.message):(e.email.hasError=!1,e.email.message=void 0);var i=o(e.password.value,{required:!0,min:6});i.hasError?(e.password.hasError=!0,e.password.message=i.message):(e.password.hasError=!1,e.password.message=void 0);var a=o(e.isMembershipAgreementAccepted.value,{required:!0});a.hasError?(e.isMembershipAgreementAccepted.hasError=!0,e.isMembershipAgreementAccepted.message=a.message):(e.isMembershipAgreementAccepted.hasError=!1,e.isMembershipAgreementAccepted.message=void 0);for(var n=0,l=e.attributes;n<l.length;n++){var d=l[n];if("BOOLEAN"!==d.type){if(d.isRequired){if("TEXT"===d.type||"DATETIME"===d.type||"DATE"===d.type||"CHOICE"===d.type||"NUMERIC"===d.type){(u=o(d.value||"",{required:!0})).hasError?(d.hasError=!0,d.message=u.message):(d.hasError=!1,d.message=void 0);continue}if("MULTIPLE_CHOICE"===d.type){var u;(u=o(d.selectedIdList||[],{required:!0})).hasError?(d.hasError=!0,d.message=u.message):(d.hasError=!1,d.message=void 0);continue}}d.hasError=!1,d.message=void 0}else void 0===d.isChecked&&(d.isChecked=!1),d.hasError=!1,d.message=void 0}return s.hasError||r.hasError||t.hasError||i.hasError||a.hasError||!1}var T={value:!1,hasError:!1,message:void 0};export{u as initRegisterForm,f as setRegisterFormBooleanAttribute,h as setRegisterFormChoiceAttribute,c as setRegisterFormDateAttribute,p as setRegisterFormDateTimeAttribute,y as setRegisterFormEmail,E as setRegisterFormFirstName,j as setRegisterFormIsMarketingAccepted,C as setRegisterFormIsMembershipAgreementAccepted,b as setRegisterFormLastName,g as setRegisterFormMultipleChoiceAttribute,v as setRegisterFormNumericAttribute,I as setRegisterFormPassword,A as setRegisterFormPhone,m as setRegisterFormTextAttribute,M as submitRegisterForm};
|
|
1
|
+
import{__assign as e,__awaiter as s,__generator as r}from'./../../../../ext/tslib/tslib.es6.mjs.js';import"../../../../analytics/analytics.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import'./../../../../ext/animejs/lib/anime.esm.js';import"../../../../packages/storefront-api-client/src/utils/api.js";import'./../../../../ext/isomorphic-fetch/fetch-npm-node.js';import"../../../../packages/storefront-api/src/index.js";import{customerStore as t}from"../../../../stores/customer/index.js";import{I18n as i}from"../../../../i18n/index.js";import{FORM_ITEM_DEFAULT_VALUE as a,validateValue as o}from"../index.js";import'./../../../../ext/lodash/sortBy.js';import"../../../../router/index.js";import"../../../../stores/cart/index.js";import{getCustomerAttributes as n,register as l}from"../../../stores/customer/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import"../../../../stores/base/index.js";import'./../../../../ext/uuid/dist/esm-browser/stringify.js';import'./../../../../ext/uuid/dist/esm-browser/v3.js';import'./../../../../ext/uuid/dist/esm-browser/native.js';import'./../../../../ext/uuid/dist/esm-browser/v5.js';import{getCustomerAttributeRegisterPageRequirement as d}from"../../customer/attribute/index.js";import"../../product-list/index.js";import"../../../../theme/styles/index.js";import'./../../../../ext/preact/dist/preact.mjs.js';import'./../../../../ext/preact/hooks/dist/hooks.mjs.js';import"../../../../utils/fetch.js";import"../../../../packages/storefront-models/src/models/merchant-settings/index.js";function u(o){o.firstName=e(e({},a),{isRequired:!0,label:i.translate("label.first_name"),placeholder:i.translate("placeholder.first_name")}),o.lastName=e(e({},a),{isRequired:!0,label:i.translate("label.last_name"),placeholder:i.translate("placeholder.last_name")}),o.email=e(e({},a),{isRequired:!0,label:i.translate("label.email"),placeholder:i.translate("placeholder.email")}),o.password=e(e({},a),{isRequired:!0,label:i.translate("label.password"),placeholder:i.translate("placeholder.password")}),o.phone=e(e({},a),{label:i.translate("label.phone"),placeholder:i.translate("placeholder.phone")}),o.isMarketingAccepted=T,o.isMembershipAgreementAccepted=e(e({},T),{isRequired:!0}),function(i){s(this,void 0,void 0,function(){var s;return r(this,function(r){switch(r.label){case 0:return i.attributes=[],i.isInitialized=!1,[4,n(t)];case 1:return s=r.sent(),i.isInitialized=!0,s.length?(i.attributes=s.filter(function(e){return"INVISIBLE"!==d(e)}).map(function(s){var r;return e(e({},a),{id:s.id,label:s.name,placeholder:s.description||"",isRequired:"MANDATORY"===d(s),type:s.type,options:"CHOICE"===s.type||"MULTIPLE_CHOICE"===s.type?(null===(r=s.options)||void 0===r?void 0:r.map(function(e){return{value:e.id,label:e.name}}))||[]:void 0,isChecked:void 0,value:void 0,selectedIdList:void 0})}),[2]):[2]}})})}(o),o.isSubmitted=!1,o.isSubmitting=!1,o.isSuccess=void 0,o.isFailure=void 0,o.responseMessage=void 0}function m(e,s,r){"string"!=typeof r&&"TEXT"!==s.type||(s.value=r)}function p(e,s,r){"string"!=typeof r&&"DATETIME"!==s.type||(s.value=r)}function c(e,s,r){"string"!=typeof r&&"DATE"!==s.type||(s.value=r)}function h(e,s,r){"string"!=typeof r&&"CHOICE"!==s.type||(s.value=r)}function v(e,s,r){"string"!=typeof r&&"NUMERIC"!==s.type||(Number.isInteger(Number(r))?s.value=r:s.value=r.slice(0,-1))}function f(e,s,r){"boolean"!=typeof r&&"CHOICE"!==s.type||(s.isChecked=r)}function g(e,s,r){"object"!=typeof r&&"MULTIPLE_CHOICE"!==s.type||(s.selectedIdList=r)}function E(e,s){e.firstName.value=s,e.isSubmitted&&N(e)}function b(e,s){e.lastName.value=s,e.isSubmitted&&N(e)}function y(e,s){e.email.value=s,e.isSubmitted&&N(e)}function I(e,s){e.password.value=s,e.isSubmitted&&N(e)}function A(e,s){e.phone.value=s,e.isSubmitted&&N(e)}function j(e,s){e.isMarketingAccepted.value=s,e.isSubmitted&&N(e)}function C(e,s){e.isMembershipAgreementAccepted.value=s,e.isSubmitted&&N(e)}function M(e){return s(this,void 0,void 0,function(){var s,a;return r(this,function(r){switch(r.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,N(e)?[2,!1]:(s=function(e){for(var s=[],r=0,t=e.attributes;r<t.length;r++){var i=t[r];if(!i.hasError)if(i.selectedIdList&&"MULTIPLE_CHOICE"===i.type)for(var a=0,o=i.selectedIdList;a<o.length;a++){var n=o[a];s.push({customerAttributeId:i.id,customerAttributeOptionId:n})}else"BOOLEAN"!==i.type?!i.value||"TEXT"!==i.type&&"NUMERIC"!==i.type?i.value&&"CHOICE"===i.type?s.push({customerAttributeId:i.id,customerAttributeOptionId:i.value}):!i.value||"DATE"!==i.type&&"DATETIME"!==i.type||s.push({customerAttributeId:i.id,value:new Date(i.value).getTime().toString()}):s.push({customerAttributeId:i.id,value:i.value}):s.push({customerAttributeId:i.id,value:i.isChecked?i.isChecked.toString():"false"})}return s}(e),e.isSubmitting=!0,[4,l(t,e.firstName.value,e.lastName.value,e.email.value,e.password.value,e.isMarketingAccepted.value,s,e.phone.value)]);case 1:return a=r.sent(),e.isSubmitting=!1,a.isSuccess?(e.isSuccess=!0,e.responseMessage=i.translate("notification.success.register"),[2,!0]):(e.isFailure=!0,e.responseMessage=i.translate("notification.failure.register"),[2,!1])}})})}function N(e){var s=o(e.firstName.value,{required:!0});s.hasError?(e.firstName.hasError=!0,e.firstName.message=s.message):(e.firstName.hasError=!1,e.firstName.message=void 0);var r=o(e.lastName.value,{required:!0});r.hasError?(e.lastName.hasError=!0,e.lastName.message=r.message):(e.lastName.hasError=!1,e.lastName.message=void 0);var t=o(e.email.value,{required:!0,email:!0});t.hasError?(e.email.hasError=!0,e.email.message=t.message):(e.email.hasError=!1,e.email.message=void 0);var i=o(e.password.value,{required:!0,min:6});i.hasError?(e.password.hasError=!0,e.password.message=i.message):(e.password.hasError=!1,e.password.message=void 0);var a=o(e.isMembershipAgreementAccepted.value,{required:!0});a.hasError?(e.isMembershipAgreementAccepted.hasError=!0,e.isMembershipAgreementAccepted.message=a.message):(e.isMembershipAgreementAccepted.hasError=!1,e.isMembershipAgreementAccepted.message=void 0);for(var n=0,l=e.attributes;n<l.length;n++){var d=l[n];if("BOOLEAN"!==d.type){if(d.isRequired){if("TEXT"===d.type||"DATETIME"===d.type||"DATE"===d.type||"CHOICE"===d.type||"NUMERIC"===d.type){(u=o(d.value||"",{required:!0})).hasError?(d.hasError=!0,d.message=u.message):(d.hasError=!1,d.message=void 0);continue}if("MULTIPLE_CHOICE"===d.type){var u;(u=o(d.selectedIdList||[],{required:!0})).hasError?(d.hasError=!0,d.message=u.message):(d.hasError=!1,d.message=void 0);continue}}d.hasError=!1,d.message=void 0}else void 0===d.isChecked&&(d.isChecked=!1),d.hasError=!1,d.message=void 0}return s.hasError||r.hasError||t.hasError||i.hasError||a.hasError||!1}var T={value:!1,hasError:!1,message:void 0};export{u as initRegisterForm,f as setRegisterFormBooleanAttribute,h as setRegisterFormChoiceAttribute,c as setRegisterFormDateAttribute,p as setRegisterFormDateTimeAttribute,y as setRegisterFormEmail,E as setRegisterFormFirstName,j as setRegisterFormIsMarketingAccepted,C as setRegisterFormIsMembershipAgreementAccepted,b as setRegisterFormLastName,g as setRegisterFormMultipleChoiceAttribute,v as setRegisterFormNumericAttribute,I as setRegisterFormPassword,A as setRegisterFormPhone,m as setRegisterFormTextAttribute,M as submitRegisterForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as
|
|
1
|
+
import{__assign as e,__awaiter as s,__generator as r}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as t}from"../../../../i18n/index.js";import{customerStore as i}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{register as a,validateOTPCode as o,customerLogin as l}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as n,validateValue as m}from"../index.js";var d=null;function u(s){s.phone=e(e({},n),{label:t.translate("label.phone"),placeholder:t.translate("placeholder.phone")}),s.code=e(e({},n),{label:t.translate("label.code"),placeholder:t.translate("placeholder.code")}),s.firstName=e(e({},n),{label:t.translate("label.first_name"),placeholder:t.translate("placeholder.first_name")}),s.lastName=e(e({},n),{label:t.translate("label.last_name"),placeholder:t.translate("placeholder.last_name")}),s.email=e(e({},n),{label:t.translate("label.email"),placeholder:t.translate("placeholder.email")}),s.isMarketingAccepted={value:!1,hasError:!1,message:void 0},s.isMembershipAgreementAccepted={value:!1,hasError:!1,message:void 0,isRequired:!0},s.step="Enter Phone Number",s.time=void 0,s.formattedTime=void 0,s.isSubmitted=!1,s.isSubmitting=!1,s.isSuccess=void 0,s.isFailure=void 0,s.responseMessage=void 0}function c(e,s){e.phone.value=s,e.isSubmitted&&"Enter Phone Number"===e.step&&M(e)}function p(e,s){e.code.value=s,e.isSubmitted&&"Verify Code"===e.step&&M(e)}function f(e,s){e.firstName.value=s,e.isSubmitted&&"Complete Profile"===e.step&&M(e)}function h(e,s){e.lastName.value=s,e.isSubmitted&&"Complete Profile"===e.step&&M(e)}function v(e,s){e.email.value=s,e.isSubmitted&&"Complete Profile"===e.step&&M(e)}function g(e,s){e.isMarketingAccepted.value=s,e.isSubmitted&&M(e)}function b(e,s){e.isMembershipAgreementAccepted.value=s,e.isSubmitted&&M(e)}function E(e){void 0===e&&(e=120);var s=Math.floor(e/60),r=e%60;return"".concat(s.toString().padStart(2,"0"),":").concat(r.toString().padStart(2,"0"))}function S(e){return s(this,void 0,void 0,function(){var s;return r(this,function(r){switch(r.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,M(e)?[2,!1]:"Enter Phone Number"!==e.step?[3,2]:[4,N(e)];case 1:return r.sent()?(e.step="Verify Code",[3,6]):[2,!1];case 2:return"Verify Code"!==e.step?[3,4]:(e.isSubmitting=!0,[4,o(i,e.code.value,e.phone.value)]);case 3:return s=r.sent(),e.isSubmitting=!1,s.isSuccess?(d&&clearInterval(d),e.time=void 0,e.formattedTime=void 0,s.flowId?(e.flowId=s.flowId,e.step="Complete Profile",[2,!0]):(e.isSuccess=!0,e.responseMessage=t.translate("notification.success.login"),e.step="Completed",[3,6])):(e.isFailure=!0,e.responseMessage=t.translate("notification.failure.login"),[2,!1]);case 4:return"Complete Profile"!==e.step?[3,6]:(e.isSubmitting=!0,[4,a(i,e.firstName.value,e.lastName.value,e.email.value,void 0,e.isMarketingAccepted.value,void 0,e.phone.value,e.flowId)]);case 5:if(s=r.sent(),e.isSubmitting=!1,!s.isSuccess)return e.isFailure=!0,e.responseMessage=t.translate("notification.failure.register"),[2,!1];e.isSuccess=!0,e.responseMessage=t.translate("notification.success.login"),r.label=6;case 6:return[2,!0]}})})}function N(e){return s(this,void 0,void 0,function(){var s;return r(this,function(r){switch(r.label){case 0:return e.isSubmitting=!0,[4,l(i,void 0,void 0,e.phone.value)];case 1:return s=r.sent(),e.isSubmitting=!1,s&&s.isSuccess?(d&&clearInterval(d),e.time=120,e.formattedTime=E(),d=setInterval(function(){e.time&&e.time>0?(e.time=e.time-1,e.formattedTime=E(e.time)):(e.time=void 0,e.formattedTime=void 0,d&&clearInterval(d))},1e3),e.otpSend=s.otpSend,e.flowId=s.flowId,[2,!0]):(e.isFailure=!0,e.responseMessage=t.translate("notification.failure.login"),[2,!1])}})})}function C(e){return s(this,void 0,void 0,function(){return r(this,function(s){switch(s.label){case 0:return"Verify Code"!==e.step?[2]:[4,N(e)];case 1:return s.sent(),[2]}})})}function M(e){var s=m(e.phone.value,{required:!0,phone:!0});s.hasError&&"Enter Phone Number"===e.step?(e.phone.hasError=!0,e.phone.message=s.message):(e.phone.hasError=!1,e.phone.message=void 0);var r=m(e.code.value,{required:!0});r.hasError&&"Verify Code"===e.step?(e.code.hasError=!0,e.code.message=r.message):(e.code.hasError=!1,e.code.message=void 0);var t=m(e.firstName.value,{required:!0});t.hasError&&"Complete Profile"===e.step?(e.firstName.hasError=!0,e.firstName.message=t.message):(e.firstName.hasError=!1,e.firstName.message=void 0);var i=m(e.lastName.value,{required:!0});i.hasError&&"Complete Profile"===e.step?(e.lastName.hasError=!0,e.lastName.message=i.message):(e.lastName.hasError=!1,e.lastName.message=void 0);var a=m(e.email.value,{required:!0,email:!0});a.hasError&&"Complete Profile"===e.step?(e.email.hasError=!0,e.email.message=a.message):(e.email.hasError=!1,e.email.message=void 0);var o=m(e.isMembershipAgreementAccepted.value,{required:!0});return o.hasError&&"Complete Profile"===e.step?(e.isMembershipAgreementAccepted.hasError=!0,e.isMembershipAgreementAccepted.message=o.message):(e.isMembershipAgreementAccepted.hasError=!1,e.isMembershipAgreementAccepted.message=void 0),s.hasError&&"Enter Phone Number"===e.step||r.hasError&&"Verify Code"===e.step||t.hasError&&"Complete Profile"===e.step||i.hasError&&"Complete Profile"===e.step||a.hasError&&"Complete Profile"===e.step||o.hasError&&"Complete Profile"===e.step}export{u as initSmsLoginForm,C as resendSmsLoginFormCode,p as setSmsLoginFormCode,v as setSmsLoginFormEmail,f as setSmsLoginFormFirstName,g as setSmsLoginFormIsMarketingAccepted,b as setSmsLoginFormIsMembershipAgreementAccepted,h as setSmsLoginFormLastName,c as setSmsLoginFormPhone,S as submitSmsLoginForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as t,__generator as i}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as r}from"../../../../i18n/index.js";import{customerStore as s}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{validateCustomerPhoneVerificationCode as o,waitForCustomerStoreInit as n,resendCustomerPhoneVerificationCode as a}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as d,validateValue as u}from"../index.js";var c=null;function m(t){t.code=e(e({},d),{label:r.translate("label.code"),placeholder:r.translate("placeholder.code")}),t.step="Enter Phone Number",t.time=void 0,t.formattedTime=void 0,t.isSubmitted=!1,t.isSubmitting=!1,t.isSuccess=void 0,t.isFailure=void 0,t.responseMessage=void 0}function l(e,t){e.code&&(e.code.value=t),e.isSubmitted&&h(e)}function f(e){void 0===e&&(e=120);var t=Math.floor(e/60),i=e%60;return"".concat(t.toString().padStart(2,"0"),":").concat(i.toString().padStart(2,"0"))}function
|
|
1
|
+
import{__assign as e,__awaiter as t,__generator as i}from'./../../../../ext/tslib/tslib.es6.mjs.js';import{I18n as r}from"../../../../i18n/index.js";import{customerStore as s}from"../../../../stores/customer/index.js";import"../../../../packages/storefront-config/src/index.js";import'./../../../../ext/lodash/_isFlattenable.js';import'./../../../../ext/lodash/sortBy.js';import"../../../../stores/base/index.js";import"../../../../stores/cart/index.js";import'./../../../../ext/mobx/dist/mobx.esm.js';import"../../../../router/index.js";import{validateCustomerPhoneVerificationCode as o,waitForCustomerStoreInit as n,resendCustomerPhoneVerificationCode as a}from"../../../stores/customer/index.js";import{FORM_ITEM_DEFAULT_VALUE as d,validateValue as u}from"../index.js";var c=null;function m(t){t.code=e(e({},d),{label:r.translate("label.code"),placeholder:r.translate("placeholder.code")}),t.step="Enter Phone Number",t.time=void 0,t.formattedTime=void 0,t.isSubmitted=!1,t.isSubmitting=!1,t.isSuccess=void 0,t.isFailure=void 0,t.responseMessage=void 0}function l(e,t){e.code&&(e.code.value=t),e.isSubmitted&&h(e)}function f(e){void 0===e&&(e=120);var t=Math.floor(e/60),i=e%60;return"".concat(t.toString().padStart(2,"0"),":").concat(i.toString().padStart(2,"0"))}function p(e){return t(this,void 0,void 0,function(){var t,a,d;return i(this,function(i){switch(i.label){case 0:return e.isSubmitted=!0,e.isSuccess=void 0,e.isFailure=void 0,e.responseMessage=void 0,h(e)?[2,!1]:"Enter Phone Number"!==e.step?[3,2]:[4,b(e)];case 1:return i.sent()?(e.step="Verify Code",[3,5]):[2,!1];case 2:return"Verify Code"!==e.step?[3,5]:(e.isSubmitting=!0,[4,n(s)]);case 3:return i.sent(),t=(null===(d=s.customer)||void 0===d?void 0:d.phone)||"",[4,o(s,e.code.value,t)];case 4:if(a=i.sent(),e.isSubmitting=!1,!a)return e.isFailure=!0,e.responseMessage=r.translate("notification.failure.verify_phone_number"),[2,!1];c&&clearInterval(c),e.time=void 0,e.formattedTime=void 0,e.isSuccess=!0,e.responseMessage=r.translate("notification.success.verify_phone_number"),e.step="Completed",s.customer&&(s.customer.isPhoneVerified=!0),i.label=5;case 5:return[2,!0]}})})}function v(e){return t(this,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return"Verify Code"!==e.step?[2]:[4,b(e)];case 1:return t.sent(),[2]}})})}function b(e){return t(this,void 0,void 0,function(){var t;return i(this,function(i){switch(i.label){case 0:return e.isSubmitting=!0,[4,a()];case 1:return t=i.sent(),e.isSubmitting=!1,t?(e.step="Verify Code",c&&clearInterval(c),e.time=120,e.formattedTime=f(),c=setInterval(function(){e.time&&e.time>0?(e.time=e.time-1,e.formattedTime=f(e.time)):(e.time=void 0,e.formattedTime=void 0,c&&clearInterval(c))},1e3),[2,!0]):(e.isFailure=!0,e.responseMessage=r.translate("notification.failure.account_info"),[2,!1])}})})}function h(e){var t=u(e.code.value,{required:!0});return t.hasError&&"Verify Code"===e.step?(e.code.hasError=!0,e.code.message=t.message):(e.code.hasError=!1,e.code.message=void 0),t.hasError&&"Verify Code"===e.step}export{m as initVerifyPhoneNumberForm,v as resendVerifyPhoneNumberFormCode,l as setVerifyPhoneNumberFormCode,p as submitVerifyPhoneNumberForm};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IkasLanguageOption, IkasProduct, IkasThemePageType } from "../../../storefront-models/src";
|
|
1
|
+
import { IkasLanguageOption, IkasLocaleOption, IkasProduct, IkasThemePageType } from "../../../storefront-models/src";
|
|
2
2
|
import { BaseStore } from "../../../stores/base";
|
|
3
3
|
/**
|
|
4
4
|
* Initializes the base store by setting the current page type.
|
|
@@ -17,6 +17,43 @@ import { BaseStore } from "../../../stores/base";
|
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
19
|
export declare function initBaseStore(pageType: IkasThemePageType): void;
|
|
20
|
+
/**
|
|
21
|
+
* Switches the storefront to the routing associated with `localeOption` and redirects the browser
|
|
22
|
+
* to the equivalent URL under that routing.
|
|
23
|
+
*
|
|
24
|
+
* Reads the routing directly from `localeOption.routing`, then performs a full-page redirect via
|
|
25
|
+
* `window.location.replace`. For CATEGORY/BRAND/PRODUCT pages, the localized slug from the page's
|
|
26
|
+
* metadata translations is used when available; otherwise the visitor stays on the current path
|
|
27
|
+
* (with the current routing prefix swapped for the new one). Query string and hash are preserved.
|
|
28
|
+
*
|
|
29
|
+
* @ai-category BaseStore, Store
|
|
30
|
+
*
|
|
31
|
+
* @param baseStore - The base store instance (used to read the current page type for slug
|
|
32
|
+
* resolution on detail pages).
|
|
33
|
+
* @param localeOption - The locale option the visitor selected. Render `baseStore.localeOptions`
|
|
34
|
+
* as a list (e.g. a country/region picker) and pass the chosen entry directly to this function.
|
|
35
|
+
* @returns void.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* import { setLocalization, baseStore } from "@ikas/bp-storefront";
|
|
40
|
+
*
|
|
41
|
+
* function LocalizationSwitcher() {
|
|
42
|
+
* return (
|
|
43
|
+
* <ul>
|
|
44
|
+
* {baseStore.localeOptions.map(option => (
|
|
45
|
+
* <li key={option.id}>
|
|
46
|
+
* <button onClick={() => setLocalization(baseStore, option)}>
|
|
47
|
+
* {option.countryName}
|
|
48
|
+
* </button>
|
|
49
|
+
* </li>
|
|
50
|
+
* ))}
|
|
51
|
+
* </ul>
|
|
52
|
+
* );
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function setLocalization(baseStore: BaseStore, localeOption: IkasLocaleOption): void;
|
|
20
57
|
/**
|
|
21
58
|
* Switches the storefront to the routing identified by `language` and redirects the browser to
|
|
22
59
|
* the equivalent URL under that routing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as n,__generator as
|
|
1
|
+
import{__awaiter as n,__generator as i}from'./../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as t}from"../../../packages/storefront-config/src/index.js";import o from'./../../../ext/lodash/flatten.js';import e from'./../../../ext/lodash/sortBy.js';import{baseStore as r}from"../../../stores/base/index.js";function a(a){r.currentPageType=a,function(){n(this,void 0,void 0,function(){var n,a,c,u,s,d,l,v;return i(this,function(i){switch(i.label){case 0:return[4,import("../../api/location/index.js")];case 1:return[4,(0,i.sent().apiGetMyCountry)()];case 2:return n=i.sent(),a=n.data,n.isSuccess&&a?(c=t.routings.filter(function(n){var i;return null===(i=n.countryCodes)||void 0===i?void 0:i.includes(a)}),c.length?(u=o(t.routings.map(function(n){return n.countryCodes||[]})),[4,import("../../api/location/index.js")]):[2]):[2];case 3:return[4,(0,i.sent().apiListCountry)({iso2:{in:u}})];case 4:return(s=i.sent()).isSuccess?(d=s.data||[],l=[],v=[],t.routings.forEach(function(n){var i;if(null===(i=n.countryCodes)||void 0===i?void 0:i.length)n.countryCodes.forEach(function(i){var t=d.find(function(n){return n.iso2===i});if(!v.some(function(n){return n.iso2===(null==t?void 0:t.iso2)})){var o={id:(null==t?void 0:t.iso2)||(null==t?void 0:t.iso3)||Date.now()+"",countryName:(null==t?void 0:t.native)||(null==t?void 0:t.name)||"",iso2:(null==t?void 0:t.iso2)||void 0,iso3:(null==t?void 0:t.iso3)||void 0,routing:n,isRecommended:i===a};v.push(o)}});else{var o={id:n.id,routing:n,isRecommended:!t.routings.some(function(n){var i;return null===(i=n.countryCodes)||void 0===i?void 0:i.includes(a)})};v.push(o)}}),t.routings.forEach(function(n){var i;if(c.some(function(i){return i.id===n.id})){var o={id:n.id,currencyCode:n.currencyCode,currencySymbol:n.currencySymbol,language:"undefined"!=typeof Intl&&void 0!==Intl.DisplayNames&&new Intl.DisplayNames([],{type:"language"}).of(n.locale)||n.locale,locale:n.locale,isSelected:n.id===(null===(i=t.getCurrentRouting())||void 0===i?void 0:i.id)||!1};l.push(o)}}),r.languageOptions=e(l,"language"),r.localeOptions=e(v,"countryName"),[2]):[2]}})})}()}function c(n,i){var t=s(i.routing);window.location.replace(t)}function u(n,i){var o=t.routings.find(function(n){return n.id===i.id});if(o){var e=s(o);window.location.replace(e)}}function s(n){var i,o,e,a;if(n.domain)return"https://".concat(n.domain);var c=window.location,u=c.origin,s=c.pathname,d=c.search,l=c.hash,v=n.path?"/".concat(n.path):"",f=r.currentPageType;if("CATEGORY"===f||"BRAND"===f||"PRODUCT"===f){var p=null===(i=window.__IKAS_DATA__)||void 0===i?void 0:i.pageSpecificData,m=null===(e=null===(o=null==p?void 0:p.metaData)||void 0===o?void 0:o.translations)||void 0===e?void 0:e.find(function(i){return i.locale===n.locale});if(null==m?void 0:m.slug)return"".concat(u).concat(v,"/").concat(m.slug).concat(d).concat(l)}var g=null===(a=t.getCurrentRouting())||void 0===a?void 0:a.path,h=s;if(g){var y="/".concat(g);s===y?h="/":s.startsWith("".concat(y,"/"))&&(h=s.slice(y.length))}return"".concat(u).concat(v).concat(h).concat(d).concat(l)}function d(t,o){return n(this,void 0,void 0,function(){var n,t,e,r,a;return i(this,function(i){switch(i.label){case 0:return[4,import("../../api/product/index.js")];case 1:return[4,(0,i.sent().apiSearchProducts)({input:{productIdList:[o.productId]}})];case 2:return n=i.sent(),(t=(null===(a=null===(r=n.data)||void 0===r?void 0:r.data)||void 0===a?void 0:a[0])||null)&&(e=t.variants.find(function(n){return n.isActive}),t.selectedVariantValues=(e||t.variants[0]).variantValues),[2,{isSuccess:n.isSuccess,product:t}]}})})}function l(t,o){return n(this,void 0,void 0,function(){var n,t,e;return i(this,function(i){switch(i.label){case 0:return[4,import("../../api/product/index.js")];case 1:return[4,(0,i.sent().apiSearchProducts)({input:{productIdList:o.productIds}})];case 2:return n=i.sent(),(t=(null===(e=n.data)||void 0===e?void 0:e.data)||null)&&t.forEach(function(n){var i=n.variants.find(function(n){return n.isActive});n.selectedVariantValues=(i||n.variants[0]).variantValues}),[2,{isSuccess:n.isSuccess,products:t}]}})})}export{d as bs_searchProductById,l as bs_searchProductsById,a as initBaseStore,u as setLanguage,c as setLocalization};
|