@pelcro/react-pelcro-js 3.21.0 → 3.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -13951,6 +13951,16 @@ function productsWithMatchedTaggedFirst() {
13951
13951
  const allProductsMinusMatched = allProducts.filter(product => !productsThatMatchArticleTag.some(matchedProduct => matchedProduct.id === product.id));
13952
13952
  return [productsThatMatchArticleTag, allProductsMinusMatched];
13953
13953
  }
13954
+ function productMatchPageLanguage(product) {
13955
+ if (!product) {
13956
+ return false;
13957
+ }
13958
+ if (product.language === null) {
13959
+ return true;
13960
+ }
13961
+ const siteLanguage = window.Pelcro.helpers.getHtmlLanguageAttribute();
13962
+ return product.language === siteLanguage;
13963
+ }
13954
13964
  SelectModalWithHook.viewId = "plan-select";
13955
13965
  class SelectModal extends React.Component {
13956
13966
  constructor(props) {
@@ -13992,22 +14002,23 @@ class SelectModal extends React.Component {
13992
14002
  const userCurrency = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$user = _window$Pelcro.user) === null || _window$Pelcro$user === void 0 ? void 0 : _window$Pelcro$user.read().currency;
13993
14003
  const userCountry = (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$user = _window$Pelcro2.user) === null || _window$Pelcro2$user === void 0 ? void 0 : _window$Pelcro2$user.location.countryCode;
13994
14004
  const userLanguage = (_window$Pelcro3 = window.Pelcro) === null || _window$Pelcro3 === void 0 ? void 0 : (_window$Pelcro3$user = _window$Pelcro3.user) === null || _window$Pelcro3$user === void 0 ? void 0 : _window$Pelcro3$user.read().language;
13995
- const productsWithPlansCountries = (_window$Pelcro4 = window.Pelcro) === null || _window$Pelcro4 === void 0 ? void 0 : (_window$Pelcro4$site = _window$Pelcro4.site) === null || _window$Pelcro4$site === void 0 ? void 0 : _window$Pelcro4$site.read().products.filter(product => {
13996
- const filteredPlans = product.plans.filter(plan => plan.countries && plan.countries.length > 0);
13997
- if (filteredPlans.length) {
13998
- return product;
13999
- }
14005
+ const productsMatchingUserCurrency = (_window$Pelcro4 = window.Pelcro) === null || _window$Pelcro4 === void 0 ? void 0 : (_window$Pelcro4$site = _window$Pelcro4.site) === null || _window$Pelcro4$site === void 0 ? void 0 : _window$Pelcro4$site.read().products.map(product => {
14006
+ const filteredPlans = product.plans.filter(plan => plan.currency === userCurrency || !userCurrency);
14007
+ return {
14008
+ ...product,
14009
+ plans: filteredPlans
14010
+ };
14000
14011
  });
14001
- const currencyMismatch = productsWithPlansCountries.length ? productsWithPlansCountries.filter(product => {
14012
+ const productsMatchingUserCountry = productsMatchingUserCurrency.filter(product => {
14002
14013
  const filteredPlans = product.plans.filter(plan => {
14003
14014
  var _plan$countries;
14004
- return (_plan$countries = plan.countries) === null || _plan$countries === void 0 ? void 0 : _plan$countries.includes(userCountry);
14015
+ return plan.countries && ((_plan$countries = plan.countries) === null || _plan$countries === void 0 ? void 0 : _plan$countries.includes(userCountry)) || !plan.countries || !plan.countries.length;
14005
14016
  });
14006
14017
  if (filteredPlans.length) return filteredPlans;
14007
- }).length === 0 : false;
14018
+ });
14008
14019
  notifyBugsnag(() => {
14009
14020
  Bugsnag.notify("SelectModal - No data viewed", event => {
14010
- var _window$Pelcro5, _window$Pelcro5$site, _window$Pelcro6, _window$Pelcro6$user, _window$Pelcro7, _window$Pelcro7$uiSet, _window$Pelcro8, _this$props, _window$Pelcro9, _window$Pelcro9$helpe, _window$Pelcro10, _window$Pelcro10$site, _window$Pelcro11, _window$Pelcro11$site;
14021
+ var _window$Pelcro5, _window$Pelcro5$site, _window$Pelcro6, _window$Pelcro6$user, _window$Pelcro7, _window$Pelcro7$uiSet, _window$Pelcro8, _this$props, _window$Pelcro9, _window$Pelcro9$helpe;
14011
14022
  event.addMetadata("MetaData", {
14012
14023
  site: (_window$Pelcro5 = window.Pelcro) === null || _window$Pelcro5 === void 0 ? void 0 : (_window$Pelcro5$site = _window$Pelcro5.site) === null || _window$Pelcro5$site === void 0 ? void 0 : _window$Pelcro5$site.read(),
14013
14024
  user: (_window$Pelcro6 = window.Pelcro) === null || _window$Pelcro6 === void 0 ? void 0 : (_window$Pelcro6$user = _window$Pelcro6.user) === null || _window$Pelcro6$user === void 0 ? void 0 : _window$Pelcro6$user.read(),
@@ -14024,12 +14035,9 @@ class SelectModal extends React.Component {
14024
14035
  userCountry: userCountry,
14025
14036
  userLanguage: userLanguage,
14026
14037
  siteLanguage: (_window$Pelcro9 = window.Pelcro) === null || _window$Pelcro9 === void 0 ? void 0 : (_window$Pelcro9$helpe = _window$Pelcro9.helpers) === null || _window$Pelcro9$helpe === void 0 ? void 0 : _window$Pelcro9$helpe.getHtmlLanguageAttribute(),
14027
- currency_mismatch: ((_window$Pelcro10 = window.Pelcro) === null || _window$Pelcro10 === void 0 ? void 0 : (_window$Pelcro10$site = _window$Pelcro10.site) === null || _window$Pelcro10$site === void 0 ? void 0 : _window$Pelcro10$site.read().products.filter(product => {
14028
- const filteredPlans = product.plans.find(plan => plan.currency === userCurrency);
14029
- if (filteredPlans) return filteredPlans;
14030
- }).length) === 0,
14031
- country_restrictions: currencyMismatch,
14032
- language_mismatch: ((_window$Pelcro11 = window.Pelcro) === null || _window$Pelcro11 === void 0 ? void 0 : (_window$Pelcro11$site = _window$Pelcro11.site) === null || _window$Pelcro11$site === void 0 ? void 0 : _window$Pelcro11$site.read().products.filter(product => product.language === userLanguage).length) === 0
14038
+ currency_mismatch: productsMatchingUserCurrency.length === 0,
14039
+ country_restrictions: productsMatchingUserCountry.length === 0,
14040
+ language_mismatch: productsMatchingUserCountry.filter(product => product.plans.length).filter(productMatchPageLanguage).length === 0
14033
14041
  });
14034
14042
  });
14035
14043
  });
package/dist/index.esm.js CHANGED
@@ -13921,6 +13921,16 @@ function productsWithMatchedTaggedFirst() {
13921
13921
  const allProductsMinusMatched = allProducts.filter(product => !productsThatMatchArticleTag.some(matchedProduct => matchedProduct.id === product.id));
13922
13922
  return [productsThatMatchArticleTag, allProductsMinusMatched];
13923
13923
  }
13924
+ function productMatchPageLanguage(product) {
13925
+ if (!product) {
13926
+ return false;
13927
+ }
13928
+ if (product.language === null) {
13929
+ return true;
13930
+ }
13931
+ const siteLanguage = window.Pelcro.helpers.getHtmlLanguageAttribute();
13932
+ return product.language === siteLanguage;
13933
+ }
13924
13934
  SelectModalWithHook.viewId = "plan-select";
13925
13935
  class SelectModal extends Component {
13926
13936
  constructor(props) {
@@ -13962,22 +13972,23 @@ class SelectModal extends Component {
13962
13972
  const userCurrency = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$user = _window$Pelcro.user) === null || _window$Pelcro$user === void 0 ? void 0 : _window$Pelcro$user.read().currency;
13963
13973
  const userCountry = (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$user = _window$Pelcro2.user) === null || _window$Pelcro2$user === void 0 ? void 0 : _window$Pelcro2$user.location.countryCode;
13964
13974
  const userLanguage = (_window$Pelcro3 = window.Pelcro) === null || _window$Pelcro3 === void 0 ? void 0 : (_window$Pelcro3$user = _window$Pelcro3.user) === null || _window$Pelcro3$user === void 0 ? void 0 : _window$Pelcro3$user.read().language;
13965
- const productsWithPlansCountries = (_window$Pelcro4 = window.Pelcro) === null || _window$Pelcro4 === void 0 ? void 0 : (_window$Pelcro4$site = _window$Pelcro4.site) === null || _window$Pelcro4$site === void 0 ? void 0 : _window$Pelcro4$site.read().products.filter(product => {
13966
- const filteredPlans = product.plans.filter(plan => plan.countries && plan.countries.length > 0);
13967
- if (filteredPlans.length) {
13968
- return product;
13969
- }
13975
+ const productsMatchingUserCurrency = (_window$Pelcro4 = window.Pelcro) === null || _window$Pelcro4 === void 0 ? void 0 : (_window$Pelcro4$site = _window$Pelcro4.site) === null || _window$Pelcro4$site === void 0 ? void 0 : _window$Pelcro4$site.read().products.map(product => {
13976
+ const filteredPlans = product.plans.filter(plan => plan.currency === userCurrency || !userCurrency);
13977
+ return {
13978
+ ...product,
13979
+ plans: filteredPlans
13980
+ };
13970
13981
  });
13971
- const currencyMismatch = productsWithPlansCountries.length ? productsWithPlansCountries.filter(product => {
13982
+ const productsMatchingUserCountry = productsMatchingUserCurrency.filter(product => {
13972
13983
  const filteredPlans = product.plans.filter(plan => {
13973
13984
  var _plan$countries;
13974
- return (_plan$countries = plan.countries) === null || _plan$countries === void 0 ? void 0 : _plan$countries.includes(userCountry);
13985
+ return plan.countries && ((_plan$countries = plan.countries) === null || _plan$countries === void 0 ? void 0 : _plan$countries.includes(userCountry)) || !plan.countries || !plan.countries.length;
13975
13986
  });
13976
13987
  if (filteredPlans.length) return filteredPlans;
13977
- }).length === 0 : false;
13988
+ });
13978
13989
  notifyBugsnag(() => {
13979
13990
  Bugsnag.notify("SelectModal - No data viewed", event => {
13980
- var _window$Pelcro5, _window$Pelcro5$site, _window$Pelcro6, _window$Pelcro6$user, _window$Pelcro7, _window$Pelcro7$uiSet, _window$Pelcro8, _this$props, _window$Pelcro9, _window$Pelcro9$helpe, _window$Pelcro10, _window$Pelcro10$site, _window$Pelcro11, _window$Pelcro11$site;
13991
+ var _window$Pelcro5, _window$Pelcro5$site, _window$Pelcro6, _window$Pelcro6$user, _window$Pelcro7, _window$Pelcro7$uiSet, _window$Pelcro8, _this$props, _window$Pelcro9, _window$Pelcro9$helpe;
13981
13992
  event.addMetadata("MetaData", {
13982
13993
  site: (_window$Pelcro5 = window.Pelcro) === null || _window$Pelcro5 === void 0 ? void 0 : (_window$Pelcro5$site = _window$Pelcro5.site) === null || _window$Pelcro5$site === void 0 ? void 0 : _window$Pelcro5$site.read(),
13983
13994
  user: (_window$Pelcro6 = window.Pelcro) === null || _window$Pelcro6 === void 0 ? void 0 : (_window$Pelcro6$user = _window$Pelcro6.user) === null || _window$Pelcro6$user === void 0 ? void 0 : _window$Pelcro6$user.read(),
@@ -13994,12 +14005,9 @@ class SelectModal extends Component {
13994
14005
  userCountry: userCountry,
13995
14006
  userLanguage: userLanguage,
13996
14007
  siteLanguage: (_window$Pelcro9 = window.Pelcro) === null || _window$Pelcro9 === void 0 ? void 0 : (_window$Pelcro9$helpe = _window$Pelcro9.helpers) === null || _window$Pelcro9$helpe === void 0 ? void 0 : _window$Pelcro9$helpe.getHtmlLanguageAttribute(),
13997
- currency_mismatch: ((_window$Pelcro10 = window.Pelcro) === null || _window$Pelcro10 === void 0 ? void 0 : (_window$Pelcro10$site = _window$Pelcro10.site) === null || _window$Pelcro10$site === void 0 ? void 0 : _window$Pelcro10$site.read().products.filter(product => {
13998
- const filteredPlans = product.plans.find(plan => plan.currency === userCurrency);
13999
- if (filteredPlans) return filteredPlans;
14000
- }).length) === 0,
14001
- country_restrictions: currencyMismatch,
14002
- language_mismatch: ((_window$Pelcro11 = window.Pelcro) === null || _window$Pelcro11 === void 0 ? void 0 : (_window$Pelcro11$site = _window$Pelcro11.site) === null || _window$Pelcro11$site === void 0 ? void 0 : _window$Pelcro11$site.read().products.filter(product => product.language === userLanguage).length) === 0
14008
+ currency_mismatch: productsMatchingUserCurrency.length === 0,
14009
+ country_restrictions: productsMatchingUserCountry.length === 0,
14010
+ language_mismatch: productsMatchingUserCountry.filter(product => product.plans.length).filter(productMatchPageLanguage).length === 0
14003
14011
  });
14004
14012
  });
14005
14013
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pelcro/react-pelcro-js",
3
3
  "description": "Pelcro's React UI Elements",
4
- "version": "3.21.0",
4
+ "version": "3.21.1",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",