thm-p3-configurator 0.0.330 → 0.0.331

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.
@@ -22,6 +22,7 @@ var _TEST_ONLY_INTERNAL_ROUTES = _interopRequireDefault(require("./__pages__/int
22
22
  var _StyleWrapper = _interopRequireDefault(require("./__containers__/StyleWrapper"));
23
23
  var _InternalBranchSelectorModal = _interopRequireDefault(require("./__containers__/internal/InternalBranchSelectorModal"));
24
24
  var _ActiveMarkerContext = require("./__context__/ActiveMarkerContext");
25
+ var _AuthSessionContext = require("./__context__/AuthSessionContext");
25
26
  var _CountryContext = require("./__context__/CountryContext");
26
27
  var _FormulaContext = require("./__context__/FormulaContext");
27
28
  var _OrderSessionContext = require("./__context__/OrderSessionContext");
@@ -70,11 +71,11 @@ const App = () => {
70
71
  (0, _Experiments.default)();
71
72
  });
72
73
  return /*#__PURE__*/_react.default.createElement(_SentryWrapper.default, null, /*#__PURE__*/_react.default.createElement(_FormulaContext.FormulaController, {
73
- defaultFormula: _constants__.CONFIGURATOR_FORMULAS.THC
74
+ defaultFormula: _constants__.CONFIGURATOR_FORMULAS.THM
74
75
  }, /*#__PURE__*/_react.default.createElement(_CountryContext.CountryController, {
75
76
  defaultCountry: APP_CONFIG.country
76
- }, /*#__PURE__*/_react.default.createElement(_OrderSessionContext.OrderSessionController, null, /*#__PURE__*/_react.default.createElement(_reactQuery.QueryClientProvider, {
77
+ }, /*#__PURE__*/_react.default.createElement(_OrderSessionContext.OrderSessionController, null, /*#__PURE__*/_react.default.createElement(_AuthSessionContext.AuthSessionProvider, null, /*#__PURE__*/_react.default.createElement(_reactQuery.QueryClientProvider, {
77
78
  client: _queryClient.default
78
- }, /*#__PURE__*/_react.default.createElement(_reactRouterDom.BrowserRouter, null, /*#__PURE__*/_react.default.createElement(_reactHotLoader.AppContainer, null, /*#__PURE__*/_react.default.createElement(_ActiveMarkerContext.ActiveMarkerProvider, null, /*#__PURE__*/_react.default.createElement(_StyleWrapper.default, null, !APP_CONFIG.internal && /*#__PURE__*/_react.default.createElement(_Navbar.default, null), APP_CONFIG.internal && /*#__PURE__*/_react.default.createElement(_InternalBranchSelectorModal.default, null), APP_CONFIG.nodeEnv === 'development' && APP_CONFIG.internal === true && /*#__PURE__*/_react.default.createElement(_TEST_ONLY_INTERNAL_ROUTES.default, null))))))))));
79
+ }, /*#__PURE__*/_react.default.createElement(_reactRouterDom.BrowserRouter, null, /*#__PURE__*/_react.default.createElement(_reactHotLoader.AppContainer, null, /*#__PURE__*/_react.default.createElement(_ActiveMarkerContext.ActiveMarkerProvider, null, /*#__PURE__*/_react.default.createElement(_StyleWrapper.default, null, !APP_CONFIG.internal && /*#__PURE__*/_react.default.createElement(_Navbar.default, null), APP_CONFIG.internal && /*#__PURE__*/_react.default.createElement(_InternalBranchSelectorModal.default, null), /*#__PURE__*/_react.default.createElement(_pages__.default, null)))))))))));
79
80
  };
80
81
  var _default = exports.default = App;
@@ -1,85 +1,126 @@
1
1
  "use strict";
2
2
 
3
+ require("core-js/modules/es.array.includes.js");
3
4
  require("core-js/modules/es.promise.js");
5
+ require("core-js/modules/es.promise.finally.js");
6
+ require("core-js/modules/es.string.includes.js");
4
7
  Object.defineProperty(exports, "__esModule", {
5
8
  value: true
6
9
  });
7
10
  exports.authenticatedProxyApi = void 0;
11
+ require("core-js/modules/es.array.includes.js");
8
12
  require("core-js/modules/es.promise.js");
13
+ require("core-js/modules/es.promise.finally.js");
14
+ require("core-js/modules/es.string.includes.js");
9
15
  var _axios = _interopRequireDefault(require("axios"));
10
- var _constants__ = require("../__constants__");
11
- var _cookieManager = require("../__helpers__/cookieManager");
12
- var _LocalStorageWorker = require("../__services__/LocalStorageWorker");
16
+ var _AuthRuntime = require("../__services__/AuthRuntime");
13
17
  function _interopRequireDefault(e) {
14
18
  return e && e.__esModule ? e : {
15
19
  default: e
16
20
  };
17
21
  }
18
- const authenticateClient = _axios.default.create({
19
- baseURL: APP_CONFIG.proxyUrl
22
+ const authenticatedClient = _axios.default.create({
23
+ baseURL: APP_CONFIG.proxyUrl,
24
+ withCredentials: true
20
25
  });
21
- const refreshClient = _axios.default.create({
22
- baseURL: APP_CONFIG.proxyUrl
26
+ const sessionClient = _axios.default.create({
27
+ baseURL: APP_CONFIG.proxyUrl,
28
+ withCredentials: true
23
29
  });
24
- refreshClient.interceptors.request.use(config => {
25
- const refreshToken = (0, _cookieManager.getRefreshToken)();
26
- config.headers.Authorization = "Bearer ".concat(refreshToken);
27
- return config;
28
- });
29
-
30
- /**
31
- * @description This interceptor:
32
- * - Appends the bearer token (For authentication)
33
- * - Appends the currently active branch Id (For authorization)
34
- */
35
- authenticateClient.interceptors.request.use(async config => {
36
- var _authSession$branch;
37
- const authSession = _LocalStorageWorker.lsw.getJson(_constants__.AUTH_SESSION_KEY);
38
- let accessToken = (0, _cookieManager.getAccessToken)();
39
- if (!accessToken && APP_CONFIG.internal) {
40
- try {
41
- const refreshResponse = await refreshClient('api/v1/auth', {
42
- method: 'PUT'
43
- });
44
- accessToken = refreshResponse.data.accessToken;
45
- (0, _cookieManager.setAccessToken)(accessToken);
46
- } catch (error) {
47
- console.log('error', error);
30
+ let refreshPromise = null;
31
+ const attachSessionHeaders = function attachSessionHeaders() {
32
+ let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
33
+ config.headers = config.headers || {};
34
+ const branchId = _AuthRuntime.authRuntime.getActiveBranchId();
35
+ if (branchId) {
36
+ config.headers['active-branch-id'] = branchId;
37
+ }
38
+ const method = (config.method || 'get').toLowerCase();
39
+ if (!['get', 'head', 'options'].includes(method)) {
40
+ const csrf = _AuthRuntime.authRuntime.getCsrfToken();
41
+ if (csrf) {
42
+ config.headers['X-CSRF-Token'] = csrf;
48
43
  }
49
44
  }
50
- config.headers.Authorization = "Bearer ".concat(accessToken);
51
- config.headers['active-branch-id'] = authSession === null || authSession === void 0 || (_authSession$branch = authSession.branch) === null || _authSession$branch === void 0 ? void 0 : _authSession$branch.entityId;
52
45
  return config;
46
+ };
47
+ authenticatedClient.interceptors.request.use(config => attachSessionHeaders(config));
48
+ sessionClient.interceptors.request.use(config => {
49
+ const normalizedConfig = attachSessionHeaders(config);
50
+ if (normalizedConfig !== null && normalizedConfig !== void 0 && normalizedConfig.headers) {
51
+ delete normalizedConfig.headers['active-branch-id'];
52
+ }
53
+ return normalizedConfig;
54
+ });
55
+ authenticatedClient.interceptors.response.use(response => response, async error => {
56
+ var _error$response, _originalRequest$url;
57
+ const status = error === null || error === void 0 || (_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status;
58
+ const originalRequest = (error === null || error === void 0 ? void 0 : error.config) || {};
59
+ if (![401, 403].includes(status) || originalRequest._retry || (_originalRequest$url = originalRequest.url) !== null && _originalRequest$url !== void 0 && _originalRequest$url.includes('api/v1/auth')) {
60
+ return Promise.reject(error);
61
+ }
62
+ originalRequest._retry = true;
63
+ if (!refreshPromise) {
64
+ refreshPromise = sessionClient('api/v1/auth', {
65
+ method: 'PUT'
66
+ }).then(response => {
67
+ var _response$data;
68
+ _AuthRuntime.authRuntime.setCsrfToken((response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.csrfToken) || null);
69
+ return response;
70
+ }).finally(() => {
71
+ refreshPromise = null;
72
+ });
73
+ }
74
+ await refreshPromise;
75
+ return authenticatedClient(originalRequest);
53
76
  });
54
77
  const authenticatedProxyApi = exports.authenticatedProxyApi = {
55
- getArticleTypes: () => authenticateClient("api/v1/articles/types", {
78
+ getSession: () => sessionClient('api/v1/auth/session', {
79
+ method: 'GET'
80
+ }),
81
+ putSessionContext: function putSessionContext() {
82
+ let {
83
+ branchEntityId,
84
+ formula,
85
+ module
86
+ } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
87
+ return authenticatedClient('api/v1/auth/context', {
88
+ method: 'PUT',
89
+ data: {
90
+ branchEntityId,
91
+ formula,
92
+ module
93
+ }
94
+ });
95
+ },
96
+ getArticleTypes: () => authenticatedClient("api/v1/articles/types", {
56
97
  method: 'GET'
57
98
  }),
58
- getCountries: () => authenticateClient("api/v1/countries", {
99
+ getCountries: () => authenticatedClient("api/v1/countries", {
59
100
  method: 'GET'
60
101
  }),
61
- putRefreshToken: () => refreshClient('api/v1/auth', {
102
+ putRefreshToken: () => sessionClient('api/v1/auth', {
62
103
  method: 'PUT'
63
104
  }),
64
- getArticleGroups: articleTypeId => authenticateClient("api/v1/articles/groups/".concat(articleTypeId), {
105
+ getArticleGroups: articleTypeId => authenticatedClient("api/v1/articles/groups/".concat(articleTypeId), {
65
106
  method: 'GET'
66
107
  }),
67
- getArticleSubGroups: (articleGroupId, formula) => authenticateClient("api/v1/articles/subgroups/".concat(articleGroupId, "?formula=").concat(formula), {
108
+ getArticleSubGroups: (articleGroupId, formula) => authenticatedClient("api/v1/articles/subgroups/".concat(articleGroupId, "?formula=").concat(formula), {
68
109
  method: 'GET'
69
110
  }),
70
- getArticles: filtersQueryString => authenticateClient("api/v1/articles?".concat(filtersQueryString), {
111
+ getArticles: filtersQueryString => authenticatedClient("api/v1/articles?".concat(filtersQueryString), {
71
112
  method: 'GET'
72
113
  }),
73
- getBrandsByArticleNumbers: articleNumbersString => authenticateClient("api/v1/articles/brands?".concat(articleNumbersString), {
114
+ getBrandsByArticleNumbers: articleNumbersString => authenticatedClient("api/v1/articles/brands?".concat(articleNumbersString), {
74
115
  method: 'GET'
75
116
  }),
76
- deleteLogout: () => authenticateClient("api/v1/auth", {
117
+ deleteLogout: () => sessionClient("api/v1/auth", {
77
118
  method: 'DELETE'
78
119
  }),
79
- getMyProfile: () => authenticateClient('api/v1/profile', {
120
+ getMyProfile: () => authenticatedClient('api/v1/profile', {
80
121
  method: 'GET'
81
122
  }),
82
- getBranchTypes: () => authenticateClient("api/v1/branch-types", {
123
+ getBranchTypes: () => authenticatedClient("api/v1/branch-types", {
83
124
  method: 'GET'
84
125
  }),
85
126
  getBranchesByType: _ref => {
@@ -91,29 +132,29 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
91
132
  isTmg = false,
92
133
  isTowCenterBranch = false
93
134
  } = _ref;
94
- return authenticateClient("api/v1/branches/by-type?searchTerm=".concat(searchTerm, "&formula=").concat(formula, "&ownershipType=").concat(ownershipType, "&organisationType=").concat(organisationType, "&isTmg=").concat(isTmg, "&isTowCenterBranch=").concat(isTowCenterBranch), {
135
+ return authenticatedClient("api/v1/branches/by-type?searchTerm=".concat(searchTerm, "&formula=").concat(formula, "&ownershipType=").concat(ownershipType, "&organisationType=").concat(organisationType, "&isTmg=").concat(isTmg, "&isTowCenterBranch=").concat(isTowCenterBranch), {
95
136
  method: 'GET'
96
137
  });
97
138
  },
98
- getMyBranchesByFormula: formula => authenticateClient("api/v1/profile/".concat(formula, "/branches"), {
139
+ getMyBranchesByFormula: formula => authenticatedClient("api/v1/profile/".concat(formula, "/branches"), {
99
140
  method: 'GET'
100
141
  }),
101
- getSingleOrderBranchTypes: branchTypesParamsString => authenticateClient("api/v1/branch-types?".concat(branchTypesParamsString), {
142
+ getSingleOrderBranchTypes: branchTypesParamsString => authenticatedClient("api/v1/branch-types?".concat(branchTypesParamsString), {
102
143
  method: 'GET'
103
144
  }),
104
- getSingleOrderBranches: branchesParamsString => authenticateClient("api/v1/branches?".concat(branchesParamsString), {
145
+ getSingleOrderBranches: branchesParamsString => authenticatedClient("api/v1/branches?".concat(branchesParamsString), {
105
146
  method: 'GET'
106
147
  }),
107
- getBranchById: id => authenticateClient("api/v1/branches/".concat(id), {
148
+ getBranchById: id => authenticatedClient("api/v1/branches/".concat(id), {
108
149
  method: 'GET'
109
150
  }),
110
- getQuotationById: id => authenticateClient("api/v1/quotations/".concat(id), {
151
+ getQuotationById: id => authenticatedClient("api/v1/quotations/".concat(id), {
111
152
  method: 'GET'
112
153
  }),
113
- getPlannedAppointmentById: id => authenticateClient("api/v1/appointments/".concat(id), {
154
+ getPlannedAppointmentById: id => authenticatedClient("api/v1/appointments/".concat(id), {
114
155
  method: 'GET'
115
156
  }),
116
- getAppointmentRequestById: id => authenticateClient("api/v1/appointment-requests/".concat(id), {
157
+ getAppointmentRequestById: id => authenticatedClient("api/v1/appointment-requests/".concat(id), {
117
158
  method: 'GET'
118
159
  }),
119
160
  getDossiers: _ref2 => {
@@ -124,7 +165,7 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
124
165
  branchId,
125
166
  formula
126
167
  } = _ref2;
127
- return authenticateClient("api/v1/dossiers?term=".concat(term, "&offset=").concat(offset, "&limit=").concat(limit).concat(branchId ? "&branchId=".concat(branchId) : '').concat(formula ? "&formula=".concat(formula) : ''), {
168
+ return authenticatedClient("api/v1/dossiers?term=".concat(term, "&offset=").concat(offset, "&limit=").concat(limit).concat(branchId ? "&branchId=".concat(branchId) : '').concat(formula ? "&formula=".concat(formula) : ''), {
128
169
  method: 'GET'
129
170
  });
130
171
  },
@@ -133,40 +174,37 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
133
174
  id,
134
175
  payload
135
176
  } = _ref3;
136
- return authenticateClient("api/v1/dossiers/".concat(id), {
177
+ return authenticatedClient("api/v1/dossiers/".concat(id), {
137
178
  method: 'PUT',
138
179
  data: payload
139
180
  });
140
181
  },
141
- postAppointmentRequest: appointmentRequestPayload => authenticateClient("api/v1/appointment-requests", {
182
+ postAppointmentRequest: appointmentRequestPayload => authenticatedClient("api/v1/appointment-requests", {
142
183
  method: 'POST',
143
184
  data: appointmentRequestPayload,
144
185
  headers: {
145
186
  'Content-Type': 'application/json'
146
187
  }
147
188
  }),
148
- postQuotation: quotationPayload => authenticateClient("api/v1/quotations", {
189
+ postQuotation: quotationPayload => authenticatedClient("api/v1/quotations", {
149
190
  method: 'POST',
150
191
  data: quotationPayload,
151
192
  headers: {
152
193
  'Content-Type': 'application/json'
153
194
  }
154
195
  }),
155
- postSingleOrder: singleOrderPayload => authenticateClient("api/v1/single-orders", {
196
+ postSingleOrder: singleOrderPayload => authenticatedClient("api/v1/single-orders", {
156
197
  method: 'POST',
157
198
  data: singleOrderPayload,
158
199
  headers: {
159
200
  'Content-Type': 'application/json'
160
201
  }
161
202
  }),
162
- postShopifyOrder: shopifyOrderPayload => authenticateClient("api/v1/single-orders/shopify", {
203
+ postShopifyOrder: shopifyOrderPayload => authenticatedClient("api/v1/single-orders/shopify", {
163
204
  method: 'POST',
164
- data: shopifyOrderPayload,
165
- headers: {
166
- 'Content-Type': 'application/json'
167
- }
205
+ data: shopifyOrderPayload
168
206
  }),
169
- postAppointment: appointmentPayload => authenticateClient("api/v1/appointments", {
207
+ postAppointment: appointmentPayload => authenticatedClient("api/v1/appointments", {
170
208
  method: 'POST',
171
209
  data: appointmentPayload,
172
210
  headers: {
@@ -178,7 +216,7 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
178
216
  payload,
179
217
  id
180
218
  } = _ref4;
181
- return authenticateClient("api/v1/quotations/".concat(id), {
219
+ return authenticatedClient("api/v1/quotations/".concat(id), {
182
220
  method: 'PUT',
183
221
  data: payload,
184
222
  headers: {
@@ -191,7 +229,7 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
191
229
  payload,
192
230
  id
193
231
  } = _ref5;
194
- return authenticateClient("api/v1/appointments/".concat(id), {
232
+ return authenticatedClient("api/v1/appointments/".concat(id), {
195
233
  method: 'PUT',
196
234
  data: payload,
197
235
  headers: {
@@ -204,7 +242,7 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
204
242
  payload,
205
243
  id
206
244
  } = _ref6;
207
- return authenticateClient("api/v1/appointment-requests/".concat(id, "?action=order"), {
245
+ return authenticatedClient("api/v1/appointment-requests/".concat(id, "?action=order"), {
208
246
  method: 'PUT',
209
247
  data: payload,
210
248
  headers: {
@@ -218,19 +256,19 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
218
256
  limit,
219
257
  offset
220
258
  } = _ref7;
221
- return authenticateClient("api/v1/discounts?limit=".concat(limit, "&offset=").concat(offset, "&formulaCode=").concat(formulaCode), {
259
+ return authenticatedClient("api/v1/discounts?limit=".concat(limit, "&offset=").concat(offset, "&formulaCode=").concat(formulaCode), {
222
260
  method: 'GET',
223
261
  headers: {
224
262
  'Content-Type': 'application/json'
225
263
  }
226
264
  });
227
265
  },
228
- getPartBrands: () => authenticateClient("api/v1/configurator/part-brands", {
266
+ getPartBrands: () => authenticatedClient("api/v1/configurator/part-brands", {
229
267
  method: 'GET'
230
268
  }),
231
269
  getOrder: orderParameters => {
232
270
  const basePath = APP_CONFIG.internal ? 'api/v1' : 'api/public/v1';
233
- return authenticateClient("".concat(basePath, "/configurator/order?").concat(orderParameters), {
271
+ return authenticatedClient("".concat(basePath, "/configurator/order?").concat(orderParameters), {
234
272
  method: 'GET'
235
273
  });
236
274
  },
@@ -239,7 +277,7 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
239
277
  return null;
240
278
  }
241
279
  const basePath = APP_CONFIG.internal ? 'api/v1' : 'api/public/v1';
242
- return authenticateClient("".concat(basePath, "/configurator/prices?").concat(partsQueryString), {
280
+ return authenticatedClient("".concat(basePath, "/configurator/prices?").concat(partsQueryString), {
243
281
  method: 'GET'
244
282
  });
245
283
  }
@@ -589,7 +589,16 @@ const useUpdatePrivateAppointmentRequestByIdMutation = id => {
589
589
  discount,
590
590
  priceCalculationDate,
591
591
  customerAgreed,
592
- montageRate
592
+ montageRate,
593
+ leasemaatschappijEntityId,
594
+ leasemaatschappijBedrijfsnaam,
595
+ leasemaatschappijContactpersoonNaam,
596
+ leasemaatschappijContactTelefoonnummer,
597
+ leasemaatschappijContactEMailadres,
598
+ zakelijkContactPersoonNaam,
599
+ zakelijkContactTelefoonnummer,
600
+ zakeiljkContactFactuuradres,
601
+ zakelijkContactEMailadres
593
602
  } = _ref11;
594
603
  const _ref12 = customer || {},
595
604
  {
@@ -623,7 +632,16 @@ const useUpdatePrivateAppointmentRequestByIdMutation = id => {
623
632
  branchId,
624
633
  priceCalculationDate,
625
634
  customerAgreed,
626
- montageRate: apiMontageRate
635
+ montageRate: apiMontageRate,
636
+ leasemaatschappijEntityId,
637
+ leasemaatschappijBedrijfsnaam,
638
+ leasemaatschappijContactpersoonNaam,
639
+ leasemaatschappijContactTelefoonnummer,
640
+ leasemaatschappijContactEMailadres,
641
+ zakelijkContactPersoonNaam,
642
+ zakelijkContactTelefoonnummer,
643
+ zakeiljkContactFactuuradres,
644
+ zakelijkContactEMailadres
627
645
  }
628
646
  });
629
647
  });
@@ -660,7 +678,16 @@ const useUpdatePrivateQuotationByIdMutation = id => {
660
678
  discount,
661
679
  extraPrice,
662
680
  priceCalculationDate,
663
- montageRate
681
+ montageRate,
682
+ leasemaatschappijEntityId,
683
+ leasemaatschappijBedrijfsnaam,
684
+ leasemaatschappijContactpersoonNaam,
685
+ leasemaatschappijContactTelefoonnummer,
686
+ leasemaatschappijContactEMailadres,
687
+ zakelijkContactPersoonNaam,
688
+ zakelijkContactTelefoonnummer,
689
+ zakeiljkContactFactuuradres,
690
+ zakelijkContactEMailadres
664
691
  } = _ref13;
665
692
  const _ref14 = customer || {},
666
693
  {
@@ -693,7 +720,16 @@ const useUpdatePrivateQuotationByIdMutation = id => {
693
720
  customer: restCustomer,
694
721
  branchId,
695
722
  priceCalculationDate,
696
- montageRate: apiMontageRate
723
+ montageRate: apiMontageRate,
724
+ leasemaatschappijEntityId,
725
+ leasemaatschappijBedrijfsnaam,
726
+ leasemaatschappijContactpersoonNaam,
727
+ leasemaatschappijContactTelefoonnummer,
728
+ leasemaatschappijContactEMailadres,
729
+ zakelijkContactPersoonNaam,
730
+ zakelijkContactTelefoonnummer,
731
+ zakeiljkContactFactuuradres,
732
+ zakelijkContactEMailadres
697
733
  }
698
734
  });
699
735
  });
@@ -732,7 +768,16 @@ const useUpdatePrivateAppointmentByIdMutation = id => {
732
768
  priceCalculationDate,
733
769
  customerAgreed,
734
770
  invoicePaymentByLeaseCompany,
735
- montageRate
771
+ montageRate,
772
+ leasemaatschappijEntityId,
773
+ leasemaatschappijBedrijfsnaam,
774
+ leasemaatschappijContactpersoonNaam,
775
+ leasemaatschappijContactTelefoonnummer,
776
+ leasemaatschappijContactEMailadres,
777
+ zakelijkContactPersoonNaam,
778
+ zakelijkContactTelefoonnummer,
779
+ zakeiljkContactFactuuradres,
780
+ zakelijkContactEMailadres
736
781
  } = _ref15;
737
782
  const _ref16 = customer || {},
738
783
  {
@@ -769,7 +814,16 @@ const useUpdatePrivateAppointmentByIdMutation = id => {
769
814
  branchId,
770
815
  priceCalculationDate,
771
816
  customerAgreed,
772
- montageRate: apiMontageRate
817
+ montageRate: apiMontageRate,
818
+ leasemaatschappijEntityId,
819
+ leasemaatschappijBedrijfsnaam,
820
+ leasemaatschappijContactpersoonNaam,
821
+ leasemaatschappijContactTelefoonnummer,
822
+ leasemaatschappijContactEMailadres,
823
+ zakelijkContactPersoonNaam,
824
+ zakelijkContactTelefoonnummer,
825
+ zakeiljkContactFactuuradres,
826
+ zakelijkContactEMailadres
773
827
  }
774
828
  });
775
829
  });
@@ -5,35 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.orderApi = void 0;
7
7
  var _axios = _interopRequireDefault(require("axios"));
8
- var _index = require("../__constants__/index.js");
9
- var _LocalStorageWorker = require("../__services__/LocalStorageWorker.js");
10
8
  function _interopRequireDefault(e) {
11
9
  return e && e.__esModule ? e : {
12
10
  default: e
13
11
  };
14
12
  }
15
13
  const publicOrderClient = _axios.default.create({
16
- baseURL: APP_CONFIG.proxyUrl
17
- });
18
- const orderClient = _axios.default.create({
19
- baseURL: APP_CONFIG.apiUrl
20
- });
21
-
22
- /**
23
- * @description This interceptor:
24
- * - Does nothing if it's the external configurator
25
- * - Otherwise: Appends the bearer token, to authenticate to the private hyper Order API
26
- */
27
- orderClient.interceptors.request.use(config => {
28
- if (!APP_CONFIG.internal) {
29
- return config;
30
- }
31
- const authSession = _LocalStorageWorker.lsw.getJson(_index.AUTH_SESSION_KEY);
32
- config.headers.Authorization = "Bearer ".concat(authSession === null || authSession === void 0 ? void 0 : authSession.accessToken);
33
- return config;
14
+ baseURL: APP_CONFIG.proxyUrl,
15
+ withCredentials: true
34
16
  });
35
17
  const orderApi = exports.orderApi = {
36
- getArticles: filters => orderClient("api/public/articles?".concat(filters)),
18
+ getArticles: filters => publicOrderClient("api/public/articles?".concat(filters)),
37
19
  getBrands: function getBrands() {
38
20
  let formula = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'THC';
39
21
  return publicOrderClient("api/public/v1/configurator/makes?formula=".concat(formula));
@@ -11,7 +11,8 @@ function _interopRequireDefault(e) {
11
11
  };
12
12
  }
13
13
  const client = _axios.default.create({
14
- baseURL: APP_CONFIG.proxyUrl
14
+ baseURL: APP_CONFIG.proxyUrl,
15
+ withCredentials: true
15
16
  });
16
17
  const publicProxyApi = exports.publicProxyApi = {
17
18
  postQuotation: quotationBody => client("api/public/v1/quotations", {
@@ -33,11 +33,12 @@ require("core-js/modules/web.url-search-params.js");
33
33
  var _react = require("react");
34
34
  var _reactQuery = require("react-query");
35
35
  var _constants__ = require("../__constants__");
36
+ var _AuthSessionContext = require("../__context__/AuthSessionContext");
36
37
  var _FormulaContext = require("../__context__/FormulaContext");
37
38
  var _OrderSessionContext = require("../__context__/OrderSessionContext");
38
39
  var _helpers__ = require("../__helpers__");
39
40
  var _singleOrderArticles = require("../__helpers__/singleOrderArticles");
40
- var _LocalStorageWorker = require("../__services__/LocalStorageWorker");
41
+ var _AuthRuntime = require("../__services__/AuthRuntime");
41
42
  var _authenticatedProxyApi = require("./authenticatedProxyApi");
42
43
  var _orderApi = require("./orderApi");
43
44
  var _publicProxyApi = require("./publicProxyApi");
@@ -541,10 +542,11 @@ const useEnrichedProductsData = (orderData, formula, branchId) => {
541
542
  * @param {String} branchId - The branch id to apply to the articles
542
543
  */
543
544
  const useProductsQuery = exports.useProductsQuery = function useProductsQuery() {
544
- var _JSON$parse, _productsData$vehicle, _productsData$vehicle2, _productsData$vehicle3, _productsData$vehicle4, _productsData$vehicle5, _productsData$answers, _productsData$vehicle6, _productsData$vehicle7, _productsData$answers2, _productsData$answers3, _productsData$answers4, _productsData$answers5, _productsData$answers6, _productsData$vehicle8, _productsData$vehicle9, _productsData$vehicle10, _productsData$vehicle11, _productsData$vehicle12, _productsData$vehicle13, _productsData$article, _productsData$article2, _productsData$cart, _productsData$article3, _productsData$article4, _productsData$article5, _productsData$article6, _productsData$article7, _productsData$article8, _productsData$article9, _productsData$article10, _productsData$article11, _productsData$article12, _productsData$totals;
545
+ var _ref3, _authSession$branch, _productsData$vehicle, _productsData$vehicle2, _productsData$vehicle3, _productsData$vehicle4, _productsData$vehicle5, _productsData$answers, _productsData$vehicle6, _productsData$vehicle7, _productsData$answers2, _productsData$answers3, _productsData$answers4, _productsData$answers5, _productsData$answers6, _productsData$vehicle8, _productsData$vehicle9, _productsData$vehicle10, _productsData$vehicle11, _productsData$vehicle12, _productsData$vehicle13, _productsData$article, _productsData$article2, _productsData$cart, _productsData$article3, _productsData$article4, _productsData$article5, _productsData$article6, _productsData$article7, _productsData$article8, _productsData$article9, _productsData$article10, _productsData$article11, _productsData$article12, _productsData$totals;
545
546
  let orderParameters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
546
547
  const normalizedOrderParams = (0, _queryKeyFactory.normalizeOrderParams)(orderParameters);
547
548
  const {
549
+ branchId: orderBranchId,
548
550
  licensePlate,
549
551
  formula
550
552
  } = normalizedOrderParams;
@@ -554,8 +556,8 @@ const useProductsQuery = exports.useProductsQuery = function useProductsQuery()
554
556
  isFetchingOrder,
555
557
  isOrderError
556
558
  } = useOrderDataQuery(normalizedOrderParams);
557
- const authSession = _LocalStorageWorker.lsw.get(_constants__.AUTH_SESSION_KEY);
558
- const branchId = (_JSON$parse = JSON.parse(authSession)) === null || _JSON$parse === void 0 || (_JSON$parse = _JSON$parse.branch) === null || _JSON$parse === void 0 ? void 0 : _JSON$parse.entityId;
559
+ const authSession = (0, _AuthSessionContext.useAuthSession)();
560
+ const branchId = (_ref3 = orderBranchId !== null && orderBranchId !== void 0 ? orderBranchId : authSession === null || authSession === void 0 || (_authSession$branch = authSession.branch) === null || _authSession$branch === void 0 ? void 0 : _authSession$branch.entityId) !== null && _ref3 !== void 0 ? _ref3 : null;
559
561
  const {
560
562
  data: productsData,
561
563
  isLoading: isLoadingEnrichedProducts,
@@ -673,7 +675,7 @@ const useBranchesQuery = branchesParams => {
673
675
  * @param {String} type - The type of branches to retrieve
674
676
  */
675
677
  exports.useBranchesQuery = useBranchesQuery;
676
- const useBranchesByType = _ref3 => {
678
+ const useBranchesByType = _ref4 => {
677
679
  let {
678
680
  formula,
679
681
  ownershipType,
@@ -681,7 +683,7 @@ const useBranchesByType = _ref3 => {
681
683
  searchTerm,
682
684
  isTmg = false,
683
685
  isTowCenterBranch = false
684
- } = _ref3;
686
+ } = _ref4;
685
687
  const branchesByTypeQuery = (0, _reactQuery.useQuery)(['branchesByType', formula, ownershipType, organisationType, searchTerm, isTmg, isTowCenterBranch], {
686
688
  queryFn: async () => {
687
689
  const response = await _authenticatedProxyApi.authenticatedProxyApi.getBranchesByType({
@@ -724,15 +726,19 @@ const useBranchByIdOrWidgetId = exports.useBranchByIdOrWidgetId = function useBr
724
726
  };
725
727
 
726
728
  /**
727
- * @description Query that requests the user branches, disabled when no auth session is found in LS
729
+ * @description Query that requests the user branches when the cookie session is authenticated
728
730
  */
729
731
  const useMyBranches = formula => {
730
732
  var _myBranchesQuery$data;
731
- const authSession = _LocalStorageWorker.lsw.get(_constants__.AUTH_SESSION_KEY);
733
+ const {
734
+ authenticated,
735
+ initialized
736
+ } = (0, _AuthSessionContext.useAuthSession)();
737
+ const sessionKey = authenticated ? 'authed' : 'anon';
732
738
  const myBranchesQuery = (0, _reactQuery.useQuery)({
733
- queryKey: ['me', 'branches', authSession, formula],
739
+ queryKey: ['me', 'branches', sessionKey, formula],
734
740
  queryFn: () => _authenticatedProxyApi.authenticatedProxyApi.getMyBranchesByFormula(formula === _constants__.CONFIGURATOR_FORMULAS.THM ? _constants__.CONFIGURATOR_FORMULAS.TM : formula).then(userRes => userRes.data),
735
- enabled: !!authSession && !!formula
741
+ enabled: Boolean(initialized && authenticated && formula)
736
742
  });
737
743
  return {
738
744
  isLoadingMyBranches: myBranchesQuery.isLoading,
@@ -788,11 +794,11 @@ const useBranchTypes = () => {
788
794
  * Available types: Quotation, appointment request and planned appointment.
789
795
  */
790
796
  exports.useBranchTypes = useBranchTypes;
791
- const usePrivateDossierByTypeAndIdQuery = _ref4 => {
797
+ const usePrivateDossierByTypeAndIdQuery = _ref5 => {
792
798
  let {
793
799
  dossierId,
794
800
  dossierType
795
- } = _ref4;
801
+ } = _ref5;
796
802
  const dossierByIdQuery = (0, _reactQuery.useQuery)([dossierType, dossierId], {
797
803
  enabled: !!dossierId && !!dossierType,
798
804
  cacheTime: 0,
@@ -840,15 +846,18 @@ const usePrivateDossierByTypeAndIdQuery = _ref4 => {
840
846
  * @description Query the discounts from Hyper, allows for pagination and filtering with formula
841
847
  */
842
848
  exports.usePrivateDossierByTypeAndIdQuery = usePrivateDossierByTypeAndIdQuery;
843
- const useActiveDiscounts = _ref5 => {
849
+ const useActiveDiscounts = _ref6 => {
844
850
  let {
845
851
  formulaCode,
846
852
  offset,
847
- limit,
848
- authSession
849
- } = _ref5;
853
+ limit
854
+ } = _ref6;
855
+ const {
856
+ authenticated,
857
+ initialized
858
+ } = (0, _AuthSessionContext.useAuthSession)();
850
859
  const activeDiscountsQuery = (0, _reactQuery.useQuery)(['activeDiscounts', formulaCode, offset, limit], {
851
- enabled: !!formulaCode && !!authSession,
860
+ enabled: Boolean(formulaCode && authenticated && initialized),
852
861
  queryFn: () => {
853
862
  return _authenticatedProxyApi.authenticatedProxyApi.getActiveDiscounts({
854
863
  formulaCode,
@@ -13,12 +13,12 @@ var _react = _interopRequireWildcard(require("react"));
13
13
  var _queries = require("../../__api__/queries");
14
14
  var _constants__ = require("../../__constants__");
15
15
  var _ActiveMarkerContext = require("../../__context__/ActiveMarkerContext");
16
+ var _AuthSessionContext = require("../../__context__/AuthSessionContext");
16
17
  var _FormulaContext = require("../../__context__/FormulaContext");
17
18
  var _OrderSessionContext = require("../../__context__/OrderSessionContext");
18
19
  var _helpers__ = require("../../__helpers__");
19
20
  var _useBreakpoint = _interopRequireDefault(require("../../__hooks__/useBreakpoint"));
20
21
  var _useUserLocation = _interopRequireDefault(require("../../__hooks__/useUserLocation"));
21
- var _LocalStorageWorker = require("../../__services__/LocalStorageWorker");
22
22
  var _LocationAutoComplete = _interopRequireDefault(require("./LocationAutoComplete"));
23
23
  var _LocationClusteredMap = _interopRequireDefault(require("./LocationClusteredMap"));
24
24
  var _LocationList = _interopRequireDefault(require("./LocationList"));
@@ -73,7 +73,7 @@ const LocationsSelector = /*#__PURE__*/_react.default.memo(() => {
73
73
  const [{
74
74
  franchiseName
75
75
  }] = (0, _OrderSessionContext.useOrderSession)();
76
- const authSession = _LocalStorageWorker.lsw.getJson(_constants__.AUTH_SESSION_KEY);
76
+ const authSession = (0, _AuthSessionContext.useAuthSession)();
77
77
  const {
78
78
  branchTypes
79
79
  } = (0, _queries.useBranchTypes)();