@ikas/storefront 4.12.0-beta.33 → 4.12.0-beta.34

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.
@@ -45,8 +45,10 @@ export declare class IkasProductVariant implements IProductVariant {
45
45
  get hasDiscount(): boolean;
46
46
  get discountAmount(): number;
47
47
  get discountPercentage(): string | 0;
48
- private get campaignOffersFinalPrice();
49
- private get campaignOffersSellPrice();
48
+ get finalPriceWithCampaignOffers(): number;
49
+ get formattedFinalPriceWithCampaignOffers(): string;
50
+ get sellPriceWithCampaignOffers(): number;
51
+ get formattedSellPriceWithCampaignOffers(): string;
50
52
  saveBackInStockReminder(email: string): Promise<boolean>;
51
53
  toJSON(): this;
52
54
  }
@@ -1 +1 @@
1
- import{__awaiter as e,__generator as t,__assign as r}from'./../../../../ext/tslib/tslib.es6.js';import{IkasProductPrice as i}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 s,IkasCustomerPriceListRuleFilterType as l}from"@ikas/storefront-models";import{IkasProductVariantFunctions as a,IkasProductPriceFunctions as d}from"@ikas/storefront-model-functions";import{IkasStorefrontConfig as f}from"@ikas/storefront-config";import{saveProductBackInStockRemind as p,listProductBackInStockRemind as b}from"@ikas/storefront-api";import m from"lodash/groupBy";import v from"lodash/sortBy";import{IkasProductVariantUnit as h}from"./unit/index.js";import{formatCurrency as g}from"../../../../utils/currency.js";import{makeAutoObservable as P}from"mobx";import{IkasBaseStore as y}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";var S=function(){function S(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 i(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 i(e)})):[],this.stock=e.stock||0,this.isActive=void 0===e.isActive||e.isActive,this.campaigns=e.campaigns||[],this.unit=e.unit?new h(e.unit):null,this.sellIfOutOfStock=e.sellIfOutOfStock||!1,this.images=v(this.images,"order"),P(this)}return Object.defineProperty(S.prototype,"mainImage",{get:function(){var e=a.getMainImage(this);return e?new u(e):void 0},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasStock",{get:function(){return a.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isBackInStockEnabled",{get:function(){return f.isBackInStockEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isBackInStockCustomerLoginRequired",{get:function(){return f.isCustomerLoginRequiredForBackInStock()},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isBackInStockReminderSaved",{get:function(){return this._backInStockReminderSaved},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"groupedAttributeValues",{get:function(){var e,t=m(this.attributes,"productAttributeId");return(null===(e=this.attributes)||void 0===e?void 0:e.map((function(e){var r=e.productAttributeId;if(r){var i=t[r];return(null==i?void 0:i.length)&&i[0].productAttribute?{attribute:i[0].productAttribute,values:i}:void 0}})).filter((function(e){return!!e})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"b2bPriceRule",{get:function(){var e,t,r=this,i=y.getInstance().customerStore.customer,n=null==i?void 0:i.priceListRules,o=function(e){var t,i,n,o;if(e.type===l.CATEGORY)return u=null===(t=e.valueList)||void 0===t?void 0:t.some((function(e){var t;return null===(t=r.product)||void 0===t?void 0:t.categories.find((function(t){return t.id===e}))}));if(e.type===l.PRODUCT)return u=null===(i=e.valueList)||void 0===i?void 0:i.some((function(e){return r.id===e}));if(e.type===l.PRODUCT_BRAND){var u=null===(n=e.valueList)||void 0===n?void 0:n.some((function(e){var t,i;return(null===(i=null===(t=r.product)||void 0===t?void 0:t.brand)||void 0===i?void 0:i.id)===e}));return u}if(e.type===l.PRODUCT_TAG){u=null===(o=e.valueList)||void 0===o?void 0:o.some((function(e){var t,i;return null===(i=null===(t=r.product)||void 0===t?void 0:t.tags)||void 0===i?void 0:i.find((function(t){return t.id===e}))}));return u}};if(n){for(var u=0,c=n;u<c.length;u++){var s=c[u];if(s.shouldMatchAllFilters?null===(e=s.filters)||void 0===e?void 0:e.every(o):null===(t=s.filters)||void 0===t?void 0:t.some(o))return s}return null}return null},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"price",{get:function(){var e,t;if(f.isB2BStorefront()){var r=y.getInstance().customerStore.customer;if(null==r?void 0:r.priceListId){var i=null===(e=this.prices)||void 0===e?void 0:e.find((function(e){return e.priceListId===r.priceListId}));if(i)return i}}return null===(t=this.prices)||void 0===t?void 0:t.find((function(e){return f.getPriceListId()?e.priceListId===f.getPriceListId():null===e.priceListId}))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"bundlePrice",{get:function(){var e,t;if(f.isB2BStorefront()){var r=y.getInstance().customerStore.customer;if(null==r?void 0:r.priceListId){var i=null===(e=this.baseBundlePrices)||void 0===e?void 0:e.find((function(e){return e.priceListId===r.priceListId}));if(i)return i}}return(null===(t=this.baseBundlePrices)||void 0===t?void 0:t.find((function(e){return f.getPriceListId()?e.priceListId===f.getPriceListId():null===e.priceListId})))||this.price},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"finalPrice",{get:function(){var e=0;(this.campaignOffersFinalPrice&&(e+=this.campaignOffersFinalPrice),this.bundleSettings)?e+=d.getFinalPrice(this.bundlePrice)+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.finalPriceWithQuantity:0)}),0):e+=d.getFinalPrice(this.price);if(!this.b2bPriceRule)return e;switch(this.b2bPriceRule.valueType){case s.DISCOUNT_RATE:return e*((100-this.b2bPriceRule.value)/100);case s.DISCOUNT_AMOUNT:return e-this.b2bPriceRule.value;case s.FIXED_PRICE:return this.b2bPriceRule.value;default:return e}},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedFinalPrice",{get:function(){return g(this.finalPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"sellPrice",{get:function(){var e=0;return this.campaignOffersSellPrice&&(e+=this.campaignOffersSellPrice),this.bundleSettings?e+this.bundlePrice.sellPrice+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.sellPriceWithQuantity:0)}),0):e+this.price.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedSellPrice",{get:function(){return g(this.sellPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedBuyPrice",{get:function(){return g(this.price.buyPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"discountPrice",{get:function(){return this.finalPrice===this.sellPrice?null:this.finalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedDiscountPrice",{get:function(){return g(this.discountPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasDiscount",{get:function(){return this.finalPrice!==this.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"discountAmount",{get:function(){return this.hasDiscount?this.sellPrice-this.finalPrice:0},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"discountPercentage",{get:function(){return this.hasDiscount?(100-100*this.finalPrice/this.sellPrice).toFixed(0):0},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"campaignOffersFinalPrice",{get:function(){var e,t;return(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})).reduce((function(e,t){return e+t.product.selectedVariant.finalPrice}),0))||0},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"campaignOffersSellPrice",{get:function(){var e,t;return(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})).reduce((function(e,t){return e+t.product.selectedVariant.sellPrice}),0))||0},enumerable:!1,configurable:!0}),S.prototype.saveBackInStockReminder=function(r){var i;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,b({email:{eq:r},productId:{eq:this.productId},variantId:{eq:this.id}})];case 1:return(e=t.sent())&&(null===(i=e.data)||void 0===i?void 0:i.length)?(this._backInStockReminderSaved=!0,[2,!1]):[3,2];case 2:return[4,p({input:{email:r,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]}}))}))},S.prototype.toJSON=function(){var e=r({},this);return delete e.product,e},S}();export{S as IkasProductVariant};
1
+ import{__awaiter as e,__generator as t,__assign as r}from'./../../../../ext/tslib/tslib.es6.js';import{IkasProductPrice as i}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 s,IkasCustomerPriceListRuleFilterType as l}from"@ikas/storefront-models";import{IkasProductVariantFunctions as a,IkasProductPriceFunctions as d}from"@ikas/storefront-model-functions";import{IkasStorefrontConfig as f}from"@ikas/storefront-config";import{saveProductBackInStockRemind as p,listProductBackInStockRemind as b}from"@ikas/storefront-api";import m from"lodash/groupBy";import h from"lodash/sortBy";import{IkasProductVariantUnit as v}from"./unit/index.js";import{formatCurrency as g}from"../../../../utils/currency.js";import{makeAutoObservable as P}from"mobx";import{IkasBaseStore as y}from"../../../../store/base.js";import"../../../../store/customer/index.js";import"../../../../store/cart/index.js";var S=function(){function S(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 i(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 i(e)})):[],this.stock=e.stock||0,this.isActive=void 0===e.isActive||e.isActive,this.campaigns=e.campaigns||[],this.unit=e.unit?new v(e.unit):null,this.sellIfOutOfStock=e.sellIfOutOfStock||!1,this.images=h(this.images,"order"),P(this)}return Object.defineProperty(S.prototype,"mainImage",{get:function(){var e=a.getMainImage(this);return e?new u(e):void 0},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasStock",{get:function(){return a.hasStock(this)},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isBackInStockEnabled",{get:function(){return f.isBackInStockEnabled()},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isBackInStockCustomerLoginRequired",{get:function(){return f.isCustomerLoginRequiredForBackInStock()},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"isBackInStockReminderSaved",{get:function(){return this._backInStockReminderSaved},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"groupedAttributeValues",{get:function(){var e,t=m(this.attributes,"productAttributeId");return(null===(e=this.attributes)||void 0===e?void 0:e.map((function(e){var r=e.productAttributeId;if(r){var i=t[r];return(null==i?void 0:i.length)&&i[0].productAttribute?{attribute:i[0].productAttribute,values:i}:void 0}})).filter((function(e){return!!e})))||[]},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"b2bPriceRule",{get:function(){var e,t,r=this,i=y.getInstance().customerStore.customer,n=null==i?void 0:i.priceListRules,o=function(e){var t,i,n,o;if(e.type===l.CATEGORY)return u=null===(t=e.valueList)||void 0===t?void 0:t.some((function(e){var t;return null===(t=r.product)||void 0===t?void 0:t.categories.find((function(t){return t.id===e}))}));if(e.type===l.PRODUCT)return u=null===(i=e.valueList)||void 0===i?void 0:i.some((function(e){return r.id===e}));if(e.type===l.PRODUCT_BRAND){var u=null===(n=e.valueList)||void 0===n?void 0:n.some((function(e){var t,i;return(null===(i=null===(t=r.product)||void 0===t?void 0:t.brand)||void 0===i?void 0:i.id)===e}));return u}if(e.type===l.PRODUCT_TAG){u=null===(o=e.valueList)||void 0===o?void 0:o.some((function(e){var t,i;return null===(i=null===(t=r.product)||void 0===t?void 0:t.tags)||void 0===i?void 0:i.find((function(t){return t.id===e}))}));return u}};if(n){for(var u=0,c=n;u<c.length;u++){var s=c[u];if(s.shouldMatchAllFilters?null===(e=s.filters)||void 0===e?void 0:e.every(o):null===(t=s.filters)||void 0===t?void 0:t.some(o))return s}return null}return null},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"price",{get:function(){var e,t;if(f.isB2BStorefront()){var r=y.getInstance().customerStore.customer;if(null==r?void 0:r.priceListId){var i=null===(e=this.prices)||void 0===e?void 0:e.find((function(e){return e.priceListId===r.priceListId}));if(i)return i}}return null===(t=this.prices)||void 0===t?void 0:t.find((function(e){return f.getPriceListId()?e.priceListId===f.getPriceListId():null===e.priceListId}))},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"bundlePrice",{get:function(){var e,t;if(f.isB2BStorefront()){var r=y.getInstance().customerStore.customer;if(null==r?void 0:r.priceListId){var i=null===(e=this.baseBundlePrices)||void 0===e?void 0:e.find((function(e){return e.priceListId===r.priceListId}));if(i)return i}}return(null===(t=this.baseBundlePrices)||void 0===t?void 0:t.find((function(e){return f.getPriceListId()?e.priceListId===f.getPriceListId():null===e.priceListId})))||this.price},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"finalPrice",{get:function(){var e=0;this.bundleSettings?e=d.getFinalPrice(this.bundlePrice)+this.bundleSettings.products.reduce((function(e,t){return e+(t.addToBundleBasePrice?t.finalPriceWithQuantity:0)}),0):e=d.getFinalPrice(this.price);if(!this.b2bPriceRule)return e;switch(this.b2bPriceRule.valueType){case s.DISCOUNT_RATE:return e*((100-this.b2bPriceRule.value)/100);case s.DISCOUNT_AMOUNT:return e-this.b2bPriceRule.value;case s.FIXED_PRICE:return this.b2bPriceRule.value;default:return e}},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedFinalPrice",{get:function(){return g(this.finalPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"sellPrice",{get:function(){return this.bundleSettings?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(S.prototype,"formattedSellPrice",{get:function(){return g(this.sellPrice,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedBuyPrice",{get:function(){return g(this.price.buyPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"discountPrice",{get:function(){return this.finalPrice===this.sellPrice?null:this.finalPrice},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"formattedDiscountPrice",{get:function(){return g(this.discountPrice||0,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"hasDiscount",{get:function(){return this.finalPrice!==this.sellPrice},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"discountAmount",{get:function(){return this.hasDiscount?this.sellPrice-this.finalPrice:0},enumerable:!1,configurable:!0}),Object.defineProperty(S.prototype,"discountPercentage",{get:function(){return this.hasDiscount?(100-100*this.finalPrice/this.sellPrice).toFixed(0):0},enumerable:!1,configurable:!0}),Object.defineProperty(S.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(S.prototype,"formattedFinalPriceWithCampaignOffers",{get:function(){return g(this.finalPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),Object.defineProperty(S.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(S.prototype,"formattedSellPriceWithCampaignOffers",{get:function(){return g(this.sellPriceWithCampaignOffers,this.price.currency||"",this.price.currencySymbol||"")},enumerable:!1,configurable:!0}),S.prototype.saveBackInStockReminder=function(r){var i;return e(this,void 0,void 0,(function(){var e;return t(this,(function(t){switch(t.label){case 0:return[4,b({email:{eq:r},productId:{eq:this.productId},variantId:{eq:this.id}})];case 1:return(e=t.sent())&&(null===(i=e.data)||void 0===i?void 0:i.length)?(this._backInStockReminderSaved=!0,[2,!1]):[3,2];case 2:return[4,p({input:{email:r,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]}}))}))},S.prototype.toJSON=function(){var e=r({},this);return delete e.product,e},S}();export{S as IkasProductVariant};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ikas/storefront",
3
- "version": "4.12.0-beta.33",
3
+ "version": "4.12.0-beta.34",
4
4
  "description": "Storefront functionality for ikas storefront themes.",
5
5
  "author": "ikas",
6
6
  "license": "ISC",
@@ -17,11 +17,11 @@
17
17
  "build": "rm -rf build && rollup -c"
18
18
  },
19
19
  "devDependencies": {
20
- "@ikas/storefront-api": "^4.12.0-beta.33",
21
- "@ikas/storefront-config": "^4.12.0-beta.33",
22
- "@ikas/storefront-model-functions": "^4.12.0-beta.33",
23
- "@ikas/storefront-models": "^4.12.0-beta.33",
24
- "@ikas/storefront-providers": "^4.12.0-beta.33",
20
+ "@ikas/storefront-api": "^4.12.0-beta.34",
21
+ "@ikas/storefront-config": "^4.12.0-beta.34",
22
+ "@ikas/storefront-model-functions": "^4.12.0-beta.34",
23
+ "@ikas/storefront-models": "^4.12.0-beta.34",
24
+ "@ikas/storefront-providers": "^4.12.0-beta.34",
25
25
  "@ikas/localized-address": "^1.0.0-beta.3",
26
26
  "@adyen/adyen-web": "^5.28.2",
27
27
  "@rollup/plugin-commonjs": "^22.0.0",
@@ -55,11 +55,11 @@
55
55
  },
56
56
  "peerDependencies": {
57
57
  "@ikas/localized-address": "^1.0.0-beta.3",
58
- "@ikas/storefront-api": "^4.12.0-beta.33",
59
- "@ikas/storefront-config": "^4.12.0-beta.33",
60
- "@ikas/storefront-model-functions": "^4.12.0-beta.33",
61
- "@ikas/storefront-models": "^4.12.0-beta.33",
62
- "@ikas/storefront-providers": "^4.12.0-beta.33",
58
+ "@ikas/storefront-api": "^4.12.0-beta.34",
59
+ "@ikas/storefront-config": "^4.12.0-beta.34",
60
+ "@ikas/storefront-model-functions": "^4.12.0-beta.34",
61
+ "@ikas/storefront-models": "^4.12.0-beta.34",
62
+ "@ikas/storefront-providers": "^4.12.0-beta.34",
63
63
  "mobx": "^6.1.3",
64
64
  "mobx-react-lite": "^3.1.5",
65
65
  "next": "12.2.0",