thm-p3-configurator 0.0.406 → 0.0.407
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 +10 -1
- package/dist/src/shared/__api__/queryKeyFactory.js +1 -1
- package/dist/src/shared/__components__/internal/InternalCustomerDetailsForm.js +7 -14
- package/dist/src/shared/__constants__/index.js +13 -1
- package/dist/src/shared/__containers__/internal/InternalAppointmentForm.js +21 -15
- package/dist/src/shared/__context__/OrderSessionContext.js +3 -1
- package/dist/src/shared/__helpers__/dossier.js +2 -1
- package/dist/src/shared/__helpers__/index.js +2 -31
- package/dist/src/shared/__hooks__/usePricingFormula.js +30 -0
- package/dist/src/shared/__pages__/internal/InternalSessionEditPage.js +12 -5
- package/package.json +1 -1
|
@@ -38,6 +38,7 @@ var _constants__ = require("../__constants__");
|
|
|
38
38
|
var _AuthSessionContext = require("../__context__/AuthSessionContext");
|
|
39
39
|
var _FormulaContext = require("../__context__/FormulaContext");
|
|
40
40
|
var _OrderSessionContext = require("../__context__/OrderSessionContext");
|
|
41
|
+
var _usePricingFormula = require("../__hooks__/usePricingFormula");
|
|
41
42
|
var _helpers__ = require("../__helpers__");
|
|
42
43
|
var _singleOrderArticles = require("../__helpers__/singleOrderArticles");
|
|
43
44
|
var _singleOrderCartArticles = require("../__helpers__/singleOrderCartArticles");
|
|
@@ -534,7 +535,15 @@ const useSingleOrderCart = () => {
|
|
|
534
535
|
exports.useSingleOrderCart = useSingleOrderCart;
|
|
535
536
|
const useOrderDataQuery = exports.useOrderDataQuery = function useOrderDataQuery() {
|
|
536
537
|
let orderParameters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
537
|
-
const
|
|
538
|
+
const [{
|
|
539
|
+
existingDossierId
|
|
540
|
+
}] = (0, _OrderSessionContext.useOrderSession)();
|
|
541
|
+
const pricingFormula = (0, _usePricingFormula.usePricingFormula)();
|
|
542
|
+
const normalizedOrderParams = (0, _queryKeyFactory.normalizeOrderParams)(_objectSpread(_objectSpread({}, orderParameters), {}, {
|
|
543
|
+
formula: pricingFormula
|
|
544
|
+
}, existingDossierId ? {
|
|
545
|
+
existingDossierEntityId: existingDossierId
|
|
546
|
+
} : {}));
|
|
538
547
|
const {
|
|
539
548
|
licensePlate,
|
|
540
549
|
model
|
|
@@ -69,7 +69,7 @@ function _toPrimitive(t, r) {
|
|
|
69
69
|
}
|
|
70
70
|
return ("string" === r ? String : Number)(t);
|
|
71
71
|
}
|
|
72
|
-
const ORDER_PARAM_PRIORITY = ['licensePlate', 'model', 'formula', 'buildYear', 'durationAnswer', 'executionAnswer1', 'executionAnswer2', 'selectBoardComputerUpdate', 'branchId', 'skipFilters', 'discountCode', 'discountAmount', 'discountPercentage', 'montageRate', 'extraPriceAmount', 'priceCalculationDate', 'cart'];
|
|
72
|
+
const ORDER_PARAM_PRIORITY = ['licensePlate', 'model', 'formula', 'buildYear', 'durationAnswer', 'executionAnswer1', 'executionAnswer2', 'selectBoardComputerUpdate', 'branchId', 'existingDossierEntityId', 'skipFilters', 'discountCode', 'discountAmount', 'discountPercentage', 'montageRate', 'extraPriceAmount', 'priceCalculationDate', 'cart'];
|
|
73
73
|
const removeNullishEntries = function removeNullishEntries() {
|
|
74
74
|
let value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
75
75
|
return Object.fromEntries(Object.entries(value).filter(_ref => {
|
|
@@ -513,18 +513,6 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
513
513
|
|
|
514
514
|
setAddressLookupTimeoutId(newTimeoutId);
|
|
515
515
|
};
|
|
516
|
-
const handlePostalCodeChange = value => {
|
|
517
|
-
updateCustomerField('zipCode', value);
|
|
518
|
-
const inferredCountry = (0, _helpers__.getCountryOptionForPostalCode)(value, countryOptions);
|
|
519
|
-
if (inferredCountry && inferredCountry.value !== (customer === null || customer === void 0 ? void 0 : customer.countryId)) {
|
|
520
|
-
updateCustomerField('countryId', inferredCountry.value);
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
// Trigger address lookup if house number is also available
|
|
524
|
-
if (customer.houseNumber) {
|
|
525
|
-
handleAddressLookup(value, customer.houseNumber);
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
516
|
|
|
529
517
|
// Cleanup timeout on unmount
|
|
530
518
|
(0, _react.useEffect)(() => {
|
|
@@ -869,7 +857,13 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
869
857
|
placeholder: "",
|
|
870
858
|
value: customer.zipCode,
|
|
871
859
|
name: "zipCode",
|
|
872
|
-
onChange:
|
|
860
|
+
onChange: value => {
|
|
861
|
+
updateCustomerField('zipCode', value);
|
|
862
|
+
// Trigger address lookup if house number is also available
|
|
863
|
+
if (customer.houseNumber) {
|
|
864
|
+
handleAddressLookup(value, customer.houseNumber);
|
|
865
|
+
}
|
|
866
|
+
},
|
|
873
867
|
isRequired: isDirectDeliveryEnabled,
|
|
874
868
|
key: "zipCode-".concat(refreshKey),
|
|
875
869
|
form: form,
|
|
@@ -922,7 +916,6 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
922
916
|
label: "Stad:".concat(addressLookupLoading ? ' (wordt opgezocht...)' : ''),
|
|
923
917
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['city']
|
|
924
918
|
}), /*#__PURE__*/_react.default.createElement(_DropdownInput.default, {
|
|
925
|
-
key: "country-".concat((customer === null || customer === void 0 ? void 0 : customer.countryId) || 'default'),
|
|
926
919
|
options: countryOptions,
|
|
927
920
|
name: "country",
|
|
928
921
|
label: "Land:",
|
|
@@ -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.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;
|
|
9
|
+
exports.normalizeFormulaForOrderApi = 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");
|
|
@@ -255,6 +255,18 @@ const normalizeFormulaInput = formula => {
|
|
|
255
255
|
const normalizedFormula = formula.trim();
|
|
256
256
|
return normalizedFormula.length > 0 ? normalizedFormula : null;
|
|
257
257
|
};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Hyper order/pricing APIs expect TM instead of THM for non-dossier flows.
|
|
261
|
+
*/
|
|
262
|
+
const normalizeFormulaForOrderApi = formula => {
|
|
263
|
+
const normalizedFormula = getConfiguratorFormulaCode(formula);
|
|
264
|
+
if (!normalizedFormula) {
|
|
265
|
+
return normalizedFormula;
|
|
266
|
+
}
|
|
267
|
+
return normalizedFormula === CONFIGURATOR_FORMULAS.THM ? CONFIGURATOR_FORMULAS.TM : normalizedFormula;
|
|
268
|
+
};
|
|
269
|
+
exports.normalizeFormulaForOrderApi = normalizeFormulaForOrderApi;
|
|
258
270
|
const getConfiguratorFormulaCode = formula => {
|
|
259
271
|
const normalizedFormula = normalizeFormulaInput(formula);
|
|
260
272
|
if (!normalizedFormula) {
|
|
@@ -830,18 +830,6 @@ const InternalAppointmentForm = _ref => {
|
|
|
830
830
|
|
|
831
831
|
setAddressLookupTimeoutId(newTimeoutId);
|
|
832
832
|
};
|
|
833
|
-
const handlePostalCodeChange = value => {
|
|
834
|
-
updateCustomerField('zipCode', value);
|
|
835
|
-
const inferredCountry = (0, _helpers__.getCountryOptionForPostalCode)(value, countryOptions);
|
|
836
|
-
if (inferredCountry && inferredCountry.value !== (customer === null || customer === void 0 ? void 0 : customer.countryId)) {
|
|
837
|
-
updateCustomerField('countryId', inferredCountry.value);
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
// Trigger address lookup if house number is also available
|
|
841
|
-
if (customer.houseNumber) {
|
|
842
|
-
handleAddressLookup(value, customer.houseNumber);
|
|
843
|
-
}
|
|
844
|
-
};
|
|
845
833
|
|
|
846
834
|
// Cleanup timeout on unmount
|
|
847
835
|
(0, _react.useEffect)(() => {
|
|
@@ -1232,7 +1220,13 @@ const InternalAppointmentForm = _ref => {
|
|
|
1232
1220
|
placeholder: "",
|
|
1233
1221
|
value: customer.zipCode,
|
|
1234
1222
|
name: "zipCode",
|
|
1235
|
-
onChange:
|
|
1223
|
+
onChange: value => {
|
|
1224
|
+
updateCustomerField('zipCode', value);
|
|
1225
|
+
// Trigger address lookup if house number is also available
|
|
1226
|
+
if (customer.houseNumber) {
|
|
1227
|
+
handleAddressLookup(value, customer.houseNumber);
|
|
1228
|
+
}
|
|
1229
|
+
},
|
|
1236
1230
|
key: "zipCode-".concat(refreshKey),
|
|
1237
1231
|
isRequired: true,
|
|
1238
1232
|
label: "Postcode:",
|
|
@@ -1330,7 +1324,13 @@ const InternalAppointmentForm = _ref => {
|
|
|
1330
1324
|
placeholder: "",
|
|
1331
1325
|
value: customer.zipCode,
|
|
1332
1326
|
name: "zipCode",
|
|
1333
|
-
onChange:
|
|
1327
|
+
onChange: value => {
|
|
1328
|
+
updateCustomerField('zipCode', value);
|
|
1329
|
+
// Trigger address lookup if house number is also available
|
|
1330
|
+
if (customer.houseNumber) {
|
|
1331
|
+
handleAddressLookup(value, customer.houseNumber);
|
|
1332
|
+
}
|
|
1333
|
+
},
|
|
1334
1334
|
key: "zipCode-".concat(refreshKey),
|
|
1335
1335
|
isRequired: true,
|
|
1336
1336
|
label: "Postcode:",
|
|
@@ -1407,7 +1407,13 @@ const InternalAppointmentForm = _ref => {
|
|
|
1407
1407
|
placeholder: "",
|
|
1408
1408
|
value: customer.zipCode,
|
|
1409
1409
|
name: "zipCode",
|
|
1410
|
-
onChange:
|
|
1410
|
+
onChange: value => {
|
|
1411
|
+
updateCustomerField('zipCode', value);
|
|
1412
|
+
// Trigger address lookup if house number is also available
|
|
1413
|
+
if (customer.houseNumber) {
|
|
1414
|
+
handleAddressLookup(value, customer.houseNumber);
|
|
1415
|
+
}
|
|
1416
|
+
},
|
|
1411
1417
|
key: "zipCode-".concat(refreshKey),
|
|
1412
1418
|
isRequired: true,
|
|
1413
1419
|
label: "Postcode:",
|
|
@@ -114,6 +114,7 @@ OrderSessionContext.displayName = 'OrderSessionContext';
|
|
|
114
114
|
const INITIAL_ORDER_SESSION_STATE = {
|
|
115
115
|
isTouched: false,
|
|
116
116
|
existingDossierId: null,
|
|
117
|
+
dossierFormulaCode: null,
|
|
117
118
|
currentDossierType: null,
|
|
118
119
|
existingDossierType: null,
|
|
119
120
|
licensePlate: null,
|
|
@@ -1373,7 +1374,8 @@ const initializeOrderSession = function initializeOrderSession() {
|
|
|
1373
1374
|
const searchParams = new URLSearchParams(window.location.search);
|
|
1374
1375
|
const shouldRestorePublicSession = APP_CONFIG.internal || searchParams.get('persistSession') === 'true';
|
|
1375
1376
|
const cachedSession = (0, _helpers__.parseJson)(window.sessionStorage.getItem(storageKey));
|
|
1376
|
-
|
|
1377
|
+
const shouldRestoreDossierEditSession = Boolean(cachedSession === null || cachedSession === void 0 ? void 0 : cachedSession.existingDossierId);
|
|
1378
|
+
if (!cachedSession || !shouldRestorePublicSession && !shouldRestoreDossierEditSession) {
|
|
1377
1379
|
if (!isPrivateSingleOrder && !APP_CONFIG.internal) {
|
|
1378
1380
|
window.sessionStorage.removeItem(storageKey);
|
|
1379
1381
|
}
|
|
@@ -109,7 +109,7 @@ const getDossierCountryId = function getDossierCountryId() {
|
|
|
109
109
|
* @description Covnerts an existing hyper dossier object into a local order session
|
|
110
110
|
*/
|
|
111
111
|
const parseDossierToOrderSession = exports.parseDossierToOrderSession = function parseDossierToOrderSession() {
|
|
112
|
-
var _ref2, _ref3, _ref4, _dossier$construction, _dossier$typeEigendom, _dossier$bedrijf, _dossier$bedrijf2, _dossier$bedrijf3, _dossier$lines, _dossier$statusBeoord, _dossier$kanaal, _dossier$kanaalPartne, _dossier$kanaalHoofka, _dossier$kanaalWebsit, _dossier$kanaal2, _dossier$statusDossie, _dossier$statusDossie2, _dossier$merk, _dossier$vestiging, _dossier$chassisnumme, _dossier$typeEigendom2, _getDossierValue, _getDossierValue2, _getDossierValue3, _getDossierValue4, _getDossierValue5, _dossier$anwbId, _dossier$leasemaatsch, _dossier$leasemaatsch2, _dossier$placeholderB, _dossier$kvkNummer, _dossier$btwNummer, _ref5, _ref6, _dossier$leasemaatsch3, _dossier$leasemaatsch4, _dossier$bedrijf4, _ref7, _ref8, _ref9, _dossier$leasemaatsch5, _dossier$leasemaatsch6, _dossier$leasemaatsch7, _dossier$leasemaatsch8, _dossier$leasemaatsch9, _dossier$leasemaatsch10, _dossier$zakelijkCont, _dossier$zakelijkCont2, _ref10, _dossier$zakeiljkCont, _dossier$zakelijkCont3, _dossier$hasGoedkeuri, _meerprijsLine$consum, _meerprijsLine$extraN;
|
|
112
|
+
var _ref2, _ref3, _ref4, _dossier$construction, _dossier$typeEigendom, _dossier$bedrijf, _dossier$bedrijf2, _dossier$bedrijf3, _dossier$lines, _dossier$statusBeoord, _dossier$kanaal, _dossier$kanaalPartne, _dossier$kanaalHoofka, _dossier$kanaalWebsit, _dossier$kanaal2, _dossier$statusDossie, _dossier$statusDossie2, _dossier$merk, _dossier$vestiging, _getConfiguratorFormu, _dossier$chassisnumme, _dossier$typeEigendom2, _getDossierValue, _getDossierValue2, _getDossierValue3, _getDossierValue4, _getDossierValue5, _dossier$anwbId, _dossier$leasemaatsch, _dossier$leasemaatsch2, _dossier$placeholderB, _dossier$kvkNummer, _dossier$btwNummer, _ref5, _ref6, _dossier$leasemaatsch3, _dossier$leasemaatsch4, _dossier$bedrijf4, _ref7, _ref8, _ref9, _dossier$leasemaatsch5, _dossier$leasemaatsch6, _dossier$leasemaatsch7, _dossier$leasemaatsch8, _dossier$leasemaatsch9, _dossier$leasemaatsch10, _dossier$zakelijkCont, _dossier$zakelijkCont2, _ref10, _dossier$zakeiljkCont, _dossier$zakelijkCont3, _dossier$hasGoedkeuri, _meerprijsLine$consum, _meerprijsLine$extraN;
|
|
113
113
|
let dossier = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
114
114
|
const resolvedBuildYear = (_ref2 = (_ref3 = (_ref4 = (_dossier$construction = dossier === null || dossier === void 0 ? void 0 : dossier.constructionYear) !== null && _dossier$construction !== void 0 ? _dossier$construction : dossier === null || dossier === void 0 ? void 0 : dossier.bouwjaar) !== null && _ref4 !== void 0 ? _ref4 : dossier === null || dossier === void 0 ? void 0 : dossier.bouwjaar2) !== null && _ref3 !== void 0 ? _ref3 : dossier === null || dossier === void 0 ? void 0 : dossier.modeljaar) !== null && _ref2 !== void 0 ? _ref2 : null;
|
|
115
115
|
const isLeaseOwnership = (dossier === null || dossier === void 0 || (_dossier$typeEigendom = dossier.typeEigendomAuto) === null || _dossier$typeEigendom === void 0 ? void 0 : _dossier$typeEigendom.title) === _constants__.VEHICLE_OWNERSHIP_TYPE.Leasemaatschappij;
|
|
@@ -165,6 +165,7 @@ const parseDossierToOrderSession = exports.parseDossierToOrderSession = function
|
|
|
165
165
|
return hasInactiveVoertuigcodering || hasBoardComputerCableset && hasNoVoertuigcodering;
|
|
166
166
|
})(),
|
|
167
167
|
selectedBranch: dossier === null || dossier === void 0 || (_dossier$vestiging = dossier.vestiging) === null || _dossier$vestiging === void 0 ? void 0 : _dossier$vestiging.entityId,
|
|
168
|
+
dossierFormulaCode: (_getConfiguratorFormu = (0, _constants__.getConfiguratorFormulaCode)(dossier === null || dossier === void 0 ? void 0 : dossier.formule)) !== null && _getConfiguratorFormu !== void 0 ? _getConfiguratorFormu : null,
|
|
168
169
|
discountCode: dossier === null || dossier === void 0 ? void 0 : dossier.discountCode,
|
|
169
170
|
anwbDiscountValidated,
|
|
170
171
|
chassisNumber: (_dossier$chassisnumme = dossier === null || dossier === void 0 ? void 0 : dossier.chassisnummer) !== null && _dossier$chassisnumme !== void 0 ? _dossier$chassisnumme : null,
|
|
@@ -3,14 +3,12 @@
|
|
|
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");
|
|
7
6
|
require("core-js/modules/es.regexp.to-string.js");
|
|
8
7
|
require("core-js/modules/es.string.ends-with.js");
|
|
9
8
|
require("core-js/modules/es.string.replace.js");
|
|
10
9
|
require("core-js/modules/es.string.trim.js");
|
|
11
10
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
12
11
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
13
|
-
require("core-js/modules/esnext.iterator.find.js");
|
|
14
12
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
15
13
|
require("core-js/modules/esnext.iterator.map.js");
|
|
16
14
|
require("core-js/modules/esnext.iterator.reduce.js");
|
|
@@ -34,26 +32,21 @@ var _exportNames = {
|
|
|
34
32
|
truncateAtPipe: true,
|
|
35
33
|
parseJson: true,
|
|
36
34
|
isBelgianDomain: true,
|
|
37
|
-
isDutchPostalCode: true,
|
|
38
|
-
isBelgianPostalCode: true,
|
|
39
|
-
getCountryOptionForPostalCode: true,
|
|
40
35
|
removeNullishProps: true,
|
|
41
36
|
createSlug: true,
|
|
42
37
|
getProxyApiErrorMessage: true,
|
|
43
38
|
formatMontageTime: true
|
|
44
39
|
};
|
|
45
|
-
exports.withStyle = exports.truncateAtPipe = exports.removeNullishProps = exports.reduceYupErrorsToObject = exports.pushToDataLayer = exports.parseJson = exports.parseDateAndTimeToTimestamp = exports.parseArrayToInputOptions = exports.normalizeArray = exports.
|
|
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;
|
|
46
41
|
require("core-js/modules/es.array.reduce.js");
|
|
47
42
|
require("core-js/modules/es.object.from-entries.js");
|
|
48
43
|
require("core-js/modules/es.regexp.exec.js");
|
|
49
|
-
require("core-js/modules/es.regexp.test.js");
|
|
50
44
|
require("core-js/modules/es.regexp.to-string.js");
|
|
51
45
|
require("core-js/modules/es.string.ends-with.js");
|
|
52
46
|
require("core-js/modules/es.string.replace.js");
|
|
53
47
|
require("core-js/modules/es.string.trim.js");
|
|
54
48
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
55
49
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
56
|
-
require("core-js/modules/esnext.iterator.find.js");
|
|
57
50
|
require("core-js/modules/esnext.iterator.map.js");
|
|
58
51
|
require("core-js/modules/esnext.iterator.reduce.js");
|
|
59
52
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
@@ -299,33 +292,11 @@ const isBelgianDomain = () => {
|
|
|
299
292
|
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();
|
|
300
293
|
return Boolean(hostname && (hostname === 'be' || hostname.endsWith('.be')));
|
|
301
294
|
};
|
|
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
|
-
};
|
|
325
295
|
|
|
326
296
|
/**
|
|
327
297
|
* @description Removes nullish properties from a passed object
|
|
328
298
|
*/
|
|
299
|
+
exports.isBelgianDomain = isBelgianDomain;
|
|
329
300
|
const removeNullishProps = exports.removeNullishProps = function removeNullishProps() {
|
|
330
301
|
let object = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
331
302
|
return Object.fromEntries(Object.entries(object).filter(_ref3 => {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.usePricingFormula = exports.default = void 0;
|
|
8
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
|
+
var _constants__ = require("../__constants__");
|
|
10
|
+
var _FormulaContext = require("../__context__/FormulaContext");
|
|
11
|
+
var _OrderSessionContext = require("../__context__/OrderSessionContext");
|
|
12
|
+
/**
|
|
13
|
+
* Formula used for Hyper order/pricing requests.
|
|
14
|
+
* When editing an existing dossier, uses the dossier's formule — not the branch formule.
|
|
15
|
+
*/
|
|
16
|
+
const usePricingFormula = () => {
|
|
17
|
+
var _getConfiguratorFormu;
|
|
18
|
+
const [{
|
|
19
|
+
existingDossierId,
|
|
20
|
+
dossierFormulaCode
|
|
21
|
+
}] = (0, _OrderSessionContext.useOrderSession)();
|
|
22
|
+
const branchFormula = (0, _FormulaContext.useFormula)();
|
|
23
|
+
if (existingDossierId && dossierFormulaCode) {
|
|
24
|
+
return dossierFormulaCode;
|
|
25
|
+
}
|
|
26
|
+
const branchResolved = (_getConfiguratorFormu = (0, _constants__.getConfiguratorFormulaCode)(branchFormula)) !== null && _getConfiguratorFormu !== void 0 ? _getConfiguratorFormu : branchFormula;
|
|
27
|
+
return (0, _constants__.normalizeFormulaForOrderApi)(branchResolved);
|
|
28
|
+
};
|
|
29
|
+
exports.usePricingFormula = usePricingFormula;
|
|
30
|
+
var _default = exports.default = usePricingFormula;
|
|
@@ -34,6 +34,7 @@ var _reactRouterDom = require("react-router-dom/cjs/react-router-dom.min");
|
|
|
34
34
|
var _authenticatedProxyApi = require("../../__api__/authenticatedProxyApi");
|
|
35
35
|
var _queries = require("../../__api__/queries");
|
|
36
36
|
var _FullPageSpinner = _interopRequireDefault(require("../../__components__/Spinners/FullPageSpinner"));
|
|
37
|
+
var _constants__ = require("../../__constants__");
|
|
37
38
|
var _FormulaContext = require("../../__context__/FormulaContext");
|
|
38
39
|
var _OrderSessionContext = require("../../__context__/OrderSessionContext");
|
|
39
40
|
var _helpers__ = require("../../__helpers__");
|
|
@@ -116,7 +117,6 @@ const InternalSessionEditPage = props => {
|
|
|
116
117
|
var _props$match;
|
|
117
118
|
const [dossiertype, dossierType] = (0, _useSearchParam.default)(['dossiertype', 'dossierType']); // Note: this is of type `DOSSIER_TYPES` (found in __constants__ folder)
|
|
118
119
|
|
|
119
|
-
const formula = (0, _FormulaContext.useFormula)();
|
|
120
120
|
const {
|
|
121
121
|
dossierById,
|
|
122
122
|
isDossierByIdError
|
|
@@ -125,14 +125,21 @@ const InternalSessionEditPage = props => {
|
|
|
125
125
|
dossierType: dossierType ? dossierType : dossiertype
|
|
126
126
|
});
|
|
127
127
|
const [_, dispatch] = (0, _OrderSessionContext.useOrderSession)();
|
|
128
|
+
const setFormula = (0, _FormulaContext.useFormulaDispatch)();
|
|
128
129
|
const history = (0, _reactRouter.useHistory)();
|
|
129
130
|
const hydrateOrderSessionByDossier = (0, _react.useCallback)(async dossierById => {
|
|
130
131
|
try {
|
|
131
|
-
var _dossierById$akkoordO, _orderRes$data, _orderRes$data2, _session$discountCode, _session$customer, _sessionProducts$sele;
|
|
132
|
+
var _dossierById$akkoordO, _getConfiguratorFormu, _orderRes$data, _orderRes$data2, _session$discountCode, _session$customer, _sessionProducts$sele;
|
|
133
|
+
window.sessionStorage.removeItem(_constants__.ORDER_SESSION_KEY);
|
|
132
134
|
const session = (0, _dossier.parseDossierToOrderSession)(dossierById);
|
|
133
135
|
session.customerAgreed = (_dossierById$akkoordO = dossierById === null || dossierById === void 0 ? void 0 : dossierById.akkoordOpmerkingen) !== null && _dossierById$akkoordO !== void 0 ? _dossierById$akkoordO : false;
|
|
136
|
+
const dossierFormula = (_getConfiguratorFormu = (0, _constants__.getConfiguratorFormulaCode)(dossierById === null || dossierById === void 0 ? void 0 : dossierById.formule)) !== null && _getConfiguratorFormu !== void 0 ? _getConfiguratorFormu : _constants__.CONFIGURATOR_FORMULAS.THM;
|
|
137
|
+
if (setFormula) {
|
|
138
|
+
setFormula(dossierFormula);
|
|
139
|
+
}
|
|
134
140
|
const orderRes = await _authenticatedProxyApi.authenticatedProxyApi.getOrder(new URLSearchParams((0, _helpers__.removeNullishProps)(_objectSpread(_objectSpread({}, session), {}, {
|
|
135
|
-
formula
|
|
141
|
+
formula: dossierFormula,
|
|
142
|
+
existingDossierEntityId: dossierById === null || dossierById === void 0 ? void 0 : dossierById.entityId
|
|
136
143
|
}))).toString());
|
|
137
144
|
|
|
138
145
|
// Note: we need to use this function to classify the products found in the dossier orderlines
|
|
@@ -159,12 +166,12 @@ const InternalSessionEditPage = props => {
|
|
|
159
166
|
console.error('hydrateOrderSessionByDossier(): ', ex);
|
|
160
167
|
history.push('/configurator/geen-dossiers');
|
|
161
168
|
}
|
|
162
|
-
}, [
|
|
169
|
+
}, [dossierType, dispatch, history, setFormula]);
|
|
163
170
|
(0, _react.useEffect)(() => {
|
|
164
171
|
if (dossierById) {
|
|
165
172
|
hydrateOrderSessionByDossier(dossierById);
|
|
166
173
|
}
|
|
167
|
-
}, [dossierById]);
|
|
174
|
+
}, [dossierById, hydrateOrderSessionByDossier]);
|
|
168
175
|
if (isDossierByIdError) {
|
|
169
176
|
return /*#__PURE__*/_react.default.createElement(_reactRouterDom.Redirect, {
|
|
170
177
|
to: "/configurator/geen-dossiers"
|