thm-p3-configurator 0.0.59 → 0.0.61

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.
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ require("core-js/modules/es.promise.js");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.orderApi = void 0;
8
+ require("core-js/modules/es.promise.js");
7
9
  var _axios = _interopRequireDefault(require("axios"));
8
10
  var _index = require("../__constants__/index.js");
9
11
  var _LocalStorageWorker = require("../__services__/LocalStorageWorker.js");
@@ -29,6 +31,17 @@ orderClient.interceptors.request.use(config => {
29
31
  config.headers.Authorization = "Bearer ".concat(authSession === null || authSession === void 0 ? void 0 : authSession.accessToken);
30
32
  return config;
31
33
  });
34
+
35
+ // Add response interceptor to handle 4xx errors
36
+ orderClient.interceptors.response.use(response => response, error => {
37
+ if (error.response && error.response.status >= 400 && error.response.status < 500) {
38
+ var _error$response$data;
39
+ // Handle client errors (4xx)
40
+ const errorMessage = ((_error$response$data = error.response.data) === null || _error$response$data === void 0 ? void 0 : _error$response$data.message) || 'Client request error';
41
+ console.error("API Error ".concat(error.response.status, ": ").concat(errorMessage));
42
+ }
43
+ return Promise.reject(error);
44
+ });
32
45
  const orderApi = exports.orderApi = {
33
46
  getOrder: orderParameters => orderClient("api".concat(APP_CONFIG.internal ? '' : '/public', "/order?").concat(orderParameters) // Remove the `/public` param if the configurator is internal,
34
47
  ),
@@ -79,7 +79,7 @@ function _toPrimitive(t, r) {
79
79
  return ("string" === r ? String : Number)(t);
80
80
  }
81
81
  const InternalSingleOrderProductOverview = _ref => {
82
- var _articles$articles, _articles$articles2;
82
+ var _articles$articles, _articles$articles2, _articles$articles3;
83
83
  let {
84
84
  filters,
85
85
  paginationChange,
@@ -103,6 +103,7 @@ const InternalSingleOrderProductOverview = _ref => {
103
103
  executionAnswer1,
104
104
  executionAnswer2
105
105
  });
106
+ const hasActiveFilters = Boolean(mergedFilters.articleNumber || mergedFilters.licensePlate || mergedFilters.model || mergedFilters.type || mergedFilters.group || mergedFilters.subgroup || mergedFilters.executionAnswer1 || mergedFilters.executionAnswer2 || mergedFilters.durationAnswer);
106
107
  const {
107
108
  articles,
108
109
  areArticlesError,
@@ -112,10 +113,13 @@ const InternalSingleOrderProductOverview = _ref => {
112
113
  className: (0, _helpers__.withStyle)('flex-grow-1 h-100')
113
114
  }, areArticlesError && /*#__PURE__*/_react.default.createElement(_DangerAlert.default, {
114
115
  message: "Er is iets fout gegaan bij het ophalen van de producten. Zorg dat je toegang hebt tot de geselecteerde vestiging. Klik op bestelling herstarten om de vestiging te wijzigen."
115
- }), articles && (articles === null || articles === void 0 || (_articles$articles = articles.articles) === null || _articles$articles === void 0 ? void 0 : _articles$articles.length) === 0 ? /*#__PURE__*/_react.default.createElement(_EmptyState.default, {
116
+ }), !hasActiveFilters && /*#__PURE__*/_react.default.createElement(_EmptyState.default, {
117
+ message: "Vind het product dat je zoekt",
118
+ subMessage: "Stel de filters in om de producten op te halen"
119
+ }), articles && hasActiveFilters && (articles === null || articles === void 0 || (_articles$articles = articles.articles) === null || _articles$articles === void 0 ? void 0 : _articles$articles.length) === 0 && /*#__PURE__*/_react.default.createElement(_EmptyState.default, {
116
120
  message: "Geen producten gevonden.",
117
121
  subMessage: "Probeer een ander filter toe te passen."
118
- }) : articles === null || articles === void 0 || (_articles$articles2 = articles.articles) === null || _articles$articles2 === void 0 ? void 0 : _articles$articles2.map(article => {
122
+ }), articles && hasActiveFilters && (articles === null || articles === void 0 || (_articles$articles2 = articles.articles) === null || _articles$articles2 === void 0 ? void 0 : _articles$articles2.length) > 0 && (articles === null || articles === void 0 || (_articles$articles3 = articles.articles) === null || _articles$articles3 === void 0 ? void 0 : _articles$articles3.map(article => {
119
123
  var _cart$find$quantity, _cart$find, _article$locationPric, _article$locationPric2;
120
124
  return /*#__PURE__*/_react.default.createElement(_SingleOrderProductCard.default, {
121
125
  key: article.articleNumber,
@@ -132,12 +136,12 @@ const InternalSingleOrderProductOverview = _ref => {
132
136
  productTitle: article.name,
133
137
  productPrice: Number(article === null || article === void 0 || (_article$locationPric2 = article.locationPrices) === null || _article$locationPric2 === void 0 ? void 0 : _article$locationPric2.priceInclVat).toFixed(2)
134
138
  });
135
- }), !articles && !areArticlesLoaded && !areArticlesError && /*#__PURE__*/_react.default.createElement("div", {
139
+ })), !articles && hasActiveFilters && !areArticlesLoaded && !areArticlesError && /*#__PURE__*/_react.default.createElement("div", {
136
140
  className: (0, _helpers__.withStyle)('flex-grow-1 h-100')
137
141
  }, /*#__PURE__*/_react.default.createElement(_EmptyState.default, {
138
142
  message: "We zijn de producten aan het laden...",
139
143
  subMessage: "Dit kan enkele seconden duren."
140
- })), !licensePlate && !model && /*#__PURE__*/_react.default.createElement(_Pagination.default, {
144
+ })), !licensePlate && hasActiveFilters && !model && /*#__PURE__*/_react.default.createElement(_Pagination.default, {
141
145
  className: (0, _helpers__.withStyle)('mt-4'),
142
146
  count: articles === null || articles === void 0 ? void 0 : articles.totalArticles,
143
147
  pageSize: 10,
@@ -39,6 +39,7 @@ var _orderApi = require("../__api__/orderApi");
39
39
  var _index = require("./index");
40
40
  var _logoPrimary = _interopRequireDefault(require("../../../public/assets/images/logo-primary.png"));
41
41
  var _image = require("../__helpers__/image");
42
+ var _index2 = require("../__constants__/index");
42
43
  function _interopRequireDefault(e) {
43
44
  return e && e.__esModule ? e : {
44
45
  default: e
@@ -184,10 +185,13 @@ const enrichArticlesWithBrandsAndPrices = async (articles, branchId, formula) =>
184
185
  brand: (_brandResponse$data$f = brandResponse.data.find(brand => brand.article === article.articleNumber)) === null || _brandResponse$data$f === void 0 ? void 0 : _brandResponse$data$f.articleBrandId
185
186
  });
186
187
  }).filter(article => article.brand);
187
- const parts = articlesWithBrands.map(article => ({
188
- partNumber: article.articleNumber,
189
- brandNumber: article.brand
190
- }));
188
+ const parts = articlesWithBrands.map(article => {
189
+ var _article$brand;
190
+ return {
191
+ partNumber: article.articleNumber,
192
+ brandNumber: (_article$brand = article.brand) !== null && _article$brand !== void 0 ? _article$brand : _index2.DEFAULT_ARTICLE_BRAND
193
+ };
194
+ });
191
195
  const pricesResponse = await _orderApi.orderApi.getArticlePrices(new URLSearchParams({
192
196
  branchId,
193
197
  formula,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",