thm-p3-configurator 0.0.398 → 0.0.400
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.
- package/dist/src/shared/__api__/queries.js +18 -6
- package/dist/src/shared/__components__/internal/InternalCustomerDetailsForm.js +29 -17
- package/dist/src/shared/__helpers__/singleOrderCartArticles.js +79 -0
- package/dist/src/shared/__helpers__/singleOrderCustomerDetails.js +18 -5
- package/package.json +1 -1
|
@@ -40,6 +40,7 @@ var _FormulaContext = require("../__context__/FormulaContext");
|
|
|
40
40
|
var _OrderSessionContext = require("../__context__/OrderSessionContext");
|
|
41
41
|
var _helpers__ = require("../__helpers__");
|
|
42
42
|
var _singleOrderArticles = require("../__helpers__/singleOrderArticles");
|
|
43
|
+
var _singleOrderCartArticles = require("../__helpers__/singleOrderCartArticles");
|
|
43
44
|
var _product = require("../__helpers__/product");
|
|
44
45
|
var _useSessionContextReady = require("../__hooks__/useSessionContextReady");
|
|
45
46
|
var _authenticatedProxyApi = require("./authenticatedProxyApi");
|
|
@@ -91,6 +92,21 @@ function _toPrimitive(t, r) {
|
|
|
91
92
|
return ("string" === r ? String : Number)(t);
|
|
92
93
|
}
|
|
93
94
|
const ORDER_QUERY_STALE_TIME_MS = 5 * 60 * 1000;
|
|
95
|
+
const fetchCartArticleLookup = async function fetchCartArticleLookup() {
|
|
96
|
+
var _directResponse$artic, _directResponse$artic2, _partFallbackResponse;
|
|
97
|
+
let articleNumbers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
98
|
+
let formula = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
99
|
+
const directResponse = await (0, _singleOrderArticles.fetchArticlesByArticleNumbers)(articleNumbers, null, false, null, formula);
|
|
100
|
+
const {
|
|
101
|
+
mergedByArticleNumber,
|
|
102
|
+
missingArticleNumbers
|
|
103
|
+
} = (0, _singleOrderCartArticles.mergeCartArticlesWithPartFallback)(articleNumbers, (_directResponse$artic = directResponse === null || directResponse === void 0 ? void 0 : directResponse.articles) !== null && _directResponse$artic !== void 0 ? _directResponse$artic : []);
|
|
104
|
+
if (!missingArticleNumbers.length) {
|
|
105
|
+
return mergedByArticleNumber;
|
|
106
|
+
}
|
|
107
|
+
const partFallbackResponse = await (0, _singleOrderArticles.fetchArticlesByArticleNumbers)(missingArticleNumbers, null, true, null, formula);
|
|
108
|
+
return (0, _singleOrderCartArticles.mergeCartArticlesWithPartFallback)(articleNumbers, (_directResponse$artic2 = directResponse === null || directResponse === void 0 ? void 0 : directResponse.articles) !== null && _directResponse$artic2 !== void 0 ? _directResponse$artic2 : [], (_partFallbackResponse = partFallbackResponse === null || partFallbackResponse === void 0 ? void 0 : partFallbackResponse.articles) !== null && _partFallbackResponse !== void 0 ? _partFallbackResponse : []).mergedByArticleNumber;
|
|
109
|
+
};
|
|
94
110
|
/**
|
|
95
111
|
* @description Retrieves the car brand options
|
|
96
112
|
*/
|
|
@@ -396,7 +412,6 @@ const useSingleOrderCart = () => {
|
|
|
396
412
|
})).toString();
|
|
397
413
|
const cartQuery = (0, _reactQuery.useQuery)(['singleOrderCart', cartOrderQuery, webshop], {
|
|
398
414
|
queryFn: async () => {
|
|
399
|
-
var _articleResponse$arti2;
|
|
400
415
|
const emptyTotals = {
|
|
401
416
|
totalQuantity: 0,
|
|
402
417
|
totalBtw: 0,
|
|
@@ -413,9 +428,7 @@ const useSingleOrderCart = () => {
|
|
|
413
428
|
|
|
414
429
|
// If webshop is selected, use Shopify prices directly without API call
|
|
415
430
|
if (webshop) {
|
|
416
|
-
|
|
417
|
-
const articleResponse = await (0, _singleOrderArticles.fetchArticlesByArticleNumbers)(singleOrderCart.map(article => article.articleNumber), null, false, null, singleOrderFormula);
|
|
418
|
-
const articleLookup = Object.fromEntries(((_articleResponse$arti = articleResponse === null || articleResponse === void 0 ? void 0 : articleResponse.articles) !== null && _articleResponse$arti !== void 0 ? _articleResponse$arti : []).map(article => [article.articleNumber, article]));
|
|
431
|
+
const articleLookup = await fetchCartArticleLookup(singleOrderCart.map(article => article.articleNumber), singleOrderFormula);
|
|
419
432
|
const articlesWithPrice = singleOrderCart.map(cartItem => {
|
|
420
433
|
var _articleLookup$cartIt, _article$name, _cartItem$brandNumber;
|
|
421
434
|
const article = (_articleLookup$cartIt = articleLookup[cartItem.articleNumber]) !== null && _articleLookup$cartIt !== void 0 ? _articleLookup$cartIt : {};
|
|
@@ -475,8 +488,7 @@ const useSingleOrderCart = () => {
|
|
|
475
488
|
validationError
|
|
476
489
|
};
|
|
477
490
|
}
|
|
478
|
-
const
|
|
479
|
-
const articleLookup = Object.fromEntries(((_articleResponse$arti2 = articleResponse === null || articleResponse === void 0 ? void 0 : articleResponse.articles) !== null && _articleResponse$arti2 !== void 0 ? _articleResponse$arti2 : []).map(article => [article.articleNumber, article]));
|
|
491
|
+
const articleLookup = await fetchCartArticleLookup(cart.map(article => article.articleNumber), singleOrderFormula);
|
|
480
492
|
const articlesWithPrice = cart.map(cartItem => {
|
|
481
493
|
var _articleLookup$cartIt2, _article$name2, _cartItem$brandNumber2;
|
|
482
494
|
const article = (_articleLookup$cartIt2 = articleLookup[cartItem.articleNumber]) !== null && _articleLookup$cartIt2 !== void 0 ? _articleLookup$cartIt2 : {};
|
|
@@ -211,8 +211,10 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
211
211
|
const normalizedOwnershipType = activeOwnershipType === _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Empty ? null : activeOwnershipType;
|
|
212
212
|
const checkboxAvailability = (0, _helpers__.getSingleOrderCheckboxAvailability)({
|
|
213
213
|
isTmg,
|
|
214
|
-
isTowCenterBranch
|
|
214
|
+
isTowCenterBranch,
|
|
215
|
+
webshop
|
|
215
216
|
});
|
|
217
|
+
const isDirectDeliveryEnabled = Boolean(anderAfleveradres || checkboxAvailability.shouldForceDirectDelivery);
|
|
216
218
|
|
|
217
219
|
// Separate customer state for each ownership type
|
|
218
220
|
const [customerDataPerType, setCustomerDataPerType] = (0, _react.useState)(() => {
|
|
@@ -258,7 +260,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
258
260
|
return defaultCountry || null;
|
|
259
261
|
}, [customer === null || customer === void 0 ? void 0 : customer.countryId, countryOptions]);
|
|
260
262
|
const isBusinessOwnership = activeOwnershipType === _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Zakelijk;
|
|
261
|
-
const needsCustomerDeliveryIdentity =
|
|
263
|
+
const needsCustomerDeliveryIdentity = isDirectDeliveryEnabled;
|
|
262
264
|
const isNetherlandsSelected = (0, _react.useMemo)(() => {
|
|
263
265
|
if (!(selectedCountry !== null && selectedCountry !== void 0 && selectedCountry.label)) return false;
|
|
264
266
|
return selectedCountry.label.toUpperCase() === 'NEDERLAND';
|
|
@@ -346,6 +348,16 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
346
348
|
}
|
|
347
349
|
}
|
|
348
350
|
}, [customer === null || customer === void 0 ? void 0 : customer.countryId, countryOptions, updateCustomerField]);
|
|
351
|
+
(0, _react.useEffect)(() => {
|
|
352
|
+
if (checkboxAvailability.shouldForceDirectDelivery && !Boolean(anderAfleveradres)) {
|
|
353
|
+
dispatch({
|
|
354
|
+
type: _OrderSessionContext.orderSessionActions.SET_ANDER_AFLEVERADRES,
|
|
355
|
+
payload: {
|
|
356
|
+
anderAfleveradres: true
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
}, [checkboxAvailability.shouldForceDirectDelivery, anderAfleveradres, dispatch]);
|
|
349
361
|
|
|
350
362
|
/**
|
|
351
363
|
* @description Auto-set Partner Portal channel for non-TMG users
|
|
@@ -524,10 +536,10 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
524
536
|
}
|
|
525
537
|
let validationSchema = webshop || !isTmg ? customerDetailsFormSchema.omit(['channelType', 'channelId']) : customerDetailsFormSchema;
|
|
526
538
|
const requiredFields = (0, _helpers__.getSingleOrderRequiredFields)({
|
|
527
|
-
anderAfleveradres,
|
|
539
|
+
anderAfleveradres: isDirectDeliveryEnabled,
|
|
528
540
|
ownershipType: normalizedOwnershipType
|
|
529
541
|
});
|
|
530
|
-
if (
|
|
542
|
+
if (isDirectDeliveryEnabled) {
|
|
531
543
|
validationSchema = validationSchema.shape({
|
|
532
544
|
singleOrderOwnershipType: (0, _yup.string)().required('Type is verplicht').notOneOf([_constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Empty], 'Type is verplicht')
|
|
533
545
|
});
|
|
@@ -641,15 +653,15 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
641
653
|
setActiveOwnershipType(val);
|
|
642
654
|
},
|
|
643
655
|
options: [_constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Particulier, _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Zakelijk],
|
|
644
|
-
isRequired:
|
|
656
|
+
isRequired: isDirectDeliveryEnabled,
|
|
645
657
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['singleOrderOwnershipType']
|
|
646
658
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
647
659
|
className: (0, _helpers__.withStyle)('col-12 mb-2')
|
|
648
660
|
}, /*#__PURE__*/_react.default.createElement(_CheckboxInput.default, {
|
|
649
661
|
name: "anderAfleveradres",
|
|
650
662
|
label: "Rechtstreeks leveren aan de klant",
|
|
651
|
-
initialValue: checkboxAvailability.canUseDirectDelivery ? Boolean(anderAfleveradres) : false,
|
|
652
|
-
isDisabled: !checkboxAvailability.canUseDirectDelivery,
|
|
663
|
+
initialValue: checkboxAvailability.shouldForceDirectDelivery ? true : checkboxAvailability.canUseDirectDelivery ? Boolean(anderAfleveradres) : false,
|
|
664
|
+
isDisabled: checkboxAvailability.shouldForceDirectDelivery || !checkboxAvailability.canUseDirectDelivery,
|
|
653
665
|
onChange: value => dispatch({
|
|
654
666
|
type: _OrderSessionContext.orderSessionActions.SET_ANDER_AFLEVERADRES,
|
|
655
667
|
payload: {
|
|
@@ -675,7 +687,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
675
687
|
initialValue: customer.firstName,
|
|
676
688
|
name: "firstName",
|
|
677
689
|
onChange: value => updateCustomerField('firstName', value),
|
|
678
|
-
isRequired:
|
|
690
|
+
isRequired: isDirectDeliveryEnabled,
|
|
679
691
|
form: form,
|
|
680
692
|
label: "Voornaam:",
|
|
681
693
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['firstName']
|
|
@@ -693,7 +705,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
693
705
|
initialValue: customer.lastName,
|
|
694
706
|
name: "lastName",
|
|
695
707
|
onChange: value => updateCustomerField('lastName', value),
|
|
696
|
-
isRequired:
|
|
708
|
+
isRequired: isDirectDeliveryEnabled,
|
|
697
709
|
form: form,
|
|
698
710
|
label: "Achternaam:",
|
|
699
711
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['lastName']
|
|
@@ -702,7 +714,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
702
714
|
initialValue: customer.email,
|
|
703
715
|
name: "email",
|
|
704
716
|
onChange: value => updateCustomerField('email', value),
|
|
705
|
-
isRequired:
|
|
717
|
+
isRequired: isDirectDeliveryEnabled,
|
|
706
718
|
form: form,
|
|
707
719
|
label: "E-mailadres:",
|
|
708
720
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['email']
|
|
@@ -712,7 +724,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
712
724
|
name: "phoneNumber",
|
|
713
725
|
onChange: value => updateCustomerField('phoneNumber', value),
|
|
714
726
|
form: form,
|
|
715
|
-
isRequired:
|
|
727
|
+
isRequired: isDirectDeliveryEnabled,
|
|
716
728
|
label: "Telefoonnummer:",
|
|
717
729
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['phoneNumber']
|
|
718
730
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -749,7 +761,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
749
761
|
setIsCompanyInputFocused(false);
|
|
750
762
|
}, 300);
|
|
751
763
|
},
|
|
752
|
-
isRequired:
|
|
764
|
+
isRequired: isDirectDeliveryEnabled && normalizedOwnershipType === _constants__.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE.Zakelijk,
|
|
753
765
|
form: form,
|
|
754
766
|
label: "Bedrijfsnaam:",
|
|
755
767
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['companyName']
|
|
@@ -838,7 +850,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
838
850
|
handleAddressLookup(value, customer.houseNumber);
|
|
839
851
|
}
|
|
840
852
|
},
|
|
841
|
-
isRequired:
|
|
853
|
+
isRequired: isDirectDeliveryEnabled,
|
|
842
854
|
key: "zipCode-".concat(refreshKey),
|
|
843
855
|
form: form,
|
|
844
856
|
label: "Postcode:",
|
|
@@ -854,7 +866,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
854
866
|
handleAddressLookup(customer.zipCode, value);
|
|
855
867
|
}
|
|
856
868
|
},
|
|
857
|
-
isRequired:
|
|
869
|
+
isRequired: isDirectDeliveryEnabled,
|
|
858
870
|
key: "houseNumber-".concat(refreshKey),
|
|
859
871
|
form: form,
|
|
860
872
|
label: "Huisnummer:",
|
|
@@ -874,7 +886,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
874
886
|
value: customer.streetName,
|
|
875
887
|
name: "streetName",
|
|
876
888
|
onChange: value => updateCustomerField('streetName', value),
|
|
877
|
-
isRequired:
|
|
889
|
+
isRequired: isDirectDeliveryEnabled,
|
|
878
890
|
key: "streetName-".concat(refreshKey),
|
|
879
891
|
form: form,
|
|
880
892
|
label: "Straat:".concat(addressLookupLoading ? ' (wordt opgezocht...)' : ''),
|
|
@@ -884,7 +896,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
884
896
|
value: customer.city,
|
|
885
897
|
name: "city",
|
|
886
898
|
onChange: value => updateCustomerField('city', value),
|
|
887
|
-
isRequired:
|
|
899
|
+
isRequired: isDirectDeliveryEnabled,
|
|
888
900
|
key: "city-".concat(refreshKey),
|
|
889
901
|
form: form,
|
|
890
902
|
label: "Stad:".concat(addressLookupLoading ? ' (wordt opgezocht...)' : ''),
|
|
@@ -893,7 +905,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
893
905
|
options: countryOptions,
|
|
894
906
|
name: "country",
|
|
895
907
|
label: "Land:",
|
|
896
|
-
isRequired:
|
|
908
|
+
isRequired: isDirectDeliveryEnabled,
|
|
897
909
|
isLoading: isLoadingCountries,
|
|
898
910
|
noOptionsMessage: "Geen landen beschikbaar",
|
|
899
911
|
placeholder: "Selecteer een land",
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.object.from-entries.js");
|
|
4
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
5
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
6
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
7
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
8
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
10
|
+
Object.defineProperty(exports, "__esModule", {
|
|
11
|
+
value: true
|
|
12
|
+
});
|
|
13
|
+
exports.mergeCartArticlesWithPartFallback = void 0;
|
|
14
|
+
require("core-js/modules/es.object.from-entries.js");
|
|
15
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
16
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
17
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
18
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
19
|
+
function ownKeys(e, r) {
|
|
20
|
+
var t = Object.keys(e);
|
|
21
|
+
if (Object.getOwnPropertySymbols) {
|
|
22
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
23
|
+
r && (o = o.filter(function (r) {
|
|
24
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
25
|
+
})), t.push.apply(t, o);
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
function _objectSpread(e) {
|
|
30
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
31
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
32
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
33
|
+
_defineProperty(e, r, t[r]);
|
|
34
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
35
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return e;
|
|
39
|
+
}
|
|
40
|
+
function _defineProperty(e, r, t) {
|
|
41
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
42
|
+
value: t,
|
|
43
|
+
enumerable: !0,
|
|
44
|
+
configurable: !0,
|
|
45
|
+
writable: !0
|
|
46
|
+
}) : e[r] = t, e;
|
|
47
|
+
}
|
|
48
|
+
function _toPropertyKey(t) {
|
|
49
|
+
var i = _toPrimitive(t, "string");
|
|
50
|
+
return "symbol" == typeof i ? i : i + "";
|
|
51
|
+
}
|
|
52
|
+
function _toPrimitive(t, r) {
|
|
53
|
+
if ("object" != typeof t || !t) return t;
|
|
54
|
+
var e = t[Symbol.toPrimitive];
|
|
55
|
+
if (void 0 !== e) {
|
|
56
|
+
var i = e.call(t, r || "default");
|
|
57
|
+
if ("object" != typeof i) return i;
|
|
58
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
59
|
+
}
|
|
60
|
+
return ("string" === r ? String : Number)(t);
|
|
61
|
+
}
|
|
62
|
+
const toArticleLookup = function toArticleLookup() {
|
|
63
|
+
let articles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
64
|
+
return Object.fromEntries(articles.filter(article => article === null || article === void 0 ? void 0 : article.articleNumber).map(article => [article.articleNumber, article]));
|
|
65
|
+
};
|
|
66
|
+
const mergeCartArticlesWithPartFallback = exports.mergeCartArticlesWithPartFallback = function mergeCartArticlesWithPartFallback() {
|
|
67
|
+
let cartArticleNumbers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
68
|
+
let directMatches = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
69
|
+
let partFallbackMatches = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
|
70
|
+
const uniqueCartArticleNumbers = [...new Set(cartArticleNumbers.filter(Boolean))];
|
|
71
|
+
const directLookup = toArticleLookup(directMatches);
|
|
72
|
+
const fallbackLookup = toArticleLookup(partFallbackMatches);
|
|
73
|
+
const missingArticleNumbers = uniqueCartArticleNumbers.filter(articleNumber => !directLookup[articleNumber]);
|
|
74
|
+
const mergedByArticleNumber = _objectSpread(_objectSpread({}, directLookup), Object.fromEntries(missingArticleNumbers.filter(articleNumber => fallbackLookup[articleNumber]).map(articleNumber => [articleNumber, fallbackLookup[articleNumber]])));
|
|
75
|
+
return {
|
|
76
|
+
mergedByArticleNumber,
|
|
77
|
+
missingArticleNumbers
|
|
78
|
+
};
|
|
79
|
+
};
|
|
@@ -5,15 +5,17 @@ require("core-js/modules/esnext.iterator.constructor.js");
|
|
|
5
5
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
6
6
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
7
7
|
require("core-js/modules/esnext.iterator.some.js");
|
|
8
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
8
9
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
9
10
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
10
11
|
Object.defineProperty(exports, "__esModule", {
|
|
11
12
|
value: true
|
|
12
13
|
});
|
|
13
|
-
exports.getSingleOrderRequiredFields = exports.getSingleOrderCheckboxAvailability = exports.getEmptySingleOrderCustomer = exports.buildSingleOrderVehiclePayload = exports.buildSingleOrderCustomerPayload = exports.buildSingleOrderBusinessContactPayload = void 0;
|
|
14
|
+
exports.shouldForceDirectDeliveryForWebshop = exports.getSingleOrderRequiredFields = exports.getSingleOrderCheckboxAvailability = exports.getEmptySingleOrderCustomer = exports.buildSingleOrderVehiclePayload = exports.buildSingleOrderCustomerPayload = exports.buildSingleOrderBusinessContactPayload = void 0;
|
|
14
15
|
require("core-js/modules/es.string.trim.js");
|
|
15
16
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
16
17
|
require("core-js/modules/esnext.iterator.some.js");
|
|
18
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
17
19
|
var _constants__ = require("../__constants__");
|
|
18
20
|
function ownKeys(e, r) {
|
|
19
21
|
var t = Object.keys(e);
|
|
@@ -58,6 +60,15 @@ function _toPrimitive(t, r) {
|
|
|
58
60
|
}
|
|
59
61
|
return ("string" === r ? String : Number)(t);
|
|
60
62
|
}
|
|
63
|
+
const normalizeWebshop = function normalizeWebshop() {
|
|
64
|
+
let webshop = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
65
|
+
return typeof webshop === 'string' ? webshop.trim().toLowerCase() : '';
|
|
66
|
+
};
|
|
67
|
+
const FORCED_DIRECT_DELIVERY_WEBSHOPS = new Set(['trekhaakland', 'trekhaken.nl']);
|
|
68
|
+
const shouldForceDirectDeliveryForWebshop = exports.shouldForceDirectDeliveryForWebshop = function shouldForceDirectDeliveryForWebshop() {
|
|
69
|
+
let webshop = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
70
|
+
return FORCED_DIRECT_DELIVERY_WEBSHOPS.has(normalizeWebshop(webshop));
|
|
71
|
+
};
|
|
61
72
|
const getEmptySingleOrderCustomer = () => ({
|
|
62
73
|
firstName: '',
|
|
63
74
|
infix: '',
|
|
@@ -84,11 +95,13 @@ exports.getEmptySingleOrderCustomer = getEmptySingleOrderCustomer;
|
|
|
84
95
|
const getSingleOrderCheckboxAvailability = _ref => {
|
|
85
96
|
let {
|
|
86
97
|
isTmg = false,
|
|
87
|
-
isTowCenterBranch = false
|
|
98
|
+
isTowCenterBranch = false,
|
|
99
|
+
webshop = null
|
|
88
100
|
} = _ref;
|
|
89
101
|
return {
|
|
90
|
-
canUseDirectDelivery: Boolean(isTmg || isTowCenterBranch),
|
|
91
|
-
canUseWarehouseSale: false
|
|
102
|
+
canUseDirectDelivery: Boolean(isTmg || isTowCenterBranch || shouldForceDirectDeliveryForWebshop(webshop)),
|
|
103
|
+
canUseWarehouseSale: false,
|
|
104
|
+
shouldForceDirectDelivery: shouldForceDirectDeliveryForWebshop(webshop)
|
|
92
105
|
};
|
|
93
106
|
};
|
|
94
107
|
exports.getSingleOrderCheckboxAvailability = getSingleOrderCheckboxAvailability;
|
|
@@ -117,7 +130,7 @@ const buildSingleOrderCustomerPayload = _ref3 => {
|
|
|
117
130
|
} = _ref3;
|
|
118
131
|
const baseCustomer = _objectSpread(_objectSpread({}, getEmptySingleOrderCustomer()), customer);
|
|
119
132
|
const payload = _objectSpread(_objectSpread({}, baseCustomer), {}, {
|
|
120
|
-
anderAfleveradres: Boolean(anderAfleveradres),
|
|
133
|
+
anderAfleveradres: Boolean(anderAfleveradres || shouldForceDirectDeliveryForWebshop(webshop)),
|
|
121
134
|
afhalenInWinkel: false,
|
|
122
135
|
anderFactuuradres: false
|
|
123
136
|
});
|