@orderingstack/front-components-product-configurator 1.3.3 → 1.3.5

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.es.js CHANGED
@@ -4889,6 +4889,10 @@ const countPrice = (formState, mainProduct) => {
4889
4889
  );
4890
4890
  if (product && (product == null ? void 0 : product.price)) {
4891
4891
  price += parseFloat(product.price) * productAmount;
4892
+ } else if (!product) {
4893
+ console.warn(
4894
+ `Error finding product: ${productId} in selCtx: ${contextName}`
4895
+ );
4892
4896
  }
4893
4897
  }
4894
4898
  }
@@ -6018,12 +6022,14 @@ function isEqual(value, other) {
6018
6022
  const propertyToEncode = ["id", "selCtx", "fltCtx"];
6019
6023
  const CHAR_TO_REPLACE = ".";
6020
6024
  const REPLACEMENT_CHAR = "#dot";
6025
+ const DASH_CHAR_TO_REPLACE = "-";
6026
+ const DASH_REPLACEMENT_CHAR = "#dash";
6021
6027
  const FIX_NUMBER_PREFIX = "#FIX_NUMBER";
6022
6028
  const encodeProduct = (product) => {
6023
6029
  return iterateOverObject(cloneDeep(product), encodeValue);
6024
6030
  };
6025
6031
  const replaceIn = (value) => {
6026
- const replaced = value.replaceAll(CHAR_TO_REPLACE, REPLACEMENT_CHAR);
6032
+ const replaced = value.replaceAll(CHAR_TO_REPLACE, REPLACEMENT_CHAR).replaceAll(DASH_CHAR_TO_REPLACE, DASH_REPLACEMENT_CHAR);
6027
6033
  if (/^\d+$/.test(replaced)) {
6028
6034
  return `${FIX_NUMBER_PREFIX}${replaced}`;
6029
6035
  } else {
@@ -6031,7 +6037,7 @@ const replaceIn = (value) => {
6031
6037
  }
6032
6038
  };
6033
6039
  const replaceOut = (value) => {
6034
- return value.replaceAll(REPLACEMENT_CHAR, CHAR_TO_REPLACE).replaceAll(FIX_NUMBER_PREFIX, "");
6040
+ return value.replaceAll(REPLACEMENT_CHAR, CHAR_TO_REPLACE).replaceAll(DASH_REPLACEMENT_CHAR, DASH_CHAR_TO_REPLACE).replaceAll(FIX_NUMBER_PREFIX, "");
6035
6041
  };
6036
6042
  const encodeValue = (key, value) => {
6037
6043
  return codeValue(key, value, replaceIn);
@@ -10413,7 +10419,7 @@ function ProductConfigurator(props) {
10413
10419
  const {
10414
10420
  getValues
10415
10421
  } = methods;
10416
- const countedProductPrice = Number((parseFloat(price || "0") + countPrice(getValues("selected"), product)).toFixed(2));
10422
+ const countedProductPrice = Number((parseFloat(price || "0") + countPrice(getValues("selected"), encodedProduct)).toFixed(2));
10417
10423
  const onSubmit = () => {
10418
10424
  console.log("onSubmit");
10419
10425
  setIsOnSubmittedOnTrue();