@ikas/storefront 6.1.0-beta.2 → 6.1.0-beta.200
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/analytics/analytics.d.ts +3 -3
- package/build/analytics/analytics.js +1 -1
- package/build/analytics/googleAnalytics.js +1 -1
- package/build/analytics/googleTagManager.d.ts +3 -2
- package/build/analytics/googleTagManager.js +1 -1
- package/build/analytics/ikasV3.d.ts +6 -0
- package/build/analytics/ikasV3.js +1 -1
- package/build/components/checkout/components/address-form/index.js +1 -1
- package/build/components/checkout/components/address-form/model.d.ts +5 -0
- package/build/components/checkout/components/address-form/model.js +1 -1
- package/build/components/checkout/components/adyen/index.js +1 -1
- package/build/components/checkout/components/button/index.d.ts +1 -0
- package/build/components/checkout/components/button/index.js +1 -1
- package/build/components/checkout/components/button/style.module.scss.js +1 -1
- package/build/components/checkout/components/cart-summary/cart-item/index.js +1 -1
- package/build/components/checkout/components/cart-summary/cart-item/style.module.scss.js +1 -1
- package/build/components/checkout/components/cart-summary/index.d.ts +4 -1
- package/build/components/checkout/components/cart-summary/index.js +1 -1
- package/build/components/checkout/components/cart-summary/style.module.scss.js +1 -1
- package/build/components/checkout/components/customer-addresses/index.d.ts +1 -0
- package/build/components/checkout/components/customer-addresses/index.js +1 -1
- package/build/components/checkout/components/error/stock-error/index.js +1 -1
- package/build/components/checkout/components/form-item/index.js +1 -1
- package/build/components/checkout/components/form-item/model.d.ts +5 -3
- package/build/components/checkout/components/form-item/model.js +1 -1
- package/build/components/checkout/components/form-item/style.module.scss.js +1 -1
- package/build/components/checkout/components/hepsipay/index.d.ts +9 -0
- package/build/components/checkout/components/hepsipay/index.js +1 -0
- package/build/components/checkout/components/input-with-button/style.module.scss.js +1 -1
- package/build/components/checkout/components/modal/index.d.ts +1 -0
- package/build/components/checkout/components/modal/index.js +1 -1
- package/build/components/checkout/components/modal/style.module.scss.js +1 -1
- package/build/components/checkout/components/offer-product/index.js +1 -1
- package/build/components/checkout/components/offer-product/style.module.scss.js +1 -1
- package/build/components/checkout/components/paypal/index.js +1 -1
- package/build/components/checkout/components/phone-number-input/index.d.ts +1 -1
- package/build/components/checkout/components/phone-number-input/index.js +1 -1
- package/build/components/checkout/components/quick-registration/completed.js +1 -1
- package/build/components/checkout/components/quick-registration/index.js +1 -1
- package/build/components/checkout/components/stripe/checkout-form.js +1 -1
- package/build/components/checkout/components/svg/coupon-code-tag.d.ts +6 -0
- package/build/components/checkout/components/svg/coupon-code-tag.js +1 -0
- package/build/components/checkout/components/svg/credit-balance.d.ts +6 -0
- package/build/components/checkout/components/svg/credit-balance.js +1 -0
- package/build/components/checkout/components/svg/gift-cart-tag.d.ts +6 -0
- package/build/components/checkout/components/svg/gift-cart-tag.js +1 -0
- package/build/components/checkout/components/svg/store-credit-tag.d.ts +6 -0
- package/build/components/checkout/components/svg/store-credit-tag.js +1 -0
- package/build/components/checkout/components/svg/subscription.d.ts +6 -0
- package/build/components/checkout/components/svg/subscription.js +1 -0
- package/build/components/checkout/index.js +1 -1
- package/build/components/checkout/model.d.ts +28 -6
- package/build/components/checkout/model.js +1 -1
- package/build/components/checkout/steps/step-info/index.js +1 -1
- package/build/components/checkout/steps/step-payment/billing-address/index.js +1 -1
- package/build/components/checkout/steps/step-payment/index.js +1 -1
- package/build/components/checkout/steps/step-payment/payment-gateways/index.js +1 -1
- package/build/components/checkout/steps/step-payment/payment-gateways/store-credit/index.d.ts +7 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/store-credit/index.js +1 -0
- package/build/components/checkout/steps/step-payment/payment-gateways/store-credit/style.module.scss.js +1 -0
- package/build/components/checkout/steps/step-shipping/index.js +1 -1
- package/build/components/checkout/steps/step-success/index.js +1 -1
- package/build/components/image/index.d.ts +1 -0
- package/build/components/image/index.js +1 -1
- package/build/components/index.d.ts +2 -0
- package/build/components/page/head.js +1 -1
- package/build/components/page/index.d.ts +6 -0
- package/build/components/page/index.js +1 -1
- package/build/components/page-editor/ThemeComponentEditor.js +1 -1
- package/build/components/page-editor/model.js +1 -1
- package/build/components/paypal-express-checkout/index.d.ts +9 -0
- package/build/components/paypal-express-checkout/index.js +1 -0
- package/build/components/plain-image/index.d.ts +13 -0
- package/build/components/plain-image/index.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/formatIncompletePhoneNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/es6/getCountries.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/formatIncompletePhoneNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/getCountries.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/getCountryCallingCode.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/isSupportedCountry.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/libphonenumber-js/min/exports/parsePhoneNumber.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/ObserverComponent.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/index.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/observer.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/useObserver.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/utils/UniversalFinalizationRegistry.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/utils/assertEnvironment.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/utils/observerBatching.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/utils/observerFinalizationRegistry.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/ext/mobx-react-lite/es/utils/printDebugValue.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/button-element-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/checkbox-item-view/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/input-item-view/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/phone-input-item-view/get-countries.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/form-element-renderer/phone-input-item-view/index.js +1 -0
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/image-column-element-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/image-element-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/product-list-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/components/social-element-renderer/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/helpers/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/form/form-settings/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/image-column/index.js +1 -1
- package/build/ext/@ikas/popup-renderer/build/popup-renderer/models/modal/step/elements/product/index.js +1 -1
- package/build/hooks/useCustomerReviews.d.ts +2 -0
- package/build/hooks/useCustomerReviews.js +1 -1
- package/build/hooks/useStore.js +1 -1
- package/build/index.js +1 -1
- package/build/models/data/checkout-settings/index.d.ts +1 -0
- package/build/models/data/checkout-settings/index.js +1 -1
- package/build/models/data/customer/review/index.d.ts +4 -1
- package/build/models/data/customer/review/index.js +1 -1
- package/build/models/data/index.d.ts +1 -0
- package/build/models/data/order/gift-card-line/index.d.ts +9 -0
- package/build/models/data/order/gift-card-line/index.js +1 -0
- package/build/models/data/order/index.d.ts +4 -0
- package/build/models/data/order/index.js +1 -1
- package/build/models/data/order/line-item/bundle-product-settings/index.d.ts +7 -0
- package/build/models/data/order/line-item/bundle-product-settings/index.js +1 -0
- package/build/models/data/order/line-item/index.d.ts +4 -0
- package/build/models/data/order/line-item/index.js +1 -1
- package/build/models/data/order/line-item/order-line-item-subscription-plan/index.d.ts +8 -0
- package/build/models/data/order/line-item/order-line-item-subscription-plan/index.js +1 -0
- package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-discount/index.d.ts +6 -0
- package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-discount/index.js +1 -0
- package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-period/index.d.ts +14 -0
- package/build/models/data/order/line-item/order-line-item-subscription-plan/order-line-item-subscription-plan-period/index.js +1 -0
- package/build/models/data/order/order-transaction-with-prices/index.d.ts +1 -0
- package/build/models/data/order/order-transaction-with-prices/index.js +1 -1
- package/build/models/data/product/campaign-offer/index.d.ts +2 -0
- package/build/models/data/product/campaign-offer/index.js +1 -1
- package/build/models/data/product/filter/index.d.ts +2 -0
- package/build/models/data/product/filter/index.js +1 -1
- package/build/models/data/product/index.d.ts +8 -0
- package/build/models/data/product/index.js +1 -1
- package/build/models/data/product/translations/index.d.ts +7 -0
- package/build/models/data/product/translations/index.js +1 -0
- package/build/models/data/product/variant/bundle-settings/bundle-product/index.js +1 -1
- package/build/models/data/product/variant/index.d.ts +3 -0
- package/build/models/data/product/variant/index.js +1 -1
- package/build/models/data/product/variant/subscription-plan/index.d.ts +12 -0
- package/build/models/data/product/variant/subscription-plan/index.js +1 -0
- package/build/models/data/product/variant/subscription-plan/product-subscription-plan-discount/index.d.ts +6 -0
- package/build/models/data/product/variant/subscription-plan/product-subscription-plan-period/index.d.ts +23 -0
- package/build/models/data/product/variant/subscription-plan/product-subscription-plan-period/index.js +1 -0
- package/build/models/data/store-credit-balance/index.d.ts +26 -0
- package/build/models/data/store-credit-balance/index.js +1 -0
- package/build/models/data/theme-json/component/prop/index.d.ts +1 -0
- package/build/models/data/theme-json/component/prop/index.js +1 -1
- package/build/models/data/theme-json/custom-data/index.d.ts +1 -0
- package/build/models/data/theme-json/custom-data/index.js +1 -1
- package/build/models/ui/customer-review-list/index.d.ts +8 -0
- package/build/models/ui/customer-review-list/index.js +1 -1
- package/build/models/ui/product-list/index.d.ts +17 -0
- package/build/models/ui/product-list/index.js +1 -1
- package/build/models/ui/validator/form/login.d.ts +20 -6
- package/build/models/ui/validator/form/login.js +1 -1
- package/build/models/ui/validator/form/register.d.ts +15 -6
- package/build/models/ui/validator/form/register.js +1 -1
- package/build/page-data-init/index.js +1 -1
- package/build/pages/checkout.js +1 -1
- package/build/store/cart/api.d.ts +2 -1
- package/build/store/cart/api.js +1 -1
- package/build/store/cart/index.d.ts +1 -0
- package/build/store/cart/index.js +1 -1
- package/build/store/checkout/index.d.ts +4 -1
- package/build/store/checkout/index.js +1 -1
- package/build/store/customer/api.d.ts +15 -2
- package/build/store/customer/api.js +1 -1
- package/build/store/customer/index.d.ts +40 -5
- package/build/store/customer/index.js +1 -1
- package/build/store/product/index.d.ts +1 -0
- package/build/utils/helper.d.ts +1 -0
- package/build/utils/helper.js +1 -1
- package/package.json +13 -12
- package/build/components/popup/index.js +0 -1
- package/build/components/popup/renderer/index.js +0 -1
- package/build/components/popup/renderer/model.js +0 -1
- package/build/components/popup/utils/index.js +0 -1
- package/build/store/storefront-popup/index.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__spreadArray as t,__assign as e,__awaiter as i,__generator as n}from'./../../../ext/tslib/tslib.es6.js';import r from"lodash/sortBy";import a from"lodash/cloneDeep";import{IkasCategory as o}from"../category/index.js";import{IkasProductVariant as s}from"./variant/index.js";import{IkasProductAttributeValue as u}from"./attribute-value/index.js";import{IkasProductVariantType as c}from"./variant-type/index.js";import{IkasBrand as d}from"../brand/index.js";import{IkasHTMLMetaData as l}from"../html-meta-data/index.js";import{IkasProductTag as p}from"./tag/index.js";import{IkasProductOptionPriceTypeEnum as f,IkasProductType as v}from"@ikas/storefront-models";export{IkasProductType}from"@ikas/storefront-models";import{IkasProductOptionSet as h}from"./option-set/index.js";import{makeObservable as m,observable as g,computed as V}from"mobx";import{IkasProductFunctions as b}from"@ikas/storefront-model-functions";import{IkasProductCampaign as y}from"./campaign/index.js";import{IkasStorefrontConfig as P}from"@ikas/storefront-config";import{IkasBaseStore as I}from"../../../store/base.js";import O from"lodash/groupBy";import{IkasProductBaseUnit as w}from"./base-unit/index.js";import{formatCurrency as S}from"../../../utils/currency.js";import"lodash/get";import T from"../../../store/product/index.js";import{IkasCustomerReviewList as j}from"../../ui/customer-review-list/index.js";import{IkasProductStar as C}from"./star/index.js";import{IkasProductCampaignOffer as x,IkasProductOffer as R}from"./campaign-offer/index.js";import{IkasProductGroup as G}from"./group/index.js";import{IkasImage as E}from"../image/index.js";import{IkasProductSalesChannel as A}from"./sales-channel/index.js";var k=function(){function k(b){void 0===b&&(b={});var O,E,L,D=this;this.metaData=null,this.brand=null,this.tags=null,this.productOptionSetId=null,this.productOptionSet=null,this.campaigns=null,this.selectedVariantValues=[],this.isFiltered=!1,this.isStatic=!1,this.bundleProductCache={},this.productGroupItems=[],this.showVariantsInGroup=!1,this.selectVariantValue=function(i,n){var r,a=D.metaData,o=D.selectedVariantValues.map((function(t){return t.variantTypeId===i.variantTypeId?i:t})),s=D.variants.find((function(t){return t.isActive&&o.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(s)D.selectedVariantValues=o;else{var u=D.variantTypes.findIndex((function(t){return t.variantType.id===i.variantTypeId}));if(u>0){var c=D.variantTypes.slice(0,u),d=D.selectedVariantValues.filter((function(t){return c.some((function(e){return e.variantType.id===t.variantTypeId}))})),l=t(t([],d,!0),[i],!1);s=D.variants.find((function(t){return t.isActive&&l.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var p=o.slice(0,o.length-1);(s=D.variants.find((function(t){return t.isActive&&p.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(s=D.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===i.id}))})))}if(!s)return;D.selectedVariantValues=s.variantValues}var f={};new URLSearchParams(window.location.search).forEach((function(t,i){var n;"vid"!==i&&(f=e(e({},f),((n={})[i]=t,n)))})),D.variantTypes.map((function(t){delete f[t.variantType.slug]}));var v=t(t([],D.variantTypes.map((function(t){var e=t.variantType,i=e.values.find((function(t){return D.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(i)return"".concat(e.slug,"=").concat(i.slug)})),!0),Object.entries(f).map((function(t){var e=t[0],i=t[1];return"".concat(e,"=").concat(i)})),!0).filter((function(t){return!!t})).join("&");if(D.setOptionRealPrices(),!n){var h="/".concat(a.slug);if(v&&(h="/".concat(a.slug,"?").concat(v)),h===window.location.pathname)return;null===(r=I.getInstance().router)||void 0===r||r.replace(h,void 0,{shallow:!1,scroll:!1})}},this.getVariantUnitPriceText=function(t){var e,i,n=t.price;if(n.unitPrice&&D.baseUnit){var r=D.baseUnit.baseAmount,a=(null===(i=null===(e=D.baseUnit)||void 0===e?void 0:e.unit)||void 0===i?void 0:i.name)||"";return"".concat(S(n.unitPrice,n.currency||"",n.currencySymbol||"")," / ").concat(r&&1!==r?r:"").concat(a)}},this.getCampaigns=function(){return i(D,void 0,void 0,(function(){var t,e,i,r,a,o=this;return n(this,(function(n){switch(n.label){case 0:return t=I.getInstance(),e=t.customerStore.customer,i=e?e.customerGroupIds:null,r=this.variants.map((function(t){return t.id})),[4,T.getProductCampaigns({input:{customerGroupIds:i,salesChannelId:P.getSalesChannelId()||"",variantIds:r}})];case 1:return a=n.sent(),this.campaigns=a.data,this.campaigns?(this.campaigns.map((function(t){o.variants.map((function(e){var i;t.variantIds.some((function(t){return t===e.id}))&&(null===(i=e.campaigns)||void 0===i||i.push(t))}))})),[2,this.campaigns]):[2]}}))}))},this.getAvailableStockLocations=function(){return i(D,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return t=this.variants.map((function(t){return t.id})),e=P.getPickupStockLocationIds(),[4,T.getVariantStockLocations({stockLocationIdList:e,variantIds:t})];case 1:return[2,i.sent().data||[]]}}))}))},this.getCustomerReviews=function(t){return i(D,void 0,void 0,(function(){var i,r,a,o,s;return n(this,(function(n){switch(n.label){case 0:return i=!!(null===(o=this.selectedVariant.bundleSettings)||void 0===o?void 0:o.products.length),r=[this.id],i&&(null===(s=this.selectedVariant.bundleSettings)||void 0===s||s.products.forEach((function(t){r.push(t.productId)}))),[4,(a=new j(e(e(e({},i?{}:{productId:this.id}),{limit:null==t?void 0:t.limit,page:null==t?void 0:t.page,hasImage:null==t?void 0:t.hasImage}),i?{productIds:r}:{}))).getInitial()];case 1:return n.sent(),[2,a]}}))}))},this.getProductOptionSet=function(){return i(D,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return this.productOptionSet?[2,!0]:this.productOptionSetId?[4,T.listProductOptionSet({id:{eq:this.productOptionSetId}})]:[2,!1];case 1:return(t=i.sent()).isSuccess&&(null===(e=t.data)||void 0===e?void 0:e.length)?(this.productOptionSet=t.data[0],this.setOptionPrices(),this.setOptionRealPrices(),[2,!0]):[2,!1]}}))}))},this.initBundleProducts=function(){return i(D,void 0,void 0,(function(){var t,e,i,r,a,o;return n(this,(function(n){switch(n.label){case 0:return t="","undefined"!=typeof window&&(e=new URLSearchParams(window.location.search),t=e.get("editLineID")||""),t?(i=null===(a=I.getInstance().cartStore.cart)||void 0===a?void 0:a.items.find((function(e){return e.id===t})))&&(r=this.variants.find((function(t){return t.id===i.variant.id})))?(this.selectedVariantValues=r.variantValues,[4,this.getBundleProductsOfVariant(r)]):[3,2]:[3,3];case 1:n.sent(),null===(o=r.bundleSettings)||void 0===o||o.products.forEach((function(t){var e,n,r;try{var a=null===(e=i.variant.bundleProducts)||void 0===e?void 0:e.find((function(e){return e.id===t.id})),o=t.product.variants.find((function(t){return t.id===(null==a?void 0:a.variant.id)}));t.product.selectedVariantValues=o.variantValues,t.quantity=(null===(r=null===(n=i.variant.bundleProducts)||void 0===n?void 0:n.find((function(t){return t.variant.id===o.id})))||void 0===r?void 0:r.quantity)||0}catch(t){console.error(t)}})),n.label=2;case 2:return[3,5];case 3:return[4,this.getBundleProductsOfVariant(this.selectedVariant)];case 4:n.sent(),n.label=5;case 5:return[2]}}))}))},this.setShowVariantsInGroup=function(t){D.showVariantsInGroup=t},this.getBundleProductsOfVariant=function(t){return i(D,void 0,void 0,(function(){var e,i,r,o,s,u,c=this;return n(this,(function(n){switch(n.label){case 0:return(null==(e=null===(r=t.bundleSettings)||void 0===r?void 0:r.products.map((function(t){return t.productId})).filter((function(t){return-1===Object.keys(c.bundleProductCache).indexOf(t)})))?void 0:e.length)?[4,T.searchProducts({input:{productIdList:e,perPage:200,priceListId:P.getPriceListId(),salesChannelId:P.getSalesChannelId()}})]:[3,2];case 1:(i=n.sent()).isSuccess&&(null===(s=null===(o=i.data)||void 0===o?void 0:o.data)||void 0===s||s.forEach((function(t){c.bundleProductCache[t.id]=t}))),n.label=2;case 2:return null===(u=t.bundleSettings)||void 0===u||u.products.forEach((function(t){var e=c.bundleProductCache[t.productId];t.setProduct(new k(a(e)))})),[2]}}))}))},this.setOptionRealPrices=function(){var t,e=D.selectedVariant||D.variants[0];if(e){var i=e.price.currency;i&&(null===(t=D.productOptionSet)||void 0===t||t.options.forEach((function(t){var e;if(t.selectSettings)t.selectSettings.values.forEach((function(t){var e;if(t.priceType===f.RATIO&&t.initPrice)if(t.otherPrices){var n=(null===(e=t.otherPrices.find((function(t){return t.currencyCode===i})))||void 0===e?void 0:e.price)||t.initPrice||1;t.price=D.selectedVariant.price.finalPrice*n/100}else t.price=D.selectedVariant.price.finalPrice*t.initPrice/100}));else if(t.priceType===f.RATIO&&t.initPrice)if(t.otherPrices){var n=(null===(e=t.otherPrices.find((function(t){return t.currencyCode===i})))||void 0===e?void 0:e.price)||t.initPrice||1;t.price=D.selectedVariant.price.finalPrice*n/100}else t.price=D.selectedVariant.price.finalPrice*t.initPrice/100})))}},this.setOptionPrices=function(){var t,e=D.variants[0];if(e){var i=e.price.currency;null===(t=D.productOptionSet)||void 0===t||t.options.forEach((function(t){var n,r;if(t.selectSettings&&t.selectSettings.values.forEach((function(t){var n,r;if(t.otherPrices)if(t.priceType===f.RATIO){var a=(null===(n=t.otherPrices.find((function(t){return t.currencyCode===i})))||void 0===n?void 0:n.price)||t.price||1;t.price=e.price.finalPrice*a}else t.price=(null===(r=t.otherPrices.find((function(t){return t.currencyCode===i})))||void 0===r?void 0:r.price)||t.price})),t.otherPrices)if(t.priceType===f.RATIO){var a=(null===(n=t.otherPrices.find((function(t){return t.currencyCode===i})))||void 0===n?void 0:n.price)||t.price||1;t.price=e.price.finalPrice*a}else t.price=(null===(r=t.otherPrices.find((function(t){return t.currencyCode===i})))||void 0===r?void 0:r.price)||t.price}))}},this.id=b.id||Date.now()+"",this.name=b.name||"",this.type=b.type||v.PHYSICAL,this.description=b.description||"",this.shortDescription=b.shortDescription||"",this.metaData=b.metaData?new l(b.metaData):null,this.brand=b.brand?new d(b.brand):null,this.categories=b.categories?b.categories.map((function(t){return new o(t)})):[],this.deleted=b.deleted||null,this.tags=b.tags?b.tags.map((function(t){return new p(t)})):[],this.variants=b.variants?b.variants.map((function(t){return new s(t)})):[],this.attributes=b.attributes?b.attributes.map((function(t){return new u(t)})):[],this.variantTypes=b.variantTypes?b.variantTypes.map((function(t){return new c(t)})):[],this.productOptionSetId=b.productOptionSetId||null,this.averageRating=null!==(O=b.averageRating)&&void 0!==O?O:null,this.reviewCount=null!==(E=b.reviewCount)&&void 0!==E?E:null,this.stars=b.stars?b.stars.map((function(t){return new C(t)})):null,this.baseUnit=b.baseUnit?new w(b.baseUnit):null,this.campaigns=(null===(L=b.campaigns)||void 0===L?void 0:L.map((function(t){return new y(t)})))||null,this.selectedVariantValues=b.selectedVariantValues||[],this.productOptionSet=b.productOptionSet?new h(b.productOptionSet):null,this.variantTypes=r(this.variantTypes,"order"),this.groupVariantsByVariantTypeId=b.groupVariantsByVariantTypeId||null,this.dynamicPriceListIds=b.dynamicPriceListIds||null,this.productVolumeDiscountId=b.productVolumeDiscountId||null,this.campaignOffers=b.campaignOffers?b.campaignOffers.map((function(t){return new x(t)})):null,this.appliedCampaignOffer=b.appliedCampaignOffer,this.offers=b.offers?b.offers.map((function(t){return new R(t)})):void 0,this.productGroup=b.productGroup?new G(b.productGroup):null,this.salesChannels=b.salesChannels?b.salesChannels.map((function(t){return new A(t)})):null,this.productGroupItems=b.productGroupItems,this.variants.forEach((function(t){return t.product=D})),this.setOptionPrices(),this.setOptionRealPrices(),this.customerReviews=b.customerReviews?new j(b.customerReviews):null,m(this,{selectedVariantValues:g,isFiltered:g,isStatic:g,showVariantsInGroup:g,hasVariant:V,hasStock:V,hasValidProductOptionValues:V,href:V,productHref:V,mainVariantType:V,mainVariantValue:V,selectedVariant:V,displayedVariantTypes:V,isCustomerReviewEnabled:V,isCustomerReviewLoginRequired:V,isAddToCartEnabled:V,groupedAttributeValues:V,selectedVariantUnitPriceText:V,displayedProductGroups:V})}return Object.defineProperty(k.prototype,"hasVariant",{get:function(){return b.hasVariant(this,this.showVariantsInGroup)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"hasStock",{get:function(){return this.isStatic?this.selectedVariant.hasStock:b.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"hasValidProductOptionValues",{get:function(){return!this.productOptionSet||this.productOptionSet.hasValidValues},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"href",{get:function(){return b.getSelectedVariantHref(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"productHref",{get:function(){return this.groupVariantsByVariantTypeId||this.isFiltered?this.href:b.getProductHref(this)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"mainVariantType",{get:function(){return b.getMainVariantType(this)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"mainVariantValue",{get:function(){return b.getMainVariantValue(this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"selectedVariant",{get:function(){if(!this.hasVariant)return this.variants[0];var t=this.selectedVariantValues.map((function(t){return t.id}));return this.variants.find((function(e){return e.variantValues.every((function(e){return t.includes(e.id)}))}))},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"displayedVariantTypes",{get:function(){return this.hasVariant?b.getDisplayedVariantTypes(this,this.selectedVariantValues):[]},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isCustomerReviewEnabled",{get:function(){return P.isCustomerReviewEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isCustomerReviewLoginRequired",{get:function(){return P.isCustomerReviewLoginRequired()},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isAddToCartEnabled",{get:function(){var t,e=!0;return null===(t=this.selectedVariant.bundleSettings)||void 0===t||t.products.forEach((function(t){0===t.quantity&&null!==t.minQuantity&&0!==t.minQuantity&&(e=!1)})),e&&this.hasValidProductOptionValues&&(this.selectedVariant.hasStock||this.selectedVariant.sellIfOutOfStock)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"groupedAttributeValues",{get:function(){var t,e=O(this.attributes,"productAttributeId");return(null===(t=this.attributes)||void 0===t?void 0:t.map((function(t){var i=t.productAttributeId;if(i){var n=e[i];return(null==n?void 0:n.length)&&n[0].productAttribute?{attribute:n[0].productAttribute,values:n}:void 0}})).filter((function(t){return!!t})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"selectedVariantUnitPriceText",{get:function(){return this.getVariantUnitPriceText(this.selectedVariant)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"displayedProductGroups",{get:function(){var e,i=this,n=[],a=[];return null===(e=this.productGroupItems)||void 0===e||e.forEach((function(t){t.groupValues.forEach((function(t){n.includes(t.name)||n.push(t.name)}))})),n.forEach((function(e){var n,o={name:e,items:[]};i.productGroupItems=r(i.productGroupItems,(function(t){var e;return parseInt((null===(e=t.order)||void 0===e?void 0:e.value)||"999",10)})),null===(n=i.productGroupItems)||void 0===n||n.forEach((function(n){var r,a,s,u=n.groupValues.find((function(t){return t.name===e}));if(u&&!o.items.some((function(t){return t.value===u.value}))){var c="";if(n.productId===i.id)c=i.href;else{var d=(null===(r=i.productGroup)||void 0===r?void 0:r.values.filter((function(t){return t.name!==e})))||[],l=t(t([],d,!0),[u],!1),p=null===(a=i.productGroupItems)||void 0===a?void 0:a.find((function(t){return l.every((function(e){return t.groupValues.some((function(t){return e.name===t.name&&e.value===t.value}))}))}));c=p?p.href:n.href}o.items.push({image:n.image?new E(n.image):null,href:c,value:u.value,isSelected:(null===(s=i.productGroupItems)||void 0===s?void 0:s.some((function(t){return t.groupValues.some((function(t){return t.value===u.value}))&&t.productId===i.id})))||!1})}})),a.push(o)})),a},enumerable:!1,configurable:!0}),k}();export{k as IkasProduct};
|
|
1
|
+
import{__spreadArray as t,__assign as e,__awaiter as i,__generator as n}from'./../../../ext/tslib/tslib.es6.js';import r from"lodash/sortBy";import a from"lodash/cloneDeep";import{IkasCategory as o}from"../category/index.js";import{IkasProductVariant as s}from"./variant/index.js";import{IkasProductAttributeValue as u}from"./attribute-value/index.js";import{IkasProductVariantType as c}from"./variant-type/index.js";import{IkasBrand as d}from"../brand/index.js";import{IkasHTMLMetaData as l}from"../html-meta-data/index.js";import{IkasProductTag as p}from"./tag/index.js";import{IkasProductOptionPriceTypeEnum as f,IkasProductType as v}from"@ikas/storefront-models";export{IkasProductType}from"@ikas/storefront-models";import{IkasProductOptionSet as h}from"./option-set/index.js";import{makeObservable as m,observable as g,computed as V}from"mobx";import{IkasProductFunctions as b}from"@ikas/storefront-model-functions";import{IkasProductCampaign as y}from"./campaign/index.js";import{IkasStorefrontConfig as P}from"@ikas/storefront-config";import{IkasBaseStore as I}from"../../../store/base.js";import O from"lodash/groupBy";import{IkasProductBaseUnit as S}from"./base-unit/index.js";import{formatCurrency as w}from"../../../utils/currency.js";import"lodash/get";import T from"../../../store/product/index.js";import{IkasCustomerReviewList as j}from"../../ui/customer-review-list/index.js";import{IkasProductStar as C}from"./star/index.js";import{IkasProductCampaignOffer as x,IkasProductOffer as R}from"./campaign-offer/index.js";import{IkasProductGroup as L}from"./group/index.js";import{IkasImage as G}from"../image/index.js";import{IkasProductSalesChannel as E}from"./sales-channel/index.js";import{IkasProductTranslation as k}from"./translations/index.js";var A=function(){function A(b){void 0===b&&(b={});var O,G,D,U=this;this.metaData=null,this.brand=null,this.tags=null,this.productOptionSetId=null,this.translations=null,this.productOptionSet=null,this.campaigns=null,this.selectedVariantValues=[],this.isFiltered=!1,this.isStatic=!1,this.bundleProductCache={},this.productGroupItems=[],this.showVariantsInGroup=!1,this.selectVariantValue=function(i,n){var r,a=U.metaData,o=U.selectedVariantValues.map((function(t){return t.variantTypeId===i.variantTypeId?i:t})),s=U.variants.find((function(t){return t.isActive&&o.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}));if(s)U.selectedVariantValues=o;else{var u=U.variantTypes.findIndex((function(t){return t.variantType.id===i.variantTypeId}));if(u>0){var c=U.variantTypes.slice(0,u),d=U.selectedVariantValues.filter((function(t){return c.some((function(e){return e.variantType.id===t.variantTypeId}))})),l=t(t([],d,!0),[i],!1);s=U.variants.find((function(t){return t.isActive&&l.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))}))}else{var p=o.slice(0,o.length-1);(s=U.variants.find((function(t){return t.isActive&&p.every((function(e){return t.variantValues.some((function(t){return t.id===e.id}))}))})))||(s=U.variants.find((function(t){return t.isActive&&t.variantValues.some((function(t){return t.id===i.id}))})))}if(!s)return;U.selectedVariantValues=s.variantValues}var f={};new URLSearchParams(window.location.search).forEach((function(t,i){var n;"vid"!==i&&(f=e(e({},f),((n={})[i]=t,n)))})),U.variantTypes.map((function(t){delete f[decodeURIComponent(t.variantType.slug)]}));var v=t(t([],Object.entries(f).map((function(t){var e=t[0],i=t[1];return"".concat(e,"=").concat(i)})),!0),U.variantTypes.map((function(t){var e=t.variantType,i=e.values.find((function(t){return U.selectedVariantValues.some((function(e){return e.id===t.id}))}));if(i)return"".concat(e.slug,"=").concat(i.slug)})),!0).filter((function(t){return!!t})).join("&");if(U.setOptionRealPrices(),!n){var h="/".concat(a.slug);if(v&&(h="/".concat(a.slug,"?").concat(v)),h===window.location.pathname)return;null===(r=I.getInstance().router)||void 0===r||r.replace(h,void 0,{shallow:!1,scroll:!1})}},this.getVariantUnitPriceText=function(t){var e,i,n=t.price;if(n.unitPrice&&U.baseUnit){var r=U.baseUnit.baseAmount,a=(null===(i=null===(e=U.baseUnit)||void 0===e?void 0:e.unit)||void 0===i?void 0:i.name)||"";return"".concat(w(n.unitPrice,n.currency||"",n.currencySymbol||"")," / ").concat(r&&1!==r?r:"").concat(a)}},this.getCampaigns=function(){return i(U,void 0,void 0,(function(){var t,e,i,r,a,o=this;return n(this,(function(n){switch(n.label){case 0:return t=I.getInstance(),e=t.customerStore.customer,i=e?e.customerGroupIds:null,r=this.variants.map((function(t){return t.id})),[4,T.getProductCampaigns({input:{customerGroupIds:i,salesChannelId:P.getSalesChannelId()||"",variantIds:r}})];case 1:return a=n.sent(),this.campaigns=a.data,this.campaigns?(this.campaigns.map((function(t){o.variants.map((function(e){var i;t.variantIds.some((function(t){return t===e.id}))&&(null===(i=e.campaigns)||void 0===i||i.push(t))}))})),[2,this.campaigns]):[2]}}))}))},this.getAvailableStockLocations=function(){return i(U,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return t=this.variants.map((function(t){return t.id})),e=P.getPickupStockLocationIds(),[4,T.getVariantStockLocations({stockLocationIdList:e,variantIds:t})];case 1:return[2,i.sent().data||[]]}}))}))},this.getCustomerReviews=function(t){return i(U,void 0,void 0,(function(){var i,r,a,o,s;return n(this,(function(n){switch(n.label){case 0:return i=!!(null===(o=this.selectedVariant.bundleSettings)||void 0===o?void 0:o.products.length),r=[this.id],i&&(null===(s=this.selectedVariant.bundleSettings)||void 0===s||s.products.forEach((function(t){r.push(t.productId)}))),[4,(a=new j(e(e(e({},i?{}:{productId:this.id}),{locale:null==t?void 0:t.locale,limit:null==t?void 0:t.limit,page:null==t?void 0:t.page,hasImage:null==t?void 0:t.hasImage,sortWithImagesFirst:null==t?void 0:t.sortWithImagesFirst}),i?{productIds:r}:{}))).getInitial()];case 1:return n.sent(),[2,a]}}))}))},this.getProductOptionSet=function(){return i(U,void 0,void 0,(function(){var t,e;return n(this,(function(i){switch(i.label){case 0:return this.productOptionSet?[2,!0]:this.productOptionSetId?[4,T.listProductOptionSet({id:{eq:this.productOptionSetId}})]:[2,!1];case 1:return(t=i.sent()).isSuccess&&(null===(e=t.data)||void 0===e?void 0:e.length)?(this.productOptionSet=t.data[0],this.setOptionPrices(),this.setOptionRealPrices(),[2,!0]):[2,!1]}}))}))},this.initBundleProducts=function(){return i(U,void 0,void 0,(function(){var t,e,i,r,a,o;return n(this,(function(n){switch(n.label){case 0:return t="","undefined"!=typeof window&&(e=new URLSearchParams(window.location.search),t=e.get("editLineID")||""),t?(i=null===(a=I.getInstance().cartStore.cart)||void 0===a?void 0:a.items.find((function(e){return e.id===t})))&&(r=this.variants.find((function(t){return t.id===i.variant.id})))?(this.selectedVariantValues=r.variantValues,[4,this.getBundleProductsOfVariant(r)]):[3,2]:[3,3];case 1:n.sent(),null===(o=r.bundleSettings)||void 0===o||o.products.forEach((function(t){var e,n,r;try{var a=null===(e=i.variant.bundleProducts)||void 0===e?void 0:e.find((function(e){return e.id===t.id})),o=t.product.variants.find((function(t){return t.id===(null==a?void 0:a.variant.id)}));t.product.selectedVariantValues=o.variantValues,t.quantity=(null===(r=null===(n=i.variant.bundleProducts)||void 0===n?void 0:n.find((function(t){return t.variant.id===o.id})))||void 0===r?void 0:r.quantity)||0}catch(t){console.error(t)}})),n.label=2;case 2:return[3,5];case 3:return[4,this.getBundleProductsOfVariant(this.selectedVariant)];case 4:n.sent(),n.label=5;case 5:return[2]}}))}))},this.setShowVariantsInGroup=function(t){U.showVariantsInGroup=t},this.getBundleProductsOfVariant=function(t){return i(U,void 0,void 0,(function(){var e,i,r,o,s,u,c=this;return n(this,(function(n){switch(n.label){case 0:return(null==(e=null===(r=t.bundleSettings)||void 0===r?void 0:r.products.map((function(t){return t.productId})).filter((function(t){return-1===Object.keys(c.bundleProductCache).indexOf(t)})))?void 0:e.length)?[4,T.searchProducts({input:{productIdList:e,perPage:200,priceListId:P.getPriceListId(),salesChannelId:P.getSalesChannelId()}})]:[3,2];case 1:(i=n.sent()).isSuccess&&(null===(s=null===(o=i.data)||void 0===o?void 0:o.data)||void 0===s||s.forEach((function(t){c.bundleProductCache[t.id]=t}))),n.label=2;case 2:return null===(u=t.bundleSettings)||void 0===u||u.products.forEach((function(t){var e=c.bundleProductCache[t.productId];t.setProduct(new A(a(e)))})),[2]}}))}))},this.getSubscriptionPlanOfVariant=function(t){return i(U,void 0,void 0,(function(){var e,i=this;return n(this,(function(n){return null===(e=t.subscriptionPlan)||void 0===e||e.periods.forEach((function(t,e){t.setProduct(i),0===e&&(t.isSelected=!0)})),[2]}))}))},this.setOptionRealPrices=function(){var t,e=U.selectedVariant||U.variants[0];if(e){var i=e.price.priceListId;null===(t=U.productOptionSet)||void 0===t||t.options.forEach((function(t){var e;if(t.selectSettings)t.selectSettings.values.forEach((function(t){var e;if(t.priceType===f.RATIO&&t.initPrice)if(t.otherPrices){var n=(null===(e=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===e?void 0:e.price)||t.initPrice||1;t.price=U.selectedVariant.price.finalPrice*n/100}else t.price=U.selectedVariant.price.finalPrice*t.initPrice/100}));else if(t.priceType===f.RATIO&&t.initPrice)if(t.otherPrices){var n=(null===(e=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===e?void 0:e.price)||t.initPrice||1;t.price=U.selectedVariant.price.finalPrice*n/100}else t.price=U.selectedVariant.price.finalPrice*t.initPrice/100}))}},this.setOptionPrices=function(){var t,e=U.variants[0];if(e){var i=e.price.priceListId;null===(t=U.productOptionSet)||void 0===t||t.options.forEach((function(t){var n,r;if(t.selectSettings&&t.selectSettings.values.forEach((function(t){var n,r;if(t.otherPrices)if(t.priceType===f.RATIO){var a=(null===(n=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===n?void 0:n.price)||t.price||1;t.price=e.price.finalPrice*a/100}else t.price=(null===(r=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===r?void 0:r.price)||t.price})),t.otherPrices)if(t.priceType===f.RATIO){var a=(null===(n=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===n?void 0:n.price)||t.price||1;t.price=e.price.finalPrice*a/100}else t.price=(null===(r=t.otherPrices.find((function(t){return t.priceListId===i})))||void 0===r?void 0:r.price)||t.price}))}},this.id=b.id||Date.now()+"",this.name=b.name||"",this.type=b.type||v.PHYSICAL,this.description=b.description||"",this.shortDescription=b.shortDescription||"",this.metaData=b.metaData?new l(b.metaData):null,this.brand=b.brand?new d(b.brand):null,this.categories=b.categories?b.categories.map((function(t){return new o(t)})):[],this.deleted=b.deleted||null,this.tags=b.tags?b.tags.map((function(t){return new p(t)})):[],this.variants=b.variants?b.variants.map((function(t){return new s(t)})):[],this.attributes=b.attributes?b.attributes.map((function(t){return new u(t)})):[],this.variantTypes=b.variantTypes?b.variantTypes.map((function(t){return new c(t)})):[],this.productOptionSetId=b.productOptionSetId||null,this.averageRating=null!==(O=b.averageRating)&&void 0!==O?O:null,this.reviewCount=null!==(G=b.reviewCount)&&void 0!==G?G:null,this.stars=b.stars?b.stars.map((function(t){return new C(t)})):null,this.baseUnit=b.baseUnit?new S(b.baseUnit):null,this.campaigns=(null===(D=b.campaigns)||void 0===D?void 0:D.map((function(t){return new y(t)})))||null,this.selectedVariantValues=b.selectedVariantValues||[],this.productOptionSet=b.productOptionSet?new h(b.productOptionSet):null,this.variantTypes=r(this.variantTypes,"order"),this.groupVariantsByVariantTypeId=b.groupVariantsByVariantTypeId||null,this.dynamicPriceListIds=b.dynamicPriceListIds||null,this.productVolumeDiscountId=b.productVolumeDiscountId||null,this.campaignOffers=b.campaignOffers?b.campaignOffers.map((function(t){return new x(t)})):null,this.appliedCampaignOffer=b.appliedCampaignOffer,this.offers=b.offers?b.offers.map((function(t){return new R(t)})):void 0,this.productGroup=b.productGroup?new L(b.productGroup):null,this.salesChannels=b.salesChannels?b.salesChannels.map((function(t){return new E(t)})):null,this.translations=b.translations?b.translations.map((function(t){return new k(t)})):null,this.productGroupItems=b.productGroupItems,this.variants.forEach((function(t){return t.product=U})),this.setOptionPrices(),this.setOptionRealPrices(),this.customerReviews=b.customerReviews?new j(b.customerReviews):null,m(this,{selectedVariantValues:g,isFiltered:g,isStatic:g,showVariantsInGroup:g,hasVariant:V,hasStock:V,hasValidProductOptionValues:V,href:V,productHref:V,mainVariantType:V,mainVariantValue:V,selectedVariant:V,displayedVariantTypes:V,isCustomerReviewEnabled:V,isCustomerReviewLoginRequired:V,isAddToCartEnabled:V,groupedAttributeValues:V,selectedVariantUnitPriceText:V,displayedProductGroups:V})}return Object.defineProperty(A.prototype,"hasVariant",{get:function(){return b.hasVariant(this,this.showVariantsInGroup)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"hasStock",{get:function(){return this.isStatic?this.selectedVariant.hasStock:b.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"hasValidProductOptionValues",{get:function(){return!this.productOptionSet||this.productOptionSet.hasValidValues},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"href",{get:function(){return b.getSelectedVariantHref(this,this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"productHref",{get:function(){return this.groupVariantsByVariantTypeId||this.isFiltered?this.href:b.getProductHref(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"mainVariantType",{get:function(){return b.getMainVariantType(this)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"mainVariantValue",{get:function(){return b.getMainVariantValue(this.selectedVariantValues)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"selectedVariant",{get:function(){if(!this.hasVariant)return this.variants[0];var t=this.selectedVariantValues.map((function(t){return t.id}));return this.variants.find((function(e){return e.variantValues.every((function(e){return t.includes(e.id)}))}))},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"displayedVariantTypes",{get:function(){return this.hasVariant?b.getDisplayedVariantTypes(this,this.selectedVariantValues):[]},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isCustomerReviewEnabled",{get:function(){return P.isCustomerReviewEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isCustomerReviewLoginRequired",{get:function(){return P.isCustomerReviewLoginRequired()},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"isAddToCartEnabled",{get:function(){var t,e=!0;return null===(t=this.selectedVariant.bundleSettings)||void 0===t||t.products.forEach((function(t){0===t.quantity&&null!==t.minQuantity&&0!==t.minQuantity&&(e=!1)})),e&&this.hasValidProductOptionValues&&(this.selectedVariant.hasStock||this.selectedVariant.sellIfOutOfStock)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"groupedAttributeValues",{get:function(){var t,e=O(this.attributes,"productAttributeId");return(null===(t=this.attributes)||void 0===t?void 0:t.map((function(t){var i=t.productAttributeId;if(i){var n=e[i];return(null==n?void 0:n.length)&&n[0].productAttribute?{attribute:n[0].productAttribute,values:n}:void 0}})).filter((function(t){return!!t})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"selectedVariantUnitPriceText",{get:function(){return this.getVariantUnitPriceText(this.selectedVariant)},enumerable:!1,configurable:!0}),Object.defineProperty(A.prototype,"displayedProductGroups",{get:function(){var e,i=this,n=[],a=[];return null===(e=this.productGroupItems)||void 0===e||e.forEach((function(t){t.groupValues.forEach((function(t){n.includes(t.name)||n.push(t.name)}))})),n.forEach((function(e){var n,o={name:e,items:[]};i.productGroupItems=r(i.productGroupItems,(function(t){var e;return parseInt((null===(e=t.order)||void 0===e?void 0:e.value)||"999",10)})),null===(n=i.productGroupItems)||void 0===n||n.forEach((function(n){var r,a,s,u=n.groupValues.find((function(t){return t.name===e}));if(u&&!o.items.some((function(t){return t.value===u.value}))){var c="";if(n.productId===i.id)c=i.href;else{var d=(null===(r=i.productGroup)||void 0===r?void 0:r.values.filter((function(t){return t.name!==e})))||[],l=t(t([],d,!0),[u],!1),p=null===(a=i.productGroupItems)||void 0===a?void 0:a.find((function(t){return l.every((function(e){return t.groupValues.some((function(t){return e.name===t.name&&e.value===t.value}))}))}));c=p?p.href:n.href}o.items.push({image:n.image?new G(n.image):null,href:c,value:u.value,isSelected:(null===(s=i.productGroupItems)||void 0===s?void 0:s.some((function(t){return t.groupValues.some((function(t){return t.value===u.value}))&&t.productId===i.id})))||!1,isSelectable:function(){var n,r,a=(null===(n=i.productGroup)||void 0===n?void 0:n.values.filter((function(t){return t.name!==e})))||[],o=t(t([],a,!0),[u],!1);return!!(null===(r=i.productGroupItems)||void 0===r?void 0:r.find((function(t){return o.every((function(e){return t.groupValues.some((function(t){return e.name===t.name&&e.value===t.value}))}))})))}(),hasStock:n.hasStock})}})),a.push(o)})),a},enumerable:!1,configurable:!0}),A}();export{A as IkasProduct};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IkasProductTranslation as IProductTranslation } from "@ikas/storefront-models";
|
|
2
|
+
export declare class IkasProductTranslation implements IProductTranslation {
|
|
3
|
+
description: string | null;
|
|
4
|
+
locale: string;
|
|
5
|
+
name: string | null;
|
|
6
|
+
constructor(data: IProductTranslation);
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var i=function(i){this.description=null,this.name=null,this.description=i.description||null,this.locale=i.locale,this.name=i.name||null};export{i as IkasProductTranslation};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{makeAutoObservable as t}from"mobx";import{formatCurrency as i}from"../../../../../../utils/currency.js";var e=function(){function e(i){void 0===i&&(i={});var e,r,n=this;this.product=null,this._initialQuantity=null,this.setProduct=function(t){t.variants=t.variants.filter((function(t){return n.filteredVariantIds.includes(t.id)})),n.product=t,n.product.selectedVariantValues=n.product.variants[0].variantValues,n.quantity=n._initialQuantity||0},this.setQuantity=function(t){var i;if(!(t<0)){var e=null===(i=n.product)||void 0===i?void 0:i.selectedVariant.stock;null!==n.minQuantity&&t<n.minQuantity?n.quantity=n.minQuantity:null!==n.maxQuantity&&t>n.maxQuantity?n.quantity=n.maxQuantity:
|
|
1
|
+
import{makeAutoObservable as t}from"mobx";import{formatCurrency as i}from"../../../../../../utils/currency.js";var e=function(){function e(i){void 0===i&&(i={});var e,r,n=this;this.product=null,this._initialQuantity=null,this.setProduct=function(t){t.variants=t.variants.filter((function(t){return n.filteredVariantIds.includes(t.id)})),n.product=t,n.product.selectedVariantValues=n.product.variants[0].variantValues,n.quantity=n._initialQuantity||0},this.setQuantity=function(t){var i;if(!(t<0)){var e=null===(i=n.product)||void 0===i?void 0:i.selectedVariant.stock;null!==n.minQuantity&&t<n.minQuantity?n.quantity=n.minQuantity:null!==n.maxQuantity&&t>n.maxQuantity?n.quantity=n.maxQuantity:e&&t>e&&null===n.maxQuantity?n.quantity=e:n.quantity=t}},this.id=i.id||"",this.addToBundleBasePrice=i.addToBundleBasePrice||null,this.discountRatio=i.discountRatio||null,this.filteredVariantIds=i.filteredVariantIds||[],this.maxQuantity=null!==(e=i.maxQuantity)&&void 0!==e?e:null,this.minQuantity=null!==(r=i.minQuantity)&&void 0!==r?r:null,this.order=i.order||0,this.productId=i.productId||"",this.quantity=i.quantity||0,this._initialQuantity=this.quantity,t(this)}return Object.defineProperty(e.prototype,"isQuantityEditable",{get:function(){return null!==this.maxQuantity||null!==this.minQuantity},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shouldDisplayPrice",{get:function(){return!0===this.addToBundleBasePrice},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"finalPrice",{get:function(){var t,i=(null===(t=this.product)||void 0===t?void 0:t.selectedVariant.finalPrice)||0;return this.addToBundleBasePrice&&this.discountRatio&&(i-=i*(this.discountRatio/100)),i},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"finalPriceWithQuantity",{get:function(){return this.finalPrice*this.quantity},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"formattedFinalPrice",{get:function(){var t,e;return i(this.finalPrice,(null===(t=this.product)||void 0===t?void 0:t.selectedVariant.price.currency)||"",(null===(e=this.product)||void 0===e?void 0:e.selectedVariant.price.currencySymbol)||"")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"formattedFinalPriceWithQuantity",{get:function(){var t,e;return i(this.finalPriceWithQuantity,(null===(t=this.product)||void 0===t?void 0:t.selectedVariant.price.currency)||"",(null===(e=this.product)||void 0===e?void 0:e.selectedVariant.price.currencySymbol)||"")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sellPrice",{get:function(){var t;return(null===(t=this.product)||void 0===t?void 0:t.selectedVariant.price.sellPrice)||0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sellPriceWithQuantity",{get:function(){return this.sellPrice*this.quantity},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"formattedSellPrice",{get:function(){var t,e;return i(this.sellPrice,(null===(t=this.product)||void 0===t?void 0:t.selectedVariant.price.currency)||"",(null===(e=this.product)||void 0===e?void 0:e.selectedVariant.price.currencySymbol)||"")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"formattedSellPriceWithQuantity",{get:function(){var t,e;return i(this.sellPriceWithQuantity,(null===(t=this.product)||void 0===t?void 0:t.selectedVariant.price.currency)||"",(null===(e=this.product)||void 0===e?void 0:e.selectedVariant.price.currencySymbol)||"")},enumerable:!1,configurable:!0}),e}();export{e as IkasBundleProduct};
|
|
@@ -7,6 +7,7 @@ import { IkasBundleSettings } from "./bundle-settings";
|
|
|
7
7
|
import { IkasCampaignType, IkasProductVariant as IProductVariant } from "@ikas/storefront-models";
|
|
8
8
|
import { IkasProductVariantUnit } from "./unit";
|
|
9
9
|
import { IkasProduct } from "..";
|
|
10
|
+
import { IkasProductSubscriptionPlan } from "./subscription-plan";
|
|
10
11
|
export declare class IkasProductVariant implements IProductVariant {
|
|
11
12
|
id: string;
|
|
12
13
|
sku: string | null;
|
|
@@ -17,6 +18,7 @@ export declare class IkasProductVariant implements IProductVariant {
|
|
|
17
18
|
attributes: IkasProductAttributeValue[];
|
|
18
19
|
prices: IkasProductPrice[];
|
|
19
20
|
stock: number;
|
|
21
|
+
subscriptionPlan: IkasProductSubscriptionPlan | null;
|
|
20
22
|
isActive: boolean;
|
|
21
23
|
productId: string;
|
|
22
24
|
sellIfOutOfStock: boolean;
|
|
@@ -68,6 +70,7 @@ export declare class IkasProductVariant implements IProductVariant {
|
|
|
68
70
|
formattedSellPriceWithQuantity: string;
|
|
69
71
|
formattedFinalPrice: string;
|
|
70
72
|
formattedFinalPriceWithQuantity: string;
|
|
73
|
+
salesChannelIds: string[] | null;
|
|
71
74
|
}[];
|
|
72
75
|
saveBackInStockReminder(email: string): Promise<boolean>;
|
|
73
76
|
toJSON(): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{IkasProductPrice as r}from"./price/index.js";import{IkasVariantValue as n}from"../../variant-type/variant-value/index.js";import{IkasProductAttributeValue as o}from"../attribute-value/index.js";import{IkasProductImage as u}from"../image/index.js";import{IkasBundleSettings as c}from"./bundle-settings/index.js";import{IkasCustomerPriceListRuleValueType as l,IkasCampaignType as a,IkasCampaignFilterType as s,IkasCampaignApplicablePrice as d,IkasCustomerPriceListRuleFilterType as p}from"@ikas/storefront-models";import{IkasProductVariantFunctions as f,IkasProductPriceFunctions as m}from"@ikas/storefront-model-functions";import{IkasStorefrontConfig as b}from"@ikas/storefront-config";import{saveProductBackInStockRemind as v,listProductBackInStockRemind as g}from"@ikas/storefront-api";import h from"lodash/groupBy";import y from"lodash/sortBy";import{IkasProductVariantUnit as P}from"./unit/index.js";import{formatCurrency as I}from"../../../../utils/currency.js";import{makeAutoObservable as S}from"mobx";import{IkasBaseStore as O}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";var j=function(){function j(e){void 0===e&&(e={}),this._backInStockReminderSaved=!1,this.product=null,this.id=e.id||Date.now()+"",this.productId=e.productId||"",this.sku=e.sku||null,this.barcodeList=e.barcodeList||[],this.baseBundlePrices=e.baseBundlePrices?e.baseBundlePrices.map((function(e){return new r(e)})):[],this.bundleSettings=e.bundleSettings?new c(e.bundleSettings):null,this.variantValues=e.variantValues?e.variantValues.map((function(e){return new n(e)})):[],this.images=e.images?e.images.map((function(e){return new u(e)})):[],this.attributes=e.attributes?e.attributes.map((function(e){return new o(e)})):[],this.prices=e.prices?e.prices.map((function(e){return new r(e)})):[],this.stock=e.stock||0,this.isActive=void 0===e.isActive||e.isActive,this.campaigns=e.campaigns||[],this.unit=e.unit?new P(e.unit):null,this.sellIfOutOfStock=e.sellIfOutOfStock||!1,this.images=y(this.images,"order"),S(this)}return Object.defineProperty(j.prototype,"mainImage",{get:function(){var e=f.getMainImage(this);return e?new u(e):void 0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"hasStock",{get:function(){return f.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isBackInStockEnabled",{get:function(){return b.isBackInStockEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isBackInStockCustomerLoginRequired",{get:function(){return b.isCustomerLoginRequiredForBackInStock()},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"isBackInStockReminderSaved",{get:function(){return this._backInStockReminderSaved},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"groupedAttributeValues",{get:function(){var e,t=h(this.attributes,"productAttributeId");return(null===(e=this.attributes)||void 0===e?void 0:e.map((function(e){var i=e.productAttributeId;if(i){var r=t[i];return(null==r?void 0:r.length)&&r[0].productAttribute?{attribute:r[0].productAttribute,values:r}:void 0}})).filter((function(e){return!!e})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"b2bPriceRule",{get:function(){var e,t,i=this,r=O.getInstance().customerStore.customer,n=null==r?void 0:r.priceListRules,o=function(e){var t,r,n,o;if(e.type===p.CATEGORY)return u=null===(t=e.valueList)||void 0===t?void 0:t.some((function(e){var t;return null===(t=i.product)||void 0===t?void 0:t.categories.find((function(t){return t.id===e}))}));if(e.type===p.PRODUCT)return u=null===(r=e.valueList)||void 0===r?void 0:r.some((function(e){return i.id===e}));if(e.type===p.PRODUCT_BRAND){var u=null===(n=e.valueList)||void 0===n?void 0:n.some((function(e){var t,r;return(null===(r=null===(t=i.product)||void 0===t?void 0:t.brand)||void 0===r?void 0:r.id)===e}));return u}if(e.type===p.PRODUCT_TAG){u=null===(o=e.valueList)||void 0===o?void 0:o.some((function(e){var t,r;return null===(r=null===(t=i.product)||void 0===t?void 0:t.tags)||void 0===r?void 0:r.find((function(t){return t.id===e}))}));return u}};if(n){for(var u=0,c=n;u<c.length;u++){var l=c[u];if(l.shouldMatchAllFilters?null===(e=l.filters)||void 0===e?void 0:e.every(o):null===(t=l.filters)||void 0===t?void 0:t.some(o))return l}return null}return null},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"price",{get:function(){var e,t;if(b.isB2BStorefront()){var i=O.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.prices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return null===(t=this.prices)||void 0===t?void 0:t.find((function(e){return b.getPriceListId()?e.priceListId===b.getPriceListId():null===e.priceListId}))},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"bundlePrice",{get:function(){var e,t;if(b.isB2BStorefront()){var i=O.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.baseBundlePrices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return(null===(t=this.baseBundlePrices)||void 0===t?void 0:t.find((function(e){return b.getPriceListId()?e.priceListId===b.getPriceListId():null===e.priceListId})))||this.price},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"finalPrice",{get:function(){var e=0;this.bundleSettings&&this.bundleSettings.products.every((function(e){return!!e.product}))?e=m.getFinalPrice(this.bundlePrice)+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.finalPriceWithQuantity:0)}),0):e=m.getFinalPrice(this.price);if(!this.b2bPriceRule)return e;switch(this.b2bPriceRule.valueType){case l.DISCOUNT_RATE:return e*((100-this.b2bPriceRule.value)/100);case l.DISCOUNT_AMOUNT:return e-this.b2bPriceRule.value;case l.FIXED_PRICE:return this.b2bPriceRule.value;default:return e}},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedFinalPrice",{get:function(){return I(this.finalPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"sellPrice",{get:function(){return this.bundleSettings&&this.bundleSettings.products.every((function(e){return!!e.product}))?this.bundlePrice.sellPrice+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.sellPriceWithQuantity:0)}),0):this.price.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedSellPrice",{get:function(){return I(this.sellPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedBuyPrice",{get:function(){return I(this.price.buyPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"appliedCampaignAmount",{get:function(){var e,t,i,r,n,o,u=this;if(!(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignId))return null;var c=(null===(r=null===(i=null===(t=this.product)||void 0===t?void 0:t.campaigns)||void 0===i?void 0:i.find((function(e){var t;return e.campaign.id===(null===(t=u.price.campaignPrice)||void 0===t?void 0:t.campaignId)})))||void 0===r?void 0:r.campaign)||null;if(!c)return null;var l={type:c.type,formattedPrice:null,discountPercentage:null},s=c.tieredDiscount&&c.tieredDiscount.rules&&c.tieredDiscount.rules.length>0&&c.tieredDiscount.rules[0].amount;return c.type===a.FIXED_AMOUNT&&(l.formattedPrice=I(c.fixedDiscount?(null===(n=c.fixedDiscount)||void 0===n?void 0:n.amount)||0:s||0,this.price.currency||"",this.price.currencySymbol||"")),c.type===a.RATIO&&(l.discountPercentage=c.fixedDiscount?(null===(o=c.fixedDiscount.amount)||void 0===o?void 0:o.toString())||null:s?s.toString():null),l},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"campaignPrice",{get:function(){var e;return(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignPrice)||null},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedCampaignPrice",{get:function(){return I(this.campaignPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"discountPrice",{get:function(){return this.finalPrice===this.sellPrice?null:this.finalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedDiscountPrice",{get:function(){return I(this.discountPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"hasDiscount",{get:function(){return this.finalPrice!==this.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"discountAmount",{get:function(){return this.hasDiscount?this.sellPrice-this.finalPrice:0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"discountPercentage",{get:function(){return this.hasDiscount?(100-100*this.finalPrice/this.sellPrice).toFixed(0):0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"finalPriceWithCampaignOffers",{get:function(){var e,t;return this.finalPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.finalPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedFinalPriceWithCampaignOffers",{get:function(){return I(this.finalPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"sellPriceWithCampaignOffers",{get:function(){var e,t;return this.sellPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.sellPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"formattedSellPriceWithCampaignOffers",{get:function(){return I(this.sellPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"campaignOffersDiscountPercentage",{get:function(){return this.finalPriceWithCampaignOffers!==this.sellPriceWithCampaignOffers?(100-100*this.finalPriceWithCampaignOffers/this.sellPriceWithCampaignOffers).toFixed(0):0},enumerable:!1,configurable:!0}),Object.defineProperty(j.prototype,"tieredDiscountProducts",{get:function(){var e,t,i,r,n=this,o=null===(i=null===(t=null===(e=this.product)||void 0===e?void 0:e.campaigns)||void 0===t?void 0:t.find((function(e){return!!e.campaign.tieredDiscount})))||void 0===i?void 0:i.campaign,u=null===(r=null==o?void 0:o.tieredDiscount)||void 0===r?void 0:r.filters;if(u){var c=u.find((function(e){return e.type===s.PRODUCT_AND_VARIANT}));if(c){var l=[];if(c.idList.map((function(e){l.push(e.replace("p:","").replace("v:",""))})),!l.some((function(e){return n.id===e||n.productId===e})))return[]}}return o&&o.tieredDiscount?o.tieredDiscount.rules.every((function(e){return!e.lineItemQuantityRange}))?[]:o.tieredDiscount.rules.map((function(e){var t,i,r,u,c=o.applicablePrice===d.SELL_PRICE?n.sellPrice:n.finalPrice,l=c*((null===(t=e.lineItemQuantityRange)||void 0===t?void 0:t.min)||1),s=I(c,n.price.currency||"",n.price.currencySymbol||""),p=I(l,n.price.currency||"",n.price.currencySymbol||""),f=o.type===a.RATIO?c-c*(e.amount||1)/100:c,m=f*((null===(i=e.lineItemQuantityRange)||void 0===i?void 0:i.min)||1)-(o.type===a.FIXED_AMOUNT&&e.amount||0),b=I(f,n.price.currency||"",n.price.currencySymbol||""),v=I(m,n.price.currency||"",n.price.currencySymbol||"");return{amount:e.amount,lineItemQuantityRange:{min:(null===(r=e.lineItemQuantityRange)||void 0===r?void 0:r.min)||0,max:(null===(u=e.lineItemQuantityRange)||void 0===u?void 0:u.max)||0},type:o.type,sellPrice:c,finalPrice:f,sellPriceWithQuantity:l,finalPriceWithQuantity:m,formattedSellPrice:s,formattedSellPriceWithQuantity:p,formattedFinalPrice:b,formattedFinalPriceWithQuantity:v}})):[]},enumerable:!1,configurable:!0}),j.prototype.saveBackInStockReminder=function(i){var r;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,g({email:{eq:i},productId:{eq:this.productId},variantId:{eq:this.id}})];case 1:return(e=t.sent())&&(null===(r=e.data)||void 0===r?void 0:r.length)?(this._backInStockReminderSaved=!0,[2,!1]):[3,2];case 2:return[4,v({input:{email:i,productId:this.productId,variantId:this.id}})];case 3:return t.sent().isSuccess?(this._backInStockReminderSaved=!0,[2,!0]):(this._backInStockReminderSaved=!1,[2,!1]);case 4:return[2]}}))}))},j.prototype.toJSON=function(){var e=i({},this);return delete e.product,e},j}();export{j as IkasProductVariant};
|
|
1
|
+
import{__awaiter as e,__generator as t,__assign as i}from'./../../../../ext/tslib/tslib.es6.js';import{IkasProductPrice as r}from"./price/index.js";import{IkasVariantValue as n}from"../../variant-type/variant-value/index.js";import{IkasProductAttributeValue as o}from"../attribute-value/index.js";import{IkasProductImage as u}from"../image/index.js";import{IkasBundleSettings as c}from"./bundle-settings/index.js";import{IkasCustomerPriceListRuleValueType as l,IkasCampaignType as s,IkasCampaignFilterType as a,IkasCampaignApplicablePrice as d,IkasCustomerPriceListRuleFilterType as p}from"@ikas/storefront-models";import{IkasProductVariantFunctions as f,IkasProductPriceFunctions as m}from"@ikas/storefront-model-functions";import{IkasStorefrontConfig as b}from"@ikas/storefront-config";import{saveProductBackInStockRemind as v,listProductBackInStockRemind as h}from"@ikas/storefront-api";import g from"lodash/groupBy";import y from"lodash/sortBy";import{IkasProductVariantUnit as P}from"./unit/index.js";import{formatCurrency as I}from"../../../../utils/currency.js";import{makeAutoObservable as S}from"mobx";import{IkasBaseStore as O}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";import{IkasProductSubscriptionPlan as j}from"./subscription-plan/index.js";var k=function(){function k(e){void 0===e&&(e={}),this._backInStockReminderSaved=!1,this.product=null,this.id=e.id||Date.now()+"",this.productId=e.productId||"",this.sku=e.sku||null,this.barcodeList=e.barcodeList||[],this.baseBundlePrices=e.baseBundlePrices?e.baseBundlePrices.map((function(e){return new r(e)})):[],this.bundleSettings=e.bundleSettings?new c(e.bundleSettings):null,this.variantValues=e.variantValues?e.variantValues.map((function(e){return new n(e)})):[],this.images=e.images?e.images.map((function(e){return new u(e)})):[],this.attributes=e.attributes?e.attributes.map((function(e){return new o(e)})):[],this.prices=e.prices?e.prices.map((function(e){return new r(e)})):[],this.stock=e.stock||0,this.subscriptionPlan=e.subscriptionPlan?new j(e.subscriptionPlan):null,this.isActive=void 0===e.isActive||e.isActive,this.campaigns=e.campaigns||[],this.unit=e.unit?new P(e.unit):null,this.sellIfOutOfStock=e.sellIfOutOfStock||!1,this.images=y(this.images,"order"),S(this)}return Object.defineProperty(k.prototype,"mainImage",{get:function(){var e=f.getMainImage(this);return e?new u(e):void 0},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"hasStock",{get:function(){return f.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isBackInStockEnabled",{get:function(){return b.isBackInStockEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isBackInStockCustomerLoginRequired",{get:function(){return b.isCustomerLoginRequiredForBackInStock()},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"isBackInStockReminderSaved",{get:function(){return this._backInStockReminderSaved},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"groupedAttributeValues",{get:function(){var e,t=g(this.attributes,"productAttributeId");return(null===(e=this.attributes)||void 0===e?void 0:e.map((function(e){var i=e.productAttributeId;if(i){var r=t[i];return(null==r?void 0:r.length)&&r[0].productAttribute?{attribute:r[0].productAttribute,values:r}:void 0}})).filter((function(e){return!!e})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"b2bPriceRule",{get:function(){var e,t,i=this,r=O.getInstance().customerStore.customer,n=null==r?void 0:r.priceListRules,o=function(e){var t,r,n,o;if(e.type===p.CATEGORY)return u=null===(t=e.valueList)||void 0===t?void 0:t.some((function(e){var t;return null===(t=i.product)||void 0===t?void 0:t.categories.find((function(t){return t.id===e}))}));if(e.type===p.PRODUCT)return u=null===(r=e.valueList)||void 0===r?void 0:r.some((function(e){return i.id===e}));if(e.type===p.PRODUCT_BRAND){var u=null===(n=e.valueList)||void 0===n?void 0:n.some((function(e){var t,r;return(null===(r=null===(t=i.product)||void 0===t?void 0:t.brand)||void 0===r?void 0:r.id)===e}));return u}if(e.type===p.PRODUCT_TAG){u=null===(o=e.valueList)||void 0===o?void 0:o.some((function(e){var t,r;return null===(r=null===(t=i.product)||void 0===t?void 0:t.tags)||void 0===r?void 0:r.find((function(t){return t.id===e}))}));return u}};if(n){for(var u=0,c=n;u<c.length;u++){var l=c[u];if(l.shouldMatchAllFilters?null===(e=l.filters)||void 0===e?void 0:e.every(o):null===(t=l.filters)||void 0===t?void 0:t.some(o))return l}return null}return null},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"price",{get:function(){var e,t;if(b.isB2BStorefront()){var i=O.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.prices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return null===(t=this.prices)||void 0===t?void 0:t.find((function(e){return b.getPriceListId()?e.priceListId===b.getPriceListId():null===e.priceListId}))},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"bundlePrice",{get:function(){var e,t;if(b.isB2BStorefront()){var i=O.getInstance().customerStore.customer;if(null==i?void 0:i.priceListId){var r=null===(e=this.baseBundlePrices)||void 0===e?void 0:e.find((function(e){return e.priceListId===i.priceListId}));if(r)return r}}return(null===(t=this.baseBundlePrices)||void 0===t?void 0:t.find((function(e){return b.getPriceListId()?e.priceListId===b.getPriceListId():null===e.priceListId})))||this.price},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"finalPrice",{get:function(){var e=0;this.bundleSettings&&this.bundleSettings.products.every((function(e){return!!e.product}))?e=m.getFinalPrice(this.bundlePrice)+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.finalPriceWithQuantity:0)}),0):e=m.getFinalPrice(this.price);if(!this.b2bPriceRule)return e;switch(this.b2bPriceRule.valueType){case l.DISCOUNT_RATE:return e*((100-this.b2bPriceRule.value)/100);case l.DISCOUNT_AMOUNT:return e-this.b2bPriceRule.value;case l.FIXED_PRICE:return this.b2bPriceRule.value;default:return e}},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"formattedFinalPrice",{get:function(){return I(this.finalPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"sellPrice",{get:function(){return this.bundleSettings&&this.bundleSettings.products.every((function(e){return!!e.product}))?this.bundlePrice.sellPrice+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.sellPriceWithQuantity:0)}),0):this.price.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"formattedSellPrice",{get:function(){return I(this.sellPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"formattedBuyPrice",{get:function(){return I(this.price.buyPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"appliedCampaignAmount",{get:function(){var e,t,i,r,n,o,u=this;if(!(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignId))return null;var c=(null===(r=null===(i=null===(t=this.product)||void 0===t?void 0:t.campaigns)||void 0===i?void 0:i.find((function(e){var t;return e.campaign.id===(null===(t=u.price.campaignPrice)||void 0===t?void 0:t.campaignId)})))||void 0===r?void 0:r.campaign)||null;if(!c)return null;var l={type:c.type,formattedPrice:null,discountPercentage:null},a=c.tieredDiscount&&c.tieredDiscount.rules&&c.tieredDiscount.rules.length>0&&c.tieredDiscount.rules[0].amount;return c.type===s.FIXED_AMOUNT&&(l.formattedPrice=I(c.fixedDiscount?(null===(n=c.fixedDiscount)||void 0===n?void 0:n.amount)||0:a||0,this.price.currency||"",this.price.currencySymbol||"")),c.type===s.RATIO&&(l.discountPercentage=c.fixedDiscount?(null===(o=c.fixedDiscount.amount)||void 0===o?void 0:o.toString())||null:a?a.toString():null),l},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"campaignPrice",{get:function(){var e;return(null===(e=this.price.campaignPrice)||void 0===e?void 0:e.campaignPrice)||null},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"formattedCampaignPrice",{get:function(){return I(this.campaignPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"discountPrice",{get:function(){return this.finalPrice===this.sellPrice?null:this.finalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"formattedDiscountPrice",{get:function(){return I(this.discountPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"hasDiscount",{get:function(){return this.finalPrice!==this.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"discountAmount",{get:function(){return this.hasDiscount?this.sellPrice-this.finalPrice:0},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"discountPercentage",{get:function(){return this.hasDiscount?(100-100*this.finalPrice/this.sellPrice).toFixed(0):0},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"finalPriceWithCampaignOffers",{get:function(){var e,t;return this.finalPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.finalPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"formattedFinalPriceWithCampaignOffers",{get:function(){return I(this.finalPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"sellPriceWithCampaignOffers",{get:function(){var e,t;return this.sellPrice+((null===(t=null===(e=this.product)||void 0===e?void 0:e.offers)||void 0===t?void 0:t.filter((function(e){return e.isSelected&&!e.isAccepted})).reduce((function(e,t){return e+t.product.selectedVariant.sellPrice}),0))||0)},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"formattedSellPriceWithCampaignOffers",{get:function(){return I(this.sellPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"campaignOffersDiscountPercentage",{get:function(){return this.finalPriceWithCampaignOffers!==this.sellPriceWithCampaignOffers?(100-100*this.finalPriceWithCampaignOffers/this.sellPriceWithCampaignOffers).toFixed(0):0},enumerable:!1,configurable:!0}),Object.defineProperty(k.prototype,"tieredDiscountProducts",{get:function(){var e,t,i,r,n=this,o=null===(i=null===(t=null===(e=this.product)||void 0===e?void 0:e.campaigns)||void 0===t?void 0:t.find((function(e){return!!e.campaign.tieredDiscount})))||void 0===i?void 0:i.campaign,u=null===(r=null==o?void 0:o.tieredDiscount)||void 0===r?void 0:r.filters;if(u){var c=u.find((function(e){return e.type===a.PRODUCT_AND_VARIANT}));if(c){var l=[];if(c.idList.map((function(e){l.push(e.replace("p:","").replace("v:",""))})),!l.some((function(e){return n.id===e||n.productId===e})))return[]}}return o&&o.tieredDiscount?o.tieredDiscount.rules.every((function(e){return!e.lineItemQuantityRange}))?[]:o.tieredDiscount.rules.map((function(e){var t,i,r,u,c=o.applicablePrice===d.SELL_PRICE?n.sellPrice:n.finalPrice,l=c*((null===(t=e.lineItemQuantityRange)||void 0===t?void 0:t.min)||1),a=I(c,n.price.currency||"",n.price.currencySymbol||""),p=I(l,n.price.currency||"",n.price.currencySymbol||""),f=o.type===s.RATIO?c-c*(e.amount||1)/100:c,m=f*((null===(i=e.lineItemQuantityRange)||void 0===i?void 0:i.min)||1)-(o.type===s.FIXED_AMOUNT&&e.amount||0),b=I(f,n.price.currency||"",n.price.currencySymbol||""),v=I(m,n.price.currency||"",n.price.currencySymbol||"");return{amount:e.amount,lineItemQuantityRange:{min:(null===(r=e.lineItemQuantityRange)||void 0===r?void 0:r.min)||0,max:(null===(u=e.lineItemQuantityRange)||void 0===u?void 0:u.max)||0},type:o.type,sellPrice:c,finalPrice:f,sellPriceWithQuantity:l,finalPriceWithQuantity:m,formattedSellPrice:a,formattedSellPriceWithQuantity:p,formattedFinalPrice:b,formattedFinalPriceWithQuantity:v,salesChannelIds:o.salesChannelIds}})):[]},enumerable:!1,configurable:!0}),k.prototype.saveBackInStockReminder=function(i){var r;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,h({email:{eq:i},productId:{eq:this.productId},variantId:{eq:this.id}})];case 1:return(e=t.sent())&&(null===(r=e.data)||void 0===r?void 0:r.length)?(this._backInStockReminderSaved=!0,[2,!1]):[3,2];case 2:return[4,v({input:{email:i,productId:this.productId,variantId:this.id}})];case 3:return t.sent().isSuccess?(this._backInStockReminderSaved=!0,[2,!0]):(this._backInStockReminderSaved=!1,[2,!1]);case 4:return[2]}}))}))},k.prototype.toJSON=function(){var e=i({},this);return delete e.product,e},k}();export{k as IkasProductVariant};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IkasSubscriptionPlanStatus, IkasSubscriptionPlanTranslation, IkasProductSubscriptionPlan as IProductSubscriptionPlan } from "@ikas/storefront-models";
|
|
2
|
+
import { IkasProductSubscriptionPlanPeriod } from "./product-subscription-plan-period";
|
|
3
|
+
export declare class IkasProductSubscriptionPlan implements IProductSubscriptionPlan {
|
|
4
|
+
name: string;
|
|
5
|
+
periods: IkasProductSubscriptionPlanPeriod[];
|
|
6
|
+
status: IkasSubscriptionPlanStatus;
|
|
7
|
+
subscriptionPlanId: string;
|
|
8
|
+
translations: IkasSubscriptionPlanTranslation[] | null;
|
|
9
|
+
isSelected: boolean;
|
|
10
|
+
constructor(data: IProductSubscriptionPlan);
|
|
11
|
+
setSelectedPeriod: (period: IkasProductSubscriptionPlanPeriod, isSelected: boolean) => void;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{makeAutoObservable as t}from"mobx";import{IkasProductSubscriptionPlanPeriod as i}from"./product-subscription-plan-period/index.js";var s=function(s){var e=this;this.isSelected=!1,this.setSelectedPeriod=function(t,i){e.periods.forEach((function(t){t.isSelected=!1})),t.isSelected=i},this.name=s.name,this.periods=s.periods.map((function(t){return new i(t)})),this.status=s.status,this.subscriptionPlanId=s.subscriptionPlanId,this.translations=s.translations,this.isSelected=s.isSelected||!1,t(this)};export{s as IkasProductSubscriptionPlan};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { IkasOrderAmountType, IkasProductSubscriptionPlanDiscount as IProductSubscriptionPlanDiscount } from "@ikas/storefront-models";
|
|
2
|
+
export declare class IkasProductSubscriptionPlanDiscount implements IProductSubscriptionPlanDiscount {
|
|
3
|
+
amount: number;
|
|
4
|
+
type: IkasOrderAmountType;
|
|
5
|
+
constructor(data: IProductSubscriptionPlanDiscount);
|
|
6
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IkasSubscriptionPlanDurationUnitType, IkasSubscriptionPlanPaymentType, IkasSubscriptionPlanStatus, IkasProductSubscriptionPlanPeriod as IProductSubscriptionPlanPeriod } from "@ikas/storefront-models";
|
|
2
|
+
import { IkasProductSubscriptionPlanDiscount } from "../product-subscription-plan-discount";
|
|
3
|
+
import { IkasProduct } from "../../..";
|
|
4
|
+
export declare class IkasProductSubscriptionPlanPeriod implements IProductSubscriptionPlanPeriod {
|
|
5
|
+
cutOffDay: number | null;
|
|
6
|
+
discount: IkasProductSubscriptionPlanDiscount | null;
|
|
7
|
+
durationUnit: IkasSubscriptionPlanDurationUnitType;
|
|
8
|
+
durationValue: number;
|
|
9
|
+
id: string;
|
|
10
|
+
maxOrders: number | null;
|
|
11
|
+
paymentType: IkasSubscriptionPlanPaymentType;
|
|
12
|
+
scheduledOrderDay: number | null;
|
|
13
|
+
status: IkasSubscriptionPlanStatus;
|
|
14
|
+
title: string;
|
|
15
|
+
isSelected: boolean;
|
|
16
|
+
product: IkasProduct | null;
|
|
17
|
+
constructor(data: IProductSubscriptionPlanPeriod);
|
|
18
|
+
get periodPrice(): number;
|
|
19
|
+
get formattedPeriodPrice(): string;
|
|
20
|
+
get totalPeriodPrice(): number;
|
|
21
|
+
get formattedTotalPeriodPrice(): string;
|
|
22
|
+
setProduct: (product: IkasProduct) => void;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{IkasOrderAmountType as t,IkasSubscriptionPlanPaymentType as e}from"@ikas/storefront-models";import{makeAutoObservable as i}from"mobx";import{formatCurrency as r}from"../../../../../../utils/currency.js";var o=function(){function o(t){var e=this;this.isSelected=!1,this.product=null,this.setProduct=function(t){e.product=t,e.product.selectedVariantValues=e.product.variants[0].variantValues},this.cutOffDay=t.cutOffDay,this.discount=t.discount,this.durationUnit=t.durationUnit,this.durationValue=t.durationValue,this.id=t.id,this.maxOrders=t.maxOrders,this.paymentType=t.paymentType,this.scheduledOrderDay=t.scheduledOrderDay,this.status=t.status,this.title=t.title,this.isSelected=t.isSelected||!1,i(this)}return Object.defineProperty(o.prototype,"periodPrice",{get:function(){var e,i,r=null!==(i=null===(e=this.product)||void 0===e?void 0:e.selectedVariant.finalPrice)&&void 0!==i?i:0;return r-(this.discount?this.discount.type===t.AMOUNT?this.discount.amount:r*(this.discount.amount/100):0)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"formattedPeriodPrice",{get:function(){var t,e;return r(this.periodPrice,(null===(t=this.product)||void 0===t?void 0:t.selectedVariant.price.currency)||"",(null===(e=this.product)||void 0===e?void 0:e.selectedVariant.price.currencySymbol)||"")},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"totalPeriodPrice",{get:function(){return this.periodPrice*(this.paymentType===e.POST_PAID?1:this.maxOrders||1)},enumerable:!1,configurable:!0}),Object.defineProperty(o.prototype,"formattedTotalPeriodPrice",{get:function(){var t,e;return r(this.totalPeriodPrice,(null===(t=this.product)||void 0===t?void 0:t.selectedVariant.price.currency)||"",(null===(e=this.product)||void 0===e?void 0:e.selectedVariant.price.currencySymbol)||"")},enumerable:!1,configurable:!0}),o}();export{o as IkasProductSubscriptionPlanPeriod};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IkasStoreCreditBalance as IStoreCreditBalance } from "@ikas/storefront-models";
|
|
2
|
+
import { IkasStoreCredit as IStoreCredit } from "@ikas/storefront-models";
|
|
3
|
+
import { IkasStoreCreditSalesChannel as IStoreCreditSalesChannel, IkasStoreCreditType } from "@ikas/storefront-models";
|
|
4
|
+
export declare class IkasStoreCreditBalance implements IStoreCreditBalance {
|
|
5
|
+
amount: number;
|
|
6
|
+
storeCredits: IkasStoreCredit[];
|
|
7
|
+
constructor(data: IStoreCreditBalance);
|
|
8
|
+
}
|
|
9
|
+
export declare class IkasStoreCredit implements IStoreCredit {
|
|
10
|
+
usedAmount: number;
|
|
11
|
+
usedAllAmount: boolean | null;
|
|
12
|
+
type: IkasStoreCreditType;
|
|
13
|
+
salesChannels: IkasStoreCreditSalesChannel[];
|
|
14
|
+
minimumRequiredCartAmount: number | null;
|
|
15
|
+
customerId: string | null;
|
|
16
|
+
code: string;
|
|
17
|
+
amount: number;
|
|
18
|
+
active: boolean;
|
|
19
|
+
constructor(data: IStoreCredit);
|
|
20
|
+
}
|
|
21
|
+
export declare class IkasStoreCreditSalesChannel implements IStoreCreditSalesChannel {
|
|
22
|
+
salesChannelId: string;
|
|
23
|
+
storefrontId: string | null;
|
|
24
|
+
storefrontRoutingId: string | null;
|
|
25
|
+
constructor(data: IStoreCreditSalesChannel);
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{makeAutoObservable as t}from"mobx";var s=function(t){this.amount=t.amount,this.storeCredits=t.storeCredits.map((function(t){return new n(t)}))},n=function(s){this.usedAmount=s.usedAmount,this.usedAllAmount=s.usedAllAmount,this.type=s.type,this.salesChannels=s.salesChannels,this.minimumRequiredCartAmount=s.minimumRequiredCartAmount,this.customerId=s.customerId,this.code=s.code,this.amount=s.amount,this.active=s.active,t(this)},e=function(s){this.salesChannelId=s.salesChannelId,this.storefrontId=s.storefrontId,this.storefrontRoutingId=s.storefrontRoutingId,t(this)};export{n as IkasStoreCredit,s as IkasStoreCreditBalance,e as IkasStoreCreditSalesChannel};
|
|
@@ -18,6 +18,7 @@ export declare class IkasThemeJsonComponentProp implements IThemeJsonComponentPr
|
|
|
18
18
|
};
|
|
19
19
|
excludedFields?: string[] | null;
|
|
20
20
|
excludedFieldsCategory?: string[] | null;
|
|
21
|
+
isFacetListNotSent?: boolean;
|
|
21
22
|
constructor(data: Partial<IkasThemeJsonComponentProp>);
|
|
22
23
|
}
|
|
23
24
|
export { IkasThemeJsonComponentPropType };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{IkasThemeJsonComponentPropType as
|
|
1
|
+
import{IkasThemeJsonComponentPropType as t}from"@ikas/storefront-models";export{IkasThemeJsonComponentPropType}from"@ikas/storefront-models";import{makeAutoObservable as e}from"mobx";var i=function(i){this.translations={},this.id=i.id||Date.now()+"",this.name=i.name||"",this.displayName=i.displayName||"",this.description=i.description||"",this.type=i.type||t.TEXT,this.isRequired=i.isRequired||!1,this.customDataId=i.customDataId||null,this.requiredPropId=i.requiredPropId,this.requiredEnumOptionId=i.requiredEnumOptionId,this.requiredEnumOptionValue=i.requiredEnumOptionValue,this.attributeTypes=i.attributeTypes||null,this.sliderData=i.sliderData||{},this.translations=i.translations||{},this.excludedFields=i.excludedFields||[],this.excludedFieldsCategory=i.excludedFieldsCategory||[],this.isFacetListNotSent=i.isFacetListNotSent||!1,e(this)};export{i as IkasThemeJsonComponentProp};
|
|
@@ -21,6 +21,7 @@ export declare class IkasThemeJsonCustomData implements IThemeJsonCustomData {
|
|
|
21
21
|
parent?: IkasThemeJsonCustomData | null;
|
|
22
22
|
excludedFields?: string[] | null;
|
|
23
23
|
excludedFieldsCategory?: string[] | null;
|
|
24
|
+
isFacetListNotSent?: boolean;
|
|
24
25
|
constructor(data?: Partial<IkasThemeJsonCustomData>);
|
|
25
26
|
get flat(): IkasThemeJsonCustomData[];
|
|
26
27
|
toJSON(): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__assign as t}from'./../../../../ext/tslib/tslib.es6.js';import i from"lodash/flatten";import{IkasThemeJsonComponentPropType as e}from"@ikas/storefront-models";var s=function(){function s(i){void 0===i&&(i={});var a,
|
|
1
|
+
import{__assign as t}from'./../../../../ext/tslib/tslib.es6.js';import i from"lodash/flatten";import{IkasThemeJsonComponentPropType as e}from"@ikas/storefront-models";var s=function(){function s(i){void 0===i&&(i={});var a,o=this;this.translations={},this.customDataId=null,this.id=i.id||"",this.name=i.name||null,this.description=i.description||null,this.typescriptName=i.name||null,this.type=i.type||e.TEXT,this.isRequired=void 0===i.isRequired||i.isRequired,this.translations=i.translations||{},this.key=i.key||null,this.parent=i.parent||null,this.itemCount=i.itemCount||null,this.attributeTypes=i.attributeTypes||null,this.enumOptions=(null===(a=i.enumOptions)||void 0===a?void 0:a.map((function(t){return new n(t)})))||null,this.customDataId=i.customDataId||null,this.sliderData=i.sliderData||{},this.isRoot=i.isRoot||!1,this.nestedData=i.nestedData?i.nestedData.map((function(i){return new s(t(t({},i),{parent:o}))})):null,this.type!==e.STATIC_LIST||this.itemCount||(this.itemCount=1),this.excludedFields=i.excludedFields||[],this.excludedFieldsCategory=i.excludedFieldsCategory||[],this.isFacetListNotSent=i.isFacetListNotSent||!1}return Object.defineProperty(s.prototype,"flat",{get:function(){if(!this.nestedData||!this.nestedData.length)return[this];var t=i(this.nestedData.map((function(t){return t.flat}))),e=[];return e.push(this),e=e.concat(t)},enumerable:!1,configurable:!0}),s.prototype.toJSON=function(){var i=t({},this);return delete i.parent,i},s}(),n=function(t){void 0===t&&(t={}),this.translations={},this.id=t.id||"",this.displayName=t.displayName||"",this.value=t.value||"",this.translations=t.translations||{}},a=function(t){void 0===t&&(t={}),this.name=t.name||null,this.description=t.description||null},o=function(t){void 0===t&&(t={}),this.displayName=t.displayName||null};export{s as IkasThemeJsonCustomData,o as IkasThemeJsonCustomDataEnumOptionTranslation,a as IkasThemeJsonCustomDataTranslation,n as IkasThemeJsonEnumOption};
|
|
@@ -9,6 +9,8 @@ export declare class IkasCustomerReviewList {
|
|
|
9
9
|
private _productId?;
|
|
10
10
|
private _hasImage?;
|
|
11
11
|
private _productIds?;
|
|
12
|
+
private _locale?;
|
|
13
|
+
private _sortWithImagesFirst?;
|
|
12
14
|
private _isLoading;
|
|
13
15
|
constructor(data: IkasCustomerReviewListParams);
|
|
14
16
|
get limit(): number;
|
|
@@ -21,6 +23,8 @@ export declare class IkasCustomerReviewList {
|
|
|
21
23
|
get isLoading(): boolean;
|
|
22
24
|
get hasImage(): boolean | undefined;
|
|
23
25
|
get productIds(): string[] | null | undefined;
|
|
26
|
+
get locale(): string | undefined;
|
|
27
|
+
get sortWithImagesFirst(): boolean | undefined;
|
|
24
28
|
private listCustomerReviews;
|
|
25
29
|
getInitial: () => Promise<void>;
|
|
26
30
|
getPrev: () => Promise<void>;
|
|
@@ -34,10 +38,13 @@ export declare class IkasCustomerReviewList {
|
|
|
34
38
|
initialized: boolean;
|
|
35
39
|
minPage: number | null | undefined;
|
|
36
40
|
productId: string | null | undefined;
|
|
41
|
+
locale: string | undefined;
|
|
42
|
+
sortWithImagesFirst: boolean | undefined;
|
|
37
43
|
};
|
|
38
44
|
}
|
|
39
45
|
export declare type IkasCustomerReviewListParams = {
|
|
40
46
|
data?: IkasCustomerReview[];
|
|
47
|
+
locale?: string;
|
|
41
48
|
limit?: number;
|
|
42
49
|
page?: number;
|
|
43
50
|
count?: number;
|
|
@@ -46,4 +53,5 @@ export declare type IkasCustomerReviewListParams = {
|
|
|
46
53
|
productId?: string;
|
|
47
54
|
productIds?: string[] | null;
|
|
48
55
|
hasImage?: boolean;
|
|
56
|
+
sortWithImagesFirst?: boolean;
|
|
49
57
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t,__generator as i,__assign as e}from'./../../../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as a}from"@ikas/storefront-config";import{makeAutoObservable as r}from"mobx";import o from"../../../store/customer/api.js";import
|
|
1
|
+
import{__awaiter as t,__generator as i,__assign as e}from'./../../../ext/tslib/tslib.es6.js';import{IkasStorefrontConfig as a}from"@ikas/storefront-config";import{makeAutoObservable as r}from"mobx";import o from"../../../store/customer/api.js";import s from"../../../store/product/index.js";import"../../data/blog/category/index.js";import"../../data/blog/content/index.js";import"../../data/blog/meta-data/index.js";import"../../data/blog/tag/index.js";import"../../data/blog/index.js";import"../../data/brand/index.js";import"@ikas/storefront-models";import"../../data/campaign-offer/index.js";import"../../data/cart/campaign-offer/index.js";import"../../data/cart/index.js";import"../../data/category/path-item/index.js";import"../../data/category/index.js";import"../../data/checkout/index.js";import"../../data/checkout-settings/index.js";import"../../data/city/index.js";import"../../data/country/index.js";import"../../data/customer/address/region/index.js";import"../../data/customer/address/index.js";import"../../data/customer/address/ikas-localized-customer-address.js";import"../../data/customer/attribute/index.js";import"../../data/customer/review/summary/index.js";import{IkasCustomerReview as n}from"../../data/customer/review/index.js";import"../../data/customer/index.js";import"../../data/customer-form-data-input/index.js";import"../../data/district/index.js";import"../../data/favorite-product/index.js";import"../../data/filter-category/index.js";import"../../data/html-meta-data/index.js";import"../../data/image/index.js";import"../../data/order/address/region/index.js";import"../../data/order/address/index.js";import"../../data/order/line-item/option/value/index.js";import"../../data/order/line-item/variant/value/index.js";import"../../data/order/line-item/variant/index.js";import"../../data/order/line-item/index.js";import"../../data/order/order-transaction-with-prices/index.js";import"../../data/order/package/index.js";import"../../data/order/transaction/index.js";import"../../data/order/index.js";import"../../data/payment-gateway/index.js";import"../../data/product/attribute-value/index.js";import"../../data/product/filter/index.js";import"../../data/product/campaign-offer/index.js";import"../../data/product/option-set/option/index.js";import"../../data/product/option-set/index.js";import"../../data/product/stock-location/index.js";import"../../data/product/variant/price/index.js";import"../../data/product/variant/index.js";import"../../data/variant-type/index.js";import"../../data/product/index.js";import"../../data/raffle/index.js";import"../../data/shipping-zone/state/city/district/region/index.js";import"../../data/state/index.js";import"../../data/storefront-popup/storefront-popup-display-filter/index.js";import"../../data/storefront-popup/storefront-popup-display-settings/index.js";import"../../data/storefront-popup/storefront-popup-page-filter/index.js";import"../../data/storefront-popup/index.js";import"../../data/theme-json/index.js";import"../../data/theme-json/component/index.js";import"../../data/theme-json/custom-data/index.js";import"../../data/variant-type/variant-value/index.js";import"@ikas/localized-address";var d=function(){function d(e){var a,o=this;this._initialized=!1,this._minPage=null,this._productId=null,this._hasImage=!1,this._productIds=null,this._isLoading=!1,this.getInitial=function(){return t(o,void 0,void 0,(function(){var t,e,a,r;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviews(this.page,this.limit,this.hasImage,this.productIds,this.locale,this.sortWithImagesFirst)];case 2:return t=i.sent(),this.data=(null===(a=t.data)||void 0===a?void 0:a.data)||[],this._count=(null===(r=t.data)||void 0===r?void 0:r.count)||0,this._initialized=!0,this._minPage=this.page,[3,5];case 3:return e=i.sent(),console.log(e),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPrev=function(){return t(o,void 0,void 0,(function(){var t,e,a,r,o;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasPrev)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),t=this._minPage-1,[4,this.listCustomerReviews(t,this.limit,this.hasImage,this.productIds,this.locale)];case 2:return e=i.sent(),this.data=(null===(r=e.data)||void 0===r?void 0:r.data.concat(this.data))||this.data,this._count=(null===(o=e.data)||void 0===o?void 0:o.count)||this._count,this._minPage=t,[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getNext=function(){return t(o,void 0,void 0,(function(){var t,e,a,r;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading||!this.hasNext)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviews(this.page+1,this.limit,this.hasImage,this.productIds,this.locale)];case 2:return t=i.sent(),this.data=this.data.concat((null===(a=t.data)||void 0===a?void 0:a.data)||[]),this._count=(null===(r=t.data)||void 0===r?void 0:r.count)||this._count,this._page=this.page+1,[3,5];case 3:return e=i.sent(),console.log(e),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.getPage=function(e){return t(o,void 0,void 0,(function(){var t,a,r,o;return i(this,(function(i){switch(i.label){case 0:if(this._isLoading)return[2];this._isLoading=!0,i.label=1;case 1:return i.trys.push([1,3,4,5]),[4,this.listCustomerReviews(e,this.limit,this.hasImage,this.productIds,this.locale)];case 2:return t=i.sent(),this.data=(null===(r=t.data)||void 0===r?void 0:r.data)||[],this._count=(null===(o=t.data)||void 0===o?void 0:o.count)||0,this._page=e,this._minPage=e,[3,5];case 3:return a=i.sent(),console.log(a),[3,5];case 4:return this._isLoading=!1,[7];case 5:return[2]}}))}))},this.data=e.data?e.data.map((function(t){return new n(t)})):[],this._limit=e.limit||5,this._page=e.page||1,this._count=e.count||0,this._initialized=e.initialized||!1,this._hasImage=e.hasImage||!1,this._minPage=e.minPage,this._productId=e.productId||null,this._productIds=e.productIds||null,this._locale=e.locale||void 0,this._sortWithImagesFirst=null!==(a=e.sortWithImagesFirst)&&void 0!==a?a:void 0,r(this)}return Object.defineProperty(d.prototype,"limit",{get:function(){return this._limit},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"page",{get:function(){return this._page},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"pageCount",{get:function(){return Math.ceil(this._count/this._limit)},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"isInitialized",{get:function(){return this._initialized},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"hasPrev",{get:function(){return!!this._minPage&&this._minPage>1},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"hasNext",{get:function(){return this.page*this.limit<this.count},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"isLoading",{get:function(){return this._isLoading},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"hasImage",{get:function(){return this._hasImage},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"productIds",{get:function(){return this._productIds},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"locale",{get:function(){return this._locale},enumerable:!1,configurable:!0}),Object.defineProperty(d.prototype,"sortWithImagesFirst",{get:function(){return this._sortWithImagesFirst},enumerable:!1,configurable:!0}),d.prototype.listCustomerReviews=function(r,n,d,u,p,c){var l,m,h;return void 0===c&&(c=!0),t(this,void 0,void 0,(function(){var t,g,f;return i(this,(function(i){switch(i.label){case 0:return[4,o.listCustomerReviews(e(e(e({},this._productId?{productId:this._productId}:{}),{input:{salesChannelId:a.getSalesChannelId()||""},pagination:{page:r,limit:n},hasImage:d,locale:p,sortWithImagesFirst:c}),u?{productIds:u}:{}))];case 1:return t=i.sent(),!(null===(l=t.data)||void 0===l?void 0:l.data)||this._productId?[3,3]:(g=null===(m=null==t?void 0:t.data)||void 0===m?void 0:m.data.map((function(t){return null==t?void 0:t.productId})),[4,s.searchProducts({input:{productIdList:g}})]);case 2:f=i.sent(),t.data.data=null===(h=null==t?void 0:t.data)||void 0===h?void 0:h.data.map((function(t){var i,a,r=null===(a=null===(i=null==f?void 0:f.data)||void 0===i?void 0:i.data)||void 0===a?void 0:a.find((function(i){return i.id===t.productId}));return e(e({},t),{product:r})})).filter((function(t){return t.product&&!t.product.deleted})),i.label=3;case 3:return[2,t]}}))}))},d.prototype.toJSON=function(){return{data:this.data,limit:this._limit,page:this._page,count:this._count,initialized:this._initialized,minPage:this._minPage,productId:this._productId,locale:this._locale,sortWithImagesFirst:this._sortWithImagesFirst}},d}();export{d as IkasCustomerReviewList};
|
|
@@ -13,6 +13,8 @@ export declare class IkasProductList {
|
|
|
13
13
|
private _infiniteScrollPage;
|
|
14
14
|
private _count;
|
|
15
15
|
private _searchKeyword;
|
|
16
|
+
private _enableSuggestions?;
|
|
17
|
+
private _baseCategoryIdList;
|
|
16
18
|
private _initialized;
|
|
17
19
|
private _minPage?;
|
|
18
20
|
private _productListPropValue;
|
|
@@ -27,17 +29,26 @@ export declare class IkasProductList {
|
|
|
27
29
|
private _fetchRequestTime;
|
|
28
30
|
private router?;
|
|
29
31
|
private _excludedFields?;
|
|
32
|
+
private _isFacetListNotSent?;
|
|
30
33
|
private _disabledSortTypes?;
|
|
34
|
+
private _suggestions?;
|
|
35
|
+
private _suggestionCategoryId;
|
|
31
36
|
constructor(data: IkasProductListParams | IkasProductList, router?: NextRouter);
|
|
32
37
|
get sort(): IkasProductListSortType;
|
|
33
38
|
get limit(): number;
|
|
34
39
|
get pageType(): IkasThemeJsonPageType;
|
|
35
40
|
get page(): number;
|
|
36
41
|
get minPage(): number;
|
|
42
|
+
get baseCategoryIdList(): string[] | null;
|
|
37
43
|
get count(): number;
|
|
38
44
|
get pageCount(): number;
|
|
39
45
|
get searchKeyword(): string;
|
|
40
46
|
set searchKeyword(value: string);
|
|
47
|
+
get enableSuggestions(): boolean | null | undefined;
|
|
48
|
+
set enableSuggestions(value: boolean | null | undefined);
|
|
49
|
+
get suggestions(): IkasSearchSuggestion[] | null | undefined;
|
|
50
|
+
get suggestionCategoryId(): string | null;
|
|
51
|
+
set suggestionCategoryId(value: string | null);
|
|
41
52
|
get isInitialized(): boolean;
|
|
42
53
|
get isFilterable(): boolean;
|
|
43
54
|
get isFiltered(): boolean | undefined;
|
|
@@ -124,6 +135,7 @@ export declare type IkasProductListParams = {
|
|
|
124
135
|
recommendedProductData?: IkasRecommendedProductProps | null;
|
|
125
136
|
viewedTogetherProductData?: IkasViewedTogetherProductProps | null;
|
|
126
137
|
excludedFields?: string[] | null;
|
|
138
|
+
isFacetListNotSent?: boolean;
|
|
127
139
|
disabledSortTypes?: IkasProductListSortByTypeEnum[] | null;
|
|
128
140
|
};
|
|
129
141
|
export declare enum IkasProductListType {
|
|
@@ -167,3 +179,8 @@ export declare enum IkasRelatedProductsType {
|
|
|
167
179
|
CATEGORY = "CATEGORY",
|
|
168
180
|
BRAND = "BRAND"
|
|
169
181
|
}
|
|
182
|
+
export declare type IkasSearchSuggestion = {
|
|
183
|
+
brandId: string | null;
|
|
184
|
+
categoryId: string | null;
|
|
185
|
+
term: string;
|
|
186
|
+
};
|