thm-p3-configurator 0.0.229 → 0.0.230

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.
@@ -136,6 +136,13 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
136
136
  'Content-Type': 'application/json'
137
137
  }
138
138
  }),
139
+ postShopifyOrder: shopifyOrderPayload => authenticateClient("api/v1/single-orders/shopify", {
140
+ method: 'POST',
141
+ data: shopifyOrderPayload,
142
+ headers: {
143
+ 'Content-Type': 'application/json'
144
+ }
145
+ }),
139
146
  postAppointment: appointmentPayload => authenticateClient("api/v1/appointments", {
140
147
  method: 'POST',
141
148
  data: appointmentPayload,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useUpdatePrivateQuotationByIdMutation = exports.useUpdatePrivateAppointmentRequestByIdMutation = exports.useUpdatePrivateAppointmentByIdMutation = exports.useCreateSingleOrderMutation = exports.useCreateQuotationMutation = exports.useCreatePrivateQuotationMutation = exports.useCreatePrivateAppointmentRequestMutation = exports.useCreatePrivateAppointmentMutation = exports.useCreateAppointmentRequestMutation = void 0;
6
+ exports.useUpdatePrivateQuotationByIdMutation = exports.useUpdatePrivateAppointmentRequestByIdMutation = exports.useUpdatePrivateAppointmentByIdMutation = exports.useCreateSingleOrderMutation = exports.useCreateShopifyOrderMutation = exports.useCreateQuotationMutation = exports.useCreatePrivateQuotationMutation = exports.useCreatePrivateAppointmentRequestMutation = 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");
@@ -128,13 +128,53 @@ const useCreateSingleOrderMutation = () => {
128
128
  };
129
129
  };
130
130
 
131
+ /**
132
+ * @description Creates a Shopify order for webshop orders
133
+ */
134
+ exports.useCreateSingleOrderMutation = useCreateSingleOrderMutation;
135
+ const useCreateShopifyOrderMutation = () => {
136
+ const createShopifyOrderMutation = (0, _reactQuery.useMutation)(_ref4 => {
137
+ let {
138
+ licensePlate,
139
+ model,
140
+ cart,
141
+ customer,
142
+ channel,
143
+ formula,
144
+ branchId,
145
+ vehicle,
146
+ internalNote,
147
+ webshop
148
+ } = _ref4;
149
+ return _authenticatedProxyApi.authenticatedProxyApi.postShopifyOrder({
150
+ licensePlate,
151
+ model,
152
+ cart,
153
+ customer,
154
+ channel,
155
+ formula,
156
+ branchId,
157
+ vehicle,
158
+ internalNote,
159
+ webshop
160
+ });
161
+ });
162
+ return {
163
+ isCreatingShopifyOrder: createShopifyOrderMutation.isLoading,
164
+ isCreateShopifyOrderError: createShopifyOrderMutation.isError,
165
+ isCreateShopifyOrderSuccess: createShopifyOrderMutation.isSuccess,
166
+ resetShopifyOrderCreation: createShopifyOrderMutation.reset,
167
+ createShopifyOrder: createShopifyOrderMutation.mutate
168
+ };
169
+ };
170
+
131
171
  /**
132
172
  * @description Creates a quotation within the private order API
133
173
  * Signs the request with the accessToken
134
174
  */
135
- exports.useCreateSingleOrderMutation = useCreateSingleOrderMutation;
175
+ exports.useCreateShopifyOrderMutation = useCreateShopifyOrderMutation;
136
176
  const useCreatePrivateQuotationMutation = () => {
137
- const createQuotationMutation = (0, _reactQuery.useMutation)(_ref4 => {
177
+ const createQuotationMutation = (0, _reactQuery.useMutation)(_ref5 => {
138
178
  let {
139
179
  vehicle,
140
180
  customer,
@@ -149,7 +189,7 @@ const useCreatePrivateQuotationMutation = () => {
149
189
  formula,
150
190
  discount,
151
191
  isExitIntent = false
152
- } = _ref4;
192
+ } = _ref5;
153
193
  return _authenticatedProxyApi.authenticatedProxyApi.postQuotation({
154
194
  isExitIntent,
155
195
  model,
@@ -181,7 +221,7 @@ const useCreatePrivateQuotationMutation = () => {
181
221
  */
182
222
  exports.useCreatePrivateQuotationMutation = useCreatePrivateQuotationMutation;
183
223
  const useCreatePrivateAppointmentMutation = () => {
184
- const createPlannedAppointmentMutation = (0, _reactQuery.useMutation)(_ref5 => {
224
+ const createPlannedAppointmentMutation = (0, _reactQuery.useMutation)(_ref6 => {
185
225
  let {
186
226
  vehicle,
187
227
  customer,
@@ -197,7 +237,7 @@ const useCreatePrivateAppointmentMutation = () => {
197
237
  formula,
198
238
  discount,
199
239
  customerAgreed
200
- } = _ref5;
240
+ } = _ref6;
201
241
  return _authenticatedProxyApi.authenticatedProxyApi.postAppointment({
202
242
  appointment,
203
243
  model,
@@ -230,7 +270,7 @@ const useCreatePrivateAppointmentMutation = () => {
230
270
  */
231
271
  exports.useCreatePrivateAppointmentMutation = useCreatePrivateAppointmentMutation;
232
272
  const useCreatePrivateAppointmentRequestMutation = () => {
233
- const createAppointmentRequestMutation = (0, _reactQuery.useMutation)(_ref6 => {
273
+ const createAppointmentRequestMutation = (0, _reactQuery.useMutation)(_ref7 => {
234
274
  let {
235
275
  vehicle,
236
276
  customer,
@@ -246,7 +286,7 @@ const useCreatePrivateAppointmentRequestMutation = () => {
246
286
  formula,
247
287
  discount,
248
288
  customerAgreed
249
- } = _ref6;
289
+ } = _ref7;
250
290
  return _authenticatedProxyApi.authenticatedProxyApi.postAppointmentRequest({
251
291
  appointment,
252
292
  model,
@@ -279,7 +319,7 @@ const useCreatePrivateAppointmentRequestMutation = () => {
279
319
  */
280
320
  exports.useCreatePrivateAppointmentRequestMutation = useCreatePrivateAppointmentRequestMutation;
281
321
  const useUpdatePrivateAppointmentRequestByIdMutation = id => {
282
- const updateAppointmentRequestByIdMutation = (0, _reactQuery.useMutation)(_ref7 => {
322
+ const updateAppointmentRequestByIdMutation = (0, _reactQuery.useMutation)(_ref8 => {
283
323
  let {
284
324
  vehicle,
285
325
  customer,
@@ -296,7 +336,7 @@ const useUpdatePrivateAppointmentRequestByIdMutation = id => {
296
336
  discount,
297
337
  priceCalculationDate,
298
338
  customerAgreed
299
- } = _ref7;
339
+ } = _ref8;
300
340
  return _authenticatedProxyApi.authenticatedProxyApi.putAppointmentRequestById({
301
341
  id,
302
342
  payload: {
@@ -333,7 +373,7 @@ const useUpdatePrivateAppointmentRequestByIdMutation = id => {
333
373
  */
334
374
  exports.useUpdatePrivateAppointmentRequestByIdMutation = useUpdatePrivateAppointmentRequestByIdMutation;
335
375
  const useUpdatePrivateQuotationByIdMutation = id => {
336
- const updateQuotationMutation = (0, _reactQuery.useMutation)(_ref8 => {
376
+ const updateQuotationMutation = (0, _reactQuery.useMutation)(_ref9 => {
337
377
  let {
338
378
  vehicle,
339
379
  customer,
@@ -347,7 +387,7 @@ const useUpdatePrivateQuotationByIdMutation = id => {
347
387
  formula,
348
388
  discount,
349
389
  priceCalculationDate
350
- } = _ref8;
390
+ } = _ref9;
351
391
  return _authenticatedProxyApi.authenticatedProxyApi.putQuotationById({
352
392
  id,
353
393
  payload: {
@@ -381,7 +421,7 @@ const useUpdatePrivateQuotationByIdMutation = id => {
381
421
  */
382
422
  exports.useUpdatePrivateQuotationByIdMutation = useUpdatePrivateQuotationByIdMutation;
383
423
  const useUpdatePrivateAppointmentByIdMutation = id => {
384
- const updateAppointmentByIdMutation = (0, _reactQuery.useMutation)(_ref9 => {
424
+ const updateAppointmentByIdMutation = (0, _reactQuery.useMutation)(_ref10 => {
385
425
  let {
386
426
  vehicle,
387
427
  customer,
@@ -398,7 +438,7 @@ const useUpdatePrivateAppointmentByIdMutation = id => {
398
438
  discount,
399
439
  priceCalculationDate,
400
440
  customerAgreed
401
- } = _ref9;
441
+ } = _ref10;
402
442
  return _authenticatedProxyApi.authenticatedProxyApi.putAppointmentById({
403
443
  id,
404
444
  payload: {
@@ -7,6 +7,7 @@ require("core-js/modules/es.promise.js");
7
7
  require("core-js/modules/es.regexp.to-string.js");
8
8
  require("core-js/modules/esnext.iterator.constructor.js");
9
9
  require("core-js/modules/esnext.iterator.filter.js");
10
+ require("core-js/modules/esnext.iterator.find.js");
10
11
  require("core-js/modules/esnext.iterator.for-each.js");
11
12
  require("core-js/modules/esnext.iterator.map.js");
12
13
  require("core-js/modules/web.dom-collections.iterator.js");
@@ -22,6 +23,7 @@ require("core-js/modules/es.object.from-entries.js");
22
23
  require("core-js/modules/es.promise.js");
23
24
  require("core-js/modules/es.regexp.to-string.js");
24
25
  require("core-js/modules/esnext.iterator.constructor.js");
26
+ require("core-js/modules/esnext.iterator.find.js");
25
27
  require("core-js/modules/esnext.iterator.for-each.js");
26
28
  require("core-js/modules/esnext.iterator.map.js");
27
29
  require("core-js/modules/web.dom-collections.iterator.js");
@@ -246,9 +248,10 @@ const useSingleOrderArticles = exports.useSingleOrderArticles = function useSing
246
248
  let filters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
247
249
  let formula = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
248
250
  let branchId = arguments.length > 2 ? arguments[2] : undefined;
249
- const articlesQuery = (0, _reactQuery.useQuery)(['singleOrderArticles', filters, branchId], {
251
+ let webshop = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
252
+ const articlesQuery = (0, _reactQuery.useQuery)(['singleOrderArticles', filters, branchId, webshop], {
250
253
  queryFn: async () => {
251
- if (!branchId) {
254
+ if (!branchId && !webshop) {
252
255
  return {
253
256
  articles: [],
254
257
  totalArticles: 0
@@ -284,7 +287,13 @@ const useSingleOrderArticles = exports.useSingleOrderArticles = function useSing
284
287
  totalArticles: 0
285
288
  };
286
289
  }
287
- const currentArticles = await (0, _singleOrderArticles.enrichArticlesWithBrandsAndPrices)(articles, branchId, formula);
290
+ let currentArticles;
291
+ if (branchId) {
292
+ currentArticles = await (0, _singleOrderArticles.enrichArticlesWithBrandsAndPrices)(articles, branchId, formula);
293
+ } else {
294
+ // If webshop is selected (online order), use formula 'THC' to fetch standard prices
295
+ currentArticles = await (0, _singleOrderArticles.enrichArticlesWithBrandsAndPrices)(articles, null, 'THL');
296
+ }
288
297
  return {
289
298
  articles: currentArticles,
290
299
  totalArticles: totalCount
@@ -319,7 +328,8 @@ exports.useCountriesQuery = useCountriesQuery;
319
328
  const useSingleOrderCart = () => {
320
329
  const [{
321
330
  singleOrderCart,
322
- singleOrderFormulaCode
331
+ singleOrderFormulaCode,
332
+ webshop
323
333
  }] = (0, _OrderSessionContext.useOrderSession)();
324
334
 
325
335
  // Create lookup map for cart totals
@@ -355,15 +365,48 @@ const useSingleOrderCart = () => {
355
365
  isSingle: true,
356
366
  cart: JSON.stringify(singleOrderCart)
357
367
  })).toString();
358
- const cartQuery = (0, _reactQuery.useQuery)(['singleOrderCart', cartOrderQuery], {
368
+ const cartQuery = (0, _reactQuery.useQuery)(['singleOrderCart', cartOrderQuery, webshop], {
359
369
  queryFn: async () => {
360
- var _articles$articles;
370
+ var _articles$articles2;
361
371
  if (!singleOrderCart.length) {
362
372
  return {
363
373
  articles: [],
364
374
  totals: []
365
375
  };
366
376
  }
377
+
378
+ // If webshop is selected, use Shopify prices directly without API call
379
+ if (webshop) {
380
+ var _articles$articles;
381
+ const articles = await (0, _singleOrderArticles.fetchArticlesByArticleNumbers)(singleOrderCart.map(article => article.articleNumber));
382
+ const articlesWithPrice = articles === null || articles === void 0 || (_articles$articles = articles.articles) === null || _articles$articles === void 0 ? void 0 : _articles$articles.map(article => {
383
+ const cartItem = singleOrderCart.find(item => item.articleNumber === article.articleNumber);
384
+ const totals = cartTotalsLookup[article.articleNumber];
385
+ return _objectSpread(_objectSpread({}, article), {}, {
386
+ price: cartItem !== null && cartItem !== void 0 && cartItem.productPriceInclVat ? Math.round(Number(cartItem === null || cartItem === void 0 ? void 0 : cartItem.productPriceInclVat) * 100) / 100 : 0,
387
+ quantity: Number(cartItem === null || cartItem === void 0 ? void 0 : cartItem.quantity),
388
+ // Add the calculated totals using Shopify prices
389
+ productBtw: totals === null || totals === void 0 ? void 0 : totals.productBtw,
390
+ productTotalExclVat: totals === null || totals === void 0 ? void 0 : totals.productTotalExclVat,
391
+ productTotalInclVat: totals === null || totals === void 0 ? void 0 : totals.productTotalInclVat,
392
+ productPrice: totals === null || totals === void 0 ? void 0 : totals.productPrice,
393
+ productPriceInclVat: totals === null || totals === void 0 ? void 0 : totals.productPriceInclVat,
394
+ individualPriceInclVat: totals === null || totals === void 0 ? void 0 : totals.individualPriceInclVat,
395
+ individualPriceExclVat: totals === null || totals === void 0 ? void 0 : totals.individualPriceExclVat
396
+ });
397
+ });
398
+ return {
399
+ articles: articlesWithPrice,
400
+ totals: {
401
+ totalQuantity: Math.round(totalQuantity * 100) / 100,
402
+ totalBtw: Math.round(totalBtw * 100) / 100,
403
+ totalExclVat: Math.round(totalExclVat * 100) / 100,
404
+ totalInclVat: Math.round(totalInclVat * 100) / 100
405
+ }
406
+ };
407
+ }
408
+
409
+ // Original logic for non-webshop orders
367
410
  const orderResults = await _authenticatedProxyApi.authenticatedProxyApi.getOrder(cartOrderQuery).then(res => res.data);
368
411
  if (!orderResults.data.cart) {
369
412
  return {
@@ -373,7 +416,7 @@ const useSingleOrderCart = () => {
373
416
  const cart = orderResults.data.cart;
374
417
  const articles = await (0, _singleOrderArticles.fetchArticlesByArticleNumbers)(cart.map(article => article.articleNumber));
375
418
  const cartLookup = Object.fromEntries(cart.map(item => [item.articleNumber, item]));
376
- const articlesWithPrice = articles === null || articles === void 0 || (_articles$articles = articles.articles) === null || _articles$articles === void 0 ? void 0 : _articles$articles.map(article => {
419
+ const articlesWithPrice = articles === null || articles === void 0 || (_articles$articles2 = articles.articles) === null || _articles$articles2 === void 0 ? void 0 : _articles$articles2.map(article => {
377
420
  const cartItem = cartLookup[article.articleNumber];
378
421
  const totals = cartTotalsLookup[article.articleNumber];
379
422
  return _objectSpread(_objectSpread({}, article), {}, {
@@ -85,21 +85,22 @@ const ProductActions = _ref2 => {
85
85
  productPrice,
86
86
  showPartStockLevel,
87
87
  setShowPartStockLevel,
88
- productPriceInclVat
88
+ productPriceInclVat,
89
+ isWebshop = false
89
90
  } = _ref2;
90
91
  return /*#__PURE__*/_react.default.createElement("div", {
91
92
  className: (0, _helpers__.withStyle)('d-flex justify-content-end')
92
93
  }, /*#__PURE__*/_react.default.createElement("div", {
93
94
  className: (0, _helpers__.withStyle)('d-flex flex-column align-items-end')
94
- }, isOutOfStock ? /*#__PURE__*/_react.default.createElement("div", {
95
+ }, !isWebshop && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isOutOfStock ? /*#__PURE__*/_react.default.createElement("div", {
95
96
  className: (0, _helpers__.withStyle)('text-danger mb-1')
96
97
  }, "Niet op voorraad") : stock === _constants__.StockStatus.InsufficientStock ? /*#__PURE__*/_react.default.createElement("div", {
97
98
  className: (0, _helpers__.withStyle)('text-warning mb-1')
98
99
  }, isTmg ? "".concat(stock, " op voorraad") : 'Weinig op voorraad') : /*#__PURE__*/_react.default.createElement("div", {
99
100
  className: (0, _helpers__.withStyle)('text-success mb-1')
100
- }, isTmg ? "".concat(stock, " op voorraad") : 'Op voorraad'), /*#__PURE__*/_react.default.createElement("div", {
101
+ }, isTmg ? "".concat(stock, " op voorraad") : 'Op voorraad')), /*#__PURE__*/_react.default.createElement("div", {
101
102
  className: (0, _helpers__.withStyle)('d-flex align-items-center')
102
- }, /*#__PURE__*/_react.default.createElement(_OutlinedButton.default, {
103
+ }, !isWebshop && /*#__PURE__*/_react.default.createElement(_OutlinedButton.default, {
103
104
  style: {
104
105
  marginRight: '1rem'
105
106
  },
@@ -129,7 +130,8 @@ const ProductCategories = _ref3 => {
129
130
  preferredPart = null,
130
131
  partStockLevels = null,
131
132
  showPartStockLevel = false,
132
- brandName = null
133
+ brandName = null,
134
+ isWebshop = false
133
135
  } = _ref3;
134
136
  return /*#__PURE__*/_react.default.createElement("div", {
135
137
  className: (0, _helpers__.withStyle)('col-md-6')
@@ -143,7 +145,7 @@ const ProductCategories = _ref3 => {
143
145
  className: (0, _helpers__.withStyle)('fst-italic mb-0')
144
146
  }, /*#__PURE__*/_react.default.createElement("strong", null, "Subgroep:"), " ", productSubgroup), preferredPart && /*#__PURE__*/_react.default.createElement("p", {
145
147
  className: (0, _helpers__.withStyle)('fst-italic mb-0')
146
- }, /*#__PURE__*/_react.default.createElement("strong", null, "Voorkeur onderdeel:"), " ", preferredPart.preferredPart), showPartStockLevel && (partStockLevels === null || partStockLevels === void 0 ? void 0 : partStockLevels.status) && /*#__PURE__*/_react.default.createElement("p", {
148
+ }, /*#__PURE__*/_react.default.createElement("strong", null, "Voorkeur onderdeel:"), " ", preferredPart.preferredPart), !isWebshop && showPartStockLevel && (partStockLevels === null || partStockLevels === void 0 ? void 0 : partStockLevels.status) && /*#__PURE__*/_react.default.createElement("p", {
147
149
  className: (0, _helpers__.withStyle)('fst-italic mb-0')
148
150
  }, /*#__PURE__*/_react.default.createElement("small", {
149
151
  className: (0, _helpers__.withStyle)(partStockLevels.status === _constants__.StockStatus.OutOfStock ? 'text-danger' : partStockLevels.status === _constants__.StockStatus.InsufficientStock ? 'text-warning' : 'text-success')
@@ -174,7 +176,8 @@ const SingleOrderProductCard = _ref4 => {
174
176
  isTmg = false,
175
177
  parts = [],
176
178
  branchId,
177
- brandName = null
179
+ brandName = null,
180
+ isWebshop = false
178
181
  } = _ref4;
179
182
  const {
180
183
  productFieldLabels
@@ -246,7 +249,8 @@ const SingleOrderProductCard = _ref4 => {
246
249
  articleNumber: articleNumber,
247
250
  preferredPart: preferredPart,
248
251
  partStockLevels: partStockLevels,
249
- showPartStockLevel: showPartStockLevel
252
+ showPartStockLevel: showPartStockLevel,
253
+ isWebshop: isWebshop
250
254
  }), (filteredProductSpecifications === null || filteredProductSpecifications === void 0 ? void 0 : filteredProductSpecifications.length) > 0 && /*#__PURE__*/_react.default.createElement(_ProductCardSpecifications.default, {
251
255
  specifications: filteredProductSpecifications,
252
256
  className: isModelArticle ? '' : 'w-100'
@@ -265,7 +269,8 @@ const SingleOrderProductCard = _ref4 => {
265
269
  handleSelected: handleSelected,
266
270
  removeFromCart: removeFromCart,
267
271
  productPrice: productPrice,
268
- productPriceInclVat: productPriceInclVat
272
+ productPriceInclVat: productPriceInclVat,
273
+ isWebshop: isWebshop
269
274
  })))));
270
275
  };
271
276
  var _default = exports.default = SingleOrderProductCard;
@@ -137,7 +137,8 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
137
137
  selectedBranch,
138
138
  appointment,
139
139
  internalNote,
140
- vehicle
140
+ vehicle,
141
+ webshop
141
142
  }, dispatch] = (0, _OrderSessionContext.useOrderSession)();
142
143
  const {
143
144
  branchById
@@ -205,7 +206,18 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
205
206
  };
206
207
  const validateForm = async () => {
207
208
  try {
208
- await customerDetailsFormSchema.validate(_objectSpread(_objectSpread({}, customer), {}, {
209
+ let validationSchema = webshop ? customerDetailsFormSchema.omit(['channelType', 'channelId']) : customerDetailsFormSchema;
210
+
211
+ // For webshop orders, make certain customer fields required
212
+ if (webshop) {
213
+ validationSchema = validationSchema.shape({
214
+ firstName: (0, _yup.string)().required('Voornaam is verplicht'),
215
+ lastName: (0, _yup.string)().required('Achternaam is verplicht'),
216
+ email: (0, _yup.string)().required('E-mailadres is verplicht').email('E-mailadres is ongeldig'),
217
+ phoneNumber: (0, _yup.string)().required('Telefoonnummer is verplicht')
218
+ });
219
+ }
220
+ await validationSchema.validate(_objectSpread(_objectSpread({}, customer), {}, {
209
221
  channelType: (channel === null || channel === void 0 ? void 0 : channel.channelType) || '',
210
222
  channelId: (channel === null || channel === void 0 ? void 0 : channel.channelId) || ''
211
223
  }), {
@@ -237,7 +249,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
237
249
  label: 'Vestiginggegevens invullen?',
238
250
  onClick: handleAutofillButtonClicked,
239
251
  isDisabled: !branchById
240
- })), /*#__PURE__*/_react.default.createElement("div", {
252
+ })), !webshop && /*#__PURE__*/_react.default.createElement("div", {
241
253
  className: (0, _helpers__.withStyle)('col-12 mb-2')
242
254
  }, /*#__PURE__*/_react.default.createElement(_DropdownInput.default, {
243
255
  options: marketingChannels === null || marketingChannels === void 0 ? void 0 : marketingChannels.map(channel => ({
@@ -294,7 +306,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
294
306
  firstName: value
295
307
  }
296
308
  }),
297
- isRequired: false,
309
+ isRequired: webshop,
298
310
  form: form,
299
311
  label: "Voornaam:",
300
312
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['firstName']
@@ -324,7 +336,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
324
336
  lastName: value
325
337
  }
326
338
  }),
327
- isRequired: false,
339
+ isRequired: webshop,
328
340
  form: form,
329
341
  label: "Achternaam:",
330
342
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['lastName']
@@ -339,7 +351,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
339
351
  email: value
340
352
  }
341
353
  }),
342
- isRequired: false,
354
+ isRequired: webshop,
343
355
  form: form,
344
356
  label: "E-mailadres:",
345
357
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['email']
@@ -355,7 +367,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
355
367
  }
356
368
  }),
357
369
  form: form,
358
- isRequired: false,
370
+ isRequired: webshop,
359
371
  label: "Telefoonnummer:",
360
372
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['phoneNumber']
361
373
  }), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
@@ -418,7 +430,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
418
430
  form: form,
419
431
  label: "Stad:",
420
432
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['city']
421
- })))), /*#__PURE__*/_react.default.createElement("div", {
433
+ })))), !webshop && /*#__PURE__*/_react.default.createElement("div", {
422
434
  className: (0, _helpers__.withStyle)('col-12')
423
435
  }, /*#__PURE__*/_react.default.createElement(_CardWide.default, null, /*#__PURE__*/_react.default.createElement("div", {
424
436
  className: (0, _helpers__.withStyle)('row')
@@ -203,7 +203,8 @@ const InternalAppointmentForm = _ref => {
203
203
  executionAnswer1,
204
204
  executionAnswer2,
205
205
  priceCalculationDate,
206
- selectedExtras
206
+ selectedExtras,
207
+ webshop
207
208
  } = order;
208
209
  const [errors, setErrors] = (0, _react.useState)({});
209
210
  const [_licensePlate, _setLicensePlate] = (0, _react.useState)();
@@ -1601,7 +1602,7 @@ const InternalAppointmentForm = _ref => {
1601
1602
  label: /*#__PURE__*/_react.default.createElement("strong", null, "Bovenstaande gecommuniceerd naar en akkoord bevonden door klant")
1602
1603
  })) : /*#__PURE__*/_react.default.createElement("div", {
1603
1604
  className: (0, _helpers__.withStyle)('text-muted my-2')
1604
- }, "Geen opties gevonden..."))), ' ')), /*#__PURE__*/_react.default.createElement("div", {
1605
+ }, "Geen opties gevonden..."))), ' ')), !webshop && /*#__PURE__*/_react.default.createElement("div", {
1605
1606
  className: (0, _helpers__.withStyle)('col-12')
1606
1607
  }, /*#__PURE__*/_react.default.createElement(_CardWide.default, null, /*#__PURE__*/_react.default.createElement("div", {
1607
1608
  className: (0, _helpers__.withStyle)('row')
@@ -27,7 +27,9 @@ var _constants__ = require("../../__constants__");
27
27
  var _FormulaContext = require("../../__context__/FormulaContext");
28
28
  var _OrderSessionContext = require("../../__context__/OrderSessionContext");
29
29
  var _useIsSingleOrder = _interopRequireDefault(require("../../__hooks__/useIsSingleOrder"));
30
+ var _useIsTmg = require("../../__hooks__/useIsTmg");
30
31
  var _LocalStorageWorker = require("../../__services__/LocalStorageWorker");
32
+ var _OrderTypeSelectorModal = _interopRequireWildcard(require("./OrderTypeSelectorModal"));
31
33
  function _interopRequireDefault(e) {
32
34
  return e && e.__esModule ? e : {
33
35
  default: e
@@ -236,20 +238,18 @@ const InternalBranchSelectorModal = () => {
236
238
  const authSession = _LocalStorageWorker.lsw.getJson(_constants__.AUTH_SESSION_KEY);
237
239
  const isSingleOrderPage = (0, _useIsSingleOrder.default)();
238
240
  const formula = (0, _FormulaContext.useFormula)();
239
- const isTMGOrganization = _react.default.useMemo(() => {
240
- var _branchTypes$byId$aut, _authSession$branch2;
241
- return (branchTypes === null || branchTypes === void 0 || (_branchTypes$byId$aut = branchTypes.byId[authSession === null || authSession === void 0 || (_authSession$branch2 = authSession.branch) === null || _authSession$branch2 === void 0 || (_authSession$branch2 = _authSession$branch2.organisatietype) === null || _authSession$branch2 === void 0 ? void 0 : _authSession$branch2[0]]) === null || _branchTypes$byId$aut === void 0 ? void 0 : _branchTypes$byId$aut.title) === _constants__.TMG_ORGANIZATION_TYPE;
242
- }, [branchTypes, authSession]);
241
+ const isTMGOrganization = (0, _useIsTmg.useIsTmg)();
243
242
  (0, _react.useEffect)(() => {
244
243
  _setSelectedBranchId(undefined);
245
244
  }, [isSingleOrderPage]);
246
245
  const isLocation = _react.default.useMemo(() => {
247
- var _branchTypes$byId$aut2, _authSession$branch3;
248
- return (branchTypes === null || branchTypes === void 0 || (_branchTypes$byId$aut2 = branchTypes.byId[authSession === null || authSession === void 0 || (_authSession$branch3 = authSession.branch) === null || _authSession$branch3 === void 0 || (_authSession$branch3 = _authSession$branch3.organisatietype) === null || _authSession$branch3 === void 0 ? void 0 : _authSession$branch3[0]]) === null || _branchTypes$byId$aut2 === void 0 ? void 0 : _branchTypes$byId$aut2.title) === _constants__.LOCATION_TYPE;
246
+ var _branchTypes$byId$aut, _authSession$branch2;
247
+ return (branchTypes === null || branchTypes === void 0 || (_branchTypes$byId$aut = branchTypes.byId[authSession === null || authSession === void 0 || (_authSession$branch2 = authSession.branch) === null || _authSession$branch2 === void 0 || (_authSession$branch2 = _authSession$branch2.organisatietype) === null || _authSession$branch2 === void 0 ? void 0 : _authSession$branch2[0]]) === null || _branchTypes$byId$aut === void 0 ? void 0 : _branchTypes$byId$aut.title) === _constants__.LOCATION_TYPE;
249
248
  }, [branchTypes, authSession]);
250
249
  const [{
251
250
  selectedBranch,
252
- existingDossierId
251
+ existingDossierId,
252
+ orderType
253
253
  }, dispatch] = (0, _OrderSessionContext.useOrderSession)();
254
254
  const {
255
255
  myBranches,
@@ -274,8 +274,13 @@ const InternalBranchSelectorModal = () => {
274
274
  className: "thm-configurator-wrapper--offset"
275
275
  }, /*#__PURE__*/_react.default.createElement(_FullPageSpinner.default, null));
276
276
  }
277
+ if ((shouldShowModalForSingleOrder || shouldShowModalForOtherPages) && isTMGOrganization && !orderType) {
278
+ return /*#__PURE__*/_react.default.createElement(_OrderTypeSelectorModal.default, {
279
+ isOpen: true
280
+ });
281
+ }
277
282
  return /*#__PURE__*/_react.default.createElement(_Modal.default, {
278
- isOpen: shouldShowModalForSingleOrder || shouldShowModalForOtherPages,
283
+ isOpen: (shouldShowModalForSingleOrder || shouldShowModalForOtherPages) && !(isTMGOrganization && orderType === _OrderTypeSelectorModal.ORDER_TYPES.ONLINE),
279
284
  title: 'Kies een vestiging:',
280
285
  size: "wide",
281
286
  hasSecondaryButton: false,
@@ -95,8 +95,13 @@ const InternalSingleOrderProductOverview = _ref => {
95
95
  durationAnswer,
96
96
  executionAnswer1,
97
97
  singleOrderFormulaCode,
98
- executionAnswer2
98
+ executionAnswer2,
99
+ webshop
99
100
  }] = (0, _OrderSessionContext.useOrderSession)();
101
+ const orderSession = {
102
+ webshop
103
+ }; // Added for filter access
104
+
100
105
  let formula = (0, _FormulaContext.useFormula)();
101
106
  if (singleOrderFormulaCode) {
102
107
  formula = singleOrderFormulaCode;
@@ -114,7 +119,7 @@ const InternalSingleOrderProductOverview = _ref => {
114
119
  articles,
115
120
  areArticlesError,
116
121
  areArticlesLoaded
117
- } = (0, _queries.useSingleOrderArticles)(mergedFilters, formula, selectedBranch);
122
+ } = (0, _queries.useSingleOrderArticles)(mergedFilters, formula, selectedBranch, orderSession.webshop);
118
123
  return /*#__PURE__*/_react.default.createElement("div", {
119
124
  className: (0, _helpers__.withStyle)('flex-grow-1 h-100')
120
125
  }, !hasActiveFilters && /*#__PURE__*/_react.default.createElement(_EmptyState.default, {
@@ -126,9 +131,17 @@ const InternalSingleOrderProductOverview = _ref => {
126
131
  }), 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 || (_articles$articles3 = _articles$articles3.filter(article => {
127
132
  var _article$locationPric;
128
133
  const productPrice = Number(article === null || article === void 0 || (_article$locationPric = article.locationPrices) === null || _article$locationPric === void 0 ? void 0 : _article$locationPric.priceExclVat);
134
+ // If webshop is selected, only show products with a price from Shopify
135
+ if (orderSession.webshop) {
136
+ return productPrice > 0;
137
+ }
138
+ // Otherwise, show if TMG or has price
129
139
  return isTmg || productPrice > 0;
130
140
  })) === null || _articles$articles3 === void 0 ? void 0 : _articles$articles3.map(article => {
131
- var _cart$find$quantity, _cart$find, _article$locationPric2, _article$locationPric3, _article$locationPric4, _article$locationPric7, _article$locationPric8;
141
+ var _article$locationPric2, _article$locationPric3, _article$locationPric4, _cart$find$quantity, _cart$find, _article$locationPric7, _article$locationPric8;
142
+ // Hide stock for webshops (online orders)
143
+ const stockQuantity = orderSession.webshop || isTmg ? 0 : (_article$locationPric2 = article === null || article === void 0 || (_article$locationPric3 = article.locationPrices) === null || _article$locationPric3 === void 0 || (_article$locationPric3 = _article$locationPric3.stock) === null || _article$locationPric3 === void 0 ? void 0 : _article$locationPric3.quantity) !== null && _article$locationPric2 !== void 0 ? _article$locationPric2 : 0;
144
+ const isOutOfStock = !orderSession.webshop && !isTmg && (article === null || article === void 0 || (_article$locationPric4 = article.locationPrices) === null || _article$locationPric4 === void 0 || (_article$locationPric4 = _article$locationPric4.stock) === null || _article$locationPric4 === void 0 ? void 0 : _article$locationPric4.status) == _constants__.StockStatus.OutOfStock;
132
145
  return /*#__PURE__*/_react.default.createElement(_SingleOrderProductCard.default, {
133
146
  isTmg: isTmg,
134
147
  branchId: selectedBranch,
@@ -141,8 +154,8 @@ const InternalSingleOrderProductOverview = _ref => {
141
154
  productId: article.articleNumber,
142
155
  quantity: (_cart$find$quantity = (_cart$find = cart.find(product => product.articleNumber === article.articleNumber)) === null || _cart$find === void 0 ? void 0 : _cart$find.quantity) !== null && _cart$find$quantity !== void 0 ? _cart$find$quantity : 0,
143
156
  isSelected: false,
144
- stock: (_article$locationPric2 = article === null || article === void 0 || (_article$locationPric3 = article.locationPrices) === null || _article$locationPric3 === void 0 || (_article$locationPric3 = _article$locationPric3.stock) === null || _article$locationPric3 === void 0 ? void 0 : _article$locationPric3.quantity) !== null && _article$locationPric2 !== void 0 ? _article$locationPric2 : 0,
145
- isOutOfStock: (article === null || article === void 0 || (_article$locationPric4 = article.locationPrices) === null || _article$locationPric4 === void 0 || (_article$locationPric4 = _article$locationPric4.stock) === null || _article$locationPric4 === void 0 ? void 0 : _article$locationPric4.status) == _constants__.StockStatus.OutOfStock,
157
+ stock: stockQuantity,
158
+ isOutOfStock: isOutOfStock,
146
159
  handleSelected: () => {
147
160
  var _article$locationPric5, _article$locationPric6;
148
161
  return handleQuantityChange(article.articleNumber, 1, article === null || article === void 0 || (_article$locationPric5 = article.locationPrices) === null || _article$locationPric5 === void 0 ? void 0 : _article$locationPric5.priceExclVat, article === null || article === void 0 || (_article$locationPric6 = article.locationPrices) === null || _article$locationPric6 === void 0 ? void 0 : _article$locationPric6.priceInclVat);
@@ -167,7 +180,8 @@ const InternalSingleOrderProductOverview = _ref => {
167
180
  productPriceInclVat: Number(article === null || article === void 0 || (_article$locationPric8 = article.locationPrices) === null || _article$locationPric8 === void 0 ? void 0 : _article$locationPric8.priceInclVat).toFixed(2),
168
181
  productType: article === null || article === void 0 ? void 0 : article.type,
169
182
  productGroup: article === null || article === void 0 ? void 0 : article.group,
170
- productSubgroup: article === null || article === void 0 ? void 0 : article.subgroup
183
+ productSubgroup: article === null || article === void 0 ? void 0 : article.subgroup,
184
+ isWebshop: !!orderSession.webshop
171
185
  });
172
186
  })), !articles && hasActiveFilters && !areArticlesLoaded && !areArticlesError && /*#__PURE__*/_react.default.createElement("div", {
173
187
  className: (0, _helpers__.withStyle)('flex-grow-1 h-100')
@@ -0,0 +1,136 @@
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
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.default = exports.WEBSHOPS = exports.ORDER_TYPES = void 0;
10
+ require("core-js/modules/web.dom-collections.iterator.js");
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _Modal = _interopRequireDefault(require("../../__components__/Modal"));
13
+ var _OrderSessionContext = require("../../__context__/OrderSessionContext");
14
+ var _helpers__ = require("../../__helpers__");
15
+ function _interopRequireDefault(e) {
16
+ return e && e.__esModule ? e : {
17
+ default: e
18
+ };
19
+ }
20
+ function _getRequireWildcardCache(e) {
21
+ if ("function" != typeof WeakMap) return null;
22
+ var r = new WeakMap(),
23
+ t = new WeakMap();
24
+ return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
25
+ return e ? t : r;
26
+ })(e);
27
+ }
28
+ function _interopRequireWildcard(e, r) {
29
+ if (!r && e && e.__esModule) return e;
30
+ if (null === e || "object" != typeof e && "function" != typeof e) return {
31
+ default: e
32
+ };
33
+ var t = _getRequireWildcardCache(r);
34
+ if (t && t.has(e)) return t.get(e);
35
+ var n = {
36
+ __proto__: null
37
+ },
38
+ a = Object.defineProperty && Object.getOwnPropertyDescriptor;
39
+ for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
40
+ var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
41
+ i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
42
+ }
43
+ return n.default = e, t && t.set(e, n), n;
44
+ }
45
+ const ORDER_TYPES = exports.ORDER_TYPES = {
46
+ ONLINE: 'online',
47
+ OFFLINE: 'offline'
48
+ };
49
+ const WEBSHOPS = exports.WEBSHOPS = {
50
+ TREKHAAKLAND: 'Trekhaakland',
51
+ TREKHAKEN_NL: 'Trekhaken.nl'
52
+ };
53
+ const OrderTypeSelectorModal = _ref => {
54
+ let {
55
+ isOpen
56
+ } = _ref;
57
+ const [, dispatch] = (0, _OrderSessionContext.useOrderSession)();
58
+ const [step, setStep] = (0, _react.useState)('type'); // 'type' or 'webshop'
59
+
60
+ const handleTypeSelect = type => {
61
+ if (type === ORDER_TYPES.ONLINE) {
62
+ setStep('webshop');
63
+ } else {
64
+ dispatch({
65
+ type: _OrderSessionContext.orderSessionActions.SET_ORDER_TYPE,
66
+ payload: {
67
+ orderType: type
68
+ }
69
+ });
70
+ }
71
+ };
72
+ const handleWebshopSelect = webshop => {
73
+ dispatch({
74
+ type: _OrderSessionContext.orderSessionActions.SET_WEBSHOP,
75
+ payload: {
76
+ webshop
77
+ }
78
+ });
79
+ dispatch({
80
+ type: _OrderSessionContext.orderSessionActions.SET_ORDER_TYPE,
81
+ payload: {
82
+ orderType: ORDER_TYPES.ONLINE
83
+ }
84
+ });
85
+ };
86
+ const handleBack = () => {
87
+ setStep('type');
88
+ };
89
+ return /*#__PURE__*/_react.default.createElement(_Modal.default, {
90
+ isOpen: isOpen,
91
+ title: step === 'type' ? 'Bestellings type:' : 'Kies een webshop:',
92
+ size: "regular",
93
+ hasPrimaryButton: false,
94
+ hasSecondaryButton: false,
95
+ onClose: step === 'webshop' ? handleBack : undefined
96
+ }, /*#__PURE__*/_react.default.createElement("div", {
97
+ className: (0, _helpers__.withStyle)('d-flex flex-column gap-3 p-2')
98
+ }, step === 'type' && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
99
+ type: "button",
100
+ className: (0, _helpers__.withStyle)('btn btn-outline-primary btn-lg w-100 d-flex align-items-center justify-content-center p-4'),
101
+ style: {
102
+ minHeight: '100px',
103
+ fontSize: '1.2rem'
104
+ },
105
+ onClick: () => handleTypeSelect(ORDER_TYPES.ONLINE)
106
+ }, "Online order"), /*#__PURE__*/_react.default.createElement("button", {
107
+ type: "button",
108
+ className: (0, _helpers__.withStyle)('btn btn-outline-secondary btn-lg w-100 d-flex align-items-center justify-content-center p-4'),
109
+ style: {
110
+ minHeight: '100px',
111
+ fontSize: '1.2rem'
112
+ },
113
+ onClick: () => handleTypeSelect(ORDER_TYPES.OFFLINE)
114
+ }, "Offline order")), step === 'webshop' && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("button", {
115
+ type: "button",
116
+ className: (0, _helpers__.withStyle)('btn btn-outline-primary btn-lg w-100 d-flex align-items-center justify-content-center p-4'),
117
+ style: {
118
+ minHeight: '80px'
119
+ },
120
+ onClick: () => handleWebshopSelect(WEBSHOPS.TREKHAAKLAND)
121
+ }, "Trekhaakland"), /*#__PURE__*/_react.default.createElement("button", {
122
+ type: "button",
123
+ className: (0, _helpers__.withStyle)('btn btn-outline-primary btn-lg w-100 d-flex align-items-center justify-content-center p-4'),
124
+ style: {
125
+ minHeight: '80px'
126
+ },
127
+ onClick: () => handleWebshopSelect(WEBSHOPS.TREKHAKEN_NL)
128
+ }, "Trekhaken.nl"), /*#__PURE__*/_react.default.createElement("button", {
129
+ type: "button",
130
+ className: (0, _helpers__.withStyle)('btn btn-link text-muted mt-2'),
131
+ onClick: handleBack
132
+ }, /*#__PURE__*/_react.default.createElement("i", {
133
+ className: "fas fa-arrow-left me-2"
134
+ }), "Terug"))));
135
+ };
136
+ var _default = exports.default = OrderTypeSelectorModal;
@@ -165,13 +165,17 @@ const INITIAL_ORDER_SESSION_STATE = {
165
165
  countryId: null,
166
166
  vatNumber: '',
167
167
  anwbId: null
168
- }
168
+ },
169
+ orderType: null,
170
+ webshop: null
169
171
  };
170
172
  const orderSessionActions = exports.orderSessionActions = {
171
173
  INITIALIZE_NEW_ORDER: 'INITIALIZE_NEW_ORDER',
172
174
  INITIALIZE_EXISTING_ORDER: 'INITIALIZE_EXISTING_ORDER',
173
175
  RESET_LICENSEPLATE_FILTERS: 'RESET_LICENSEPLATE_FILTERS',
174
176
  SET_LICENSEPLATE_FILTERS: 'SET_LICENSEPLATE_FILTERS',
177
+ SET_ORDER_TYPE: 'SET_ORDER_TYPE',
178
+ SET_WEBSHOP: 'SET_WEBSHOP',
175
179
  SET_IS_TOUCHED: 'SET_IS_TOUCHED',
176
180
  SET_LICENSE_PLATE: 'SET_LICENSE_PLATE',
177
181
  SET_BUILD_YEAR: 'SET_BUILD_YEAR',
@@ -317,7 +321,12 @@ const orderSessionReducer = (state, action) => {
317
321
  {
318
322
  return _objectSpread(_objectSpread({}, INITIAL_ORDER_SESSION_STATE), {}, {
319
323
  singleOrderCart: [],
320
- isTouched: true
324
+ isTouched: true,
325
+ // Preserve these to prevent OrderTypeSelectorModal from reopening
326
+ selectedBranch: state.selectedBranch,
327
+ orderType: state.orderType,
328
+ webshop: state.webshop,
329
+ singleOrderFormulaCode: state.singleOrderFormulaCode
321
330
  });
322
331
  }
323
332
  case orderSessionActions.SET_VEHICLE_CHASSIS_NUMBER:
@@ -1038,6 +1047,24 @@ const orderSessionReducer = (state, action) => {
1038
1047
  })
1039
1048
  });
1040
1049
  }
1050
+ case orderSessionActions.SET_ORDER_TYPE:
1051
+ {
1052
+ const {
1053
+ orderType
1054
+ } = action.payload;
1055
+ return _objectSpread(_objectSpread({}, state), {}, {
1056
+ orderType
1057
+ });
1058
+ }
1059
+ case orderSessionActions.SET_WEBSHOP:
1060
+ {
1061
+ const {
1062
+ webshop
1063
+ } = action.payload;
1064
+ return _objectSpread(_objectSpread({}, state), {}, {
1065
+ webshop
1066
+ });
1067
+ }
1041
1068
  default:
1042
1069
  return state;
1043
1070
  }
@@ -131,6 +131,12 @@ const InternalSingleOrderPage = () => {
131
131
  isCreateSingleOrderError,
132
132
  isCreateSingleOrderSuccess
133
133
  } = (0, _mutations.useCreateSingleOrderMutation)();
134
+ const {
135
+ createShopifyOrder,
136
+ isCreatingShopifyOrder,
137
+ isCreateShopifyOrderError,
138
+ isCreateShopifyOrderSuccess
139
+ } = (0, _mutations.useCreateShopifyOrderMutation)();
134
140
  const [{
135
141
  singleOrderCart,
136
142
  channel,
@@ -142,7 +148,8 @@ const InternalSingleOrderPage = () => {
142
148
  singleOrderFormulaCode,
143
149
  licensePlate,
144
150
  durationAnswer,
145
- model
151
+ model,
152
+ webshop
146
153
  }, dispatch] = (0, _OrderSessionContext.useOrderSession)();
147
154
  let formula = (0, _FormulaContext.useFormula)();
148
155
  if (singleOrderFormulaCode) {
@@ -154,13 +161,15 @@ const InternalSingleOrderPage = () => {
154
161
  isLoadingBranchById
155
162
  } = (0, _queries.useBranchByIdOrWidgetId)(selectedBranch);
156
163
  (0, _react.useEffect)(() => {
157
- if (isCreateSingleOrderSuccess) {
164
+ if (isCreateSingleOrderSuccess || isCreateShopifyOrderSuccess) {
165
+ setIsDirectSelectorModalOpen(false);
166
+ setHasUserDismissedModal(true);
158
167
  dispatch({
159
168
  type: _OrderSessionContext.orderSessionActions.EMPTY_SINGLE_ORDER_CART
160
169
  });
161
170
  setShowProductOverview(true);
162
171
  }
163
- }, [isCreateSingleOrderSuccess]);
172
+ }, [isCreateSingleOrderSuccess, isCreateShopifyOrderSuccess]);
164
173
 
165
174
  // Reset dismissed state when branch changes
166
175
  (0, _react.useEffect)(() => {
@@ -170,15 +179,18 @@ const InternalSingleOrderPage = () => {
170
179
  }, [selectedBranch]);
171
180
  (0, _react.useEffect)(() => {
172
181
  const hasActiveFilters = filters.type || filters.group || filters.subgroup || filters.articleNumber || filters.showAllArticles;
173
- if (selectedBranch && !licensePlate && !model && !hasActiveFilters && !isLoadingBranchById && !hasUserDismissedModal) {
182
+
183
+ // Don't open modal if order was just successfully created
184
+ const orderJustCompleted = isCreateSingleOrderSuccess || isCreateShopifyOrderSuccess;
185
+ if (showProductOverview && selectedBranch && !licensePlate && !model && !hasActiveFilters && !isLoadingBranchById && !hasUserDismissedModal && !orderJustCompleted) {
174
186
  setIsDirectSelectorModalOpen(true);
175
187
  } else {
176
- // Close modal if filters become active while it's open
177
- if (hasActiveFilters && isDirectSelectorModalOpen) {
188
+ // Close modal if filters become active or we're on details page
189
+ if ((hasActiveFilters || !showProductOverview) && isDirectSelectorModalOpen) {
178
190
  setIsDirectSelectorModalOpen(false);
179
191
  }
180
192
  }
181
- }, [selectedBranch, licensePlate, model, filters, isLoadingBranchById, isDirectSelectorModalOpen, hasUserDismissedModal]);
193
+ }, [selectedBranch, licensePlate, model, filters, isLoadingBranchById, isDirectSelectorModalOpen, hasUserDismissedModal, isCreateSingleOrderSuccess, isCreateShopifyOrderSuccess, showProductOverview]);
182
194
  const resetOrderSession = (0, _react.useCallback)(() => {
183
195
  dispatch({
184
196
  type: _OrderSessionContext.orderSessionActions.RESET_SINGLE_ORDER
@@ -307,31 +319,51 @@ const InternalSingleOrderPage = () => {
307
319
  var _customerFormRef$curr;
308
320
  const isValid = await ((_customerFormRef$curr = customerFormRef.current) === null || _customerFormRef$curr === void 0 ? void 0 : _customerFormRef$curr.validateForm());
309
321
  if (isValid) {
310
- const preferredDateTime = appointment !== null && appointment !== void 0 && appointment.date && appointment !== null && appointment !== void 0 && appointment.time ? (0, _helpers__.parseDateAndTimeToTimestamp)(appointment === null || appointment === void 0 ? void 0 : appointment.date, appointment === null || appointment === void 0 ? void 0 : appointment.time) : null;
311
- vehicle.ownershipType = vehicle.singleOrderOwnershipType;
312
- delete vehicle.singleOrderOwnershipType;
313
- createSingleOrder({
314
- licensePlate: filters.licensePlate,
315
- model: filters.model,
316
- cart: singleOrderCart,
317
- vehicle,
318
- customer,
319
- formula,
320
- branchId: selectedBranch,
321
- channel,
322
- preferredDateTime,
323
- internalNote: internalNote === null || internalNote === void 0 ? void 0 : internalNote.internalNote
322
+ const vehiclePayload = _objectSpread(_objectSpread({}, vehicle), {}, {
323
+ ownershipType: vehicle.singleOrderOwnershipType || vehicle.ownershipType
324
324
  });
325
+ delete vehiclePayload.singleOrderOwnershipType;
326
+
327
+ // If webshop is selected, create Shopify order instead
328
+ if (webshop) {
329
+ createShopifyOrder({
330
+ licensePlate: filters.licensePlate,
331
+ model: filters.model,
332
+ cart: singleOrderCart,
333
+ vehicle: vehiclePayload,
334
+ customer,
335
+ formula,
336
+ webshop,
337
+ branchId: selectedBranch,
338
+ channel,
339
+ internalNote: internalNote === null || internalNote === void 0 ? void 0 : internalNote.internalNote
340
+ });
341
+ } else {
342
+ // Regular flow for offline orders
343
+ const preferredDateTime = appointment !== null && appointment !== void 0 && appointment.date && appointment !== null && appointment !== void 0 && appointment.time ? (0, _helpers__.parseDateAndTimeToTimestamp)(appointment === null || appointment === void 0 ? void 0 : appointment.date, appointment === null || appointment === void 0 ? void 0 : appointment.time) : null;
344
+ createSingleOrder({
345
+ licensePlate: filters.licensePlate,
346
+ model: filters.model,
347
+ cart: singleOrderCart,
348
+ vehicle: vehiclePayload,
349
+ customer,
350
+ formula,
351
+ branchId: selectedBranch,
352
+ channel,
353
+ preferredDateTime,
354
+ internalNote: internalNote === null || internalNote === void 0 ? void 0 : internalNote.internalNote
355
+ });
356
+ }
325
357
  }
326
358
  };
327
359
  return /*#__PURE__*/_react.default.createElement("div", {
328
360
  className: (0, _helpers__.withStyle)('vh-100')
329
- }, isCreateSingleOrderSuccess && /*#__PURE__*/_react.default.createElement(_InternalSingleOrderSuccessModal.default, {
330
- isOpen: isCreateSingleOrderSuccess
361
+ }, (isCreateSingleOrderSuccess || isCreateShopifyOrderSuccess) && /*#__PURE__*/_react.default.createElement(_InternalSingleOrderSuccessModal.default, {
362
+ isOpen: isCreateSingleOrderSuccess || isCreateShopifyOrderSuccess
331
363
  }), /*#__PURE__*/_react.default.createElement(_Header.default, {
332
364
  title: "Losse producten bestellen",
333
365
  subtitle: branchById !== null && branchById !== void 0 && branchById.name ? "Vestiging: ".concat(branchById === null || branchById === void 0 ? void 0 : branchById.name) : ''
334
- }), /*#__PURE__*/_react.default.createElement(_DirectVehicleSelectorModal.default, {
366
+ }), showProductOverview && !isCreateSingleOrderSuccess && !isCreateShopifyOrderSuccess && /*#__PURE__*/_react.default.createElement(_DirectVehicleSelectorModal.default, {
335
367
  isOpen: isDirectSelectorModalOpen,
336
368
  onSubmit: filterModelOrLicenseplate,
337
369
  handleSelectedFilterChange: handleSelectedFilterChange,
@@ -364,7 +396,7 @@ const InternalSingleOrderPage = () => {
364
396
  }) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_LinkButton.default, {
365
397
  label: "Terug naar producten",
366
398
  onClick: () => setShowProductOverview(true)
367
- }), !isCreateSingleOrderSuccess && isCreateSingleOrderError && /*#__PURE__*/_react.default.createElement(_DangerAlert.default, {
399
+ }), !(isCreateSingleOrderSuccess || isCreateShopifyOrderSuccess) && (isCreateSingleOrderError || isCreateShopifyOrderError) && /*#__PURE__*/_react.default.createElement(_DangerAlert.default, {
368
400
  className: "mt-2 mx-0",
369
401
  message: "Er is iets fout gegaan bij het bestellen. Probeer het opnieuw. Momenteel kunnen in hyper alleen losse orders worden gemaakt als een kenteken of model is geselecteerd in de filters."
370
402
  }), /*#__PURE__*/_react.default.createElement(_InternalCustomerDetailsForm.default, {
@@ -382,7 +414,7 @@ const InternalSingleOrderPage = () => {
382
414
  handleQuantityChange: handleQuantityChange,
383
415
  showProductOverview: showProductOverview,
384
416
  handleSubmit: handleSubmit,
385
- disabledCreateOrder: !singleOrderCart.length || isCreatingSingleOrder,
417
+ disabledCreateOrder: !singleOrderCart.length || isCreatingSingleOrder || isCreatingShopifyOrder,
386
418
  toggleOverview: () => setShowProductOverview(false)
387
419
  })))), /*#__PURE__*/_react.default.createElement(_BottomNavigationBar.default, null)));
388
420
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.229",
3
+ "version": "0.0.230",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",