thm-p3-configurator 0.0.228 → 0.0.229

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.
@@ -44,12 +44,13 @@ var _ProductTableSectionTotal = _interopRequireDefault(require("../__components_
44
44
  var _ProductTableStaticRow = _interopRequireDefault(require("../__components__/ProductTable/ProductTableStaticRow"));
45
45
  var _ProductTableTotal = _interopRequireDefault(require("../__components__/ProductTable/ProductTableTotal"));
46
46
  var _FullPageSpinner = _interopRequireDefault(require("../__components__/Spinners/FullPageSpinner"));
47
+ var _constants__ = require("../__constants__");
47
48
  var _FormulaContext = require("../__context__/FormulaContext");
48
49
  var _OrderSessionContext = require("../__context__/OrderSessionContext");
49
- var _constants__ = require("../__constants__");
50
50
  var _helpers__ = require("../__helpers__");
51
51
  var _image = require("../__helpers__/image");
52
52
  var _product = require("../__helpers__/product");
53
+ var _useIsTmg = require("../__hooks__/useIsTmg");
53
54
  var _InternalDiscountForm = _interopRequireDefault(require("./internal/InternalDiscountForm"));
54
55
  function _interopRequireDefault(e) {
55
56
  return e && e.__esModule ? e : {
@@ -127,6 +128,7 @@ function _toPrimitive(t, r) {
127
128
  const ProductCartTable = () => {
128
129
  var _marketCorrection$con;
129
130
  const formula = (0, _FormulaContext.useFormula)();
131
+ const isTmg = (0, _useIsTmg.useIsTmg)();
130
132
  const [isToggled, setIsToggled] = (0, _react.useState)(false);
131
133
  const [{
132
134
  licensePlate,
@@ -179,6 +181,7 @@ const ProductCartTable = () => {
179
181
  discountPercentage,
180
182
  formula
181
183
  });
184
+ console.log('Cart Input:', cartInput);
182
185
  const marketCorrection = cart === null || cart === void 0 ? void 0 : cart.find(item => item.articleNumber === 'MC');
183
186
  let mainProducts = [];
184
187
  let accessoireProducts = [];
@@ -200,7 +203,9 @@ const ProductCartTable = () => {
200
203
  salesPriceInclVat: 0,
201
204
  margin: 0,
202
205
  marginPercentage: 0,
203
- hasLocationTotal: false
206
+ hasLocationTotal: false,
207
+ catalogPriceExcl: 0,
208
+ salesPriceIncl: 0
204
209
  };
205
210
  }
206
211
  if (!product) {
@@ -209,11 +214,26 @@ const ProductCartTable = () => {
209
214
  salesPrice: 0,
210
215
  margin: 0,
211
216
  marginPercentage: 0,
212
- hasLocationTotal: false
217
+ hasLocationTotal: false,
218
+ catalogPriceExcl: 0,
219
+ salesPriceIncl: 0
220
+ };
221
+ }
222
+
223
+ // TMG case: when TMG and toggled, show catalog price excl and verkoop prijs incl
224
+ if (isTmg && isToggled && product !== null && product !== void 0 && product.consumerPrices) {
225
+ return {
226
+ purchasePrice: 0,
227
+ salesPrice: 0,
228
+ margin: 0,
229
+ hasLocationTotal: false,
230
+ catalogPriceExcl: product.consumerPrices.listPriceExclVat || 0,
231
+ salesPriceIncl: product.consumerPrices.priceInclVat || 0
213
232
  };
214
233
  }
215
234
  let purchasePrice = 0;
216
235
  let salesPrice = 0;
236
+ console.log('Cart Item:', cartItem);
217
237
  const hasLocationTotal = (cartItem === null || cartItem === void 0 ? void 0 : cartItem.locationTotal) !== undefined && (cartItem === null || cartItem === void 0 ? void 0 : cartItem.locationTotal) !== null;
218
238
 
219
239
  // Get prices directly from product objects
@@ -229,7 +249,9 @@ const ProductCartTable = () => {
229
249
  purchasePrice,
230
250
  salesPrice,
231
251
  margin,
232
- hasLocationTotal
252
+ hasLocationTotal,
253
+ catalogPriceExcl: 0,
254
+ salesPriceIncl: 0
233
255
  };
234
256
  };
235
257
  if (products) {
@@ -272,17 +294,24 @@ const ProductCartTable = () => {
272
294
  if (isLoadingProducts) {
273
295
  return /*#__PURE__*/_react.default.createElement(_FullPageSpinner.default, null);
274
296
  }
297
+ console.log('Hyper API Response:', cart);
275
298
  return /*#__PURE__*/_react.default.createElement("div", {
276
299
  className: (0, _helpers__.withStyle)("content col-lg")
277
300
  }, /*#__PURE__*/_react.default.createElement(_TogglableCard.default, {
278
301
  title: 'Overzicht',
279
- untoggleButton: selectedBranch ? 'Verberg inkoopprijzen' : undefined,
280
- toggleButton: selectedBranch ? 'Toon inkoopprijzen' : undefined,
302
+ untoggleButton: selectedBranch || isTmg ? 'Verberg inkoopprijzen' : undefined,
303
+ toggleButton: selectedBranch || isTmg ? 'Toon inkoopprijzen' : undefined,
281
304
  onToggle: toggled => setIsToggled(toggled)
282
305
  }, /*#__PURE__*/_react.default.createElement("table", {
283
306
  className: (0, _helpers__.withStyle)('cart__table table table-borderless align-middle')
284
307
  }, /*#__PURE__*/_react.default.createElement(_ProductTableHead.default, {
285
- columns: [{}, {}, {}, {}, ...(isToggled ? [{
308
+ columns: [{}, {}, {}, {}, ...(isToggled ? isTmg ? [{}, {
309
+ text: 'Catalogprijs (excl. btw)',
310
+ className: 'fw-bold text-end'
311
+ }, {
312
+ text: 'Verkoop Prijs (incl. btw)',
313
+ className: 'fw-bold text-end'
314
+ }] : [{
286
315
  text: 'Marge (excl. btw)',
287
316
  className: 'fw-bold text-end'
288
317
  }, {
@@ -305,15 +334,27 @@ const ProductCartTable = () => {
305
334
  salesPrice,
306
335
  margin,
307
336
  marginPercentage,
308
- hasLocationTotal
337
+ hasLocationTotal,
338
+ catalogPriceExcl,
339
+ salesPriceIncl
309
340
  } = product.priceInfo;
341
+ console.log('Product:', {
342
+ subgroupName: (product === null || product === void 0 ? void 0 : product.subgroupName) || (product === null || product === void 0 ? void 0 : product.groupName) || product.title,
343
+ priceInfo: product.priceInfo
344
+ });
310
345
  return /*#__PURE__*/_react.default.createElement(_ProductTableStaticRow.default, {
311
346
  key: product.articleNumber,
312
347
  productTitle: (product === null || product === void 0 ? void 0 : product.subgroupName) || (product === null || product === void 0 ? void 0 : product.groupName) || product.title,
313
348
  productImage: product !== null && product !== void 0 && (_product$images = product.images) !== null && _product$images !== void 0 && _product$images[0] ? (0, _image.getImageFromHyper)({
314
349
  imageId: (_product$images2 = product.images) === null || _product$images2 === void 0 ? void 0 : _product$images2[0]
315
350
  }) : _logoPrimary.default,
316
- extraCells: [{}, {}, {}, ...(isToggled ? [{
351
+ extraCells: [{}, {}, {}, ...(isToggled ? isTmg ? [{}, {
352
+ text: (0, _helpers__.formatPrice)(catalogPriceExcl),
353
+ className: 'cart__table-price text-end'
354
+ }, {
355
+ text: (0, _helpers__.formatPrice)(salesPriceIncl),
356
+ className: 'cart__table-price text-end'
357
+ }] : [{
317
358
  text: hasLocationTotal ? (0, _helpers__.formatPrice)(margin) : 'N.v.t.',
318
359
  className: 'cart__table-price text-end'
319
360
  }, {
@@ -331,7 +372,13 @@ const ProductCartTable = () => {
331
372
  productTitle: 'Montage',
332
373
  productSubtitle: (0, _helpers__.formatMontageTime)(totals === null || totals === void 0 ? void 0 : totals.montageTime),
333
374
  productImage: _montagePlaceholder.default,
334
- extraCells: [{}, {}, {}, ...(isToggled ? [{
375
+ extraCells: [{}, {}, {}, ...(isToggled ? isTmg ? [{}, {
376
+ text: 'N.v.t.',
377
+ className: 'cart__table-price text-end'
378
+ }, {
379
+ text: (0, _helpers__.formatPrice)(totals === null || totals === void 0 ? void 0 : totals.montagePricePlusMarketCorrectionInclVat),
380
+ className: 'cart__table-price text-end'
381
+ }] : [{
335
382
  text: 'N.v.t.',
336
383
  className: 'cart__table-price text-end'
337
384
  }, {
@@ -347,7 +394,13 @@ const ProductCartTable = () => {
347
394
  }), isToggled && marketCorrection && /*#__PURE__*/_react.default.createElement(_ProductTableStaticRow.default, {
348
395
  productTitle: 'Marktcorrectie',
349
396
  productImage: _montagePlaceholder.default,
350
- extraCells: [{}, {}, {}, ...(isToggled ? [{
397
+ extraCells: [{}, {}, {}, ...(isToggled ? isTmg ? [{}, {
398
+ text: 'N.v.t.',
399
+ className: 'cart__table-price text-end'
400
+ }, {
401
+ text: (0, _helpers__.formatPrice)(totals === null || totals === void 0 ? void 0 : totals.montagePriceInclVat),
402
+ className: 'cart__table-price text-end'
403
+ }] : [{
351
404
  text: (marketCorrection === null || marketCorrection === void 0 ? void 0 : marketCorrection.locationTotal) > 0 ? (0, _helpers__.formatPrice)(((_marketCorrection$con = marketCorrection === null || marketCorrection === void 0 ? void 0 : marketCorrection.consumerTotal) !== null && _marketCorrection$con !== void 0 ? _marketCorrection$con : 0) / 1.21 - marketCorrection.locationTotal) : 'N.v.t.',
352
405
  className: 'cart__table-price text-end'
353
406
  }, {
@@ -364,7 +417,13 @@ const ProductCartTable = () => {
364
417
  isEditable: true,
365
418
  editLabel: 'Wijzig je trekhaakpakket',
366
419
  editLink: '/configurator/trekhaakpakket',
367
- extraCells: [{}, {}, ...(isToggled ? [{
420
+ extraCells: [{}, {}, ...(isToggled ? isTmg ? [{}, {
421
+ text: '',
422
+ className: 'fw-bold text-end'
423
+ }, {
424
+ text: '',
425
+ className: 'fw-bold text-end'
426
+ }] : [{
368
427
  text: '',
369
428
  className: 'fw-bold text-end'
370
429
  }, {
@@ -376,7 +435,7 @@ const ProductCartTable = () => {
376
435
  }] : [{}, {}, {}, {
377
436
  text: 'Subtotaal (incl. btw)',
378
437
  className: 'fw-bold text-end pb-2'
379
- }]), ...(isToggled ? [{
438
+ }]), ...(isToggled ? isTmg ? [] : [{
380
439
  text: (0, _helpers__.formatPrice)(mainProductsSubtotal),
381
440
  className: 'fw-bold text-end pb-2'
382
441
  }, {
@@ -396,7 +455,9 @@ const ProductCartTable = () => {
396
455
  salesPrice,
397
456
  margin,
398
457
  marginPercentage,
399
- hasLocationTotal
458
+ hasLocationTotal,
459
+ catalogPriceExcl,
460
+ salesPriceIncl
400
461
  } = product.priceInfo;
401
462
  let canProductBeAltered = canAlterQuantity;
402
463
  if (!canAlterQuantity && !(allArticleNumbers !== null && allArticleNumbers !== void 0 && allArticleNumbers.includes(product.articleNumber))) {
@@ -409,7 +470,13 @@ const ProductCartTable = () => {
409
470
  productImage: product !== null && product !== void 0 && (_product$images3 = product.images) !== null && _product$images3 !== void 0 && _product$images3[0] ? (0, _image.getImageFromHyper)({
410
471
  imageId: (_product$images4 = product.images) === null || _product$images4 === void 0 ? void 0 : _product$images4[0]
411
472
  }) : _logoPrimary.default,
412
- extraCells: [{}, {}, {}, ...(isToggled ? [{
473
+ extraCells: [{}, {}, {}, ...(isToggled ? isTmg ? [{}, {
474
+ text: (0, _helpers__.formatPrice)(catalogPriceExcl),
475
+ className: 'cart__table-price text-end'
476
+ }, {
477
+ text: (0, _helpers__.formatPrice)(salesPriceIncl),
478
+ className: 'cart__table-price text-end'
479
+ }] : [{
413
480
  text: hasLocationTotal ? (0, _helpers__.formatPrice)(margin) : 'N.v.t.',
414
481
  className: 'cart__table-price text-end'
415
482
  }, {
@@ -443,7 +510,13 @@ const ProductCartTable = () => {
443
510
  });
444
511
  }), /*#__PURE__*/_react.default.createElement(_ProductTableSectionTotal.default, {
445
512
  isEditable: false,
446
- extraCells: [{}, {}, ...(isToggled ? [{
513
+ extraCells: [{}, {}, ...(isToggled ? isTmg ? [{}, {
514
+ text: '',
515
+ className: 'fw-bold text-end'
516
+ }, {
517
+ text: '',
518
+ className: 'fw-bold text-end'
519
+ }] : [{
447
520
  text: '',
448
521
  className: 'fw-bold text-end'
449
522
  }, {
@@ -455,7 +528,7 @@ const ProductCartTable = () => {
455
528
  }] : [{}, {}, {}, {
456
529
  text: 'Subtotaal (incl. btw)',
457
530
  className: 'fw-bold text-end pb-2'
458
- }]), ...(isToggled ? [{
531
+ }]), ...(isToggled ? isTmg ? [] : [{
459
532
  text: (0, _helpers__.formatPrice)(accessoireProductsSubtotal),
460
533
  className: 'fw-bold text-end pb-2'
461
534
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.228",
3
+ "version": "0.0.229",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",