thm-p3-configurator 0.0.286 → 0.0.287

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.
@@ -368,8 +368,9 @@ const ProductCartTable = () => {
368
368
  };
369
369
  }
370
370
 
371
- // TMG case
372
- if (isTmg && isToggled && product !== null && product !== void 0 && product.consumerPrices) {
371
+ // TMG-style case (used for TOGGLED_TMG display mode)
372
+ // This provides more robust price calculations with proper fallbacks
373
+ if (useTmgDisplayMode && isToggled && product !== null && product !== void 0 && product.consumerPrices) {
373
374
  var _product$locationPric, _ref, _ref2, _cartItem$consumerTot, _product$consumerPric;
374
375
  const purchasePrice = locationTotal || Number((product === null || product === void 0 || (_product$locationPric = product.locationPrices) === null || _product$locationPric === void 0 ? void 0 : _product$locationPric.priceExclVat) || 0);
375
376
  const salesPriceRaw = (_ref = (_ref2 = (_cartItem$consumerTot = cartItem === null || cartItem === void 0 ? void 0 : cartItem.consumerTotal) !== null && _cartItem$consumerTot !== void 0 ? _cartItem$consumerTot : product === null || product === void 0 || (_product$consumerPric = product.consumerPrices) === null || _product$consumerPric === void 0 ? void 0 : _product$consumerPric.priceInclVat) !== null && _ref2 !== void 0 ? _ref2 : product === null || product === void 0 ? void 0 : product.price) !== null && _ref !== void 0 ? _ref : 0;
@@ -435,7 +436,7 @@ const ProductCartTable = () => {
435
436
  mainProducts: rawMainProducts.map(enhanceProduct),
436
437
  accessoireProducts: rawAccessoireProducts.map(enhanceProduct)
437
438
  };
438
- }, [products, selectedTowbar, selectedCombiset, selectedCableset, selectedBoardComputer, selectedExtras, cartLookup, consumerDiscounts, isTmg, isToggled]);
439
+ }, [products, selectedTowbar, selectedCombiset, selectedCableset, selectedBoardComputer, selectedExtras, cartLookup, consumerDiscounts, useTmgDisplayMode, isToggled]);
439
440
 
440
441
  // Calculate subtotals
441
442
  const subtotals = (0, _react.useMemo)(() => {
@@ -473,30 +474,31 @@ const ProductCartTable = () => {
473
474
  const montageExclVat = isToggled && !useTmgDisplayMode ? Number((totals === null || totals === void 0 ? void 0 : totals.totalMontageExclVat) || 0) : 0;
474
475
  const marketCorrectionExclVat = isToggled && !useTmgDisplayMode && marketCorrectionValues.hasValue ? marketCorrectionValues.salesExcl : 0;
475
476
 
476
- // TMG subtotals
477
- const tmgCatalog = isTmg ? mainProducts.reduce((t, p) => {
477
+ // TMG-style subtotals (used for TOGGLED_TMG display mode)
478
+ // Calculate whenever useTmgDisplayMode is true (TMG users OR THC users without discount capability)
479
+ const tmgCatalog = useTmgDisplayMode ? mainProducts.reduce((t, p) => {
478
480
  var _p$priceInfo2;
479
481
  return t + Number((p === null || p === void 0 || (_p$priceInfo2 = p.priceInfo) === null || _p$priceInfo2 === void 0 ? void 0 : _p$priceInfo2.catalogPriceExcl) || 0);
480
482
  }, 0) : 0;
481
- const tmgMargin = isTmg ? mainProducts.reduce((t, p) => {
483
+ const tmgMargin = useTmgDisplayMode ? mainProducts.reduce((t, p) => {
482
484
  var _p$priceInfo3;
483
485
  return t + Number((p === null || p === void 0 || (_p$priceInfo3 = p.priceInfo) === null || _p$priceInfo3 === void 0 ? void 0 : _p$priceInfo3.margin) || 0);
484
486
  }, 0) + (isToggled && marketCorrectionValues.hasValue ? marketCorrectionValues.margin : 0) : 0;
485
- const tmgSales = isTmg ? mainProducts.reduce((t, p) => {
487
+ const tmgSales = useTmgDisplayMode ? mainProducts.reduce((t, p) => {
486
488
  var _p$priceInfo4;
487
489
  return t + Number((p === null || p === void 0 || (_p$priceInfo4 = p.priceInfo) === null || _p$priceInfo4 === void 0 ? void 0 : _p$priceInfo4.salesPrice) || 0);
488
490
  }, 0) + Number((totals === null || totals === void 0 ? void 0 : totals.totalMontageExclVat) || 0) + (isToggled && marketCorrectionValues.hasValue ? marketCorrectionValues.salesExcl : 0) : 0;
489
491
 
490
- // Accessories TMG subtotals
491
- const accessoryTmgCatalog = isTmg ? accessoireProducts.reduce((t, p) => {
492
+ // Accessories TMG-style subtotals
493
+ const accessoryTmgCatalog = useTmgDisplayMode ? accessoireProducts.reduce((t, p) => {
492
494
  var _p$priceInfo5;
493
495
  return t + Number((p === null || p === void 0 || (_p$priceInfo5 = p.priceInfo) === null || _p$priceInfo5 === void 0 ? void 0 : _p$priceInfo5.catalogPriceExcl) || 0);
494
496
  }, 0) : 0;
495
- const accessoryTmgMargin = isTmg ? accessoireProducts.reduce((t, p) => {
497
+ const accessoryTmgMargin = useTmgDisplayMode ? accessoireProducts.reduce((t, p) => {
496
498
  var _p$priceInfo6;
497
499
  return t + Number((p === null || p === void 0 || (_p$priceInfo6 = p.priceInfo) === null || _p$priceInfo6 === void 0 ? void 0 : _p$priceInfo6.margin) || 0);
498
500
  }, 0) : 0;
499
- const accessoryTmgSales = isTmg ? accessoireProducts.reduce((t, p) => {
501
+ const accessoryTmgSales = useTmgDisplayMode ? accessoireProducts.reduce((t, p) => {
500
502
  var _p$priceInfo7;
501
503
  return t + Number((p === null || p === void 0 || (_p$priceInfo7 = p.priceInfo) === null || _p$priceInfo7 === void 0 ? void 0 : _p$priceInfo7.salesPrice) || 0);
502
504
  }, 0) : 0;
@@ -522,7 +524,7 @@ const ProductCartTable = () => {
522
524
  }
523
525
  }
524
526
  };
525
- }, [mainProducts, accessoireProducts, marketCorrectionValues, isToggled, isTmg, useTmgDisplayMode, totals]);
527
+ }, [mainProducts, accessoireProducts, marketCorrectionValues, isToggled, useTmgDisplayMode, totals]);
526
528
 
527
529
  // ============================================================================
528
530
  // RENDER HELPERS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.286",
3
+ "version": "0.0.287",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",