thm-p3-configurator 0.0.378 → 0.0.381

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.
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveBusinessBranchesFormula = void 0;
7
+ var _constants__ = require("../__constants__");
8
+ const resolveBusinessBranchesFormula = formulaRaw => {
9
+ var _ref, _formulaRaw$entityId;
10
+ if (formulaRaw == null) {
11
+ return undefined;
12
+ }
13
+ if (typeof formulaRaw === 'string') {
14
+ return formulaRaw;
15
+ }
16
+ return (_ref = (_formulaRaw$entityId = formulaRaw === null || formulaRaw === void 0 ? void 0 : formulaRaw.entityId) !== null && _formulaRaw$entityId !== void 0 ? _formulaRaw$entityId : formulaRaw === null || formulaRaw === void 0 ? void 0 : formulaRaw.id) !== null && _ref !== void 0 ? _ref : (0, _constants__.getConfiguratorFormulaCode)(formulaRaw);
17
+ };
18
+ exports.resolveBusinessBranchesFormula = resolveBusinessBranchesFormula;
@@ -40,6 +40,7 @@ var _helpers__ = require("../__helpers__");
40
40
  var _singleOrderArticles = require("../__helpers__/singleOrderArticles");
41
41
  var _useSessionContextReady = require("../__hooks__/useSessionContextReady");
42
42
  var _authenticatedProxyApi = require("./authenticatedProxyApi");
43
+ var _businessBranches = require("./businessBranches");
43
44
  var _orderApi = require("./orderApi");
44
45
  var _publicProxyApi = require("./publicProxyApi");
45
46
  var _queryKeyFactory = require("./queryKeyFactory");
@@ -748,13 +749,12 @@ const useBranchesByType = _ref4 => {
748
749
  };
749
750
  exports.useBranchesByType = useBranchesByType;
750
751
  const useBusinessBranches = _ref5 => {
751
- var _getConfiguratorFormu;
752
752
  let {
753
753
  searchTerm,
754
754
  formula: formulaRaw,
755
755
  enabled = true
756
756
  } = _ref5;
757
- const formula = (_getConfiguratorFormu = (0, _constants__.getConfiguratorFormulaCode)(formulaRaw)) !== null && _getConfiguratorFormu !== void 0 ? _getConfiguratorFormu : typeof formulaRaw === 'string' ? formulaRaw : formulaRaw === null || formulaRaw === void 0 ? void 0 : formulaRaw.entityId;
757
+ const formula = (0, _businessBranches.resolveBusinessBranchesFormula)(formulaRaw);
758
758
  const businessBranchesQuery = (0, _reactQuery.useQuery)(['businessBranches', searchTerm, formula], {
759
759
  queryFn: async () => {
760
760
  const response = await _authenticatedProxyApi.authenticatedProxyApi.getBusinessBranches({
@@ -31,7 +31,6 @@ var _yup = require("yup");
31
31
  var _queries = require("../../__api__/queries");
32
32
  var _constants__ = require("../../__constants__");
33
33
  var _AuthSessionContext = require("../../__context__/AuthSessionContext");
34
- var _FormulaContext = require("../../__context__/FormulaContext");
35
34
  var _OrderSessionContext = require("../../__context__/OrderSessionContext");
36
35
  var _helpers__ = require("../../__helpers__");
37
36
  var _useIsTmg = require("../../__hooks__/useIsTmg");
@@ -161,7 +160,7 @@ const customerDetailsFormSchema = (0, _yup.object)({
161
160
  })
162
161
  });
163
162
  const InternalCustomerDetailsForm = (_ref, ref) => {
164
- var _customer$vatNumber, _customer$kvkNumber, _branchTypes$byId$aut, _authSession$branch;
163
+ var _customer$vatNumber, _customer$kvkNumber, _branchTypes$byId$aut, _authSession$branch, _authSession$branch2;
165
164
  let {
166
165
  errors = {},
167
166
  onValidationError,
@@ -198,7 +197,6 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
198
197
  }, [countries]);
199
198
  const authSession = (0, _AuthSessionContext.useAuthSession)();
200
199
  const isTmg = (0, _useIsTmg.useIsTmg)();
201
- const formula = (0, _FormulaContext.useFormula)();
202
200
  const [companySearchTerm, setCompanySearchTerm] = (0, _react.useState)('');
203
201
  const [isCompanyInputFocused, setIsCompanyInputFocused] = (0, _react.useState)(false);
204
202
  const [addressLookupLoading, setAddressLookupLoading] = (0, _react.useState)(false);
@@ -332,15 +330,12 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
332
330
  isLoadingMarketingChannels
333
331
  } = (0, _queries.useMarketingChannels)(branchType);
334
332
  const {
335
- branchesByType,
336
- isLoadingBranchesByType
337
- } = (0, _queries.useBranchesByType)({
338
- isTmg,
339
- isTowCenterBranch,
333
+ businessBranches,
334
+ isLoadingBusinessBranches
335
+ } = (0, _queries.useBusinessBranches)({
340
336
  searchTerm: companySearchTerm,
341
- formula,
342
- ownershipType: activeOwnershipType,
343
- organisationType: branchType
337
+ formula: authSession === null || authSession === void 0 || (_authSession$branch2 = authSession.branch) === null || _authSession$branch2 === void 0 ? void 0 : _authSession$branch2.formule,
338
+ enabled: isBusinessOwnership
344
339
  });
345
340
  (0, _react.useEffect)(() => {
346
341
  if (!(customer !== null && customer !== void 0 && customer.countryId) && countryOptions !== null && countryOptions !== void 0 && countryOptions.length) {
@@ -758,7 +753,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
758
753
  form: form,
759
754
  label: "Bedrijfsnaam:",
760
755
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['companyName']
761
- }), isCompanyInputFocused && companySearchTerm && companySearchTerm.length >= 3 && branchesByType && branchesByType.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
756
+ }), isCompanyInputFocused && companySearchTerm && companySearchTerm.length >= 3 && businessBranches && businessBranches.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
762
757
  className: (0, _helpers__.withStyle)('dropdown-results position-absolute w-100 border rounded bg-white shadow'),
763
758
  style: {
764
759
  maxHeight: '200px',
@@ -771,9 +766,9 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
771
766
  onMouseDown: e => {
772
767
  e.preventDefault();
773
768
  }
774
- }, isLoadingBranchesByType && /*#__PURE__*/_react.default.createElement("div", {
769
+ }, isLoadingBusinessBranches && /*#__PURE__*/_react.default.createElement("div", {
775
770
  className: (0, _helpers__.withStyle)('p-2 text-center')
776
- }, /*#__PURE__*/_react.default.createElement("span", null, "Zoeken...")), branchesByType.map(branch => /*#__PURE__*/_react.default.createElement("div", {
771
+ }, /*#__PURE__*/_react.default.createElement("span", null, "Zoeken...")), businessBranches.map(branch => /*#__PURE__*/_react.default.createElement("div", {
777
772
  key: branch.entityId,
778
773
  className: (0, _helpers__.withStyle)('dropdown-item p-2 border-bottom'),
779
774
  style: {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.VAT_RATE = exports.MARKET_CORRECTION_ARTICLE_NUMBER = exports.EXTRA_PRICE_ARTICLE_NUMBER = exports.CART_TABLE_PRICE_CELL_CLASS = exports.CART_TABLE_DISPLAY_MODES = exports.CART_TABLE_BOLD_END_CLASS = void 0;
6
+ exports.VAT_RATE = exports.MARKET_CORRECTION_ARTICLE_NUMBER = exports.EXTRA_PRICE_ARTICLE_NUMBER = exports.DISCOUNT_MONTAGESET_ARTICLE_NUMBER = exports.CART_TABLE_PRICE_CELL_CLASS = exports.CART_TABLE_DISPLAY_MODES = exports.CART_TABLE_BOLD_END_CLASS = void 0;
7
7
  /**
8
8
  * Display modes for the cart table:
9
9
  * - DEFAULT: No purchase prices shown (7 columns)
@@ -29,4 +29,7 @@ const VAT_RATE = exports.VAT_RATE = 1.21;
29
29
  const MARKET_CORRECTION_ARTICLE_NUMBER = exports.MARKET_CORRECTION_ARTICLE_NUMBER = 'MC';
30
30
 
31
31
  /** Extra price (Meerprijs) article number */
32
- const EXTRA_PRICE_ARTICLE_NUMBER = exports.EXTRA_PRICE_ARTICLE_NUMBER = 'MEERPRIJS';
32
+ const EXTRA_PRICE_ARTICLE_NUMBER = exports.EXTRA_PRICE_ARTICLE_NUMBER = 'MEERPRIJS';
33
+
34
+ /** Cart line for combi / montageset discount (not a catalog product) */
35
+ const DISCOUNT_MONTAGESET_ARTICLE_NUMBER = exports.DISCOUNT_MONTAGESET_ARTICLE_NUMBER = 'DISCOUNT MONTAGESET';
@@ -406,6 +406,7 @@ const ProductCartTable = () => {
406
406
  const cartLookup = (0, _react.useMemo)(() => cart ? Object.fromEntries(cart.map(item => [item.articleNumber, item])) : {}, [cart]);
407
407
  const marketCorrection = cart === null || cart === void 0 ? void 0 : cart.find(item => item.articleNumber === _cartTable.MARKET_CORRECTION_ARTICLE_NUMBER);
408
408
  const extraPriceItem = cart === null || cart === void 0 ? void 0 : cart.find(item => item.articleNumber === _cartTable.EXTRA_PRICE_ARTICLE_NUMBER);
409
+ const discountMontagesetItem = cart === null || cart === void 0 ? void 0 : cart.find(item => item.articleNumber === _cartTable.DISCOUNT_MONTAGESET_ARTICLE_NUMBER);
409
410
  const extraPriceValues = (0, _react.useMemo)(() => {
410
411
  const consumerTotal = Number(extraPriceItem === null || extraPriceItem === void 0 ? void 0 : extraPriceItem.consumerTotal) || 0;
411
412
  const hasValue = consumerTotal !== 0;
@@ -738,6 +739,10 @@ const ProductCartTable = () => {
738
739
  productSubtitle: (0, _helpers__.formatMontageTime)(totals === null || totals === void 0 ? void 0 : totals.montageTime),
739
740
  productImage: _montagePlaceholder.default,
740
741
  extraCells: (0, _cartTable2.getMontageCells)(displayMode, totals === null || totals === void 0 ? void 0 : totals.totalMontageExclVat, totals === null || totals === void 0 ? void 0 : totals.montagePricePlusMarketCorrectionInclVat, montageRateCellOverrides, showCatalogPrice)
742
+ }), mainProducts.length > 0 && APP_CONFIG.internal && discountMontagesetItem && discountMontagesetItem.consumerTotal != null && discountMontagesetItem.consumerTotal !== '' && /*#__PURE__*/_react.default.createElement(_ProductTableStaticRow.default, {
743
+ productTitle: "Korting montageset",
744
+ productImage: _montagePlaceholder.default,
745
+ extraCells: (0, _cartTable2.getDiscountMontagesetCells)(displayMode, discountMontagesetItem.consumerTotal, showCatalogPrice)
741
746
  }), isToggled && marketCorrectionValues.hasValue && /*#__PURE__*/_react.default.createElement(_ProductTableStaticRow.default, {
742
747
  productTitle: "Marktcorrectie",
743
748
  productImage: _montagePlaceholder.default,
@@ -32,11 +32,11 @@ var _FormulaContext = require("../__context__/FormulaContext");
32
32
  var _OrderSessionContext = require("../__context__/OrderSessionContext");
33
33
  var _helpers__ = require("../__helpers__");
34
34
  var _image = require("../__helpers__/image");
35
- var _Datalayer = require("../__services__/Datalayer");
36
35
  var _montageRate = require("../__helpers__/montageRate");
37
36
  var _product = require("../__helpers__/product");
38
37
  var _useIsTmg = require("../__hooks__/useIsTmg");
39
38
  var _useIsTowmotive = require("../__hooks__/useIsTowmotive");
39
+ var _Datalayer = require("../__services__/Datalayer");
40
40
  var _BoardComputerCard = _interopRequireDefault(require("./BoardComputerCard"));
41
41
  function _interopRequireDefault(e) {
42
42
  return e && e.__esModule ? e : {
@@ -5,7 +5,7 @@ require("core-js/modules/web.dom-collections.iterator.js");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.textCell = exports.priceCell = exports.placeholderCell = exports.getTotalRowCells = exports.getSectionTotalCells = exports.getMontageCells = exports.getMarketCorrectionCells = exports.getMainProductCells = exports.getExtraPriceCells = exports.getDiscountRowCells = exports.getCartTableHeaderColumns = exports.getCartTableDisplayMode = exports.getAccessoryProductCells = exports.emptyCells = exports.emptyCell = void 0;
8
+ exports.textCell = exports.priceCell = exports.placeholderCell = exports.getTotalRowCells = exports.getSectionTotalCells = exports.getMontageCells = exports.getMarketCorrectionCells = exports.getMainProductCells = exports.getExtraPriceCells = exports.getDiscountRowCells = exports.getDiscountMontagesetCells = exports.getCartTableHeaderColumns = exports.getCartTableDisplayMode = exports.getAccessoryProductCells = exports.emptyCells = exports.emptyCell = void 0;
9
9
  require("core-js/modules/esnext.iterator.map.js");
10
10
  require("core-js/modules/web.dom-collections.iterator.js");
11
11
  var _cartTable = require("../__constants__/cartTable");
@@ -244,6 +244,31 @@ const getMontageCells = exports.getMontageCells = function getMontageCells(displ
244
244
  }
245
245
  };
246
246
 
247
+ /**
248
+ * Montageset discount row (API pseudo-article). Same column layout as montage:
249
+ * no purchase/margin; non-editable korting cell; price from consumerTotal (incl. BTW in default mode).
250
+ *
251
+ * @param {string} displayMode
252
+ * @param {number|string|null|undefined} consumerTotalIncl - consumerTotal from cart (incl. BTW)
253
+ * @param {boolean} showCatalogPrice
254
+ */
255
+ const getDiscountMontagesetCells = exports.getDiscountMontagesetCells = function getDiscountMontagesetCells(displayMode, consumerTotalIncl) {
256
+ let showCatalogPrice = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
257
+ const salesIncl = Number(consumerTotalIncl);
258
+ const salesExcl = salesIncl / _cartTable.VAT_RATE;
259
+ const baseCells = [{}, {}, {}];
260
+ const nvt = textCell('N.v.t.', _cartTable.CART_TABLE_PRICE_CELL_CLASS);
261
+ switch (displayMode) {
262
+ case _cartTable.CART_TABLE_DISPLAY_MODES.TOGGLED_TMG:
263
+ return [...baseCells, nvt, nvt, ...(showCatalogPrice ? [nvt] : []), priceCell(salesExcl)];
264
+ case _cartTable.CART_TABLE_DISPLAY_MODES.TOGGLED_STANDARD:
265
+ return [...baseCells, nvt, nvt, ...(showCatalogPrice ? [nvt] : []), emptyCell(_cartTable.CART_TABLE_PRICE_CELL_CLASS), priceCell(salesExcl)];
266
+ case _cartTable.CART_TABLE_DISPLAY_MODES.DEFAULT:
267
+ default:
268
+ return [{}, {}, {}, {}, {}, priceCell(salesIncl)];
269
+ }
270
+ };
271
+
247
272
  /**
248
273
  * Generate extra cells for the market correction row
249
274
  * @param {string} displayMode - Current display mode
@@ -267,7 +267,7 @@ const InternalAppointmentPage = () => {
267
267
  }, "Vul het onderstaande formulier"), /*#__PURE__*/_react.default.createElement("h2", {
268
268
  className: (0, _helpers__.withStyle)('fw-normal')
269
269
  }, "in om een afspraak te maken.")), /*#__PURE__*/_react.default.createElement("div", {
270
- className: (0, _helpers__.withStyle)('col-12 col-lg-8')
270
+ className: (0, _helpers__.withStyle)('col-12 col-xxl-8')
271
271
  }, /*#__PURE__*/_react.default.createElement(_InternalAppointmentForm.default, {
272
272
  onSubmit: handleSubmit,
273
273
  submitErrorMessage: submitErrorMessage,
@@ -276,7 +276,7 @@ const InternalAppointmentPage = () => {
276
276
  isSuccess: isCreatePlannedAppointmentSuccess || isCreateAppointmentRequestSuccess || isUpdateAppointmentSuccess || isUpdateAppointmentRequestSuccess,
277
277
  entityId: createdEntityId || existingDossierId
278
278
  })), /*#__PURE__*/_react.default.createElement("div", {
279
- className: (0, _helpers__.withStyle)("sidebar col-12 col-lg-4 pt-5")
279
+ className: (0, _helpers__.withStyle)("sidebar col col-xxl-4 pt-5")
280
280
  }, /*#__PURE__*/_react.default.createElement(_VehicleData.default, {
281
281
  key: "configurator-vehicle-data"
282
282
  }), /*#__PURE__*/_react.default.createElement(_ProductCartSide.default, null))))), anchorEl && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement(_Modal.default, {
@@ -38,9 +38,9 @@ const InternalExtraProductsPage = () => {
38
38
  })), /*#__PURE__*/_react.default.createElement("div", {
39
39
  className: (0, _helpers__.withStyle)('row gx-5 mt-3 mt-lg-5')
40
40
  }, /*#__PURE__*/_react.default.createElement("div", {
41
- className: (0, _helpers__.withStyle)('col-lg')
41
+ className: (0, _helpers__.withStyle)('col-xxl')
42
42
  }, /*#__PURE__*/_react.default.createElement(_ExtraProductsOverview.default, null)), /*#__PURE__*/_react.default.createElement("div", {
43
- className: (0, _helpers__.withStyle)("sidebar col-xxl-auto col-lg-4 pt-5")
43
+ className: (0, _helpers__.withStyle)("sidebar col-xxl-auto col-lg-12 pt-5")
44
44
  }, /*#__PURE__*/_react.default.createElement(_VehicleData.default, {
45
45
  key: "configurator-vehicle-data"
46
46
  }), /*#__PURE__*/_react.default.createElement(_ProductCartSide.default, null)))), /*#__PURE__*/_react.default.createElement(_BottomNavigationBar.default, null)));
@@ -45,9 +45,9 @@ const InternalOverviewPage = () => {
45
45
  })), /*#__PURE__*/_react.default.createElement("div", {
46
46
  className: (0, _helpers__.withStyle)('row gx-5 mt-3 mt-lg-5')
47
47
  }, /*#__PURE__*/_react.default.createElement("div", {
48
- className: (0, _helpers__.withStyle)('col-lg')
48
+ className: (0, _helpers__.withStyle)('col-xxl')
49
49
  }, /*#__PURE__*/_react.default.createElement(_internal.InternalDiscountCodeSelector, null), /*#__PURE__*/_react.default.createElement(_ProductsCartOverview.default, null), /*#__PURE__*/_react.default.createElement(_ProductDiscountCard.default, null)), /*#__PURE__*/_react.default.createElement("div", {
50
- className: (0, _helpers__.withStyle)("sidebar col-xxl-auto col-lg-4 pt-5")
50
+ className: (0, _helpers__.withStyle)("sidebar col-xxl-auto col-lg-12 pt-5")
51
51
  }, /*#__PURE__*/_react.default.createElement(_VehicleData.default, {
52
52
  key: "configurator-vehicle-data"
53
53
  }), /*#__PURE__*/_react.default.createElement("div", {
@@ -39,9 +39,9 @@ const InternalProductsPage = () => {
39
39
  })), /*#__PURE__*/_react.default.createElement("div", {
40
40
  className: (0, _helpers__.withStyle)('row gx-5 mt-3 mt-lg-5')
41
41
  }, /*#__PURE__*/_react.default.createElement("div", {
42
- className: (0, _helpers__.withStyle)("col-lg")
42
+ className: (0, _helpers__.withStyle)("col-xxl")
43
43
  }, /*#__PURE__*/_react.default.createElement(_ProductsOverview.default, null)), /*#__PURE__*/_react.default.createElement("div", {
44
- className: (0, _helpers__.withStyle)("sidebar col-xxl-auto col-lg-4 pt-5")
44
+ className: (0, _helpers__.withStyle)("sidebar col-xxl-auto col-lg-12 pt-5")
45
45
  }, APP_CONFIG.internal && /*#__PURE__*/_react.default.createElement(_InternalPriceCalculationSelector.default, null), /*#__PURE__*/_react.default.createElement(_VehicleData.default, {
46
46
  key: "configurator-vehicle-data"
47
47
  }), /*#__PURE__*/_react.default.createElement(_ProductCartSide.default, null)))), /*#__PURE__*/_react.default.createElement(_BottomNavigationBar.default, null)));
@@ -421,7 +421,7 @@ const InternalSingleOrderPage = () => {
421
421
  }), /*#__PURE__*/_react.default.createElement("div", {
422
422
  className: (0, _helpers__.withStyle)('row gx-5 mt-3 mt-lg-5')
423
423
  }, /*#__PURE__*/_react.default.createElement("div", {
424
- className: (0, _helpers__.withStyle)("col-lg")
424
+ className: (0, _helpers__.withStyle)("col-xxl")
425
425
  }, showProductOverview ? /*#__PURE__*/_react.default.createElement(_InternalSingleOrderProductOverview.default, {
426
426
  removeFromCart: removeFromCart,
427
427
  filters: filters,
@@ -439,7 +439,7 @@ const InternalSingleOrderPage = () => {
439
439
  errors: customerErrors,
440
440
  onValidationError: handleCustomerValidationError
441
441
  }))), /*#__PURE__*/_react.default.createElement("div", {
442
- className: (0, _helpers__.withStyle)("sidebar col-xxl-auto col-lg-4 pt-3")
442
+ className: (0, _helpers__.withStyle)("sidebar col-xxl-auto col-lg-12 pt-3")
443
443
  }, (licensePlate || model) && /*#__PURE__*/_react.default.createElement(_VehicleData.default, {
444
444
  key: "single-order-vehicle-data",
445
445
  isFilter: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.378",
3
+ "version": "0.0.381",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",