@ikas/bp-storefront 1.4.0-beta.170 → 1.4.0-beta.171
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as n,__generator as
|
|
1
|
+
import{__awaiter as n,__generator as o}from'./../../../ext/tslib/tslib.es6.mjs.js';import{IkasStorefrontConfig as i}from"../../../packages/storefront-config/src/index.js";import t from'./../../../ext/lodash/flatten.js';import e from'./../../../ext/lodash/sortBy.js';import{baseStore as r}from"../../../stores/base/index.js";function c(c){r.currentPageType=c,function(){n(this,void 0,void 0,function(){var n,c,a,u,s,d,l,v;return o(this,function(o){switch(o.label){case 0:return[4,import("../../api/location/index.js")];case 1:return[4,(0,o.sent().apiGetMyCountry)()];case 2:return n=o.sent(),c=n.data,n.isSuccess&&c?(a=i.routings.filter(function(n){var o;return null===(o=n.countryCodes)||void 0===o?void 0:o.includes(c)}),a.length?(u=t(i.routings.map(function(n){return n.countryCodes||[]})),[4,import("../../api/location/index.js")]):[2]):[2];case 3:return[4,(0,o.sent().apiListCountry)({iso2:{in:u}})];case 4:return(s=o.sent()).isSuccess?(d=s.data||[],l=[],v=[],i.routings.forEach(function(n){var o;if(null===(o=n.countryCodes)||void 0===o?void 0:o.length)n.countryCodes.forEach(function(o){var i=d.find(function(n){return n.iso2===o});if(!v.some(function(n){return n.iso2===(null==i?void 0:i.iso2)})){var t={id:(null==i?void 0:i.iso2)||(null==i?void 0:i.iso3)||Date.now()+"",countryName:(null==i?void 0:i.native)||(null==i?void 0:i.name)||"",iso2:(null==i?void 0:i.iso2)||void 0,iso3:(null==i?void 0:i.iso3)||void 0,routing:n,isRecommended:o===c};v.push(t)}});else{var t={id:n.id,routing:n,isRecommended:!i.routings.some(function(n){var o;return null===(o=n.countryCodes)||void 0===o?void 0:o.includes(c)})};v.push(t)}}),i.routings.forEach(function(n){var o;if(a.some(function(o){return o.id===n.id})){var t={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===(o=i.getCurrentRouting())||void 0===o?void 0:o.id)||!1};l.push(t)}}),r.languageOptions=e(l,"language"),r.localeOptions=e(v,"countryName"),[2]):[2]}})})}()}function a(n,o){var i=s(o.routing);window.location.replace(i)}function u(n,o){var t=i.routings.find(function(n){return n.id===o.id});if(t){var e=s(t);window.location.replace(e)}}function s(n){var o,t,e,c;if(n.domain)return"https://".concat(n.domain);var a=window.location,u=a.origin,s=a.pathname,d=a.search,l=a.hash,v=n.path?"/".concat(n.path):"",f=r.currentPageType;if("CATEGORY"===f||"BRAND"===f||"PRODUCT"===f){var p=null===(o=window.__IKAS_DATA__)||void 0===o?void 0:o.pageSpecificData,m=null===(e=null===(t=null==p?void 0:p.metaData)||void 0===t?void 0:t.translations)||void 0===e?void 0:e.find(function(o){return o.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===(c=i.getCurrentRouting())||void 0===c?void 0:c.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(i,t){return n(this,void 0,void 0,function(){var n,i,e,r;return o(this,function(o){switch(o.label){case 0:return[4,import("../../api/product/index.js")];case 1:return[4,(0,o.sent().apiSearchProducts)({input:{productIdList:[t.productId]}})];case 2:return n=o.sent(),(i=(null===(r=null===(e=n.data)||void 0===e?void 0:e.data)||void 0===r?void 0:r[0])||null)&&l(i),[2,{isSuccess:n.isSuccess,product:i}]}})})}function l(n){var o=n.variants.find(function(n){return n.isActive})||n.variants[0];o&&(n.selectedVariantValues=o.variantValues)}function v(i,t){return n(this,void 0,void 0,function(){var n,i,e;return o(this,function(o){switch(o.label){case 0:return t.productIds.length?[4,import("../../api/product/index.js")]:[2,{isSuccess:!0,products:[]}];case 1:return[4,(0,o.sent().apiSearchProducts)({input:{productIdList:t.productIds}})];case 2:return n=o.sent(),(i=(null===(e=n.data)||void 0===e?void 0:e.data)||null)&&i.forEach(l),[2,{isSuccess:n.isSuccess,products:i}]}})})}export{d as bs_searchProductById,v as bs_searchProductsById,c as initBaseStore,u as setLanguage,a as setLocalization};
|