thm-p3-configurator 0.0.403 → 0.0.404
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/public/assets/images/tm-logo-old.png +0 -0
- package/dist/public/assets/images/tm-logo.png +0 -0
- package/dist/src/shared/__api__/__tests__/queryKeyFactory.test.js +1 -1
- package/dist/src/shared/__components__/internal/InternalCustomerDetailsForm.js +31 -19
- package/dist/src/shared/__constants__/__tests__/index.test.js +7 -7
- package/dist/src/shared/__constants__/index.js +12 -7
- package/dist/src/shared/__containers__/ProductsCartOverview.js +3 -1
- package/dist/src/shared/__containers__/internal/InternalAppointmentForm.js +49 -69
- package/dist/src/shared/__containers__/internal/InternalQuotationForm.js +2 -8
- package/dist/src/shared/__helpers__/countryOptions.js +42 -0
- package/dist/src/shared/__helpers__/index.js +31 -2
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
@@ -90,7 +90,7 @@ describe('queryKeyFactory', () => {
|
|
|
90
90
|
});
|
|
91
91
|
it('includes formula in brands and build-years keys', () => {
|
|
92
92
|
expect((0, _queryKeyFactory.getBrandsQueryKey)('TMG')).toEqual(['brands', 'TMG']);
|
|
93
|
-
expect((0, _queryKeyFactory.getBrandsQueryKey)('
|
|
93
|
+
expect((0, _queryKeyFactory.getBrandsQueryKey)('TBE')).toEqual(['brands', 'TBE']);
|
|
94
94
|
expect((0, _queryKeyFactory.getBuildYearsQueryKey)({
|
|
95
95
|
brand: 'Volvo',
|
|
96
96
|
formula: 'TMG'
|
|
@@ -33,6 +33,7 @@ var _constants__ = require("../../__constants__");
|
|
|
33
33
|
var _AuthSessionContext = require("../../__context__/AuthSessionContext");
|
|
34
34
|
var _OrderSessionContext = require("../../__context__/OrderSessionContext");
|
|
35
35
|
var _helpers__ = require("../../__helpers__");
|
|
36
|
+
var _countryOptions = require("../../__helpers__/countryOptions");
|
|
36
37
|
var _useIsTmg = require("../../__hooks__/useIsTmg");
|
|
37
38
|
var _AddressLookupService = _interopRequireDefault(require("../../__services__/AddressLookupService"));
|
|
38
39
|
var _LinkButton = _interopRequireDefault(require("../Buttons/LinkButton"));
|
|
@@ -187,14 +188,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
187
188
|
countries,
|
|
188
189
|
isLoadingCountries
|
|
189
190
|
} = (0, _queries.useCountriesQuery)();
|
|
190
|
-
const countryOptions = (0, _react.useMemo)(() =>
|
|
191
|
-
var _countries$results;
|
|
192
|
-
if (!(countries !== null && countries !== void 0 && (_countries$results = countries.results) !== null && _countries$results !== void 0 && _countries$results.length)) return [];
|
|
193
|
-
return countries.results.map(country => ({
|
|
194
|
-
label: country.title,
|
|
195
|
-
value: country.entityId
|
|
196
|
-
}));
|
|
197
|
-
}, [countries]);
|
|
191
|
+
const countryOptions = (0, _react.useMemo)(() => (0, _countryOptions.buildCountryDropdownOptions)(countries === null || countries === void 0 ? void 0 : countries.results), [countries]);
|
|
198
192
|
const authSession = (0, _AuthSessionContext.useAuthSession)();
|
|
199
193
|
const isTmg = (0, _useIsTmg.useIsTmg)();
|
|
200
194
|
const [companySearchTerm, setCompanySearchTerm] = (0, _react.useState)('');
|
|
@@ -263,10 +257,15 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
263
257
|
const needsCustomerDeliveryIdentity = isDirectDeliveryEnabled;
|
|
264
258
|
const isNetherlandsSelected = (0, _react.useMemo)(() => {
|
|
265
259
|
if (!(selectedCountry !== null && selectedCountry !== void 0 && selectedCountry.label)) return false;
|
|
266
|
-
return selectedCountry.label.toUpperCase() ===
|
|
260
|
+
return selectedCountry.label.toUpperCase() === _constants__.COUNTRY_NAMES.NETHERLANDS;
|
|
261
|
+
}, [selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.label]);
|
|
262
|
+
const isBelgiumSelected = (0, _react.useMemo)(() => {
|
|
263
|
+
if (!(selectedCountry !== null && selectedCountry !== void 0 && selectedCountry.label)) return false;
|
|
264
|
+
const normalizedCountryLabel = selectedCountry.label.trim().toUpperCase();
|
|
265
|
+
return normalizedCountryLabel === _constants__.COUNTRY_NAMES.BELGIUM || normalizedCountryLabel === _constants__.COUNTRY_NAMES.BELGIUM_FALLBACK;
|
|
267
266
|
}, [selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.label]);
|
|
268
|
-
const shouldRequireKvkNumber = needsCustomerDeliveryIdentity && isBusinessOwnership && (isNetherlandsSelected || !(customer !== null && customer !== void 0 && (_customer$vatNumber = customer.vatNumber) !== null && _customer$vatNumber !== void 0 && _customer$vatNumber.trim()));
|
|
269
|
-
const shouldRequireVatNumber = needsCustomerDeliveryIdentity && isBusinessOwnership && !isNetherlandsSelected && !(customer !== null && customer !== void 0 && (_customer$kvkNumber = customer.kvkNumber) !== null && _customer$kvkNumber !== void 0 && _customer$kvkNumber.trim());
|
|
267
|
+
const shouldRequireKvkNumber = needsCustomerDeliveryIdentity && isBusinessOwnership && (isNetherlandsSelected || !isNetherlandsSelected && !isBelgiumSelected && !(customer !== null && customer !== void 0 && (_customer$vatNumber = customer.vatNumber) !== null && _customer$vatNumber !== void 0 && _customer$vatNumber.trim()));
|
|
268
|
+
const shouldRequireVatNumber = needsCustomerDeliveryIdentity && isBusinessOwnership && (isBelgiumSelected || !isNetherlandsSelected && !isBelgiumSelected && !(customer !== null && customer !== void 0 && (_customer$kvkNumber = customer.kvkNumber) !== null && _customer$kvkNumber !== void 0 && _customer$kvkNumber.trim()));
|
|
270
269
|
|
|
271
270
|
// Helper to update customer data for the active ownership type
|
|
272
271
|
const updateCustomerField = (0, _react.useCallback)((field, value) => {
|
|
@@ -505,6 +504,18 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
505
504
|
|
|
506
505
|
setAddressLookupTimeoutId(newTimeoutId);
|
|
507
506
|
};
|
|
507
|
+
const handlePostalCodeChange = value => {
|
|
508
|
+
updateCustomerField('zipCode', value);
|
|
509
|
+
const inferredCountry = (0, _helpers__.getCountryOptionForPostalCode)(value, countryOptions);
|
|
510
|
+
if (inferredCountry && inferredCountry.value !== (customer === null || customer === void 0 ? void 0 : customer.countryId)) {
|
|
511
|
+
updateCustomerField('countryId', inferredCountry.value);
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
// Trigger address lookup if house number is also available
|
|
515
|
+
if (customer.houseNumber) {
|
|
516
|
+
handleAddressLookup(value, customer.houseNumber);
|
|
517
|
+
}
|
|
518
|
+
};
|
|
508
519
|
|
|
509
520
|
// Cleanup timeout on unmount
|
|
510
521
|
(0, _react.useEffect)(() => {
|
|
@@ -526,7 +537,13 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
526
537
|
});
|
|
527
538
|
return false;
|
|
528
539
|
}
|
|
529
|
-
if (
|
|
540
|
+
if (isBelgiumSelected && !hasVatNumber) {
|
|
541
|
+
onValidationError === null || onValidationError === void 0 || onValidationError({
|
|
542
|
+
vatNumber: 'BTW-nummer is verplicht voor zakelijke dossiers in België'
|
|
543
|
+
});
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
if (!isNetherlandsSelected && !isBelgiumSelected && !hasKvkNumber && !hasVatNumber) {
|
|
530
547
|
onValidationError === null || onValidationError === void 0 || onValidationError({
|
|
531
548
|
kvkNumber: 'Vul een KVK- of BTW-nummer in',
|
|
532
549
|
vatNumber: 'Vul een KVK- of BTW-nummer in'
|
|
@@ -843,13 +860,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
843
860
|
placeholder: "",
|
|
844
861
|
value: customer.zipCode,
|
|
845
862
|
name: "zipCode",
|
|
846
|
-
onChange:
|
|
847
|
-
updateCustomerField('zipCode', value);
|
|
848
|
-
// Trigger address lookup if house number is also available
|
|
849
|
-
if (customer.houseNumber) {
|
|
850
|
-
handleAddressLookup(value, customer.houseNumber);
|
|
851
|
-
}
|
|
852
|
-
},
|
|
863
|
+
onChange: handlePostalCodeChange,
|
|
853
864
|
isRequired: isDirectDeliveryEnabled,
|
|
854
865
|
key: "zipCode-".concat(refreshKey),
|
|
855
866
|
form: form,
|
|
@@ -902,6 +913,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
902
913
|
label: "Stad:".concat(addressLookupLoading ? ' (wordt opgezocht...)' : ''),
|
|
903
914
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['city']
|
|
904
915
|
}), /*#__PURE__*/_react.default.createElement(_DropdownInput.default, {
|
|
916
|
+
key: "country-".concat((customer === null || customer === void 0 ? void 0 : customer.countryId) || 'default'),
|
|
905
917
|
options: countryOptions,
|
|
906
918
|
name: "country",
|
|
907
919
|
label: "Land:",
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
var _index = require("../index");
|
|
4
4
|
describe('__constants__/formula helpers', () => {
|
|
5
|
-
it('keeps
|
|
6
|
-
expect((0, _index.mapBranchFormulaToConfiguratorFormula)('
|
|
7
|
-
expect((0, _index.mapBranchFormulaToConfiguratorFormula)('Trekhaakcentrum Business')).toBe(_index.CONFIGURATOR_FORMULAS.
|
|
5
|
+
it('keeps TBE exact when normalizing branch formulas', () => {
|
|
6
|
+
expect((0, _index.mapBranchFormulaToConfiguratorFormula)('TBE')).toBe(_index.CONFIGURATOR_FORMULAS.TBE);
|
|
7
|
+
expect((0, _index.mapBranchFormulaToConfiguratorFormula)('Trekhaakcentrum Business')).toBe(_index.CONFIGURATOR_FORMULAS.TBE);
|
|
8
8
|
});
|
|
9
9
|
it('normalizes known formula titles and codes without collapsing unknown codes', () => {
|
|
10
10
|
expect((0, _index.getConfiguratorFormulaCode)('Trekhaakcentrum')).toBe(_index.CONFIGURATOR_FORMULAS.THC);
|
|
11
11
|
expect((0, _index.getConfiguratorFormulaCode)('TowMotive')).toBe(_index.CONFIGURATOR_FORMULAS.TOW);
|
|
12
|
-
expect((0, _index.getConfiguratorFormulaCode)('
|
|
12
|
+
expect((0, _index.getConfiguratorFormulaCode)('tbe')).toBe(_index.CONFIGURATOR_FORMULAS.TBE);
|
|
13
13
|
expect((0, _index.getConfiguratorFormulaCode)('abc')).toBe('ABC');
|
|
14
14
|
});
|
|
15
|
-
it('treats
|
|
15
|
+
it('treats TBE as THC-family for theme decisions only', () => {
|
|
16
16
|
expect((0, _index.isThcFamilyFormula)(_index.CONFIGURATOR_FORMULAS.THC)).toBe(true);
|
|
17
|
-
expect((0, _index.isThcFamilyFormula)(_index.CONFIGURATOR_FORMULAS.
|
|
18
|
-
expect((0, _index.getThemeFormulaForConfiguratorFormula)(_index.CONFIGURATOR_FORMULAS.
|
|
17
|
+
expect((0, _index.isThcFamilyFormula)(_index.CONFIGURATOR_FORMULAS.TBE)).toBe(true);
|
|
18
|
+
expect((0, _index.getThemeFormulaForConfiguratorFormula)(_index.CONFIGURATOR_FORMULAS.TBE)).toBe(_index.CONFIGURATOR_FORMULAS.THC);
|
|
19
19
|
});
|
|
20
20
|
});
|
|
@@ -6,7 +6,7 @@ require("core-js/modules/es.string.trim.js");
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
-
exports.mapBranchFormulaToConfiguratorFormula = exports.isThcFamilyFormula = exports.getThemeFormulaForConfiguratorFormula = exports.getConfiguratorFormulaCode = exports.VESTIGING_TYPE_ID = exports.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE = exports.VEHICLE_OWNERSHIP_TYPE = exports.VEHICLE_CODING_SUBGROUP_NAME = exports.USER_GEOLOCATION_KEY = exports.TOWMOTIVE_ORGANIZATION_TYPE = exports.TMG_ORGANIZATION_TYPE = exports.StockStatus = exports.STATUS_ASSESSMENT = exports.PRODUCT_CATEGORIES = exports.PRIVATE_SINGLE_ORDER_SESSION_KEY = exports.PARTNER_PORTAL_PAGE_TITLES_BY_THEME = exports.PARTNER_PORTAL_CHANNEL_TITLE = exports.ORDER_SESSION_KEY = exports.NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA = exports.NAVIGATION_STEPS_INTERNAL = exports.NAVIGATION_STEPS_EXTERNAL = exports.NAVIGATION_BUTTONS = exports.MOUSE_EXIT_INTENT_THROTTLE = exports.MOUSE_EXIT_INTENT_OFFSET = exports.LOCATION_TYPE = exports.LOCATION_CHANGE_BUTTON_LABEL = exports.LOCALE = exports.LEASE_TYPE_ID = exports.FORM_ERROR_MESSAGES = exports.EXECUTION_HELP_CONTACT_DETAILS_BY_FORMULA = exports.DOSSIER_TYPES = exports.DISCOUNT_TYPES = exports.DEFAULT_MAP_LONGITUDE = exports.DEFAULT_MAP_LATITUDE = exports.DEFAULT_ARTICLE_BRAND = exports.DAY_NAMES = exports.CONFIGURATOR_FORMULAS = exports.BRANCH_THEME_BY_FORMULA = exports.BRANCH_FORMULAS = exports.BOARD_COMPUTER_DISABLED_KEY = exports.ApiStockStatus = exports.AUTH_SESSION_KEY = exports.ARTICLE_SPECS_TRANSLATIONS = exports.ARTICLES_SYSTEM_FIELDS = exports.API_ERROR_CODES = exports.ALL_EXPERIMENTS = exports.ACTIVE_VARIANTS = void 0;
|
|
9
|
+
exports.mapBranchFormulaToConfiguratorFormula = exports.isThcFamilyFormula = exports.getThemeFormulaForConfiguratorFormula = exports.getConfiguratorFormulaCode = exports.VESTIGING_TYPE_ID = exports.VEHICLE_SINGLE_ORDER_OWNERSHIP_TYPE = exports.VEHICLE_OWNERSHIP_TYPE = exports.VEHICLE_CODING_SUBGROUP_NAME = exports.USER_GEOLOCATION_KEY = exports.TOWMOTIVE_ORGANIZATION_TYPE = exports.TMG_ORGANIZATION_TYPE = exports.StockStatus = exports.STATUS_ASSESSMENT = exports.PRODUCT_CATEGORIES = exports.PRIVATE_SINGLE_ORDER_SESSION_KEY = exports.PARTNER_PORTAL_PAGE_TITLES_BY_THEME = exports.PARTNER_PORTAL_CHANNEL_TITLE = exports.ORDER_SESSION_KEY = exports.NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA = exports.NAVIGATION_STEPS_INTERNAL = exports.NAVIGATION_STEPS_EXTERNAL = exports.NAVIGATION_BUTTONS = exports.MOUSE_EXIT_INTENT_THROTTLE = exports.MOUSE_EXIT_INTENT_OFFSET = exports.LOCATION_TYPE = exports.LOCATION_CHANGE_BUTTON_LABEL = exports.LOCALE = exports.LEASE_TYPE_ID = exports.FORM_ERROR_MESSAGES = exports.EXECUTION_HELP_CONTACT_DETAILS_BY_FORMULA = exports.DOSSIER_TYPES = exports.DISCOUNT_TYPES = exports.DEFAULT_MAP_LONGITUDE = exports.DEFAULT_MAP_LATITUDE = exports.DEFAULT_ARTICLE_BRAND = exports.DAY_NAMES = exports.COUNTRY_NAMES = exports.CONFIGURATOR_FORMULAS = exports.BRANCH_THEME_BY_FORMULA = exports.BRANCH_FORMULAS = exports.BOARD_COMPUTER_DISABLED_KEY = exports.ApiStockStatus = exports.AUTH_SESSION_KEY = exports.ARTICLE_SPECS_TRANSLATIONS = exports.ARTICLES_SYSTEM_FIELDS = exports.API_ERROR_CODES = exports.ALL_EXPERIMENTS = exports.ACTIVE_VARIANTS = void 0;
|
|
10
10
|
require("core-js/modules/es.array.includes.js");
|
|
11
11
|
require("core-js/modules/es.string.includes.js");
|
|
12
12
|
require("core-js/modules/es.string.trim.js");
|
|
@@ -27,6 +27,11 @@ const FORM_ERROR_MESSAGES = exports.FORM_ERROR_MESSAGES = {
|
|
|
27
27
|
licensePlateMin: 'Kenteken moet minimaal 6 characters bevatten',
|
|
28
28
|
licensePlateMax: 'Kenteken mag maximaal 8 characters bevatten'
|
|
29
29
|
};
|
|
30
|
+
const COUNTRY_NAMES = exports.COUNTRY_NAMES = {
|
|
31
|
+
NETHERLANDS: 'NEDERLAND',
|
|
32
|
+
BELGIUM: 'BELGIË',
|
|
33
|
+
BELGIUM_FALLBACK: 'BELGIE'
|
|
34
|
+
};
|
|
30
35
|
const BRANCH_FORMULAS = exports.BRANCH_FORMULAS = {
|
|
31
36
|
Trekhaakcentrum: 'Trekhaakcentrum',
|
|
32
37
|
TowMotiveGroup: 'TowMotive Group',
|
|
@@ -228,7 +233,7 @@ const ApiStockStatus = exports.ApiStockStatus = {
|
|
|
228
233
|
const CONFIGURATOR_FORMULAS = exports.CONFIGURATOR_FORMULAS = {
|
|
229
234
|
THM: 'THM',
|
|
230
235
|
THC: 'THC',
|
|
231
|
-
|
|
236
|
+
TBE: 'TBE',
|
|
232
237
|
TMG: 'TMG',
|
|
233
238
|
TOW: 'TOW',
|
|
234
239
|
TM: 'TOW',
|
|
@@ -267,10 +272,10 @@ const getConfiguratorFormulaCode = formula => {
|
|
|
267
272
|
case 'thc':
|
|
268
273
|
case 'trekhaakcentrum':
|
|
269
274
|
return CONFIGURATOR_FORMULAS.THC;
|
|
270
|
-
case '
|
|
275
|
+
case 'tbe':
|
|
271
276
|
case 'trekhaakcentrum belgie':
|
|
272
277
|
case 'trekhaakcentrum business':
|
|
273
|
-
return CONFIGURATOR_FORMULAS.
|
|
278
|
+
return CONFIGURATOR_FORMULAS.TBE;
|
|
274
279
|
case 'thm':
|
|
275
280
|
case 'trekhaakmontage':
|
|
276
281
|
return CONFIGURATOR_FORMULAS.THM;
|
|
@@ -281,7 +286,7 @@ const getConfiguratorFormulaCode = formula => {
|
|
|
281
286
|
exports.getConfiguratorFormulaCode = getConfiguratorFormulaCode;
|
|
282
287
|
const isThcFamilyFormula = formula => {
|
|
283
288
|
const normalizedFormula = getConfiguratorFormulaCode(formula);
|
|
284
|
-
return normalizedFormula === CONFIGURATOR_FORMULAS.THC || normalizedFormula === CONFIGURATOR_FORMULAS.
|
|
289
|
+
return normalizedFormula === CONFIGURATOR_FORMULAS.THC || normalizedFormula === CONFIGURATOR_FORMULAS.TBE;
|
|
285
290
|
};
|
|
286
291
|
exports.isThcFamilyFormula = isThcFamilyFormula;
|
|
287
292
|
const getThemeFormulaForConfiguratorFormula = formula => {
|
|
@@ -307,7 +312,7 @@ const NO_PRODUCTS_CONTACT_DETAILS_BY_FORMULA = exports.NO_PRODUCTS_CONTACT_DETAI
|
|
|
307
312
|
companyName: 'Trekhaakcentrum',
|
|
308
313
|
logoAltText: 'Trekhaakcentrum Logo'
|
|
309
314
|
},
|
|
310
|
-
[CONFIGURATOR_FORMULAS.
|
|
315
|
+
[CONFIGURATOR_FORMULAS.TBE]: {
|
|
311
316
|
email: 'order@trekhaakcentrum.nl',
|
|
312
317
|
phoneDisplay: '+31 162 - 490 910',
|
|
313
318
|
phoneHref: 'tel:+31162490910',
|
|
@@ -345,7 +350,7 @@ const EXECUTION_HELP_CONTACT_DETAILS_BY_FORMULA = exports.EXECUTION_HELP_CONTACT
|
|
|
345
350
|
phoneDisplay: '+31 85 202 0660',
|
|
346
351
|
phoneHref: 'tel:+31852020660'
|
|
347
352
|
},
|
|
348
|
-
[CONFIGURATOR_FORMULAS.
|
|
353
|
+
[CONFIGURATOR_FORMULAS.TBE]: {
|
|
349
354
|
phoneDisplay: '+31 85 202 0660',
|
|
350
355
|
phoneHref: 'tel:+31852020660'
|
|
351
356
|
}
|
|
@@ -612,11 +612,13 @@ const ProductCartTable = () => {
|
|
|
612
612
|
var _p$priceInfo14;
|
|
613
613
|
return t + Number((p === null || p === void 0 || (_p$priceInfo14 = p.priceInfo) === null || _p$priceInfo14 === void 0 ? void 0 : _p$priceInfo14.salesPrice) || 0);
|
|
614
614
|
}, 0) : 0;
|
|
615
|
+
const apiMontageSubtotalIncl = (totals === null || totals === void 0 ? void 0 : totals.subtotalMontageInclVat) != null ? Number(totals.subtotalMontageInclVat) : null;
|
|
616
|
+
const mainSubtotalIncl = !isToggled && apiMontageSubtotalIncl !== null && Number.isFinite(apiMontageSubtotalIncl) ? apiMontageSubtotalIncl : mainInclVat + montageInclVat;
|
|
615
617
|
return {
|
|
616
618
|
main: {
|
|
617
619
|
purchase: mainPurchase,
|
|
618
620
|
margin: mainMargin,
|
|
619
|
-
inclVat:
|
|
621
|
+
inclVat: mainSubtotalIncl,
|
|
620
622
|
exclVat: mainExclVat + montageExclVat + marketCorrectionExclVat,
|
|
621
623
|
tmg: {
|
|
622
624
|
catalog: tmgCatalog,
|
|
@@ -51,6 +51,7 @@ var _AuthSessionContext = require("../../__context__/AuthSessionContext");
|
|
|
51
51
|
var _FormulaContext = require("../../__context__/FormulaContext");
|
|
52
52
|
var _OrderSessionContext = require("../../__context__/OrderSessionContext");
|
|
53
53
|
var _helpers__ = require("../../__helpers__");
|
|
54
|
+
var _countryOptions = require("../../__helpers__/countryOptions");
|
|
54
55
|
var _product = require("../../__helpers__/product");
|
|
55
56
|
var _ui = require("../../__helpers__/ui");
|
|
56
57
|
var _useIsTmg = require("../../__hooks__/useIsTmg");
|
|
@@ -156,6 +157,7 @@ const internalAppointmentFormSchema = (0, _yup.object)({
|
|
|
156
157
|
houseNumberAddition: (0, _yup.string)().nullable(),
|
|
157
158
|
streetName: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
|
|
158
159
|
city: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
|
|
160
|
+
countryId: (0, _yup.string)().required(_constants__.FORM_ERROR_MESSAGES.required),
|
|
159
161
|
date: (0, _yup.string)().nullable(),
|
|
160
162
|
time: (0, _yup.string)().nullable(),
|
|
161
163
|
customerAgreed: (0, _yup.boolean)().required(_constants__.FORM_ERROR_MESSAGES.required).isTrue(_constants__.FORM_ERROR_MESSAGES.required),
|
|
@@ -217,7 +219,7 @@ const getBranchCity = function getBranchCity() {
|
|
|
217
219
|
return (branch === null || branch === void 0 ? void 0 : branch.city) || (branch === null || branch === void 0 ? void 0 : branch.gemeente) || '';
|
|
218
220
|
};
|
|
219
221
|
const InternalAppointmentForm = _ref => {
|
|
220
|
-
var _branchTypes$byId$aut, _authSession$branch, _authSession$branch2, _contextCustomer$note2;
|
|
222
|
+
var _branchTypes$byId$aut, _authSession$branch, _customer$vatNumber, _customer$kvkNumber, _authSession$branch2, _contextCustomer$note2;
|
|
221
223
|
let {
|
|
222
224
|
onSubmit = payload => {},
|
|
223
225
|
isError = false,
|
|
@@ -393,14 +395,7 @@ const InternalAppointmentForm = _ref => {
|
|
|
393
395
|
countries,
|
|
394
396
|
isLoadingCountries
|
|
395
397
|
} = (0, _queries.useCountriesQuery)();
|
|
396
|
-
const countryOptions = (0, _react.useMemo)(() =>
|
|
397
|
-
var _countries$results;
|
|
398
|
-
if (!(countries !== null && countries !== void 0 && (_countries$results = countries.results) !== null && _countries$results !== void 0 && _countries$results.length)) return [];
|
|
399
|
-
return countries.results.map(country => ({
|
|
400
|
-
label: country.title,
|
|
401
|
-
value: country.entityId
|
|
402
|
-
}));
|
|
403
|
-
}, [countries]);
|
|
398
|
+
const countryOptions = (0, _react.useMemo)(() => (0, _countryOptions.buildCountryDropdownOptions)(countries === null || countries === void 0 ? void 0 : countries.results), [countries]);
|
|
404
399
|
const branchType = branchTypes === null || branchTypes === void 0 || (_branchTypes$byId$aut = branchTypes.byId[authSession === null || authSession === void 0 || (_authSession$branch = authSession.branch) === null || _authSession$branch === void 0 || (_authSession$branch = _authSession$branch.organisatietype) === null || _authSession$branch === void 0 ? void 0 : _authSession$branch[0]]) === null || _branchTypes$byId$aut === void 0 ? void 0 : _branchTypes$byId$aut.title;
|
|
405
400
|
const {
|
|
406
401
|
marketingChannels,
|
|
@@ -443,23 +438,23 @@ const InternalAppointmentForm = _ref => {
|
|
|
443
438
|
if (!(customer !== null && customer !== void 0 && customer.countryId) && countryOptions !== null && countryOptions !== void 0 && countryOptions.length) {
|
|
444
439
|
const defaultCountry = countryOptions.find(option => option.label === 'NEDERLAND');
|
|
445
440
|
if (defaultCountry) {
|
|
446
|
-
|
|
447
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
|
|
448
|
-
payload: {
|
|
449
|
-
countryId: defaultCountry.value
|
|
450
|
-
}
|
|
451
|
-
});
|
|
441
|
+
updateCustomerField('countryId', defaultCountry.value);
|
|
452
442
|
}
|
|
453
443
|
}
|
|
454
|
-
}, [customer === null || customer === void 0 ? void 0 : customer.countryId, countryOptions,
|
|
444
|
+
}, [customer === null || customer === void 0 ? void 0 : customer.countryId, countryOptions, updateCustomerField]);
|
|
455
445
|
const isBusinessOwnership = activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk;
|
|
456
446
|
const isLeaseOwnership = activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Leasemaatschappij;
|
|
457
447
|
const isNetherlandsSelected = (0, _react.useMemo)(() => {
|
|
458
448
|
if (!(selectedCountry !== null && selectedCountry !== void 0 && selectedCountry.label)) return false;
|
|
459
|
-
return selectedCountry.label.toUpperCase() ===
|
|
449
|
+
return selectedCountry.label.toUpperCase() === _constants__.COUNTRY_NAMES.NETHERLANDS;
|
|
460
450
|
}, [selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.label]);
|
|
461
|
-
const
|
|
462
|
-
|
|
451
|
+
const isBelgiumSelected = (0, _react.useMemo)(() => {
|
|
452
|
+
if (!(selectedCountry !== null && selectedCountry !== void 0 && selectedCountry.label)) return false;
|
|
453
|
+
const normalizedCountryLabel = selectedCountry.label.trim().toUpperCase();
|
|
454
|
+
return normalizedCountryLabel === _constants__.COUNTRY_NAMES.BELGIUM || normalizedCountryLabel === _constants__.COUNTRY_NAMES.BELGIUM_FALLBACK;
|
|
455
|
+
}, [selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.label]);
|
|
456
|
+
const shouldRequireKvkNumber = isBusinessOwnership && (isNetherlandsSelected || !isNetherlandsSelected && !isBelgiumSelected && !(customer !== null && customer !== void 0 && (_customer$vatNumber = customer.vatNumber) !== null && _customer$vatNumber !== void 0 && _customer$vatNumber.trim()));
|
|
457
|
+
const shouldRequireVatNumber = isBusinessOwnership && (isBelgiumSelected || !isNetherlandsSelected && !isBelgiumSelected && !(customer !== null && customer !== void 0 && (_customer$kvkNumber = customer.kvkNumber) !== null && _customer$kvkNumber !== void 0 && _customer$kvkNumber.trim()));
|
|
463
458
|
const {
|
|
464
459
|
branchById
|
|
465
460
|
} = (0, _queries.useBranchByIdOrWidgetId)(selectedBranch);
|
|
@@ -502,7 +497,7 @@ const InternalAppointmentForm = _ref => {
|
|
|
502
497
|
const handleSubmit = async function handleSubmit() {
|
|
503
498
|
let appointmentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _constants__.DOSSIER_TYPES.PlannedAppointment;
|
|
504
499
|
try {
|
|
505
|
-
var _customer$
|
|
500
|
+
var _customer$kvkNumber2, _customer$vatNumber2, _customer$firstName, _customer$lastName, _customer$phoneNumber, _customer$houseNumber, _customer$houseNumber2, _customer$streetName, _customer$countryId, _customer$city, _customer$email, _ref3, _contextCustomer$anwb, _contextCustomer$note, _customer$zipCode, _customer$companyName, _customer$kvkNumber3, _customer$vatNumber3, _ref4, _vehicle$leaseNumber, _vehicle$leaseNumberU, _customer$companyName2, _customer$kvkNumber4, _customer$vatNumber4;
|
|
506
501
|
setErrors({});
|
|
507
502
|
if (!model) {
|
|
508
503
|
// Note: this does not throw on error.
|
|
@@ -524,8 +519,8 @@ const InternalAppointmentForm = _ref => {
|
|
|
524
519
|
return;
|
|
525
520
|
}
|
|
526
521
|
}
|
|
527
|
-
const hasKvkNumber = !!(customer !== null && customer !== void 0 && (_customer$
|
|
528
|
-
const hasVatNumber = !!(customer !== null && customer !== void 0 && (_customer$
|
|
522
|
+
const hasKvkNumber = !!(customer !== null && customer !== void 0 && (_customer$kvkNumber2 = customer.kvkNumber) !== null && _customer$kvkNumber2 !== void 0 && _customer$kvkNumber2.trim());
|
|
523
|
+
const hasVatNumber = !!(customer !== null && customer !== void 0 && (_customer$vatNumber2 = customer.vatNumber) !== null && _customer$vatNumber2 !== void 0 && _customer$vatNumber2.trim());
|
|
529
524
|
if (isBusinessOwnership) {
|
|
530
525
|
if (isNetherlandsSelected && !hasKvkNumber) {
|
|
531
526
|
setErrors({
|
|
@@ -533,7 +528,13 @@ const InternalAppointmentForm = _ref => {
|
|
|
533
528
|
});
|
|
534
529
|
return;
|
|
535
530
|
}
|
|
536
|
-
if (
|
|
531
|
+
if (isBelgiumSelected && !hasVatNumber) {
|
|
532
|
+
setErrors({
|
|
533
|
+
vatNumber: 'BTW-nummer is verplicht voor zakelijke dossiers in België'
|
|
534
|
+
});
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
if (!isNetherlandsSelected && !isBelgiumSelected && !hasKvkNumber && !hasVatNumber) {
|
|
537
538
|
setErrors({
|
|
538
539
|
kvkNumber: 'Vul een KVK- of BTW-nummer in',
|
|
539
540
|
vatNumber: 'Vul een KVK- of BTW-nummer in'
|
|
@@ -577,8 +578,8 @@ const InternalAppointmentForm = _ref => {
|
|
|
577
578
|
note: (_contextCustomer$note = contextCustomer === null || contextCustomer === void 0 ? void 0 : contextCustomer.note) !== null && _contextCustomer$note !== void 0 ? _contextCustomer$note : undefined,
|
|
578
579
|
zipCode: (_customer$zipCode = customer === null || customer === void 0 ? void 0 : customer.zipCode) !== null && _customer$zipCode !== void 0 ? _customer$zipCode : undefined,
|
|
579
580
|
companyName: activeOwnershipType !== _constants__.VEHICLE_OWNERSHIP_TYPE.Leasemaatschappij ? (_customer$companyName = customer === null || customer === void 0 ? void 0 : customer.companyName) !== null && _customer$companyName !== void 0 ? _customer$companyName : undefined : undefined,
|
|
580
|
-
kvkNumber: (_customer$
|
|
581
|
-
vatNumber: (_customer$
|
|
581
|
+
kvkNumber: (_customer$kvkNumber3 = customer === null || customer === void 0 ? void 0 : customer.kvkNumber) !== null && _customer$kvkNumber3 !== void 0 ? _customer$kvkNumber3 : undefined,
|
|
582
|
+
vatNumber: (_customer$vatNumber3 = customer === null || customer === void 0 ? void 0 : customer.vatNumber) !== null && _customer$vatNumber3 !== void 0 ? _customer$vatNumber3 : undefined
|
|
582
583
|
})),
|
|
583
584
|
customerAgreed,
|
|
584
585
|
appointment,
|
|
@@ -630,8 +631,8 @@ const InternalAppointmentForm = _ref => {
|
|
|
630
631
|
});
|
|
631
632
|
payload.customer = _objectSpread(_objectSpread({}, payload.customer || {}), {}, {
|
|
632
633
|
companyName: activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk ? (_customer$companyName2 = customer === null || customer === void 0 ? void 0 : customer.companyName) !== null && _customer$companyName2 !== void 0 ? _customer$companyName2 : '' : '',
|
|
633
|
-
kvkNumber: activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk ? (_customer$
|
|
634
|
-
vatNumber: activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk ? (_customer$
|
|
634
|
+
kvkNumber: activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk ? (_customer$kvkNumber4 = customer === null || customer === void 0 ? void 0 : customer.kvkNumber) !== null && _customer$kvkNumber4 !== void 0 ? _customer$kvkNumber4 : '' : '',
|
|
635
|
+
vatNumber: activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk ? (_customer$vatNumber4 = customer === null || customer === void 0 ? void 0 : customer.vatNumber) !== null && _customer$vatNumber4 !== void 0 ? _customer$vatNumber4 : '' : ''
|
|
635
636
|
});
|
|
636
637
|
if (existingDossierId && appointmentType === _constants__.DOSSIER_TYPES.PlannedAppointment && typeof invoicePaymentByLeaseCompany === 'boolean') {
|
|
637
638
|
payload.invoicePaymentByLeaseCompany = activeOwnershipType === _constants__.VEHICLE_OWNERSHIP_TYPE.Leasemaatschappij ? invoicePaymentByLeaseCompany : false;
|
|
@@ -771,6 +772,18 @@ const InternalAppointmentForm = _ref => {
|
|
|
771
772
|
|
|
772
773
|
setAddressLookupTimeoutId(newTimeoutId);
|
|
773
774
|
};
|
|
775
|
+
const handlePostalCodeChange = value => {
|
|
776
|
+
updateCustomerField('zipCode', value);
|
|
777
|
+
const inferredCountry = (0, _helpers__.getCountryOptionForPostalCode)(value, countryOptions);
|
|
778
|
+
if (inferredCountry && inferredCountry.value !== (customer === null || customer === void 0 ? void 0 : customer.countryId)) {
|
|
779
|
+
updateCustomerField('countryId', inferredCountry.value);
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
// Trigger address lookup if house number is also available
|
|
783
|
+
if (customer.houseNumber) {
|
|
784
|
+
handleAddressLookup(value, customer.houseNumber);
|
|
785
|
+
}
|
|
786
|
+
};
|
|
774
787
|
|
|
775
788
|
// Cleanup timeout on unmount
|
|
776
789
|
(0, _react.useEffect)(() => {
|
|
@@ -1161,13 +1174,7 @@ const InternalAppointmentForm = _ref => {
|
|
|
1161
1174
|
placeholder: "",
|
|
1162
1175
|
value: customer.zipCode,
|
|
1163
1176
|
name: "zipCode",
|
|
1164
|
-
onChange:
|
|
1165
|
-
updateCustomerField('zipCode', value);
|
|
1166
|
-
// Trigger address lookup if house number is also available
|
|
1167
|
-
if (customer.houseNumber) {
|
|
1168
|
-
handleAddressLookup(value, customer.houseNumber);
|
|
1169
|
-
}
|
|
1170
|
-
},
|
|
1177
|
+
onChange: handlePostalCodeChange,
|
|
1171
1178
|
key: "zipCode-".concat(refreshKey),
|
|
1172
1179
|
isRequired: true,
|
|
1173
1180
|
label: "Postcode:",
|
|
@@ -1219,7 +1226,7 @@ const InternalAppointmentForm = _ref => {
|
|
|
1219
1226
|
options: countryOptions,
|
|
1220
1227
|
name: "country",
|
|
1221
1228
|
label: "Land:",
|
|
1222
|
-
isRequired:
|
|
1229
|
+
isRequired: true,
|
|
1223
1230
|
isLoading: isLoadingCountries,
|
|
1224
1231
|
noOptionsMessage: "Geen landen beschikbaar",
|
|
1225
1232
|
placeholder: "Selecteer een land",
|
|
@@ -1229,12 +1236,7 @@ const InternalAppointmentForm = _ref => {
|
|
|
1229
1236
|
let {
|
|
1230
1237
|
value
|
|
1231
1238
|
} = _ref6;
|
|
1232
|
-
return
|
|
1233
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
|
|
1234
|
-
payload: {
|
|
1235
|
-
countryId: value
|
|
1236
|
-
}
|
|
1237
|
-
});
|
|
1239
|
+
return updateCustomerField('countryId', value);
|
|
1238
1240
|
}
|
|
1239
1241
|
}), /*#__PURE__*/_react.default.createElement("h6", {
|
|
1240
1242
|
className: (0, _helpers__.withStyle)('modal-title mb-2 mt-3')
|
|
@@ -1270,13 +1272,7 @@ const InternalAppointmentForm = _ref => {
|
|
|
1270
1272
|
placeholder: "",
|
|
1271
1273
|
value: customer.zipCode,
|
|
1272
1274
|
name: "zipCode",
|
|
1273
|
-
onChange:
|
|
1274
|
-
updateCustomerField('zipCode', value);
|
|
1275
|
-
// Trigger address lookup if house number is also available
|
|
1276
|
-
if (customer.houseNumber) {
|
|
1277
|
-
handleAddressLookup(value, customer.houseNumber);
|
|
1278
|
-
}
|
|
1279
|
-
},
|
|
1275
|
+
onChange: handlePostalCodeChange,
|
|
1280
1276
|
key: "zipCode-".concat(refreshKey),
|
|
1281
1277
|
isRequired: true,
|
|
1282
1278
|
label: "Postcode:",
|
|
@@ -1328,7 +1324,7 @@ const InternalAppointmentForm = _ref => {
|
|
|
1328
1324
|
options: countryOptions,
|
|
1329
1325
|
name: "country",
|
|
1330
1326
|
label: "Land:",
|
|
1331
|
-
isRequired:
|
|
1327
|
+
isRequired: true,
|
|
1332
1328
|
isLoading: isLoadingCountries,
|
|
1333
1329
|
noOptionsMessage: "Geen landen beschikbaar",
|
|
1334
1330
|
placeholder: "Selecteer een land",
|
|
@@ -1338,12 +1334,7 @@ const InternalAppointmentForm = _ref => {
|
|
|
1338
1334
|
let {
|
|
1339
1335
|
value
|
|
1340
1336
|
} = _ref7;
|
|
1341
|
-
return
|
|
1342
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
|
|
1343
|
-
payload: {
|
|
1344
|
-
countryId: value
|
|
1345
|
-
}
|
|
1346
|
-
});
|
|
1337
|
+
return updateCustomerField('countryId', value);
|
|
1347
1338
|
}
|
|
1348
1339
|
})) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_TextInput.default, {
|
|
1349
1340
|
placeholder: "",
|
|
@@ -1358,13 +1349,7 @@ const InternalAppointmentForm = _ref => {
|
|
|
1358
1349
|
placeholder: "",
|
|
1359
1350
|
value: customer.zipCode,
|
|
1360
1351
|
name: "zipCode",
|
|
1361
|
-
onChange:
|
|
1362
|
-
updateCustomerField('zipCode', value);
|
|
1363
|
-
// Trigger address lookup if house number is also available
|
|
1364
|
-
if (customer.houseNumber) {
|
|
1365
|
-
handleAddressLookup(value, customer.houseNumber);
|
|
1366
|
-
}
|
|
1367
|
-
},
|
|
1352
|
+
onChange: handlePostalCodeChange,
|
|
1368
1353
|
key: "zipCode-".concat(refreshKey),
|
|
1369
1354
|
isRequired: true,
|
|
1370
1355
|
label: "Postcode:",
|
|
@@ -1416,7 +1401,7 @@ const InternalAppointmentForm = _ref => {
|
|
|
1416
1401
|
options: countryOptions,
|
|
1417
1402
|
name: "country",
|
|
1418
1403
|
label: "Land:",
|
|
1419
|
-
isRequired:
|
|
1404
|
+
isRequired: true,
|
|
1420
1405
|
isLoading: isLoadingCountries,
|
|
1421
1406
|
noOptionsMessage: "Geen landen beschikbaar",
|
|
1422
1407
|
placeholder: "Selecteer een land",
|
|
@@ -1426,12 +1411,7 @@ const InternalAppointmentForm = _ref => {
|
|
|
1426
1411
|
let {
|
|
1427
1412
|
value
|
|
1428
1413
|
} = _ref8;
|
|
1429
|
-
return
|
|
1430
|
-
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
|
|
1431
|
-
payload: {
|
|
1432
|
-
countryId: value
|
|
1433
|
-
}
|
|
1434
|
-
});
|
|
1414
|
+
return updateCustomerField('countryId', value);
|
|
1435
1415
|
}
|
|
1436
1416
|
})))))), /*#__PURE__*/_react.default.createElement("div", {
|
|
1437
1417
|
className: (0, _helpers__.withStyle)('col-12 mb-4')
|
|
@@ -46,6 +46,7 @@ var _AuthSessionContext = require("../../__context__/AuthSessionContext");
|
|
|
46
46
|
var _FormulaContext = require("../../__context__/FormulaContext");
|
|
47
47
|
var _OrderSessionContext = require("../../__context__/OrderSessionContext");
|
|
48
48
|
var _helpers__ = require("../../__helpers__");
|
|
49
|
+
var _countryOptions = require("../../__helpers__/countryOptions");
|
|
49
50
|
var _product = require("../../__helpers__/product");
|
|
50
51
|
var _ui = require("../../__helpers__/ui");
|
|
51
52
|
var _useIsTmg = require("../../__hooks__/useIsTmg");
|
|
@@ -433,14 +434,7 @@ const InternalQuotationForm = _ref => {
|
|
|
433
434
|
return (option === null || option === void 0 || (_option$value = option.value) === null || _option$value === void 0 ? void 0 : _option$value.entityId) === (customer === null || customer === void 0 ? void 0 : customer.leasemaatschappijEntityId);
|
|
434
435
|
}) || buildLeaseCompanyOption(customer);
|
|
435
436
|
}, [customer, leaseCompanyOptions]);
|
|
436
|
-
const countryOptions = (0, _react.useMemo)(() =>
|
|
437
|
-
var _countries$results;
|
|
438
|
-
if (!(countries !== null && countries !== void 0 && (_countries$results = countries.results) !== null && _countries$results !== void 0 && _countries$results.length)) return [];
|
|
439
|
-
return countries.results.map(country => ({
|
|
440
|
-
label: country.title,
|
|
441
|
-
value: country.entityId
|
|
442
|
-
}));
|
|
443
|
-
}, [countries]);
|
|
437
|
+
const countryOptions = (0, _react.useMemo)(() => (0, _countryOptions.buildCountryDropdownOptions)(countries === null || countries === void 0 ? void 0 : countries.results), [countries]);
|
|
444
438
|
const initialCountry = (0, _react.useMemo)(() => {
|
|
445
439
|
if (!(countryOptions !== null && countryOptions !== void 0 && countryOptions.length)) return null;
|
|
446
440
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.array.sort.js");
|
|
4
|
+
require("core-js/modules/es.string.trim.js");
|
|
5
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
6
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
7
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
exports.buildCountryDropdownOptions = void 0;
|
|
12
|
+
require("core-js/modules/es.array.sort.js");
|
|
13
|
+
require("core-js/modules/es.string.trim.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.map.js");
|
|
17
|
+
var _constants__ = require("../__constants__");
|
|
18
|
+
const PRIORITY_COUNTRY_LABELS = [_constants__.COUNTRY_NAMES.NETHERLANDS, _constants__.COUNTRY_NAMES.BELGIUM, _constants__.COUNTRY_NAMES.BELGIUM_FALLBACK];
|
|
19
|
+
const normalizeCountryLabel = label => (label || '').trim().toUpperCase();
|
|
20
|
+
const getCountrySortPriority = label => {
|
|
21
|
+
const normalized = normalizeCountryLabel(label);
|
|
22
|
+
const index = PRIORITY_COUNTRY_LABELS.findIndex(priorityLabel => normalizeCountryLabel(priorityLabel) === normalized);
|
|
23
|
+
return index === -1 ? PRIORITY_COUNTRY_LABELS.length : index;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* @description Maps Hyper countries to dropdown options: Nederland and België first, then A–Z.
|
|
28
|
+
*/
|
|
29
|
+
const buildCountryDropdownOptions = exports.buildCountryDropdownOptions = function buildCountryDropdownOptions() {
|
|
30
|
+
let countries = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
31
|
+
if (!(countries !== null && countries !== void 0 && countries.length)) return [];
|
|
32
|
+
return countries.filter(country => country.title && country.entityId).map(country => ({
|
|
33
|
+
label: country.title,
|
|
34
|
+
value: country.entityId
|
|
35
|
+
})).sort((a, b) => {
|
|
36
|
+
const priorityDiff = getCountrySortPriority(a.label) - getCountrySortPriority(b.label);
|
|
37
|
+
if (priorityDiff !== 0) return priorityDiff;
|
|
38
|
+
return (a.label || '').localeCompare(b.label || '', 'nl', {
|
|
39
|
+
sensitivity: 'base'
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
};
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
require("core-js/modules/es.array.reduce.js");
|
|
4
4
|
require("core-js/modules/es.object.from-entries.js");
|
|
5
5
|
require("core-js/modules/es.regexp.exec.js");
|
|
6
|
+
require("core-js/modules/es.regexp.test.js");
|
|
6
7
|
require("core-js/modules/es.regexp.to-string.js");
|
|
7
8
|
require("core-js/modules/es.string.ends-with.js");
|
|
8
9
|
require("core-js/modules/es.string.replace.js");
|
|
9
10
|
require("core-js/modules/es.string.trim.js");
|
|
10
11
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
11
12
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
13
|
+
require("core-js/modules/esnext.iterator.find.js");
|
|
12
14
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
13
15
|
require("core-js/modules/esnext.iterator.map.js");
|
|
14
16
|
require("core-js/modules/esnext.iterator.reduce.js");
|
|
@@ -32,21 +34,26 @@ var _exportNames = {
|
|
|
32
34
|
truncateAtPipe: true,
|
|
33
35
|
parseJson: true,
|
|
34
36
|
isBelgianDomain: true,
|
|
37
|
+
isDutchPostalCode: true,
|
|
38
|
+
isBelgianPostalCode: true,
|
|
39
|
+
getCountryOptionForPostalCode: true,
|
|
35
40
|
removeNullishProps: true,
|
|
36
41
|
createSlug: true,
|
|
37
42
|
getProxyApiErrorMessage: true,
|
|
38
43
|
formatMontageTime: true
|
|
39
44
|
};
|
|
40
|
-
exports.withStyle = exports.truncateAtPipe = exports.removeNullishProps = exports.reduceYupErrorsToObject = exports.pushToDataLayer = exports.parseJson = exports.parseDateAndTimeToTimestamp = exports.parseArrayToInputOptions = exports.normalizeArray = exports.isBelgianDomain = exports.groupByKey = exports.getProxyApiErrorMessage = exports.getConfiguratorThemeClassByFormula = exports.getConfiguratorThemeClass = exports.getConfiguratorButtonVariant = exports.formatPrice = exports.formatMontageTime = exports.createSlug = void 0;
|
|
45
|
+
exports.withStyle = exports.truncateAtPipe = exports.removeNullishProps = exports.reduceYupErrorsToObject = exports.pushToDataLayer = exports.parseJson = exports.parseDateAndTimeToTimestamp = exports.parseArrayToInputOptions = exports.normalizeArray = exports.isDutchPostalCode = exports.isBelgianPostalCode = exports.isBelgianDomain = exports.groupByKey = exports.getProxyApiErrorMessage = exports.getCountryOptionForPostalCode = exports.getConfiguratorThemeClassByFormula = exports.getConfiguratorThemeClass = exports.getConfiguratorButtonVariant = exports.formatPrice = exports.formatMontageTime = exports.createSlug = void 0;
|
|
41
46
|
require("core-js/modules/es.array.reduce.js");
|
|
42
47
|
require("core-js/modules/es.object.from-entries.js");
|
|
43
48
|
require("core-js/modules/es.regexp.exec.js");
|
|
49
|
+
require("core-js/modules/es.regexp.test.js");
|
|
44
50
|
require("core-js/modules/es.regexp.to-string.js");
|
|
45
51
|
require("core-js/modules/es.string.ends-with.js");
|
|
46
52
|
require("core-js/modules/es.string.replace.js");
|
|
47
53
|
require("core-js/modules/es.string.trim.js");
|
|
48
54
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
49
55
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
56
|
+
require("core-js/modules/esnext.iterator.find.js");
|
|
50
57
|
require("core-js/modules/esnext.iterator.map.js");
|
|
51
58
|
require("core-js/modules/esnext.iterator.reduce.js");
|
|
52
59
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
@@ -292,11 +299,33 @@ const isBelgianDomain = () => {
|
|
|
292
299
|
const hostname = (_window$location = window.location) === null || _window$location === void 0 || (_window$location = _window$location.hostname) === null || _window$location === void 0 ? void 0 : _window$location.toLowerCase();
|
|
293
300
|
return Boolean(hostname && (hostname === 'be' || hostname.endsWith('.be')));
|
|
294
301
|
};
|
|
302
|
+
exports.isBelgianDomain = isBelgianDomain;
|
|
303
|
+
const isDutchPostalCode = postalCode => {
|
|
304
|
+
if (!postalCode) return false;
|
|
305
|
+
const cleanedPostalCode = postalCode.replace(/\s/g, '');
|
|
306
|
+
return /^[1-9][0-9]{3}[A-Z]{2}$/i.test(cleanedPostalCode);
|
|
307
|
+
};
|
|
308
|
+
exports.isDutchPostalCode = isDutchPostalCode;
|
|
309
|
+
const isBelgianPostalCode = postalCode => {
|
|
310
|
+
if (!postalCode) return false;
|
|
311
|
+
const cleanedPostalCode = postalCode.replace(/\s/g, '');
|
|
312
|
+
return /^[1-9][0-9]{3}$/.test(cleanedPostalCode);
|
|
313
|
+
};
|
|
314
|
+
exports.isBelgianPostalCode = isBelgianPostalCode;
|
|
315
|
+
const normalizeCountryLabel = function normalizeCountryLabel() {
|
|
316
|
+
let label = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
317
|
+
return label.normalize('NFD').replace(/[\u0300-\u036f]/g, '').toUpperCase();
|
|
318
|
+
};
|
|
319
|
+
const getCountryOptionForPostalCode = exports.getCountryOptionForPostalCode = function getCountryOptionForPostalCode(postalCode) {
|
|
320
|
+
let countryOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
321
|
+
const countryName = isDutchPostalCode(postalCode) ? 'NEDERLAND' : isBelgianPostalCode(postalCode) ? 'BELGIE' : null;
|
|
322
|
+
if (!countryName) return null;
|
|
323
|
+
return countryOptions.find(option => normalizeCountryLabel(option === null || option === void 0 ? void 0 : option.label) === countryName) || null;
|
|
324
|
+
};
|
|
295
325
|
|
|
296
326
|
/**
|
|
297
327
|
* @description Removes nullish properties from a passed object
|
|
298
328
|
*/
|
|
299
|
-
exports.isBelgianDomain = isBelgianDomain;
|
|
300
329
|
const removeNullishProps = exports.removeNullishProps = function removeNullishProps() {
|
|
301
330
|
let object = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
302
331
|
return Object.fromEntries(Object.entries(object).filter(_ref3 => {
|