thm-p3-configurator 0.0.69 → 0.0.71

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.
@@ -1,11 +1,9 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.promise.js");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.orderApi = void 0;
8
- require("core-js/modules/es.promise.js");
9
7
  var _axios = _interopRequireDefault(require("axios"));
10
8
  var _index = require("../__constants__/index.js");
11
9
  var _LocalStorageWorker = require("../__services__/LocalStorageWorker.js");
@@ -31,25 +29,9 @@ orderClient.interceptors.request.use(config => {
31
29
  config.headers.Authorization = "Bearer ".concat(authSession === null || authSession === void 0 ? void 0 : authSession.accessToken);
32
30
  return config;
33
31
  });
34
-
35
- // Add response interceptor to handle 4xx errors
36
- orderClient.interceptors.response.use(response => response, error => {
37
- if (error.response && error.response.status >= 400 && error.response.status < 500) {
38
- console.error('API Error:', {
39
- status: error.response.status,
40
- statusText: error.response.statusText,
41
- data: error.response.data,
42
- url: error.config.url
43
- });
44
- }
45
- return Promise.reject(error);
46
- });
47
32
  const orderApi = exports.orderApi = {
48
- getOrder: orderParameters => {
49
- console.log(orderParameters);
50
- return orderClient("api".concat(APP_CONFIG.internal ? '' : '/public', "/order?").concat(orderParameters) // Remove the `/public` param if the configurator is internal,
51
- );
52
- },
33
+ getOrder: orderParameters => orderClient("api".concat(APP_CONFIG.internal ? '' : '/public', "/order?").concat(orderParameters) // Remove the `/public` param if the configurator is internal,
34
+ ),
53
35
  getArticlePrices: partsQueryString => orderClient("api".concat(APP_CONFIG.internal ? '' : '/public', "/prices?").concat(partsQueryString)),
54
36
  getArticles: filters => orderClient("api/public/articles?".concat(filters)),
55
37
  getBrands: () => orderClient('api/public/makes'),
@@ -297,9 +297,13 @@ const useSingleOrderArticles = exports.useSingleOrderArticles = function useSing
297
297
  */
298
298
  const useSingleOrderCart = () => {
299
299
  const [{
300
- singleOrderCart
300
+ singleOrderCart,
301
+ singleOrderFormulaCode
301
302
  }] = (0, _OrderSessionContext.useOrderSession)();
302
- const formula = (0, _FormulaContext.useFormula)();
303
+ let formula = (0, _FormulaContext.useFormula)();
304
+ if (singleOrderFormulaCode) {
305
+ formula = singleOrderFormulaCode;
306
+ }
303
307
  let cartOrderQuery = new URLSearchParams((0, _helpers__.removeNullishProps)({
304
308
  formula,
305
309
  isSingle: true,
@@ -11,11 +11,13 @@ require("core-js/modules/web.dom-collections.iterator.js");
11
11
  var _reactGoogleMaps = require("@vis.gl/react-google-maps");
12
12
  var _react = _interopRequireWildcard(require("react"));
13
13
  var _queries = require("../../__api__/queries");
14
+ var _constants__ = require("../../__constants__");
14
15
  var _FormulaContext = require("../../__context__/FormulaContext");
15
16
  var _OrderSessionContext = require("../../__context__/OrderSessionContext");
16
17
  var _helpers__ = require("../../__helpers__");
17
18
  var _useBreakpoint = _interopRequireDefault(require("../../__hooks__/useBreakpoint"));
18
19
  var _useUserLocation = _interopRequireDefault(require("../../__hooks__/useUserLocation"));
20
+ var _LocalStorageWorker = require("../../__services__/LocalStorageWorker");
19
21
  var _LocationAutoComplete = _interopRequireDefault(require("./LocationAutoComplete"));
20
22
  var _LocationClusteredMap = _interopRequireDefault(require("./LocationClusteredMap"));
21
23
  var _LocationList = _interopRequireDefault(require("./LocationList"));
@@ -66,19 +68,36 @@ const LocationsSelector = /*#__PURE__*/_react.default.memo(() => {
66
68
  const [{
67
69
  franchiseName
68
70
  }] = (0, _OrderSessionContext.useOrderSession)();
71
+ const authSession = _LocalStorageWorker.lsw.getJson(_constants__.AUTH_SESSION_KEY);
69
72
  const {
70
- branches: locations
71
- } = (0, _queries.useBranchesQuery)({
72
- offset: 0,
73
- limit: 400,
74
- formula,
75
- franchiseName
76
- });
73
+ branchTypes
74
+ } = (0, _queries.useBranchTypes)();
75
+ const isTMGOrganization = _react.default.useMemo(() => {
76
+ var _branchTypes$byId$aut, _authSession$branch;
77
+ return (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) === _constants__.TMG_ORGANIZATION_TYPE;
78
+ }, [branchTypes, authSession]);
79
+ let locations;
80
+ if (isTMGOrganization) {
81
+ const {
82
+ branches
83
+ } = (0, _queries.useBranchesQuery)({
84
+ offset: 0,
85
+ limit: 400,
86
+ formula,
87
+ franchiseName
88
+ });
89
+ locations = (branches === null || branches === void 0 ? void 0 : branches.results) || [];
90
+ } else {
91
+ const {
92
+ myBranches
93
+ } = (0, _queries.useMyBranches)(formula);
94
+ locations = myBranches || [];
95
+ }
77
96
  const {
78
97
  byId,
79
98
  allIds
80
99
  } = (0, _react.useMemo)(() => (0, _helpers__.normalizeArray)({
81
- array: (locations === null || locations === void 0 ? void 0 : locations.results) || [],
100
+ array: locations || [],
82
101
  key: 'entityId'
83
102
  }), [locations]);
84
103
  (0, _react.useEffect)(() => {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.VEHICLE_OWNERSHIP_TYPE = exports.USER_GEOLOCATION_KEY = exports.TMG_ORGANIZATION_TYPE = exports.StockStatus = exports.PRODUCT_CATEGORIES = exports.PRIVATE_SINGLE_ORDER_SESSION_KEY = exports.ORDER_SESSION_KEY = 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.LOCALE = exports.FORM_ERROR_MESSAGES = exports.DOSSIER_TYPES = exports.DISCOUNT_TYPES = exports.DEFAULT_MAP_LONGITUDE = exports.DEFAULT_MAP_LATITUDE = exports.DEFAULT_ARTICLE_BRAND = exports.CONFIGURATOR_FORMULAS = exports.BOARD_COMPUTER_DISABLED_KEY = exports.AUTH_SESSION_KEY = exports.ARTICLES_SYSTEM_FIELDS = exports.API_ERROR_CODES = exports.ANWB_DISCOUNT_CODE = exports.ALL_EXPERIMENTS = exports.ACTIVE_VARIANTS = void 0;
6
+ exports.VEHICLE_OWNERSHIP_TYPE = exports.USER_GEOLOCATION_KEY = exports.TMG_ORGANIZATION_TYPE = exports.StockStatus = exports.PRODUCT_CATEGORIES = exports.PRIVATE_SINGLE_ORDER_SESSION_KEY = exports.ORDER_SESSION_KEY = 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.FORM_ERROR_MESSAGES = exports.DOSSIER_TYPES = exports.DISCOUNT_TYPES = exports.DEFAULT_MAP_LONGITUDE = exports.DEFAULT_MAP_LATITUDE = exports.DEFAULT_ARTICLE_BRAND = exports.CONFIGURATOR_FORMULAS = exports.BOARD_COMPUTER_DISABLED_KEY = exports.AUTH_SESSION_KEY = exports.ARTICLES_SYSTEM_FIELDS = exports.API_ERROR_CODES = exports.ANWB_DISCOUNT_CODE = exports.ALL_EXPERIMENTS = exports.ACTIVE_VARIANTS = void 0;
7
7
  const DOSSIER_TYPES = exports.DOSSIER_TYPES = {
8
8
  Quotation: 'quotation',
9
9
  AppointmentRequest: 'appointment-request',
@@ -90,6 +90,11 @@ const NAVIGATION_BUTTONS = exports.NAVIGATION_BUTTONS = {
90
90
  label: 'Maak een afspraak',
91
91
  type: 'next',
92
92
  shouldShowForDossierTypes: [DOSSIER_TYPES.AppointmentRequest, DOSSIER_TYPES.PlannedAppointment]
93
+ }, {
94
+ to: '/configurator/montagelocatie',
95
+ label: 'Wijzig de locatie',
96
+ type: 'next',
97
+ shouldShowForDossierTypes: [DOSSIER_TYPES.Quotation]
93
98
  }],
94
99
  '/configurator/montagelocatie': [{
95
100
  to: '/configurator/overzicht',
@@ -98,7 +103,13 @@ const NAVIGATION_BUTTONS = exports.NAVIGATION_BUTTONS = {
98
103
  }, {
99
104
  to: '/configurator/gegevens',
100
105
  label: 'Maak een afspraak',
101
- type: 'next'
106
+ type: 'next',
107
+ shouldShowForDossierTypes: [DOSSIER_TYPES.AppointmentRequest, DOSSIER_TYPES.PlannedAppointment]
108
+ }, {
109
+ to: '/configurator/offerte',
110
+ label: 'Mail mij de offerte',
111
+ type: 'next',
112
+ shouldShowForDossierTypes: [DOSSIER_TYPES.Quotation]
102
113
  }]
103
114
  };
104
115
  const DEFAULT_MAP_LATITUDE = exports.DEFAULT_MAP_LATITUDE = 52.090736;
@@ -130,6 +141,7 @@ const CONFIGURATOR_FORMULAS = exports.CONFIGURATOR_FORMULAS = {
130
141
  THC: 'THC',
131
142
  TMG: 'TMG'
132
143
  };
144
+ const LOCATION_CHANGE_BUTTON_LABEL = exports.LOCATION_CHANGE_BUTTON_LABEL = 'Wijzig de locatie';
133
145
  const TMG_ORGANIZATION_TYPE = exports.TMG_ORGANIZATION_TYPE = 'TowMotive Group';
134
146
  const LOCATION_TYPE = exports.LOCATION_TYPE = 'Vestiging';
135
147
  const ANWB_DISCOUNT_CODE = exports.ANWB_DISCOUNT_CODE = 'ANWBTHC25';
@@ -94,7 +94,8 @@ const BottomNavigationBar = () => {
94
94
  selectedCableset,
95
95
  selectedCombiset,
96
96
  selectedBranch,
97
- existingDossierType
97
+ existingDossierType,
98
+ allowLocationChange
98
99
  }] = (0, _OrderSessionContext.useOrderSession)();
99
100
  if (!(buttons !== null && buttons !== void 0 && buttons.length)) {
100
101
  return null;
@@ -119,6 +120,12 @@ const BottomNavigationBar = () => {
119
120
  if (existingDossierType && shouldShowForDossierTypes.length && !shouldShowForDossierTypes.includes(existingDossierType)) {
120
121
  return null;
121
122
  }
123
+ if (label === _constants__.LOCATION_CHANGE_BUTTON_LABEL && to === '/configurator/montagelocatie' && allowLocationChange === false) {
124
+ return null;
125
+ }
126
+ if (to === '/configurator/montagelocatie' && existingDossierType && !allowLocationChange) {
127
+ to = '/configurator/gegevens';
128
+ }
122
129
  return /*#__PURE__*/_react.default.createElement("div", {
123
130
  key: 'link-' + label,
124
131
  className: (0, _helpers__.withStyle)("col-12 col-sm-auto d-flex order-2 order-sm-0 justify-content-".concat(buttons.length > 1 ? 'center' : 'end', " mt-1"))
@@ -62,7 +62,7 @@ const VehicleData = _ref => {
62
62
  isDefaultExpanded: true,
63
63
  body: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, ' ', /*#__PURE__*/_react.default.createElement("div", {
64
64
  className: (0, _helpers__.withStyle)('col-auto col-md-12 text-center')
65
- }, /*#__PURE__*/_react.default.createElement("img", {
65
+ }, !isFilter && /*#__PURE__*/_react.default.createElement("img", {
66
66
  className: (0, _helpers__.withStyle)('vehicle-data__image img-fluid rounded-1 mx-0 mb-1'),
67
67
  src: (0, _image.getImageFromHyper)({
68
68
  imageId: vehicleLogo
@@ -164,6 +164,7 @@ const InternalAppointmentForm = _ref => {
164
164
  chassisNumber,
165
165
  channel,
166
166
  durationAnswer,
167
+ allowLocationChange,
167
168
  selectedBoardComputer,
168
169
  selectedCableset,
169
170
  selectedCombiset,
@@ -256,7 +257,7 @@ const InternalAppointmentForm = _ref => {
256
257
  });
257
258
  await onSubmit((0, _helpers__.removeNullishProps)({
258
259
  vehicle,
259
- customer: _objectSpread(_objectSpread({}, customer), {}, {
260
+ customer: (0, _helpers__.removeNullishProps)(_objectSpread(_objectSpread({}, customer), {}, {
260
261
  firstName: (_customer$firstName = customer === null || customer === void 0 ? void 0 : customer.firstName) !== null && _customer$firstName !== void 0 ? _customer$firstName : undefined,
261
262
  lastName: (_customer$lastName = customer === null || customer === void 0 ? void 0 : customer.lastName) !== null && _customer$lastName !== void 0 ? _customer$lastName : undefined,
262
263
  phoneNumber: (_customer$phoneNumber = customer === null || customer === void 0 ? void 0 : customer.phoneNumber) !== null && _customer$phoneNumber !== void 0 ? _customer$phoneNumber : undefined,
@@ -269,7 +270,7 @@ const InternalAppointmentForm = _ref => {
269
270
  zipCode: (_customer$zipCode = customer === null || customer === void 0 ? void 0 : customer.zipCode) !== null && _customer$zipCode !== void 0 ? _customer$zipCode : undefined,
270
271
  companyName: (_customer$companyName = customer === null || customer === void 0 ? void 0 : customer.companyName) !== null && _customer$companyName !== void 0 ? _customer$companyName : undefined,
271
272
  invoiceEmail: (_customer$invoiceEmai = customer === null || customer === void 0 ? void 0 : customer.invoiceEmail) !== null && _customer$invoiceEmai !== void 0 ? _customer$invoiceEmai : undefined
272
- }),
273
+ })),
273
274
  customerAgreed,
274
275
  appointment,
275
276
  channel,
@@ -690,7 +691,7 @@ const InternalAppointmentForm = _ref => {
690
691
  className: (0, _helpers__.withStyle)('d-flex align-items-center justify-content-end mt-4')
691
692
  }, /*#__PURE__*/_react.default.createElement(_NavigationButton.default, {
692
693
  variant: "link",
693
- to: '/configurator/montagelocatie',
694
+ to: allowLocationChange ? '/configurator/montagelocatie' : '/configurator/overzicht',
694
695
  label: 'Vorige',
695
696
  state: {
696
697
  prevPathName: history.location.pathname
@@ -68,9 +68,6 @@ const NormalPageModalContent = _ref => {
68
68
  const [_selectedBranchId, _setSelectedBranchId] = (0, _react.useState)();
69
69
  const [_branches, _setBranches] = (0, _react.useState)([]);
70
70
  const formula = (0, _FormulaContext.useFormula)();
71
- const {
72
- branchTypes
73
- } = (0, _queries.useBranchTypes)();
74
71
  const {
75
72
  myBranches,
76
73
  isLoadingMyBranches
@@ -112,6 +112,7 @@ const INITIAL_ORDER_SESSION_STATE = {
112
112
  executionAnswer1: null,
113
113
  executionAnswer2: null,
114
114
  priceCalculationDate: new Date().getTime(),
115
+ allowLocationChange: false,
115
116
  durationOptions: [],
116
117
  execution1Options: [],
117
118
  execution2Options: [],
@@ -67,7 +67,7 @@ function _toPrimitive(t, r) {
67
67
  * @description Covnerts an existing hyper dossier object into a local order session
68
68
  */
69
69
  const parseDossierToOrderSession = exports.parseDossierToOrderSession = function parseDossierToOrderSession() {
70
- var _dossier$kanaal, _dossier$kanaalPartne, _dossier$kanaalHoofka, _dossier$vestiging, _dossier$typeEigendom, _Date, _dossier$klant, _dossier$klant2, _dossier$klant3, _dossier$klant4, _dossier$klant5, _dossier$klant$postal, _dossier$klant6, _dossier$klant$city, _dossier$klant7, _dossier$klant$street, _dossier$klant8, _dossier$klant$huisnu, _dossier$klant9;
70
+ var _dossier$kanaal, _dossier$kanaalPartne, _dossier$kanaalHoofka, _dossier$statusDossie, _dossier$statusDossie2, _dossier$vestiging, _dossier$typeEigendom, _Date, _dossier$klant, _dossier$klant2, _dossier$klant3, _dossier$klant4, _dossier$klant5, _dossier$klant$postal, _dossier$klant6, _dossier$klant$city, _dossier$klant7, _dossier$klant$street, _dossier$klant8, _dossier$klant$huisnu, _dossier$klant9;
71
71
  let dossier = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
72
72
  return {
73
73
  licensePlate: dossier === null || dossier === void 0 ? void 0 : dossier.kenteken,
@@ -92,6 +92,7 @@ const parseDossierToOrderSession = exports.parseDossierToOrderSession = function
92
92
  selectedDiscountedProducts: [],
93
93
  // TODO
94
94
  selectedBoardComputer: null,
95
+ allowLocationChange: (_dossier$statusDossie = dossier === null || dossier === void 0 || (_dossier$statusDossie2 = dossier.statusDossier) === null || _dossier$statusDossie2 === void 0 ? void 0 : _dossier$statusDossie2.vestigingWijzigenToegestaan) !== null && _dossier$statusDossie !== void 0 ? _dossier$statusDossie : false,
95
96
  // Static:
96
97
  franchiseName: null,
97
98
  buildYear: null,
@@ -3,17 +3,18 @@
3
3
  require("core-js/modules/es.weak-map.js");
4
4
  require("core-js/modules/web.dom-collections.iterator.js");
5
5
  require("core-js/modules/es.weak-map.js");
6
- require("core-js/modules/web.dom-collections.iterator.js");
7
6
  Object.defineProperty(exports, "__esModule", {
8
7
  value: true
9
8
  });
10
9
  exports.default = void 0;
10
+ require("core-js/modules/web.dom-collections.iterator.js");
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _reactRouter = require("react-router");
13
13
  var _queries = require("../../__api__/queries");
14
14
  var _Header = _interopRequireDefault(require("../../__components__/Header"));
15
15
  var _LocationsSelector = _interopRequireDefault(require("../../__components__/LocationsSelector"));
16
16
  var _NavigationSteps = _interopRequireDefault(require("../../__components__/NavigationSteps"));
17
+ var _OrderSessionContext = require("../../__context__/OrderSessionContext");
17
18
  var _constants__ = require("../../__constants__");
18
19
  var _BottomNavigationBar = _interopRequireDefault(require("../../__containers__/BottomNavigationBar"));
19
20
  var _internal = require("../../__containers__/internal");
@@ -60,6 +61,10 @@ const InternalLocationsPage = _ref => {
60
61
  const history = (0, _reactRouter.useHistory)();
61
62
  const formula = (0, _FormulaContext.useFormula)();
62
63
  const authSession = _LocalStorageWorker.lsw.getJson(_constants__.AUTH_SESSION_KEY);
64
+ const [{
65
+ allowLocationChange,
66
+ existingDossierId
67
+ }] = (0, _OrderSessionContext.useOrderSession)();
63
68
  (0, _react.useEffect)(() => {
64
69
  var _branchTypes$byId$aut, _authSession$branch, _location$state;
65
70
  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;
@@ -69,6 +74,10 @@ const InternalLocationsPage = _ref => {
69
74
  return;
70
75
  }
71
76
 
77
+ // if we are editing an existing dossier and allowLocationChange is truethy, allowthe user to edit the location
78
+ if (allowLocationChange && existingDossierId) {
79
+ return;
80
+ }
72
81
  // Step 2: skip this page if the branch type is not TowMotive Group
73
82
  // If the previous page is appointment page ("gegevens") -> go back to overview ("overzicht")
74
83
  // Otherwise: proceed to the appointment page ("gegevens")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.69",
3
+ "version": "0.0.71",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",