thm-p3-configurator 0.0.47 → 0.0.48

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.
Files changed (37) hide show
  1. package/dist/index.js +6 -0
  2. package/dist/src/shared/__api__/authenticatedProxyApi.js +22 -0
  3. package/dist/src/shared/__api__/mutations.js +44 -10
  4. package/dist/src/shared/__api__/orderApi.js +16 -0
  5. package/dist/src/shared/__api__/queries.js +228 -3
  6. package/dist/src/shared/__components__/Buttons/OutlinedButton.js +61 -0
  7. package/dist/src/shared/__components__/Buttons/PrimaryButton.js +3 -2
  8. package/dist/src/shared/__components__/Cards/ExpandableCard.js +2 -1
  9. package/dist/src/shared/__components__/DangerAlert.js +23 -0
  10. package/dist/src/shared/__components__/EmptyState.js +30 -0
  11. package/dist/src/shared/__components__/Form/DropdownInput.js +2 -1
  12. package/dist/src/shared/__components__/Form/NumericInput.js +88 -20
  13. package/dist/src/shared/__components__/Form/TextInput.js +2 -2
  14. package/dist/src/shared/__components__/Modal.js +2 -1
  15. package/dist/src/shared/__components__/Pagination.js +83 -0
  16. package/dist/src/shared/__components__/SingleOrderCartCard.js +74 -0
  17. package/dist/src/shared/__components__/SingleOrderProductCard.js +159 -0
  18. package/dist/src/shared/__components__/internal/InternalCustomerDetailsForm.js +383 -0
  19. package/dist/src/shared/__constants__/index.js +7 -1
  20. package/dist/src/shared/__containers__/LicensePlateForm.js +18 -11
  21. package/dist/src/shared/__containers__/ManualSelectionForm.js +14 -4
  22. package/dist/src/shared/__containers__/ProductDiscountCard.js +1 -2
  23. package/dist/src/shared/__containers__/internal/InternalBranchSelectorModal.js +30 -25
  24. package/dist/src/shared/__containers__/internal/InternalLicenseplateModal.js +71 -0
  25. package/dist/src/shared/__containers__/internal/InternalSingleOrderCart.js +93 -0
  26. package/dist/src/shared/__containers__/internal/InternalSingleOrderFilters.js +164 -0
  27. package/dist/src/shared/__containers__/internal/InternalSingleOrderProductOverview.js +141 -0
  28. package/dist/src/shared/__containers__/internal/InternalSingleOrderSidebar.js +21 -0
  29. package/dist/src/shared/__containers__/internal/InternalSingleOrderSuccessModal.js +33 -0
  30. package/dist/src/shared/__context__/OrderSessionContext.js +75 -16
  31. package/dist/src/shared/__helpers__/singleOrderArticles.js +230 -0
  32. package/dist/src/shared/__hooks__/useArticleTypes.js +23 -0
  33. package/dist/src/shared/__hooks__/useIsSingleOrder.js +18 -0
  34. package/dist/src/shared/__pages__/internal/InternalSingleOrderPage.js +273 -0
  35. package/dist/src/shared/__pages__/internal/__TEST_ONLY_INTERNAL_ROUTES.js +4 -0
  36. package/dist/src/shared/__pages__/internal/index.js +7 -0
  37. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -93,6 +93,12 @@ Object.defineProperty(exports, "InternalSessionEditPage", {
93
93
  return _index.InternalSessionEditPage;
94
94
  }
95
95
  });
96
+ Object.defineProperty(exports, "InternalSingleOrderPage", {
97
+ enumerable: true,
98
+ get: function get() {
99
+ return _index.InternalSingleOrderPage;
100
+ }
101
+ });
96
102
  Object.defineProperty(exports, "OrderSessionController", {
97
103
  enumerable: true,
98
104
  get: function get() {
@@ -29,6 +29,21 @@ authenticateClient.interceptors.request.use(config => {
29
29
  return config;
30
30
  });
31
31
  const authenticatedProxyApi = exports.authenticatedProxyApi = {
32
+ getArticleTypes: () => authenticateClient("api/v1/articles/types", {
33
+ method: 'GET'
34
+ }),
35
+ getArticleGroups: articleTypeId => authenticateClient("api/v1/articles/groups/".concat(articleTypeId), {
36
+ method: 'GET'
37
+ }),
38
+ getArticleSubGroups: (articleGroupId, formula) => authenticateClient("api/v1/articles/subgroups/".concat(articleGroupId, "?formula=").concat(formula), {
39
+ method: 'GET'
40
+ }),
41
+ getArticles: filtersQueryString => authenticateClient("api/v1/articles?".concat(filtersQueryString), {
42
+ method: 'GET'
43
+ }),
44
+ getBrandsByArticleNumbers: articleNumbersString => authenticateClient("api/v1/articles/brands?".concat(articleNumbersString), {
45
+ method: 'GET'
46
+ }),
32
47
  deleteLogout: () => authenticateClient("api/v1/auth", {
33
48
  method: 'DELETE'
34
49
  }),
@@ -57,6 +72,13 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
57
72
  'Content-Type': 'application/json'
58
73
  }
59
74
  }),
75
+ postSingleOrder: singleOrderPayload => authenticateClient("api/v1/single-orders", {
76
+ method: 'POST',
77
+ data: singleOrderPayload,
78
+ headers: {
79
+ 'Content-Type': 'application/json'
80
+ }
81
+ }),
60
82
  postAppointment: appointmentPayload => authenticateClient("api/v1/appointments", {
61
83
  method: 'POST',
62
84
  data: appointmentPayload,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useUpdatePrivateQuotationByIdMutation = exports.useUpdatePrivateAppointmentByIdMutation = exports.useCreateQuotationMutation = exports.useCreatePrivateQuotationMutation = exports.useCreatePrivateAppointmentMutation = exports.useCreateAppointmentRequestMutation = void 0;
6
+ exports.useUpdatePrivateQuotationByIdMutation = exports.useUpdatePrivateAppointmentByIdMutation = exports.useCreateSingleOrderMutation = exports.useCreateQuotationMutation = exports.useCreatePrivateQuotationMutation = exports.useCreatePrivateAppointmentMutation = exports.useCreateAppointmentRequestMutation = void 0;
7
7
  var _reactQuery = require("react-query");
8
8
  var _authenticatedProxyApi = require("./authenticatedProxyApi");
9
9
  var _publicProxyApi = require("./publicProxyApi");
@@ -88,13 +88,47 @@ const useCreateAppointmentRequestMutation = () => {
88
88
  };
89
89
  };
90
90
 
91
+ /**
92
+ * @description Creates a single order
93
+ */
94
+ exports.useCreateAppointmentRequestMutation = useCreateAppointmentRequestMutation;
95
+ const useCreateSingleOrderMutation = () => {
96
+ const createSingleOrderMutation = (0, _reactQuery.useMutation)(_ref3 => {
97
+ let {
98
+ licensePlate,
99
+ model,
100
+ cart,
101
+ customer,
102
+ formula,
103
+ branchId,
104
+ channel
105
+ } = _ref3;
106
+ return _authenticatedProxyApi.authenticatedProxyApi.postSingleOrder({
107
+ licensePlate,
108
+ model,
109
+ cart,
110
+ customer,
111
+ formula,
112
+ branchId,
113
+ channel
114
+ });
115
+ });
116
+ return {
117
+ isCreatingSingleOrder: createSingleOrderMutation.isLoading,
118
+ isCreateSingleOrderError: createSingleOrderMutation.isError,
119
+ isCreateSingleOrderSuccess: createSingleOrderMutation.isSuccess,
120
+ resetSingleOrderCreation: createSingleOrderMutation.reset,
121
+ createSingleOrder: createSingleOrderMutation.mutate
122
+ };
123
+ };
124
+
91
125
  /**
92
126
  * @description Creates a quotation within the private order API
93
127
  * Signs the request with the accessToken
94
128
  */
95
- exports.useCreateAppointmentRequestMutation = useCreateAppointmentRequestMutation;
129
+ exports.useCreateSingleOrderMutation = useCreateSingleOrderMutation;
96
130
  const useCreatePrivateQuotationMutation = () => {
97
- const createQuotationMutation = (0, _reactQuery.useMutation)(_ref3 => {
131
+ const createQuotationMutation = (0, _reactQuery.useMutation)(_ref4 => {
98
132
  let {
99
133
  vehicle,
100
134
  customer,
@@ -108,7 +142,7 @@ const useCreatePrivateQuotationMutation = () => {
108
142
  formula,
109
143
  discount,
110
144
  isExitIntent = false
111
- } = _ref3;
145
+ } = _ref4;
112
146
  return _authenticatedProxyApi.authenticatedProxyApi.postQuotation({
113
147
  isExitIntent,
114
148
  model,
@@ -139,7 +173,7 @@ const useCreatePrivateQuotationMutation = () => {
139
173
  */
140
174
  exports.useCreatePrivateQuotationMutation = useCreatePrivateQuotationMutation;
141
175
  const useCreatePrivateAppointmentMutation = () => {
142
- const createPlannedAppointmentMutation = (0, _reactQuery.useMutation)(_ref4 => {
176
+ const createPlannedAppointmentMutation = (0, _reactQuery.useMutation)(_ref5 => {
143
177
  let {
144
178
  vehicle,
145
179
  customer,
@@ -154,7 +188,7 @@ const useCreatePrivateAppointmentMutation = () => {
154
188
  formula,
155
189
  discount,
156
190
  customerAgreed
157
- } = _ref4;
191
+ } = _ref5;
158
192
  return _authenticatedProxyApi.authenticatedProxyApi.postAppointment({
159
193
  appointment,
160
194
  model,
@@ -186,7 +220,7 @@ const useCreatePrivateAppointmentMutation = () => {
186
220
  */
187
221
  exports.useCreatePrivateAppointmentMutation = useCreatePrivateAppointmentMutation;
188
222
  const useUpdatePrivateQuotationByIdMutation = id => {
189
- const updateQuotationMutation = (0, _reactQuery.useMutation)(_ref5 => {
223
+ const updateQuotationMutation = (0, _reactQuery.useMutation)(_ref6 => {
190
224
  let {
191
225
  vehicle,
192
226
  customer,
@@ -200,7 +234,7 @@ const useUpdatePrivateQuotationByIdMutation = id => {
200
234
  formula,
201
235
  discount,
202
236
  priceCalculationDate
203
- } = _ref5;
237
+ } = _ref6;
204
238
  return _authenticatedProxyApi.authenticatedProxyApi.putQuotationById({
205
239
  id,
206
240
  payload: {
@@ -234,7 +268,7 @@ const useUpdatePrivateQuotationByIdMutation = id => {
234
268
  */
235
269
  exports.useUpdatePrivateQuotationByIdMutation = useUpdatePrivateQuotationByIdMutation;
236
270
  const useUpdatePrivateAppointmentByIdMutation = id => {
237
- const updateAppointmentByIdMutation = (0, _reactQuery.useMutation)(_ref6 => {
271
+ const updateAppointmentByIdMutation = (0, _reactQuery.useMutation)(_ref7 => {
238
272
  let {
239
273
  vehicle,
240
274
  customer,
@@ -249,7 +283,7 @@ const useUpdatePrivateAppointmentByIdMutation = id => {
249
283
  formula,
250
284
  discount,
251
285
  priceCalculationDate
252
- } = _ref6;
286
+ } = _ref7;
253
287
  return _authenticatedProxyApi.authenticatedProxyApi.putAppointmentById({
254
288
  id,
255
289
  payload: {
@@ -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,9 +31,23 @@ 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 log 4xx errors
36
+ orderClient.interceptors.response.use(response => response, error => {
37
+ if (error.response && error.response.status >= 400 && error.response.status < 500) {
38
+ console.error('4xx Error Response:', {
39
+ status: error.response.status,
40
+ url: error.config.url,
41
+ data: error.response.data
42
+ });
43
+ }
44
+ return Promise.reject(error);
45
+ });
32
46
  const orderApi = exports.orderApi = {
33
47
  getOrder: orderParameters => orderClient("api".concat(APP_CONFIG.internal ? '' : '/public', "/order?").concat(orderParameters) // Remove the `/public` param if the configurator is internal,
34
48
  ),
49
+ getArticlePrices: partsQueryString => orderClient("api".concat(APP_CONFIG.internal ? '' : '/public', "/prices?").concat(partsQueryString)),
50
+ getArticles: filters => orderClient("api/public/articles?".concat(filters)),
35
51
  getBrands: () => orderClient('api/public/makes'),
36
52
  getBuildYears: brand => orderClient("api/public/makes/".concat(brand, "/years")),
37
53
  getModels: _ref => {
@@ -2,25 +2,83 @@
2
2
 
3
3
  require("core-js/modules/es.symbol.description.js");
4
4
  require("core-js/modules/es.json.stringify.js");
5
+ require("core-js/modules/es.object.from-entries.js");
6
+ require("core-js/modules/es.promise.js");
5
7
  require("core-js/modules/es.regexp.to-string.js");
8
+ require("core-js/modules/esnext.iterator.constructor.js");
9
+ require("core-js/modules/esnext.iterator.filter.js");
10
+ require("core-js/modules/esnext.iterator.for-each.js");
11
+ require("core-js/modules/esnext.iterator.map.js");
6
12
  require("core-js/modules/web.dom-collections.iterator.js");
7
13
  require("core-js/modules/web.url-search-params.js");
14
+ require("core-js/modules/esnext.iterator.constructor.js");
15
+ require("core-js/modules/esnext.iterator.filter.js");
16
+ require("core-js/modules/esnext.iterator.for-each.js");
8
17
  Object.defineProperty(exports, "__esModule", {
9
18
  value: true
10
19
  });
11
- exports.useQuestionsQuery = exports.useProductsQuery = exports.useProductFieldLabels = exports.usePrivateDossierByTypeAndIdQuery = exports.useMyBranches = exports.useModelsQuery = exports.useMarketingChannels = exports.useBuildYearsQuery = exports.useBrandsQuery = exports.useBranchesQuery = exports.useBranchTypes = exports.useBranchByIdOrWidgetId = exports.useActiveDiscounts = void 0;
20
+ exports.useSingleOrderCart = exports.useSingleOrderArticles = exports.useQuestionsQuery = exports.useProductsQuery = exports.useProductFieldLabels = exports.usePrivateDossierByTypeAndIdQuery = exports.useMyBranches = exports.useModelsQuery = exports.useMarketingChannels = exports.useBuildYearsQuery = exports.useBrandsQuery = exports.useBranchesQuery = exports.useBranchTypes = exports.useBranchByIdOrWidgetId = exports.useArticleTypes = exports.useArticleSubGroups = exports.useArticleGroups = exports.useActiveDiscounts = void 0;
12
21
  require("core-js/modules/es.symbol.description.js");
13
22
  require("core-js/modules/es.json.stringify.js");
23
+ require("core-js/modules/es.object.from-entries.js");
24
+ require("core-js/modules/es.promise.js");
14
25
  require("core-js/modules/es.regexp.to-string.js");
26
+ require("core-js/modules/esnext.iterator.map.js");
15
27
  require("core-js/modules/web.dom-collections.iterator.js");
16
28
  require("core-js/modules/web.url-search-params.js");
17
29
  var _reactQuery = require("react-query");
18
30
  var _constants__ = require("../__constants__");
31
+ var _FormulaContext = require("../__context__/FormulaContext");
32
+ var _OrderSessionContext = require("../__context__/OrderSessionContext");
19
33
  var _helpers__ = require("../__helpers__");
34
+ var _singleOrderArticles = require("../__helpers__/singleOrderArticles");
20
35
  var _LocalStorageWorker = require("../__services__/LocalStorageWorker");
21
36
  var _authenticatedProxyApi = require("./authenticatedProxyApi");
22
37
  var _orderApi = require("./orderApi");
23
38
  var _publicProxyApi = require("./publicProxyApi");
39
+ function ownKeys(e, r) {
40
+ var t = Object.keys(e);
41
+ if (Object.getOwnPropertySymbols) {
42
+ var o = Object.getOwnPropertySymbols(e);
43
+ r && (o = o.filter(function (r) {
44
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
45
+ })), t.push.apply(t, o);
46
+ }
47
+ return t;
48
+ }
49
+ function _objectSpread(e) {
50
+ for (var r = 1; r < arguments.length; r++) {
51
+ var t = null != arguments[r] ? arguments[r] : {};
52
+ r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
53
+ _defineProperty(e, r, t[r]);
54
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
55
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
56
+ });
57
+ }
58
+ return e;
59
+ }
60
+ function _defineProperty(e, r, t) {
61
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
62
+ value: t,
63
+ enumerable: !0,
64
+ configurable: !0,
65
+ writable: !0
66
+ }) : e[r] = t, e;
67
+ }
68
+ function _toPropertyKey(t) {
69
+ var i = _toPrimitive(t, "string");
70
+ return "symbol" == typeof i ? i : i + "";
71
+ }
72
+ function _toPrimitive(t, r) {
73
+ if ("object" != typeof t || !t) return t;
74
+ var e = t[Symbol.toPrimitive];
75
+ if (void 0 !== e) {
76
+ var i = e.call(t, r || "default");
77
+ if ("object" != typeof i) return i;
78
+ throw new TypeError("@@toPrimitive must return a primitive value.");
79
+ }
80
+ return ("string" === r ? String : Number)(t);
81
+ }
24
82
  /**
25
83
  * @description Retrieves the car brand options
26
84
  */
@@ -61,9 +119,59 @@ const useBuildYearsQuery = _ref => {
61
119
  };
62
120
 
63
121
  /**
64
- * @description Retrieves the product field labels
122
+ * @description Retrieves the article types
65
123
  */
66
124
  exports.useBuildYearsQuery = useBuildYearsQuery;
125
+ const useArticleTypes = () => {
126
+ const articleTypesQuery = (0, _reactQuery.useQuery)('articleTypes', {
127
+ queryFn: () => _authenticatedProxyApi.authenticatedProxyApi.getArticleTypes().then(res => res.data)
128
+ });
129
+ return {
130
+ isLoadingArticleTypes: articleTypesQuery.isLoading,
131
+ isArticleTypesError: articleTypesQuery.isError,
132
+ articleTypes: articleTypesQuery === null || articleTypesQuery === void 0 ? void 0 : articleTypesQuery.data
133
+ };
134
+ };
135
+
136
+ /**
137
+ * @description Retrieves the article groups for a given article type
138
+ */
139
+ exports.useArticleTypes = useArticleTypes;
140
+ const useArticleGroups = exports.useArticleGroups = function useArticleGroups() {
141
+ var _articleGroupsQuery$d;
142
+ let articleTypeId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
143
+ const articleGroupsQuery = (0, _reactQuery.useQuery)(['articleGroups', articleTypeId], {
144
+ enabled: !!articleTypeId,
145
+ queryFn: () => _authenticatedProxyApi.authenticatedProxyApi.getArticleGroups(articleTypeId).then(res => res.data)
146
+ });
147
+ return {
148
+ isLoadingArticleGroups: articleGroupsQuery.isLoading,
149
+ isArticleGroupsError: articleGroupsQuery.isError,
150
+ articleGroups: (_articleGroupsQuery$d = articleGroupsQuery === null || articleGroupsQuery === void 0 ? void 0 : articleGroupsQuery.data) !== null && _articleGroupsQuery$d !== void 0 ? _articleGroupsQuery$d : []
151
+ };
152
+ };
153
+
154
+ /**
155
+ * @description Retrieves the article sub groups for a given article group
156
+ */
157
+ const useArticleSubGroups = exports.useArticleSubGroups = function useArticleSubGroups() {
158
+ var _articleSubGroupsQuer;
159
+ let articleGroupId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
160
+ let formula = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
161
+ const articleSubGroupsQuery = (0, _reactQuery.useQuery)(['articleSubGroups', articleGroupId, formula], {
162
+ enabled: !!articleGroupId && !!formula,
163
+ queryFn: () => _authenticatedProxyApi.authenticatedProxyApi.getArticleSubGroups(articleGroupId, formula).then(res => res.data)
164
+ });
165
+ return {
166
+ isLoadingArticleSubGroups: articleSubGroupsQuery.isLoading,
167
+ isArticleSubGroupsError: articleSubGroupsQuery.isError,
168
+ articleSubGroups: (_articleSubGroupsQuer = articleSubGroupsQuery === null || articleSubGroupsQuery === void 0 ? void 0 : articleSubGroupsQuery.data) !== null && _articleSubGroupsQuer !== void 0 ? _articleSubGroupsQuer : []
169
+ };
170
+ };
171
+
172
+ /**
173
+ * @description Retrieves the product field labels
174
+ */
67
175
  const useProductFieldLabels = () => {
68
176
  const productFieldsQuery = (0, _reactQuery.useQuery)('productFieldLabels', {
69
177
  queryFn: () => _publicProxyApi.publicProxyApi.getProductFieldLabels().then(res => res.data)
@@ -123,9 +231,126 @@ const useModelsQuery = _ref2 => {
123
231
  };
124
232
 
125
233
  /**
126
- * @description Retrieves the products of an order
234
+ * @description Retrieves the articles for a single order
235
+ * @param {Object} filters - The filters to apply to the articles
236
+ * @param {String} formula - The formula to apply to the articles
237
+ * @param {String} branchId - The branch id to apply to the articles
238
+ * @returns {Object} The articles and the total count of articles
127
239
  */
128
240
  exports.useModelsQuery = useModelsQuery;
241
+ const useSingleOrderArticles = exports.useSingleOrderArticles = function useSingleOrderArticles() {
242
+ let filters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
243
+ let formula = arguments.length > 1 ? arguments[1] : undefined;
244
+ let branchId = arguments.length > 2 ? arguments[2] : undefined;
245
+ const articlesQuery = (0, _reactQuery.useQuery)(['singleOrderArticles', filters, branchId], {
246
+ queryFn: async () => {
247
+ if (!branchId) {
248
+ return {
249
+ articles: [],
250
+ totalArticles: 0
251
+ };
252
+ }
253
+ const {
254
+ articleNumber,
255
+ licensePlate,
256
+ model
257
+ } = filters;
258
+ let articles = [],
259
+ totalCount = 0;
260
+ if (!articleNumber && !licensePlate && !model) {
261
+ ({
262
+ articles,
263
+ totalCount
264
+ } = await (0, _singleOrderArticles.fetchArticlesByFilters)(filters));
265
+ } else if ((licensePlate || model) && !articleNumber) {
266
+ ({
267
+ articles,
268
+ totalCount
269
+ } = await (0, _singleOrderArticles.fetchArticlesByLicensePlateAndModel)(filters, formula, branchId));
270
+ } else if (!licensePlate && !model && articleNumber) {
271
+ ({
272
+ articles,
273
+ totalCount
274
+ } = await (0, _singleOrderArticles.fetchArticlesByArticleNumbers)([articleNumber]));
275
+ }
276
+ if (totalCount === 0) {
277
+ return {
278
+ articles: [],
279
+ totalArticles: 0
280
+ };
281
+ }
282
+ return {
283
+ articles: await (0, _singleOrderArticles.enrichArticlesWithBrandsAndPrices)(articles, branchId, formula),
284
+ totalArticles: totalCount
285
+ };
286
+ }
287
+ });
288
+ return {
289
+ isLoadingArticles: articlesQuery.isFetching,
290
+ areArticlesError: articlesQuery.isError,
291
+ articles: articlesQuery === null || articlesQuery === void 0 ? void 0 : articlesQuery.data
292
+ };
293
+ };
294
+
295
+ /**
296
+ * @description Get the current cart from the custom hyper api
297
+ */
298
+ const useSingleOrderCart = () => {
299
+ const [{
300
+ model,
301
+ licensePlate,
302
+ singleOrderCart
303
+ }] = (0, _OrderSessionContext.useOrderSession)();
304
+ const formula = (0, _FormulaContext.useFormula)();
305
+ let cartOrderQuery = new URLSearchParams((0, _helpers__.removeNullishProps)({
306
+ model,
307
+ licensePlate,
308
+ formula,
309
+ isSingle: true,
310
+ cart: JSON.stringify(singleOrderCart)
311
+ })).toString();
312
+ const cartQuery = (0, _reactQuery.useQuery)(['singleOrderCart', cartOrderQuery], {
313
+ queryFn: async () => {
314
+ var _articles$articles;
315
+ if (!singleOrderCart.length) {
316
+ return {
317
+ articles: [],
318
+ totals: []
319
+ };
320
+ }
321
+ const orderResults = await _orderApi.orderApi.getOrder(cartOrderQuery).then(res => res.data);
322
+ if (!orderResults.data.cart) {
323
+ return {
324
+ cart: []
325
+ };
326
+ }
327
+ const cart = orderResults.data.cart;
328
+ const articles = await (0, _singleOrderArticles.fetchArticlesByArticleNumbers)(cart.map(article => article.articleNumber));
329
+ const cartLookup = Object.fromEntries(cart.map(item => [item.articleNumber, item]));
330
+ const articlesWithPrice = articles === null || articles === void 0 || (_articles$articles = articles.articles) === null || _articles$articles === void 0 ? void 0 : _articles$articles.map(article => {
331
+ const cartItem = cartLookup[article.articleNumber];
332
+ return _objectSpread(_objectSpread({}, article), {}, {
333
+ price: cartItem !== null && cartItem !== void 0 && cartItem.consumerTotal ? Math.round(Number(cartItem === null || cartItem === void 0 ? void 0 : cartItem.consumerTotal) * 100) / 100 : 0,
334
+ quantity: Number(cartItem === null || cartItem === void 0 ? void 0 : cartItem.quantity)
335
+ });
336
+ });
337
+ return {
338
+ articles: articlesWithPrice,
339
+ totals: orderResults.data.totals
340
+ };
341
+ }
342
+ });
343
+ return {
344
+ isLoadingCart: cartQuery.isFetching,
345
+ isCartError: cartQuery.isError,
346
+ cart: cartQuery === null || cartQuery === void 0 ? void 0 : cartQuery.data
347
+ };
348
+ };
349
+
350
+ /**
351
+ * @description Retrieves the products of an order
352
+ */
353
+ exports.useSingleOrderCart = useSingleOrderCart;
129
354
  const useProductsQuery = orderParameters => {
130
355
  var _productsQuery$data, _productsQuery$data2, _productsQuery$data3, _productsQuery$data4, _productsQuery$data5, _productsQuery$data6, _productsQuery$data7, _productsQuery$data8, _productsQuery$data9, _productsQuery$data$a, _productsQuery$data10, _productsQuery$data$c, _productsQuery$data11, _productsQuery$data$a2, _productsQuery$data12, _productsQuery$data$a3, _productsQuery$data13, _productsQuery$data$a4, _productsQuery$data14, _productsQuery$data15, _productsQuery$data16, _productsQuery$data$a5, _productsQuery$data17, _productsQuery$data$t, _productsQuery$data18;
131
356
  const {
@@ -0,0 +1,61 @@
1
+ "use strict";
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
+ require("core-js/modules/web.dom-collections.iterator.js");
7
+ Object.defineProperty(exports, "__esModule", {
8
+ value: true
9
+ });
10
+ exports.default = void 0;
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _helpers__ = require("../../__helpers__");
13
+ function _getRequireWildcardCache(e) {
14
+ if ("function" != typeof WeakMap) return null;
15
+ var r = new WeakMap(),
16
+ t = new WeakMap();
17
+ return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
18
+ return e ? t : r;
19
+ })(e);
20
+ }
21
+ function _interopRequireWildcard(e, r) {
22
+ if (!r && e && e.__esModule) return e;
23
+ if (null === e || "object" != typeof e && "function" != typeof e) return {
24
+ default: e
25
+ };
26
+ var t = _getRequireWildcardCache(r);
27
+ if (t && t.has(e)) return t.get(e);
28
+ var n = {
29
+ __proto__: null
30
+ },
31
+ a = Object.defineProperty && Object.getOwnPropertyDescriptor;
32
+ for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
33
+ var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
34
+ i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
35
+ }
36
+ return n.default = e, t && t.set(e, n), n;
37
+ }
38
+ const OutlinedButton = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
39
+ let {
40
+ type = 'button',
41
+ isNarrow = false,
42
+ isDisabled,
43
+ onClick,
44
+ label,
45
+ icon,
46
+ className
47
+ } = _ref;
48
+ return /*#__PURE__*/_react.default.createElement("button", {
49
+ className: (0, _helpers__.withStyle)("btn btn-outline-primary ".concat(isNarrow ? 'btn-narrow' : '', " ").concat(className || '')),
50
+ type: type,
51
+ ref: ref,
52
+ disabled: isDisabled,
53
+ onClick: onClick
54
+ }, icon && /*#__PURE__*/_react.default.createElement("i", {
55
+ className: icon,
56
+ style: {
57
+ marginRight: '8px'
58
+ }
59
+ }), label);
60
+ });
61
+ var _default = exports.default = OutlinedButton;
@@ -41,10 +41,11 @@ const PrimaryButton = /*#__PURE__*/(0, _react.forwardRef)((_ref, ref) => {
41
41
  isNarrow = false,
42
42
  isDisabled,
43
43
  onClick,
44
- label
44
+ label,
45
+ className
45
46
  } = _ref;
46
47
  return /*#__PURE__*/_react.default.createElement("button", {
47
- className: (0, _helpers__.withStyle)("btn btn-primary ".concat(isNarrow ? 'btn-narrow' : '')),
48
+ className: (0, _helpers__.withStyle)("btn btn-primary ".concat(isNarrow ? 'btn-narrow' : '', " ").concat(className)),
48
49
  type: type,
49
50
  ref: ref,
50
51
  disabled: isDisabled,
@@ -42,6 +42,7 @@ const ExpandableCard = _ref => {
42
42
  collapseLabel,
43
43
  body,
44
44
  expandedBody,
45
+ isCard = true,
45
46
  isDefaultExpanded = false
46
47
  } = _ref;
47
48
  const [isExpanded, setIsExpanded] = (0, _react.useState)(isDefaultExpanded);
@@ -58,7 +59,7 @@ const ExpandableCard = _ref => {
58
59
  "aria-controls": "collapseOne",
59
60
  onClick: () => setIsExpanded(prev => !prev)
60
61
  }, isExpanded ? collapseLabel : expandLabel)), /*#__PURE__*/_react.default.createElement("div", {
61
- className: (0, _helpers__.withStyle)('card-body')
62
+ className: (0, _helpers__.withStyle)("".concat(isCard ? 'card-body' : ''))
62
63
  }, /*#__PURE__*/_react.default.createElement("div", {
63
64
  className: (0, _helpers__.withStyle)('container-fluid g-0')
64
65
  }, /*#__PURE__*/_react.default.createElement("div", {
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _helpers__ = require("../__helpers__");
9
+ function _interopRequireDefault(e) {
10
+ return e && e.__esModule ? e : {
11
+ default: e
12
+ };
13
+ }
14
+ const DangerAlert = _ref => {
15
+ let {
16
+ message,
17
+ className = ''
18
+ } = _ref;
19
+ return /*#__PURE__*/_react.default.createElement("div", {
20
+ className: (0, _helpers__.withStyle)("alert alert-danger ".concat(className))
21
+ }, /*#__PURE__*/_react.default.createElement("strong", null, message || 'Er is iets fout gegaan.'));
22
+ };
23
+ var _default = exports.default = DangerAlert;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _helpers__ = require("../__helpers__");
9
+ function _interopRequireDefault(e) {
10
+ return e && e.__esModule ? e : {
11
+ default: e
12
+ };
13
+ }
14
+ const EmptyState = _ref => {
15
+ let {
16
+ message,
17
+ subMessage,
18
+ className = ''
19
+ } = _ref;
20
+ return /*#__PURE__*/_react.default.createElement("div", {
21
+ className: (0, _helpers__.withStyle)('card__horizontal') + (0, _helpers__.withStyle)(className)
22
+ }, /*#__PURE__*/_react.default.createElement("div", {
23
+ className: (0, _helpers__.withStyle)('card-body')
24
+ }, /*#__PURE__*/_react.default.createElement("h5", {
25
+ className: (0, _helpers__.withStyle)('card-title')
26
+ }, message), subMessage && subMessage.length > 0 && /*#__PURE__*/_react.default.createElement("p", {
27
+ className: (0, _helpers__.withStyle)('card-text')
28
+ }, subMessage)));
29
+ };
30
+ var _default = exports.default = EmptyState;
@@ -102,7 +102,7 @@ const DropdownInput = _ref => {
102
102
  placeholder = 'Maak een keuze',
103
103
  onChange,
104
104
  form,
105
- initialValue,
105
+ initialValue = '',
106
106
  errorMessage = '',
107
107
  isClearable = false
108
108
  } = _ref;
@@ -126,6 +126,7 @@ const DropdownInput = _ref => {
126
126
  isClearable: isClearable,
127
127
  name: name,
128
128
  form: form,
129
+ initialValue: initialValue,
129
130
  value: value,
130
131
  options: options,
131
132
  placeholder: placeholder,