thm-p3-configurator 0.0.71 → 0.0.72

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,14 +1,10 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.weak-map.js");
4
- require("core-js/modules/web.dom-collections.iterator.js");
5
- require("core-js/modules/es.weak-map.js");
6
3
  Object.defineProperty(exports, "__esModule", {
7
4
  value: true
8
5
  });
9
6
  exports.default = void 0;
10
- require("core-js/modules/web.dom-collections.iterator.js");
11
- var _react = _interopRequireWildcard(require("react"));
7
+ var _react = _interopRequireDefault(require("react"));
12
8
  var _reactPaginate = _interopRequireDefault(require("react-paginate"));
13
9
  var _helpers__ = require("../__helpers__");
14
10
  function _interopRequireDefault(e) {
@@ -16,46 +12,19 @@ function _interopRequireDefault(e) {
16
12
  default: e
17
13
  };
18
14
  }
19
- function _getRequireWildcardCache(e) {
20
- if ("function" != typeof WeakMap) return null;
21
- var r = new WeakMap(),
22
- t = new WeakMap();
23
- return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
24
- return e ? t : r;
25
- })(e);
26
- }
27
- function _interopRequireWildcard(e, r) {
28
- if (!r && e && e.__esModule) return e;
29
- if (null === e || "object" != typeof e && "function" != typeof e) return {
30
- default: e
31
- };
32
- var t = _getRequireWildcardCache(r);
33
- if (t && t.has(e)) return t.get(e);
34
- var n = {
35
- __proto__: null
36
- },
37
- a = Object.defineProperty && Object.getOwnPropertyDescriptor;
38
- for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
39
- var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
40
- i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
41
- }
42
- return n.default = e, t && t.set(e, n), n;
43
- }
44
15
  const Pagination = _ref => {
45
16
  let {
46
- initialPage = 1,
17
+ currentPage = 0,
47
18
  label = 'resultaten',
48
- count = 1,
19
+ count = 0,
49
20
  pageSize = 1,
50
21
  className = '',
51
22
  onPageChange = selectedPage => {}
52
23
  } = _ref;
53
- const [page, setPage] = (0, _react.useState)(initialPage);
54
24
  const handlePageChange = _ref2 => {
55
25
  let {
56
26
  selected
57
27
  } = _ref2;
58
- setPage(selected);
59
28
  onPageChange(selected);
60
29
  };
61
30
  return /*#__PURE__*/_react.default.createElement("nav", {
@@ -73,10 +42,11 @@ const Pagination = _ref => {
73
42
  pageLinkClassName: (0, _helpers__.withStyle)('page-link'),
74
43
  pageRangeDisplayed: 3,
75
44
  previousLabel: 'Vorige',
76
- subContainerClassName: (0, _helpers__.withStyle)('pages pagination')
45
+ subContainerClassName: (0, _helpers__.withStyle)('pages pagination'),
46
+ forcePage: currentPage
77
47
  }), /*#__PURE__*/_react.default.createElement("div", {
78
48
  className: (0, _helpers__.withStyle)('mt-2 section__pagination-caption')
79
- }, /*#__PURE__*/_react.default.createElement("p", null, (page + 1) * pageSize <= count ? (page + 1) * pageSize : count, " /", ' ', count, " ", label)));
49
+ }, /*#__PURE__*/_react.default.createElement("p", null, (currentPage + 1) * pageSize - pageSize + 1, " to", ' ', (currentPage + 1) * pageSize <= count ? (currentPage + 1) * pageSize : count, ' ', "van ", count, " ", label)));
80
50
  };
81
51
 
82
52
  // we can optimise cause right now it re-renders on every state change (count)
@@ -113,13 +113,32 @@ const ProductActions = _ref4 => {
113
113
  label: "Verwijder"
114
114
  }))));
115
115
  };
116
- const SingleOrderProductCard = _ref5 => {
116
+ const ProductCategories = _ref5 => {
117
+ let {
118
+ productType = null,
119
+ productGroup = null,
120
+ productSubgroup = null
121
+ } = _ref5;
122
+ return /*#__PURE__*/_react.default.createElement("div", {
123
+ className: (0, _helpers__.withStyle)('mb-3')
124
+ }, productType && /*#__PURE__*/_react.default.createElement("p", {
125
+ className: (0, _helpers__.withStyle)('fst-italic mb-0')
126
+ }, /*#__PURE__*/_react.default.createElement("strong", null, "Type:"), " ", productType), productGroup && /*#__PURE__*/_react.default.createElement("p", {
127
+ className: (0, _helpers__.withStyle)('fst-italic mb-0')
128
+ }, /*#__PURE__*/_react.default.createElement("strong", null, "Groep:"), " ", productGroup), productSubgroup && /*#__PURE__*/_react.default.createElement("p", {
129
+ className: (0, _helpers__.withStyle)('fst-italic mb-0')
130
+ }, /*#__PURE__*/_react.default.createElement("strong", null, "Subgroep:"), " ", productSubgroup));
131
+ };
132
+ const SingleOrderProductCard = _ref6 => {
117
133
  let {
118
134
  productId,
119
135
  isSelected,
120
136
  isOutOfStock,
121
137
  handleSelected,
122
138
  productImage,
139
+ productType,
140
+ productGroup,
141
+ productSubgroup,
123
142
  productTitle,
124
143
  productDescription,
125
144
  productPrice,
@@ -127,7 +146,7 @@ const SingleOrderProductCard = _ref5 => {
127
146
  quantity = 0,
128
147
  handleQuantityChange,
129
148
  removeFromCart
130
- } = _ref5;
149
+ } = _ref6;
131
150
  return /*#__PURE__*/_react.default.createElement("div", {
132
151
  key: productId + "-".concat(Date.now()),
133
152
  className: (0, _helpers__.withStyle)("card card__horizontal card__link ".concat(isSelected ? 'active' : '', " container-fluid p-0 my-3"))
@@ -143,7 +162,11 @@ const SingleOrderProductCard = _ref5 => {
143
162
  className: (0, _helpers__.withStyle)('card-title mb-3')
144
163
  }, productTitle, /*#__PURE__*/_react.default.createElement("span", {
145
164
  className: (0, _helpers__.withStyle)('ms-2')
146
- }, "\u20AC", productPrice)), /*#__PURE__*/_react.default.createElement(ProductDescription, {
165
+ }, "\u20AC", productPrice)), (productType || productGroup || productSubgroup) && /*#__PURE__*/_react.default.createElement(ProductCategories, {
166
+ productType: productType,
167
+ productGroup: productGroup,
168
+ productSubgroup: productSubgroup
169
+ }), /*#__PURE__*/_react.default.createElement(ProductDescription, {
147
170
  description: productDescription
148
171
  }), /*#__PURE__*/_react.default.createElement(ProductSpecifications, {
149
172
  specifications: productSpecifications
@@ -138,7 +138,10 @@ const InternalSingleOrderProductOverview = _ref => {
138
138
  productDescription: article === null || article === void 0 ? void 0 : article.description,
139
139
  productImage: article.image,
140
140
  productTitle: article.name,
141
- productPrice: Number(article === null || article === void 0 || (_article$locationPric2 = article.locationPrices) === null || _article$locationPric2 === void 0 ? void 0 : _article$locationPric2.priceInclVat).toFixed(2)
141
+ productPrice: Number(article === null || article === void 0 || (_article$locationPric2 = article.locationPrices) === null || _article$locationPric2 === void 0 ? void 0 : _article$locationPric2.priceInclVat).toFixed(2),
142
+ productType: article === null || article === void 0 ? void 0 : article.type,
143
+ productGroup: article === null || article === void 0 ? void 0 : article.group,
144
+ productSubgroup: article === null || article === void 0 ? void 0 : article.subgroup
142
145
  });
143
146
  })), !articles && hasActiveFilters && !areArticlesLoaded && !areArticlesError && /*#__PURE__*/_react.default.createElement("div", {
144
147
  className: (0, _helpers__.withStyle)('flex-grow-1 h-100')
@@ -149,6 +152,7 @@ const InternalSingleOrderProductOverview = _ref => {
149
152
  className: (0, _helpers__.withStyle)('mt-4'),
150
153
  count: articles === null || articles === void 0 ? void 0 : articles.totalArticles,
151
154
  pageSize: 10,
155
+ currentPage: filters.page,
152
156
  onPageChange: page => paginationChange('page', page)
153
157
  }));
154
158
  };
@@ -368,6 +368,7 @@ const orderSessionReducer = (state, action) => {
368
368
  brand,
369
369
  selectedBranch: (state === null || state === void 0 ? void 0 : state.selectedBranch) || (INITIAL_ORDER_SESSION_STATE === null || INITIAL_ORDER_SESSION_STATE === void 0 ? void 0 : INITIAL_ORDER_SESSION_STATE.selectedBranch),
370
370
  discountCode: (state === null || state === void 0 ? void 0 : state.discountCode) || (INITIAL_ORDER_SESSION_STATE === null || INITIAL_ORDER_SESSION_STATE === void 0 ? void 0 : INITIAL_ORDER_SESSION_STATE.discountCode),
371
+ singleOrderCart: (state === null || state === void 0 ? void 0 : state.singleOrderCart) || (INITIAL_ORDER_SESSION_STATE === null || INITIAL_ORDER_SESSION_STATE === void 0 ? void 0 : INITIAL_ORDER_SESSION_STATE.singleOrderCart),
371
372
  isTouched: true
372
373
  });
373
374
  }
@@ -181,9 +181,9 @@ const enrichArticlesWithBrandsAndPrices = async (articles, branchId, formula) =>
181
181
  throw new Error('Failed to fetch the brands of the articles');
182
182
  }
183
183
  const articlesWithBrands = articles.map(article => {
184
- var _brandResponse$data$f;
184
+ var _brandResponse$data$f, _brandResponse$data$f2;
185
185
  return _objectSpread(_objectSpread({}, article), {}, {
186
- brand: (_brandResponse$data$f = brandResponse.data.find(brand => brand.article === article.articleNumber)) === null || _brandResponse$data$f === void 0 ? void 0 : _brandResponse$data$f.articleBrandId
186
+ brand: (_brandResponse$data$f = (_brandResponse$data$f2 = brandResponse.data.find(brand => brand.article === article.articleNumber)) === null || _brandResponse$data$f2 === void 0 ? void 0 : _brandResponse$data$f2.articleBrandId) !== null && _brandResponse$data$f !== void 0 ? _brandResponse$data$f : _index2.DEFAULT_ARTICLE_BRAND
187
187
  });
188
188
  }).filter(article => article.brand);
189
189
  const parts = articlesWithBrands.map(article => {
@@ -216,7 +216,8 @@ const enrichArticlesWithBrandsAndPrices = async (articles, branchId, formula) =>
216
216
  };
217
217
  exports.enrichArticlesWithBrandsAndPrices = enrichArticlesWithBrandsAndPrices;
218
218
  const formatModelArticle = article => {
219
- var _ref3, _article$name, _ref4, _article$description$, _article$description, _article$boldDescript, _article$boldDescript2, _article$specificatio, _article$images, _article$images2, _article$articleNumbe;
219
+ var _ref3, _article$name, _ref4, _article$description$, _article$description, _article$boldDescript, _article$boldDescript2, _article$specificatio, _article$images, _article$images2, _article$articleNumbe, _article$type, _article$group, _article$subgroup;
220
+ console.log('article', article);
220
221
  return {
221
222
  name: (_ref3 = (_article$name = article.name) !== null && _article$name !== void 0 ? _article$name : article === null || article === void 0 ? void 0 : article.title) !== null && _ref3 !== void 0 ? _ref3 : null,
222
223
  description: (_ref4 = (_article$description$ = article === null || article === void 0 || (_article$description = article.description) === null || _article$description === void 0 || (_article$description = _article$description.ops) === null || _article$description === void 0 || (_article$description = _article$description[0]) === null || _article$description === void 0 ? void 0 : _article$description.insert) !== null && _article$description$ !== void 0 ? _article$description$ : article === null || article === void 0 ? void 0 : article.remark) !== null && _ref4 !== void 0 ? _ref4 : null,
@@ -225,11 +226,14 @@ const formatModelArticle = article => {
225
226
  image: article !== null && article !== void 0 && (_article$images = article.images) !== null && _article$images !== void 0 && _article$images[0] ? (0, _image.getImageFromHyper)({
226
227
  imageId: article === null || article === void 0 || (_article$images2 = article.images) === null || _article$images2 === void 0 ? void 0 : _article$images2[0]
227
228
  }) : _logoPrimary.default,
228
- articleNumber: (_article$articleNumbe = article.articleNumber) !== null && _article$articleNumbe !== void 0 ? _article$articleNumbe : ''
229
+ articleNumber: (_article$articleNumbe = article.articleNumber) !== null && _article$articleNumbe !== void 0 ? _article$articleNumbe : '',
230
+ type: article === null || article === void 0 || (_article$type = article.type) === null || _article$type === void 0 ? void 0 : _article$type.title,
231
+ group: article === null || article === void 0 || (_article$group = article.group) === null || _article$group === void 0 ? void 0 : _article$group.title,
232
+ subgroup: article === null || article === void 0 || (_article$subgroup = article.subgroup) === null || _article$subgroup === void 0 ? void 0 : _article$subgroup.title
229
233
  };
230
234
  };
231
235
  const formatGenericArticle = article => {
232
- var _article$images3, _article$images4, _article$articleNumbe2;
236
+ var _article$images3, _article$images4, _article$articleNumbe2, _article$type2, _article$group2, _article$subgroup2;
233
237
  const specificationPairs = [['C2 module', article === null || article === void 0 ? void 0 : article.c2Module], ['Check control', article === null || article === void 0 ? void 0 : article.checkControl], ['Direct current', article === null || article === void 0 ? void 0 : article.directCurrent], ['Draw weight', article === null || article === void 0 ? void 0 : article.drawWeight], ['D value', article === null || article === void 0 ? void 0 : article.dValue], ['Foglight shutdown', article === null || article === void 0 ? void 0 : article.foglightShutdown], ['PDC shutdown', article === null || article === void 0 ? void 0 : article.pdcShutdown], ['Switched PSU', article === null || article === void 0 ? void 0 : article.switchedPsu], ['LED', article === null || article === void 0 ? void 0 : article.led]];
234
238
  const specification = specificationPairs.filter(_ref5 => {
235
239
  let [_, value] = _ref5;
@@ -246,6 +250,9 @@ const formatGenericArticle = article => {
246
250
  image: article !== null && article !== void 0 && (_article$images3 = article.images) !== null && _article$images3 !== void 0 && _article$images3[0] ? (0, _image.getImageFromHyper)({
247
251
  imageId: article === null || article === void 0 || (_article$images4 = article.images) === null || _article$images4 === void 0 ? void 0 : _article$images4[0]
248
252
  }) : _logoPrimary.default,
249
- articleNumber: (_article$articleNumbe2 = article.articleNumber) !== null && _article$articleNumbe2 !== void 0 ? _article$articleNumbe2 : ''
253
+ articleNumber: (_article$articleNumbe2 = article.articleNumber) !== null && _article$articleNumbe2 !== void 0 ? _article$articleNumbe2 : '',
254
+ type: article === null || article === void 0 || (_article$type2 = article.type) === null || _article$type2 === void 0 ? void 0 : _article$type2.title,
255
+ group: article === null || article === void 0 || (_article$group2 = article.group) === null || _article$group2 === void 0 ? void 0 : _article$group2.title,
256
+ subgroup: article === null || article === void 0 || (_article$subgroup2 = article.subgroup) === null || _article$subgroup2 === void 0 ? void 0 : _article$subgroup2.title
250
257
  };
251
258
  };
@@ -120,7 +120,7 @@ const InternalSingleOrderPage = () => {
120
120
  articleNumber: null,
121
121
  model: null,
122
122
  showAllArticles: false,
123
- page: 1
123
+ page: 0
124
124
  });
125
125
  const customerFormRef = (0, _react.useRef)();
126
126
  const {
@@ -170,7 +170,14 @@ const InternalSingleOrderPage = () => {
170
170
  type: _OrderSessionContext.orderSessionActions.RESET_LICENSEPLATE_FILTERS
171
171
  });
172
172
  }
173
+ if (filter === 'page') {
174
+ setFilters(_objectSpread(_objectSpread({}, filters), {}, {
175
+ [filter]: value
176
+ }));
177
+ return;
178
+ }
173
179
  setFilters(_objectSpread(_objectSpread({}, filters), {}, {
180
+ page: 0,
174
181
  [filter]: value
175
182
  }));
176
183
  }, [filters]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.71",
3
+ "version": "0.0.72",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",