thm-p3-configurator 0.0.269 → 0.0.271
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.png +0 -0
- package/dist/src/shared/__api__/authenticatedProxyApi.js +30 -8
- package/dist/src/shared/__api__/mutations.js +158 -19
- package/dist/src/shared/__components__/Header.js +4 -1
- package/dist/src/shared/__components__/Navbar.js +4 -1
- package/dist/src/shared/__components__/Spinners/FullPageSpinner.js +4 -1
- package/dist/src/shared/__components__/internal/InternalCustomerDetailsForm.js +86 -14
- package/dist/src/shared/__containers__/internal/InternalAppointmentForm.js +32 -6
- package/dist/src/shared/__hooks__/useCheckEmailExists.js +73 -0
- package/dist/src/shared/__pages__/internal/InternalAppointmentPage.js +162 -5
- package/dist/src/shared/__pages__/internal/InternalQuotationPage.js +160 -4
- package/package.json +1 -1
|
Binary file
|
|
@@ -115,6 +115,28 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
|
|
|
115
115
|
getAppointmentRequestById: id => authenticateClient("api/v1/appointment-requests/".concat(id), {
|
|
116
116
|
method: 'GET'
|
|
117
117
|
}),
|
|
118
|
+
getDossiers: _ref2 => {
|
|
119
|
+
let {
|
|
120
|
+
term,
|
|
121
|
+
offset = 0,
|
|
122
|
+
limit = 10,
|
|
123
|
+
branchId,
|
|
124
|
+
formula
|
|
125
|
+
} = _ref2;
|
|
126
|
+
return authenticateClient("api/v1/dossiers?term=".concat(term, "&offset=").concat(offset, "&limit=").concat(limit).concat(branchId ? "&branchId=".concat(branchId) : '').concat(formula ? "&formula=".concat(formula) : ''), {
|
|
127
|
+
method: 'GET'
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
putDossierById: _ref3 => {
|
|
131
|
+
let {
|
|
132
|
+
id,
|
|
133
|
+
payload
|
|
134
|
+
} = _ref3;
|
|
135
|
+
return authenticateClient("api/v1/dossiers/".concat(id), {
|
|
136
|
+
method: 'PUT',
|
|
137
|
+
data: payload
|
|
138
|
+
});
|
|
139
|
+
},
|
|
118
140
|
postAppointmentRequest: appointmentRequestPayload => authenticateClient("api/v1/appointment-requests", {
|
|
119
141
|
method: 'POST',
|
|
120
142
|
data: appointmentRequestPayload,
|
|
@@ -150,11 +172,11 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
|
|
|
150
172
|
'Content-Type': 'application/json'
|
|
151
173
|
}
|
|
152
174
|
}),
|
|
153
|
-
putQuotationById:
|
|
175
|
+
putQuotationById: _ref4 => {
|
|
154
176
|
let {
|
|
155
177
|
payload,
|
|
156
178
|
id
|
|
157
|
-
} =
|
|
179
|
+
} = _ref4;
|
|
158
180
|
return authenticateClient("api/v1/quotations/".concat(id), {
|
|
159
181
|
method: 'PUT',
|
|
160
182
|
data: payload,
|
|
@@ -163,11 +185,11 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
|
|
|
163
185
|
}
|
|
164
186
|
});
|
|
165
187
|
},
|
|
166
|
-
putAppointmentById:
|
|
188
|
+
putAppointmentById: _ref5 => {
|
|
167
189
|
let {
|
|
168
190
|
payload,
|
|
169
191
|
id
|
|
170
|
-
} =
|
|
192
|
+
} = _ref5;
|
|
171
193
|
return authenticateClient("api/v1/appointments/".concat(id), {
|
|
172
194
|
method: 'PUT',
|
|
173
195
|
data: payload,
|
|
@@ -176,11 +198,11 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
|
|
|
176
198
|
}
|
|
177
199
|
});
|
|
178
200
|
},
|
|
179
|
-
putAppointmentRequestById:
|
|
201
|
+
putAppointmentRequestById: _ref6 => {
|
|
180
202
|
let {
|
|
181
203
|
payload,
|
|
182
204
|
id
|
|
183
|
-
} =
|
|
205
|
+
} = _ref6;
|
|
184
206
|
return authenticateClient("api/v1/appointment-requests/".concat(id, "?action=order"), {
|
|
185
207
|
method: 'PUT',
|
|
186
208
|
data: payload,
|
|
@@ -189,12 +211,12 @@ const authenticatedProxyApi = exports.authenticatedProxyApi = {
|
|
|
189
211
|
}
|
|
190
212
|
});
|
|
191
213
|
},
|
|
192
|
-
getActiveDiscounts:
|
|
214
|
+
getActiveDiscounts: _ref7 => {
|
|
193
215
|
let {
|
|
194
216
|
formulaCode,
|
|
195
217
|
limit,
|
|
196
218
|
offset
|
|
197
|
-
} =
|
|
219
|
+
} = _ref7;
|
|
198
220
|
return authenticateClient("api/v1/discounts?limit=".concat(limit, "&offset=").concat(offset, "&formulaCode=").concat(formulaCode), {
|
|
199
221
|
method: 'GET',
|
|
200
222
|
headers: {
|
|
@@ -1,12 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
require("core-js/modules/es.array.includes.js");
|
|
4
|
+
require("core-js/modules/es.promise.js");
|
|
5
|
+
require("core-js/modules/es.string.includes.js");
|
|
6
|
+
require("core-js/modules/es.array.includes.js");
|
|
7
|
+
require("core-js/modules/es.string.includes.js");
|
|
3
8
|
Object.defineProperty(exports, "__esModule", {
|
|
4
9
|
value: true
|
|
5
10
|
});
|
|
6
11
|
exports.useUpdatePrivateQuotationByIdMutation = exports.useUpdatePrivateAppointmentRequestByIdMutation = exports.useUpdatePrivateAppointmentByIdMutation = exports.useCreateSingleOrderMutation = exports.useCreateShopifyOrderMutation = exports.useCreateQuotationMutation = exports.useCreatePrivateQuotationMutation = exports.useCreatePrivateAppointmentRequestMutation = exports.useCreatePrivateAppointmentMutation = exports.useCreateAppointmentRequestMutation = void 0;
|
|
12
|
+
require("core-js/modules/es.promise.js");
|
|
7
13
|
var _reactQuery = require("react-query");
|
|
8
14
|
var _authenticatedProxyApi = require("./authenticatedProxyApi");
|
|
9
15
|
var _publicProxyApi = require("./publicProxyApi");
|
|
16
|
+
const _excluded = ["linkToExistingCustomerId"],
|
|
17
|
+
_excluded2 = ["linkToExistingCustomerId"],
|
|
18
|
+
_excluded3 = ["linkToExistingCustomerId"],
|
|
19
|
+
_excluded4 = ["linkToExistingCustomerId"],
|
|
20
|
+
_excluded5 = ["linkToExistingCustomerId"],
|
|
21
|
+
_excluded6 = ["linkToExistingCustomerId"];
|
|
22
|
+
function _objectWithoutProperties(e, t) {
|
|
23
|
+
if (null == e) return {};
|
|
24
|
+
var o,
|
|
25
|
+
r,
|
|
26
|
+
i = _objectWithoutPropertiesLoose(e, t);
|
|
27
|
+
if (Object.getOwnPropertySymbols) {
|
|
28
|
+
var s = Object.getOwnPropertySymbols(e);
|
|
29
|
+
for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
30
|
+
}
|
|
31
|
+
return i;
|
|
32
|
+
}
|
|
33
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
34
|
+
if (null == r) return {};
|
|
35
|
+
var t = {};
|
|
36
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
37
|
+
if (e.includes(n)) continue;
|
|
38
|
+
t[n] = r[n];
|
|
39
|
+
}
|
|
40
|
+
return t;
|
|
41
|
+
}
|
|
10
42
|
/**
|
|
11
43
|
* @description Creates a quotation
|
|
12
44
|
*/
|
|
@@ -193,7 +225,12 @@ const useCreatePrivateQuotationMutation = () => {
|
|
|
193
225
|
isExitIntent = false,
|
|
194
226
|
montageRate
|
|
195
227
|
} = _ref5;
|
|
196
|
-
|
|
228
|
+
const _ref6 = customer || {},
|
|
229
|
+
{
|
|
230
|
+
linkToExistingCustomerId
|
|
231
|
+
} = _ref6,
|
|
232
|
+
restCustomer = _objectWithoutProperties(_ref6, _excluded);
|
|
233
|
+
const createQuotation = () => _authenticatedProxyApi.authenticatedProxyApi.postQuotation({
|
|
197
234
|
isExitIntent,
|
|
198
235
|
model,
|
|
199
236
|
vehicle,
|
|
@@ -205,10 +242,41 @@ const useCreatePrivateQuotationMutation = () => {
|
|
|
205
242
|
answers,
|
|
206
243
|
cart,
|
|
207
244
|
selectBoardComputerUpdate,
|
|
208
|
-
customer:
|
|
245
|
+
customer: restCustomer,
|
|
209
246
|
branchId,
|
|
210
247
|
montageRate
|
|
211
248
|
});
|
|
249
|
+
if (linkToExistingCustomerId) {
|
|
250
|
+
return _authenticatedProxyApi.authenticatedProxyApi.postQuotation({
|
|
251
|
+
isExitIntent,
|
|
252
|
+
model,
|
|
253
|
+
vehicle,
|
|
254
|
+
chassisNumber,
|
|
255
|
+
licensePlate,
|
|
256
|
+
channel,
|
|
257
|
+
formula,
|
|
258
|
+
discount,
|
|
259
|
+
answers,
|
|
260
|
+
cart,
|
|
261
|
+
selectBoardComputerUpdate,
|
|
262
|
+
customer: restCustomer,
|
|
263
|
+
branchId,
|
|
264
|
+
montageRate
|
|
265
|
+
}).then(async res => {
|
|
266
|
+
var _res$data;
|
|
267
|
+
const entityId = (_res$data = res.data) === null || _res$data === void 0 || (_res$data = _res$data.data) === null || _res$data === void 0 ? void 0 : _res$data.entityId;
|
|
268
|
+
if (entityId) {
|
|
269
|
+
await _authenticatedProxyApi.authenticatedProxyApi.putDossierById({
|
|
270
|
+
id: entityId,
|
|
271
|
+
payload: {
|
|
272
|
+
klant: linkToExistingCustomerId
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
return res;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
return createQuotation();
|
|
212
280
|
});
|
|
213
281
|
return {
|
|
214
282
|
isCreatingQuotation: createQuotationMutation.isLoading,
|
|
@@ -226,7 +294,8 @@ const useCreatePrivateQuotationMutation = () => {
|
|
|
226
294
|
*/
|
|
227
295
|
exports.useCreatePrivateQuotationMutation = useCreatePrivateQuotationMutation;
|
|
228
296
|
const useCreatePrivateAppointmentMutation = () => {
|
|
229
|
-
const createPlannedAppointmentMutation = (0, _reactQuery.useMutation)(
|
|
297
|
+
const createPlannedAppointmentMutation = (0, _reactQuery.useMutation)(async _ref7 => {
|
|
298
|
+
var _response$data;
|
|
230
299
|
let {
|
|
231
300
|
vehicle,
|
|
232
301
|
customer,
|
|
@@ -244,8 +313,13 @@ const useCreatePrivateAppointmentMutation = () => {
|
|
|
244
313
|
customerAgreed,
|
|
245
314
|
invoicePaymentByLeaseCompany,
|
|
246
315
|
montageRate
|
|
247
|
-
} =
|
|
248
|
-
|
|
316
|
+
} = _ref7;
|
|
317
|
+
const _ref8 = customer || {},
|
|
318
|
+
{
|
|
319
|
+
linkToExistingCustomerId
|
|
320
|
+
} = _ref8,
|
|
321
|
+
restCustomer = _objectWithoutProperties(_ref8, _excluded2);
|
|
322
|
+
const response = await _authenticatedProxyApi.authenticatedProxyApi.postAppointment({
|
|
249
323
|
appointment,
|
|
250
324
|
model,
|
|
251
325
|
vehicle,
|
|
@@ -257,12 +331,22 @@ const useCreatePrivateAppointmentMutation = () => {
|
|
|
257
331
|
answers,
|
|
258
332
|
cart,
|
|
259
333
|
selectBoardComputerUpdate,
|
|
260
|
-
customer:
|
|
334
|
+
customer: restCustomer,
|
|
261
335
|
branchId,
|
|
262
336
|
customerAgreed,
|
|
263
337
|
invoicePaymentByLeaseCompany,
|
|
264
338
|
montageRate
|
|
265
339
|
});
|
|
340
|
+
const entityId = (_response$data = response.data) === null || _response$data === void 0 || (_response$data = _response$data.data) === null || _response$data === void 0 ? void 0 : _response$data.entityId;
|
|
341
|
+
if (linkToExistingCustomerId && entityId) {
|
|
342
|
+
await _authenticatedProxyApi.authenticatedProxyApi.putDossierById({
|
|
343
|
+
id: entityId,
|
|
344
|
+
payload: {
|
|
345
|
+
klant: linkToExistingCustomerId
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
return response;
|
|
266
350
|
});
|
|
267
351
|
return {
|
|
268
352
|
isCreatingPlannedAppointment: createPlannedAppointmentMutation.isLoading,
|
|
@@ -280,7 +364,8 @@ const useCreatePrivateAppointmentMutation = () => {
|
|
|
280
364
|
*/
|
|
281
365
|
exports.useCreatePrivateAppointmentMutation = useCreatePrivateAppointmentMutation;
|
|
282
366
|
const useCreatePrivateAppointmentRequestMutation = () => {
|
|
283
|
-
const createAppointmentRequestMutation = (0, _reactQuery.useMutation)(
|
|
367
|
+
const createAppointmentRequestMutation = (0, _reactQuery.useMutation)(async _ref9 => {
|
|
368
|
+
var _response$data2;
|
|
284
369
|
let {
|
|
285
370
|
vehicle,
|
|
286
371
|
customer,
|
|
@@ -297,8 +382,13 @@ const useCreatePrivateAppointmentRequestMutation = () => {
|
|
|
297
382
|
discount,
|
|
298
383
|
customerAgreed,
|
|
299
384
|
montageRate
|
|
300
|
-
} =
|
|
301
|
-
|
|
385
|
+
} = _ref9;
|
|
386
|
+
const _ref10 = customer || {},
|
|
387
|
+
{
|
|
388
|
+
linkToExistingCustomerId
|
|
389
|
+
} = _ref10,
|
|
390
|
+
restCustomer = _objectWithoutProperties(_ref10, _excluded3);
|
|
391
|
+
const response = await _authenticatedProxyApi.authenticatedProxyApi.postAppointmentRequest({
|
|
302
392
|
appointment,
|
|
303
393
|
model,
|
|
304
394
|
vehicle,
|
|
@@ -310,11 +400,21 @@ const useCreatePrivateAppointmentRequestMutation = () => {
|
|
|
310
400
|
answers,
|
|
311
401
|
cart,
|
|
312
402
|
selectBoardComputerUpdate,
|
|
313
|
-
customer:
|
|
403
|
+
customer: restCustomer,
|
|
314
404
|
branchId,
|
|
315
405
|
customerAgreed,
|
|
316
406
|
montageRate
|
|
317
407
|
});
|
|
408
|
+
const entityId = (_response$data2 = response.data) === null || _response$data2 === void 0 || (_response$data2 = _response$data2.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.entityId;
|
|
409
|
+
if (linkToExistingCustomerId && entityId) {
|
|
410
|
+
await _authenticatedProxyApi.authenticatedProxyApi.putDossierById({
|
|
411
|
+
id: entityId,
|
|
412
|
+
payload: {
|
|
413
|
+
klant: linkToExistingCustomerId
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
return response;
|
|
318
418
|
});
|
|
319
419
|
return {
|
|
320
420
|
isCreatingAppointmentRequest: createAppointmentRequestMutation.isLoading,
|
|
@@ -332,7 +432,7 @@ const useCreatePrivateAppointmentRequestMutation = () => {
|
|
|
332
432
|
*/
|
|
333
433
|
exports.useCreatePrivateAppointmentRequestMutation = useCreatePrivateAppointmentRequestMutation;
|
|
334
434
|
const useUpdatePrivateAppointmentRequestByIdMutation = id => {
|
|
335
|
-
const updateAppointmentRequestByIdMutation = (0, _reactQuery.useMutation)(
|
|
435
|
+
const updateAppointmentRequestByIdMutation = (0, _reactQuery.useMutation)(async _ref11 => {
|
|
336
436
|
let {
|
|
337
437
|
vehicle,
|
|
338
438
|
customer,
|
|
@@ -349,7 +449,20 @@ const useUpdatePrivateAppointmentRequestByIdMutation = id => {
|
|
|
349
449
|
discount,
|
|
350
450
|
priceCalculationDate,
|
|
351
451
|
customerAgreed
|
|
352
|
-
} =
|
|
452
|
+
} = _ref11;
|
|
453
|
+
const _ref12 = customer || {},
|
|
454
|
+
{
|
|
455
|
+
linkToExistingCustomerId
|
|
456
|
+
} = _ref12,
|
|
457
|
+
restCustomer = _objectWithoutProperties(_ref12, _excluded4);
|
|
458
|
+
if (linkToExistingCustomerId) {
|
|
459
|
+
await _authenticatedProxyApi.authenticatedProxyApi.putDossierById({
|
|
460
|
+
id,
|
|
461
|
+
payload: {
|
|
462
|
+
klant: linkToExistingCustomerId
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
}
|
|
353
466
|
return _authenticatedProxyApi.authenticatedProxyApi.putAppointmentRequestById({
|
|
354
467
|
id,
|
|
355
468
|
payload: {
|
|
@@ -364,7 +477,7 @@ const useUpdatePrivateAppointmentRequestByIdMutation = id => {
|
|
|
364
477
|
answers,
|
|
365
478
|
cart,
|
|
366
479
|
selectBoardComputerUpdate,
|
|
367
|
-
customer,
|
|
480
|
+
customer: restCustomer,
|
|
368
481
|
branchId,
|
|
369
482
|
priceCalculationDate,
|
|
370
483
|
customerAgreed
|
|
@@ -387,7 +500,7 @@ const useUpdatePrivateAppointmentRequestByIdMutation = id => {
|
|
|
387
500
|
*/
|
|
388
501
|
exports.useUpdatePrivateAppointmentRequestByIdMutation = useUpdatePrivateAppointmentRequestByIdMutation;
|
|
389
502
|
const useUpdatePrivateQuotationByIdMutation = id => {
|
|
390
|
-
const updateQuotationMutation = (0, _reactQuery.useMutation)(
|
|
503
|
+
const updateQuotationMutation = (0, _reactQuery.useMutation)(async _ref13 => {
|
|
391
504
|
let {
|
|
392
505
|
vehicle,
|
|
393
506
|
customer,
|
|
@@ -401,7 +514,20 @@ const useUpdatePrivateQuotationByIdMutation = id => {
|
|
|
401
514
|
formula,
|
|
402
515
|
discount,
|
|
403
516
|
priceCalculationDate
|
|
404
|
-
} =
|
|
517
|
+
} = _ref13;
|
|
518
|
+
const _ref14 = customer || {},
|
|
519
|
+
{
|
|
520
|
+
linkToExistingCustomerId
|
|
521
|
+
} = _ref14,
|
|
522
|
+
restCustomer = _objectWithoutProperties(_ref14, _excluded5);
|
|
523
|
+
if (linkToExistingCustomerId) {
|
|
524
|
+
await _authenticatedProxyApi.authenticatedProxyApi.putDossierById({
|
|
525
|
+
id,
|
|
526
|
+
payload: {
|
|
527
|
+
klant: linkToExistingCustomerId
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
405
531
|
return _authenticatedProxyApi.authenticatedProxyApi.putQuotationById({
|
|
406
532
|
id,
|
|
407
533
|
payload: {
|
|
@@ -414,7 +540,7 @@ const useUpdatePrivateQuotationByIdMutation = id => {
|
|
|
414
540
|
answers,
|
|
415
541
|
cart,
|
|
416
542
|
selectBoardComputerUpdate,
|
|
417
|
-
customer,
|
|
543
|
+
customer: restCustomer,
|
|
418
544
|
branchId,
|
|
419
545
|
priceCalculationDate
|
|
420
546
|
}
|
|
@@ -436,7 +562,7 @@ const useUpdatePrivateQuotationByIdMutation = id => {
|
|
|
436
562
|
*/
|
|
437
563
|
exports.useUpdatePrivateQuotationByIdMutation = useUpdatePrivateQuotationByIdMutation;
|
|
438
564
|
const useUpdatePrivateAppointmentByIdMutation = id => {
|
|
439
|
-
const updateAppointmentByIdMutation = (0, _reactQuery.useMutation)(
|
|
565
|
+
const updateAppointmentByIdMutation = (0, _reactQuery.useMutation)(async _ref15 => {
|
|
440
566
|
let {
|
|
441
567
|
vehicle,
|
|
442
568
|
customer,
|
|
@@ -453,7 +579,20 @@ const useUpdatePrivateAppointmentByIdMutation = id => {
|
|
|
453
579
|
discount,
|
|
454
580
|
priceCalculationDate,
|
|
455
581
|
customerAgreed
|
|
456
|
-
} =
|
|
582
|
+
} = _ref15;
|
|
583
|
+
const _ref16 = customer || {},
|
|
584
|
+
{
|
|
585
|
+
linkToExistingCustomerId
|
|
586
|
+
} = _ref16,
|
|
587
|
+
restCustomer = _objectWithoutProperties(_ref16, _excluded6);
|
|
588
|
+
if (linkToExistingCustomerId) {
|
|
589
|
+
await _authenticatedProxyApi.authenticatedProxyApi.putDossierById({
|
|
590
|
+
id,
|
|
591
|
+
payload: {
|
|
592
|
+
klant: linkToExistingCustomerId
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}
|
|
457
596
|
return _authenticatedProxyApi.authenticatedProxyApi.putAppointmentById({
|
|
458
597
|
id,
|
|
459
598
|
payload: {
|
|
@@ -468,7 +607,7 @@ const useUpdatePrivateAppointmentByIdMutation = id => {
|
|
|
468
607
|
answers,
|
|
469
608
|
cart,
|
|
470
609
|
selectBoardComputerUpdate,
|
|
471
|
-
customer,
|
|
610
|
+
customer: restCustomer,
|
|
472
611
|
branchId,
|
|
473
612
|
priceCalculationDate,
|
|
474
613
|
customerAgreed
|
|
@@ -8,7 +8,9 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _logoPrimaryIcon = _interopRequireDefault(require("../../../public/assets/images/logo-primary-icon.svg"));
|
|
9
9
|
var _logoThcWhite = _interopRequireDefault(require("../../../public/assets/images/logo-thc-white.svg"));
|
|
10
10
|
var _logoTmgPrimary = _interopRequireDefault(require("../../../public/assets/images/logo-tmg-primary.png"));
|
|
11
|
+
var _tmLogo = _interopRequireDefault(require("../../../public/assets/images/tm-logo.png"));
|
|
11
12
|
var _constants__ = require("../__constants__");
|
|
13
|
+
var _FormulaContext = require("../__context__/FormulaContext");
|
|
12
14
|
var _helpers__ = require("../__helpers__");
|
|
13
15
|
var _useBranchTheme = require("../__hooks__/useBranchTheme");
|
|
14
16
|
function _interopRequireDefault(e) {
|
|
@@ -22,6 +24,7 @@ const Header = _ref => {
|
|
|
22
24
|
subtitle = ''
|
|
23
25
|
} = _ref;
|
|
24
26
|
const theme = (0, _useBranchTheme.useBranchTheme)();
|
|
27
|
+
const formula = (0, _FormulaContext.useFormula)();
|
|
25
28
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
26
29
|
className: (0, _helpers__.withStyle)("hero hero--offset")
|
|
27
30
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -32,7 +35,7 @@ const Header = _ref => {
|
|
|
32
35
|
className: (0, _helpers__.withStyle)('col hero__logo-container')
|
|
33
36
|
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
34
37
|
className: (0, _helpers__.withStyle)("hero__logo ".concat(theme === _constants__.BRANCH_THEME_BY_FORMULA.TowMotiveGroup ? 'hero__logo--tmg' : '')),
|
|
35
|
-
src: theme === _constants__.BRANCH_THEME_BY_FORMULA.Trekhaakcentrum ? _logoThcWhite.default : theme === _constants__.BRANCH_THEME_BY_FORMULA.TowMotiveGroup ? _logoTmgPrimary.default : _logoPrimaryIcon.default,
|
|
38
|
+
src: formula === _constants__.CONFIGURATOR_FORMULAS.TM ? _tmLogo.default : theme === _constants__.BRANCH_THEME_BY_FORMULA.Trekhaakcentrum ? _logoThcWhite.default : theme === _constants__.BRANCH_THEME_BY_FORMULA.TowMotiveGroup ? _logoTmgPrimary.default : _logoPrimaryIcon.default,
|
|
36
39
|
alt: "Trekhaak Montage"
|
|
37
40
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
38
41
|
className: (0, _helpers__.withStyle)('hero__inner d-none d-lg-block')
|
|
@@ -8,7 +8,9 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
8
8
|
var _logoThcWhite = _interopRequireDefault(require("../../../public/assets/images/logo-thc-white.svg"));
|
|
9
9
|
var _logoTmgPrimary = _interopRequireDefault(require("../../../public/assets/images/logo-tmg-primary.png"));
|
|
10
10
|
var _logoWhite = _interopRequireDefault(require("../../../public/assets/images/logo-white.svg"));
|
|
11
|
+
var _tmLogo = _interopRequireDefault(require("../../../public/assets/images/tm-logo.png"));
|
|
11
12
|
var _constants__ = require("../__constants__");
|
|
13
|
+
var _FormulaContext = require("../__context__/FormulaContext");
|
|
12
14
|
var _helpers__ = require("../__helpers__");
|
|
13
15
|
var _useBranchTheme = require("../__hooks__/useBranchTheme");
|
|
14
16
|
function _interopRequireDefault(e) {
|
|
@@ -21,6 +23,7 @@ const Navbar = _ref => {
|
|
|
21
23
|
onPhoneClicked
|
|
22
24
|
} = _ref;
|
|
23
25
|
const theme = (0, _useBranchTheme.useBranchTheme)();
|
|
26
|
+
const formula = (0, _FormulaContext.useFormula)();
|
|
24
27
|
return /*#__PURE__*/_react.default.createElement("nav", {
|
|
25
28
|
className: (0, _helpers__.withStyle)("navbar fixed-top ".concat(theme === _constants__.BRANCH_THEME_BY_FORMULA.Trekhaakcentrum ? 'thc' : theme === _constants__.BRANCH_THEME_BY_FORMULA.TowMotiveGroup ? 'tmg' : ''))
|
|
26
29
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -30,7 +33,7 @@ const Navbar = _ref => {
|
|
|
30
33
|
href: APP_CONFIG.websiteHost
|
|
31
34
|
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
32
35
|
className: (0, _helpers__.withStyle)('img-fluid'),
|
|
33
|
-
src: theme === _constants__.BRANCH_THEME_BY_FORMULA.Trekhaakcentrum ? _logoThcWhite.default : theme === _constants__.BRANCH_THEME_BY_FORMULA.TowMotiveGroup ? _logoTmgPrimary.default : _logoWhite.default,
|
|
36
|
+
src: formula === _constants__.CONFIGURATOR_FORMULAS.TM ? _tmLogo.default : theme === _constants__.BRANCH_THEME_BY_FORMULA.Trekhaakcentrum ? _logoThcWhite.default : theme === _constants__.BRANCH_THEME_BY_FORMULA.TowMotiveGroup ? _logoTmgPrimary.default : _logoWhite.default,
|
|
34
37
|
alt: "Trekhaakmontage"
|
|
35
38
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
36
39
|
className: (0, _helpers__.withStyle)('navbar__phone ms-10 d-none d-sm-flex')
|
|
@@ -11,10 +11,12 @@ require("core-js/modules/web.dom-collections.iterator.js");
|
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _logoThcWhite = _interopRequireDefault(require("../../../../public/assets/images/logo-thc-white.svg"));
|
|
13
13
|
var _logoTmgPrimary = _interopRequireDefault(require("../../../../public/assets/images/logo-tmg-primary.png"));
|
|
14
|
+
var _tmLogo = _interopRequireDefault(require("../../../../public/assets/images/tm-logo.png"));
|
|
14
15
|
var _logoWhite = _interopRequireDefault(require("../../../../public/assets/images/logo-white.png"));
|
|
15
16
|
var _constants__ = require("../../__constants__");
|
|
16
17
|
var _helpers__ = require("../../__helpers__");
|
|
17
18
|
var _useBranchTheme = require("../../__hooks__/useBranchTheme");
|
|
19
|
+
var _FormulaContext = require("../../__context__/FormulaContext");
|
|
18
20
|
function _interopRequireDefault(e) {
|
|
19
21
|
return e && e.__esModule ? e : {
|
|
20
22
|
default: e
|
|
@@ -51,6 +53,7 @@ const FullPageSpinner = _ref => {
|
|
|
51
53
|
} = _ref;
|
|
52
54
|
const [hasRendered, setHasRendered] = (0, _react.useState)();
|
|
53
55
|
const theme = (0, _useBranchTheme.useBranchTheme)();
|
|
56
|
+
const formula = (0, _FormulaContext.useFormula)();
|
|
54
57
|
(0, _react.useEffect)(() => {
|
|
55
58
|
setHasRendered(true);
|
|
56
59
|
}, []);
|
|
@@ -64,7 +67,7 @@ const FullPageSpinner = _ref => {
|
|
|
64
67
|
className: "fas fa-cog fa-spin"
|
|
65
68
|
}), ' '), children ? children : /*#__PURE__*/_react.default.createElement("img", {
|
|
66
69
|
className: (0, _helpers__.withStyle)('loader__logo'),
|
|
67
|
-
src: theme === _constants__.BRANCH_THEME_BY_FORMULA.Trekhaakcentrum ? _logoThcWhite.default : theme === _constants__.BRANCH_THEME_BY_FORMULA.TowMotiveGroup ? _logoTmgPrimary.default : _logoWhite.default,
|
|
70
|
+
src: formula === _constants__.CONFIGURATOR_FORMULAS.TM ? _tmLogo.default : theme === _constants__.BRANCH_THEME_BY_FORMULA.Trekhaakcentrum ? _logoThcWhite.default : theme === _constants__.BRANCH_THEME_BY_FORMULA.TowMotiveGroup ? _logoTmgPrimary.default : _logoWhite.default,
|
|
68
71
|
alt: "Trekhaak Montage - Configurator"
|
|
69
72
|
}));
|
|
70
73
|
};
|
|
@@ -28,6 +28,7 @@ var _FormulaContext = require("../../__context__/FormulaContext");
|
|
|
28
28
|
var _OrderSessionContext = require("../../__context__/OrderSessionContext");
|
|
29
29
|
var _helpers__ = require("../../__helpers__");
|
|
30
30
|
var _useIsTmg = require("../../__hooks__/useIsTmg");
|
|
31
|
+
var _AddressLookupService = _interopRequireDefault(require("../../__services__/AddressLookupService"));
|
|
31
32
|
var _LocalStorageWorker = require("../../__services__/LocalStorageWorker");
|
|
32
33
|
var _LinkButton = _interopRequireDefault(require("../Buttons/LinkButton"));
|
|
33
34
|
var _CardWide = _interopRequireDefault(require("../Cards/CardWide"));
|
|
@@ -179,6 +180,9 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
179
180
|
const formula = (0, _FormulaContext.useFormula)();
|
|
180
181
|
const [companySearchTerm, setCompanySearchTerm] = (0, _react.useState)('');
|
|
181
182
|
const [isCompanyInputFocused, setIsCompanyInputFocused] = (0, _react.useState)(false);
|
|
183
|
+
const [addressLookupLoading, setAddressLookupLoading] = (0, _react.useState)(false);
|
|
184
|
+
const [addressLookupTimeoutId, setAddressLookupTimeoutId] = (0, _react.useState)(null);
|
|
185
|
+
const addressLookupService = new _AddressLookupService.default();
|
|
182
186
|
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;
|
|
183
187
|
const {
|
|
184
188
|
marketingChannels,
|
|
@@ -311,6 +315,62 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
311
315
|
});
|
|
312
316
|
}
|
|
313
317
|
};
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* @description Debounced address lookup function
|
|
321
|
+
*/
|
|
322
|
+
const performAddressLookup = async (postcode, houseNumber) => {
|
|
323
|
+
if (!postcode || !houseNumber) return;
|
|
324
|
+
try {
|
|
325
|
+
setAddressLookupLoading(true);
|
|
326
|
+
const addressInfo = await addressLookupService.lookup(postcode, houseNumber);
|
|
327
|
+
if (addressInfo && addressInfo.street && addressInfo.city) {
|
|
328
|
+
// Auto-fill street and city fields
|
|
329
|
+
dispatch({
|
|
330
|
+
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_STREET_NAME,
|
|
331
|
+
payload: {
|
|
332
|
+
streetName: addressInfo.street
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
dispatch({
|
|
336
|
+
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_CITY,
|
|
337
|
+
payload: {
|
|
338
|
+
city: addressInfo.city
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
} catch (error) {
|
|
343
|
+
console.error('Address lookup failed:', error);
|
|
344
|
+
} finally {
|
|
345
|
+
setAddressLookupLoading(false);
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* @description Handles address lookup with debouncing
|
|
351
|
+
*/
|
|
352
|
+
const handleAddressLookup = (postcode, houseNumber) => {
|
|
353
|
+
// Clear existing timeout
|
|
354
|
+
if (addressLookupTimeoutId) {
|
|
355
|
+
clearTimeout(addressLookupTimeoutId);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Set new timeout for debounced lookup
|
|
359
|
+
const newTimeoutId = setTimeout(() => {
|
|
360
|
+
performAddressLookup(postcode, houseNumber);
|
|
361
|
+
}, 800); // 800ms delay
|
|
362
|
+
|
|
363
|
+
setAddressLookupTimeoutId(newTimeoutId);
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
// Cleanup timeout on unmount
|
|
367
|
+
(0, _react.useEffect)(() => {
|
|
368
|
+
return () => {
|
|
369
|
+
if (addressLookupTimeoutId) {
|
|
370
|
+
clearTimeout(addressLookupTimeoutId);
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
}, [addressLookupTimeoutId]);
|
|
314
374
|
const validateForm = async () => {
|
|
315
375
|
try {
|
|
316
376
|
let validationSchema = webshop || !isTmg ? customerDetailsFormSchema.omit(['channelType', 'channelId']) : customerDetailsFormSchema;
|
|
@@ -653,12 +713,18 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
653
713
|
placeholder: "",
|
|
654
714
|
initialValue: customer.zipCode,
|
|
655
715
|
name: "zipCode",
|
|
656
|
-
onChange: value =>
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
716
|
+
onChange: value => {
|
|
717
|
+
dispatch({
|
|
718
|
+
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_ZIP_CODE,
|
|
719
|
+
payload: {
|
|
720
|
+
zipCode: value
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
// Trigger address lookup if house number is also available
|
|
724
|
+
if (customer.houseNumber) {
|
|
725
|
+
handleAddressLookup(value, customer.houseNumber);
|
|
660
726
|
}
|
|
661
|
-
}
|
|
727
|
+
},
|
|
662
728
|
isRequired: false,
|
|
663
729
|
form: form,
|
|
664
730
|
label: "Postcode:",
|
|
@@ -667,12 +733,18 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
667
733
|
placeholder: "",
|
|
668
734
|
initialValue: customer.houseNumber,
|
|
669
735
|
name: "houseNumber",
|
|
670
|
-
onChange: value =>
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
736
|
+
onChange: value => {
|
|
737
|
+
dispatch({
|
|
738
|
+
type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_HOUSE_NUMBER,
|
|
739
|
+
payload: {
|
|
740
|
+
houseNumber: value
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
// Trigger address lookup if postcode is also available
|
|
744
|
+
if (customer.zipCode) {
|
|
745
|
+
handleAddressLookup(customer.zipCode, value);
|
|
674
746
|
}
|
|
675
|
-
}
|
|
747
|
+
},
|
|
676
748
|
isRequired: false,
|
|
677
749
|
form: form,
|
|
678
750
|
label: "Huisnummer:",
|
|
@@ -692,7 +764,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
692
764
|
label: "Huisnummer toevoeging:",
|
|
693
765
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['houseNumberAddition']
|
|
694
766
|
}), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
|
|
695
|
-
placeholder:
|
|
767
|
+
placeholder: addressLookupLoading ? 'Adres wordt opgezocht...' : '',
|
|
696
768
|
initialValue: customer.streetName,
|
|
697
769
|
name: "streetName",
|
|
698
770
|
onChange: value => dispatch({
|
|
@@ -703,10 +775,10 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
703
775
|
}),
|
|
704
776
|
isRequired: false,
|
|
705
777
|
form: form,
|
|
706
|
-
label: "Straat:",
|
|
778
|
+
label: "Straat:".concat(addressLookupLoading ? ' (wordt opgezocht...)' : ''),
|
|
707
779
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['streetName']
|
|
708
780
|
}), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
|
|
709
|
-
placeholder:
|
|
781
|
+
placeholder: addressLookupLoading ? 'Stad wordt opgezocht...' : '',
|
|
710
782
|
initialValue: customer.city,
|
|
711
783
|
name: "city",
|
|
712
784
|
onChange: value => dispatch({
|
|
@@ -717,7 +789,7 @@ const InternalCustomerDetailsForm = (_ref, ref) => {
|
|
|
717
789
|
}),
|
|
718
790
|
isRequired: false,
|
|
719
791
|
form: form,
|
|
720
|
-
label: "Stad:",
|
|
792
|
+
label: "Stad:".concat(addressLookupLoading ? ' (wordt opgezocht...)' : ''),
|
|
721
793
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['city']
|
|
722
794
|
}), /*#__PURE__*/_react.default.createElement(_DropdownInput.default, {
|
|
723
795
|
options: countryOptions,
|
|
@@ -7,6 +7,7 @@ require("core-js/modules/es.regexp.exec.js");
|
|
|
7
7
|
require("core-js/modules/es.regexp.to-string.js");
|
|
8
8
|
require("core-js/modules/es.string.includes.js");
|
|
9
9
|
require("core-js/modules/es.string.replace.js");
|
|
10
|
+
require("core-js/modules/es.string.trim.js");
|
|
10
11
|
require("core-js/modules/es.weak-map.js");
|
|
11
12
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
12
13
|
require("core-js/modules/esnext.iterator.filter.js");
|
|
@@ -27,6 +28,7 @@ require("core-js/modules/es.regexp.exec.js");
|
|
|
27
28
|
require("core-js/modules/es.regexp.to-string.js");
|
|
28
29
|
require("core-js/modules/es.string.includes.js");
|
|
29
30
|
require("core-js/modules/es.string.replace.js");
|
|
31
|
+
require("core-js/modules/es.string.trim.js");
|
|
30
32
|
require("core-js/modules/esnext.iterator.constructor.js");
|
|
31
33
|
require("core-js/modules/esnext.iterator.find.js");
|
|
32
34
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
@@ -292,6 +294,13 @@ const InternalAppointmentForm = _ref => {
|
|
|
292
294
|
}
|
|
293
295
|
}
|
|
294
296
|
}, [customer === null || customer === void 0 ? void 0 : customer.countryId, countryOptions, dispatch]);
|
|
297
|
+
const isBusinessOwnership = (vehicle === null || vehicle === void 0 ? void 0 : vehicle.ownershipType) === _constants__.VEHICLE_OWNERSHIP_TYPE.Zakelijk;
|
|
298
|
+
const isNetherlandsSelected = (0, _react.useMemo)(() => {
|
|
299
|
+
if (!(selectedCountry !== null && selectedCountry !== void 0 && selectedCountry.label)) return false;
|
|
300
|
+
return selectedCountry.label.toUpperCase() === 'NEDERLAND';
|
|
301
|
+
}, [selectedCountry === null || selectedCountry === void 0 ? void 0 : selectedCountry.label]);
|
|
302
|
+
const shouldRequireKvkNumber = isBusinessOwnership && (isNetherlandsSelected || !isNetherlandsSelected && !(customer !== null && customer !== void 0 && customer.vatNumber));
|
|
303
|
+
const shouldRequireVatNumber = isBusinessOwnership && !isNetherlandsSelected && !(customer !== null && customer !== void 0 && customer.kvkNumber);
|
|
295
304
|
const {
|
|
296
305
|
branchById
|
|
297
306
|
} = (0, _queries.useBranchByIdOrWidgetId)(selectedBranch);
|
|
@@ -333,8 +342,8 @@ const InternalAppointmentForm = _ref => {
|
|
|
333
342
|
const handleSubmit = async function handleSubmit() {
|
|
334
343
|
let appointmentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _constants__.DOSSIER_TYPES.PlannedAppointment;
|
|
335
344
|
try {
|
|
336
|
-
var _customer$firstName, _customer$lastName, _customer$phoneNumber, _customer$houseNumber, _customer$houseNumber2, _customer$streetName, _customer$countryId, _customer$city, _customer$email, _customer$note, _customer$zipCode, _customer$companyName, _customer$
|
|
337
|
-
setErrors(
|
|
345
|
+
var _customer$kvkNumber, _customer$vatNumber, _customer$firstName, _customer$lastName, _customer$phoneNumber, _customer$houseNumber, _customer$houseNumber2, _customer$streetName, _customer$countryId, _customer$city, _customer$email, _customer$note, _customer$zipCode, _customer$companyName, _customer$kvkNumber2, _customer$vatNumber2, _ref2;
|
|
346
|
+
setErrors({});
|
|
338
347
|
if (!model) {
|
|
339
348
|
// Note: this does not throw on error.
|
|
340
349
|
const licensePlateErrors = validateLicensePlate();
|
|
@@ -355,6 +364,23 @@ const InternalAppointmentForm = _ref => {
|
|
|
355
364
|
return;
|
|
356
365
|
}
|
|
357
366
|
}
|
|
367
|
+
const hasKvkNumber = !!(customer !== null && customer !== void 0 && (_customer$kvkNumber = customer.kvkNumber) !== null && _customer$kvkNumber !== void 0 && _customer$kvkNumber.trim());
|
|
368
|
+
const hasVatNumber = !!(customer !== null && customer !== void 0 && (_customer$vatNumber = customer.vatNumber) !== null && _customer$vatNumber !== void 0 && _customer$vatNumber.trim());
|
|
369
|
+
if (isBusinessOwnership) {
|
|
370
|
+
if (isNetherlandsSelected && !hasKvkNumber) {
|
|
371
|
+
setErrors({
|
|
372
|
+
kvkNumber: 'KVK-nummer is verplicht voor zakelijke dossiers in Nederland'
|
|
373
|
+
});
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
if (!isNetherlandsSelected && !hasKvkNumber && !hasVatNumber) {
|
|
377
|
+
setErrors({
|
|
378
|
+
kvkNumber: 'Vul een KVK- of BTW-nummer in',
|
|
379
|
+
vatNumber: 'Vul een KVK- of BTW-nummer in'
|
|
380
|
+
});
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
358
384
|
|
|
359
385
|
// Note: this throws on error.
|
|
360
386
|
internalAppointmentFormSchema.validateSync(_objectSpread(_objectSpread(_objectSpread({}, vehicle), customer), {}, {
|
|
@@ -392,8 +418,8 @@ const InternalAppointmentForm = _ref => {
|
|
|
392
418
|
note: (_customer$note = customer === null || customer === void 0 ? void 0 : customer.note) !== null && _customer$note !== void 0 ? _customer$note : undefined,
|
|
393
419
|
zipCode: (_customer$zipCode = customer === null || customer === void 0 ? void 0 : customer.zipCode) !== null && _customer$zipCode !== void 0 ? _customer$zipCode : undefined,
|
|
394
420
|
companyName: (_customer$companyName = customer === null || customer === void 0 ? void 0 : customer.companyName) !== null && _customer$companyName !== void 0 ? _customer$companyName : undefined,
|
|
395
|
-
kvkNumber: (_customer$
|
|
396
|
-
vatNumber: (_customer$
|
|
421
|
+
kvkNumber: (_customer$kvkNumber2 = customer === null || customer === void 0 ? void 0 : customer.kvkNumber) !== null && _customer$kvkNumber2 !== void 0 ? _customer$kvkNumber2 : undefined,
|
|
422
|
+
vatNumber: (_customer$vatNumber2 = customer === null || customer === void 0 ? void 0 : customer.vatNumber) !== null && _customer$vatNumber2 !== void 0 ? _customer$vatNumber2 : undefined
|
|
397
423
|
})),
|
|
398
424
|
customerAgreed,
|
|
399
425
|
invoicePaymentByLeaseCompany: invoicePaymentByLeaseCompany !== null && invoicePaymentByLeaseCompany !== void 0 ? invoicePaymentByLeaseCompany : undefined,
|
|
@@ -1245,7 +1271,7 @@ const InternalAppointmentForm = _ref => {
|
|
|
1245
1271
|
}
|
|
1246
1272
|
}),
|
|
1247
1273
|
key: "kvkNumber-".concat(refreshKey),
|
|
1248
|
-
isRequired:
|
|
1274
|
+
isRequired: shouldRequireKvkNumber,
|
|
1249
1275
|
form: "quotation",
|
|
1250
1276
|
label: "KVK-nummer:",
|
|
1251
1277
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['kvkNumber']
|
|
@@ -1260,7 +1286,7 @@ const InternalAppointmentForm = _ref => {
|
|
|
1260
1286
|
}
|
|
1261
1287
|
}),
|
|
1262
1288
|
key: "vatNumber-".concat(refreshKey),
|
|
1263
|
-
isRequired:
|
|
1289
|
+
isRequired: shouldRequireVatNumber,
|
|
1264
1290
|
form: "quotation",
|
|
1265
1291
|
label: "BTW-nummer:",
|
|
1266
1292
|
errorMessage: errors === null || errors === void 0 ? void 0 : errors['vatNumber']
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.promise.js");
|
|
4
|
+
require("core-js/modules/es.string.trim.js");
|
|
5
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.useCheckEmailExists = void 0;
|
|
10
|
+
require("core-js/modules/es.promise.js");
|
|
11
|
+
require("core-js/modules/es.string.trim.js");
|
|
12
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
13
|
+
var _react = require("react");
|
|
14
|
+
var _authenticatedProxyApi = require("../__api__/authenticatedProxyApi");
|
|
15
|
+
const useCheckEmailExists = () => {
|
|
16
|
+
const [isChecking, setIsChecking] = (0, _react.useState)(false);
|
|
17
|
+
const checkEmailExists = async email => {
|
|
18
|
+
if (!email || !email.trim()) {
|
|
19
|
+
return {
|
|
20
|
+
status: 'error',
|
|
21
|
+
emailExists: null,
|
|
22
|
+
message: 'Geen e-mailadres opgegeven.'
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
setIsChecking(true);
|
|
26
|
+
try {
|
|
27
|
+
var _response$data;
|
|
28
|
+
const response = await _authenticatedProxyApi.authenticatedProxyApi.getDossiers({
|
|
29
|
+
term: email.trim(),
|
|
30
|
+
limit: 1
|
|
31
|
+
});
|
|
32
|
+
if (response.status === 200 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.results) {
|
|
33
|
+
var _matchingDossier$klan, _matchingDossier$klan2;
|
|
34
|
+
const hasMatchingDossier = response.data.results.length > 0;
|
|
35
|
+
const matchingDossier = hasMatchingDossier ? response.data.results[0] : null;
|
|
36
|
+
const matchingCustomerId = (matchingDossier === null || matchingDossier === void 0 || (_matchingDossier$klan = matchingDossier.klant) === null || _matchingDossier$klan === void 0 ? void 0 : _matchingDossier$klan.entityId) || (matchingDossier === null || matchingDossier === void 0 || (_matchingDossier$klan2 = matchingDossier.klant) === null || _matchingDossier$klan2 === void 0 ? void 0 : _matchingDossier$klan2.id) || (matchingDossier === null || matchingDossier === void 0 ? void 0 : matchingDossier.klant) || null;
|
|
37
|
+
setIsChecking(false);
|
|
38
|
+
if (hasMatchingDossier) {
|
|
39
|
+
return {
|
|
40
|
+
status: 'success',
|
|
41
|
+
emailExists: true,
|
|
42
|
+
message: 'Dit e-mailadres is al in gebruik.',
|
|
43
|
+
matchingDossier,
|
|
44
|
+
existingCustomerId: matchingCustomerId
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
status: 'success',
|
|
49
|
+
emailExists: false,
|
|
50
|
+
message: null,
|
|
51
|
+
matchingDossier: null,
|
|
52
|
+
existingCustomerId: null
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
} catch (error) {
|
|
56
|
+
setIsChecking(false);
|
|
57
|
+
return {
|
|
58
|
+
status: 'error',
|
|
59
|
+
emailExists: null,
|
|
60
|
+
message: 'Er is een fout opgetreden bij het controleren van het e-mailadres.',
|
|
61
|
+
matchingDossier: null,
|
|
62
|
+
existingCustomerId: null
|
|
63
|
+
};
|
|
64
|
+
} finally {
|
|
65
|
+
setIsChecking(false);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
checkEmailExists,
|
|
70
|
+
isChecking
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
exports.useCheckEmailExists = useCheckEmailExists;
|
|
@@ -1,17 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.promise.js");
|
|
4
|
+
require("core-js/modules/es.string.trim.js");
|
|
5
|
+
require("core-js/modules/es.weak-map.js");
|
|
6
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
7
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
4
9
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
10
|
+
require("core-js/modules/es.weak-map.js");
|
|
11
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
12
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
13
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
5
14
|
Object.defineProperty(exports, "__esModule", {
|
|
6
15
|
value: true
|
|
7
16
|
});
|
|
8
17
|
exports.default = void 0;
|
|
9
18
|
require("core-js/modules/es.promise.js");
|
|
19
|
+
require("core-js/modules/es.string.trim.js");
|
|
10
20
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
11
|
-
var _react =
|
|
21
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
22
|
+
var _reactDom = require("react-dom");
|
|
12
23
|
var _reactQuery = require("react-query");
|
|
13
24
|
var _mutations = require("../../__api__/mutations");
|
|
25
|
+
var _queries = require("../../__api__/queries");
|
|
14
26
|
var _Header = _interopRequireDefault(require("../../__components__/Header"));
|
|
27
|
+
var _Modal = _interopRequireDefault(require("../../__components__/Modal"));
|
|
15
28
|
var _NavigationSteps = _interopRequireDefault(require("../../__components__/NavigationSteps"));
|
|
16
29
|
var _constants__ = require("../../__constants__");
|
|
17
30
|
var _internal = require("../../__containers__/internal");
|
|
@@ -20,18 +33,108 @@ var _ProductCartSide = _interopRequireDefault(require("../../__containers__/Prod
|
|
|
20
33
|
var _FormulaContext = require("../../__context__/FormulaContext");
|
|
21
34
|
var _OrderSessionContext = require("../../__context__/OrderSessionContext");
|
|
22
35
|
var _helpers__ = require("../../__helpers__");
|
|
36
|
+
var _useCheckEmailExists = require("../../__hooks__/useCheckEmailExists");
|
|
23
37
|
function _interopRequireDefault(e) {
|
|
24
38
|
return e && e.__esModule ? e : {
|
|
25
39
|
default: e
|
|
26
40
|
};
|
|
27
41
|
}
|
|
42
|
+
function _getRequireWildcardCache(e) {
|
|
43
|
+
if ("function" != typeof WeakMap) return null;
|
|
44
|
+
var r = new WeakMap(),
|
|
45
|
+
t = new WeakMap();
|
|
46
|
+
return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
|
|
47
|
+
return e ? t : r;
|
|
48
|
+
})(e);
|
|
49
|
+
}
|
|
50
|
+
function _interopRequireWildcard(e, r) {
|
|
51
|
+
if (!r && e && e.__esModule) return e;
|
|
52
|
+
if (null === e || "object" != typeof e && "function" != typeof e) return {
|
|
53
|
+
default: e
|
|
54
|
+
};
|
|
55
|
+
var t = _getRequireWildcardCache(r);
|
|
56
|
+
if (t && t.has(e)) return t.get(e);
|
|
57
|
+
var n = {
|
|
58
|
+
__proto__: null
|
|
59
|
+
},
|
|
60
|
+
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
61
|
+
for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
62
|
+
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
63
|
+
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
|
|
64
|
+
}
|
|
65
|
+
return n.default = e, t && t.set(e, n), n;
|
|
66
|
+
}
|
|
67
|
+
function ownKeys(e, r) {
|
|
68
|
+
var t = Object.keys(e);
|
|
69
|
+
if (Object.getOwnPropertySymbols) {
|
|
70
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
71
|
+
r && (o = o.filter(function (r) {
|
|
72
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
73
|
+
})), t.push.apply(t, o);
|
|
74
|
+
}
|
|
75
|
+
return t;
|
|
76
|
+
}
|
|
77
|
+
function _objectSpread(e) {
|
|
78
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
79
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
80
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
81
|
+
_defineProperty(e, r, t[r]);
|
|
82
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
83
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
return e;
|
|
87
|
+
}
|
|
88
|
+
function _defineProperty(e, r, t) {
|
|
89
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
90
|
+
value: t,
|
|
91
|
+
enumerable: !0,
|
|
92
|
+
configurable: !0,
|
|
93
|
+
writable: !0
|
|
94
|
+
}) : e[r] = t, e;
|
|
95
|
+
}
|
|
96
|
+
function _toPropertyKey(t) {
|
|
97
|
+
var i = _toPrimitive(t, "string");
|
|
98
|
+
return "symbol" == typeof i ? i : i + "";
|
|
99
|
+
}
|
|
100
|
+
function _toPrimitive(t, r) {
|
|
101
|
+
if ("object" != typeof t || !t) return t;
|
|
102
|
+
var e = t[Symbol.toPrimitive];
|
|
103
|
+
if (void 0 !== e) {
|
|
104
|
+
var i = e.call(t, r || "default");
|
|
105
|
+
if ("object" != typeof i) return i;
|
|
106
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
107
|
+
}
|
|
108
|
+
return ("string" === r ? String : Number)(t);
|
|
109
|
+
}
|
|
28
110
|
const InternalAppointmentPage = () => {
|
|
29
111
|
const formula = (0, _FormulaContext.useFormula)();
|
|
30
112
|
const [{
|
|
31
|
-
existingDossierId
|
|
113
|
+
existingDossierId,
|
|
114
|
+
existingDossierType
|
|
32
115
|
}] = (0, _OrderSessionContext.useOrderSession)();
|
|
33
116
|
const queryClient = (0, _reactQuery.useQueryClient)();
|
|
34
117
|
const [createdEntityId, setCreatedEntityId] = _react.default.useState(null);
|
|
118
|
+
const [isEmailConflictModalShown, setIsEmailConflictModalShown] = (0, _react.useState)(false);
|
|
119
|
+
const [pendingPayload, setPendingPayload] = (0, _react.useState)(null);
|
|
120
|
+
const [emailConflictData, setEmailConflictData] = (0, _react.useState)(null);
|
|
121
|
+
const [anchorEl, setAnchorEl] = (0, _react.useState)();
|
|
122
|
+
(0, _react.useEffect)(() => {
|
|
123
|
+
if (typeof window !== 'undefined') {
|
|
124
|
+
const appEl = window.document.getElementsByTagName('main');
|
|
125
|
+
setAnchorEl(appEl === null || appEl === void 0 ? void 0 : appEl[0]);
|
|
126
|
+
}
|
|
127
|
+
}, []);
|
|
128
|
+
const {
|
|
129
|
+
checkEmailExists,
|
|
130
|
+
isChecking: isCheckingEmail
|
|
131
|
+
} = (0, _useCheckEmailExists.useCheckEmailExists)();
|
|
132
|
+
const {
|
|
133
|
+
dossierById
|
|
134
|
+
} = (0, _queries.usePrivateDossierByTypeAndIdQuery)({
|
|
135
|
+
dossierId: existingDossierId,
|
|
136
|
+
dossierType: existingDossierType
|
|
137
|
+
});
|
|
35
138
|
const {
|
|
36
139
|
createPlannedAppointment,
|
|
37
140
|
isCreatePlannedAppointmentError,
|
|
@@ -60,7 +163,7 @@ const InternalAppointmentPage = () => {
|
|
|
60
163
|
isUpdatingAppointmentRequest,
|
|
61
164
|
data: updateAppointmentRequestData
|
|
62
165
|
} = (0, _mutations.useUpdatePrivateAppointmentRequestByIdMutation)(existingDossierId);
|
|
63
|
-
const
|
|
166
|
+
const performSubmit = async payload => {
|
|
64
167
|
if (payload !== null && payload !== void 0 && payload.appointmentType && payload.appointmentType === _constants__.DOSSIER_TYPES.PlannedAppointment) {
|
|
65
168
|
var _response$data2;
|
|
66
169
|
if (existingDossierId) {
|
|
@@ -91,6 +194,44 @@ const InternalAppointmentPage = () => {
|
|
|
91
194
|
}
|
|
92
195
|
}
|
|
93
196
|
};
|
|
197
|
+
const handleSubmit = async payload => {
|
|
198
|
+
var _dossierById$klant, _payload$customer;
|
|
199
|
+
const originalEmail = (dossierById === null || dossierById === void 0 || (_dossierById$klant = dossierById.klant) === null || _dossierById$klant === void 0 ? void 0 : _dossierById$klant.email2) || '';
|
|
200
|
+
const normalizedOriginalEmail = originalEmail.trim().toLowerCase();
|
|
201
|
+
const normalizedCurrentEmail = (((_payload$customer = payload.customer) === null || _payload$customer === void 0 ? void 0 : _payload$customer.email) || '').trim().toLowerCase();
|
|
202
|
+
if (normalizedCurrentEmail && normalizedCurrentEmail !== normalizedOriginalEmail) {
|
|
203
|
+
const emailCheckResult = await checkEmailExists(payload.customer.email);
|
|
204
|
+
if (emailCheckResult.status === 'success' && emailCheckResult.emailExists) {
|
|
205
|
+
setPendingPayload(payload);
|
|
206
|
+
setEmailConflictData(emailCheckResult);
|
|
207
|
+
setIsEmailConflictModalShown(true);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
await performSubmit(payload);
|
|
212
|
+
};
|
|
213
|
+
const handleLinkContact = () => {
|
|
214
|
+
if (pendingPayload) {
|
|
215
|
+
const linkToExistingCustomerId = emailConflictData === null || emailConflictData === void 0 ? void 0 : emailConflictData.existingCustomerId;
|
|
216
|
+
const payloadToSubmit = linkToExistingCustomerId ? _objectSpread(_objectSpread({}, pendingPayload), {}, {
|
|
217
|
+
customer: _objectSpread(_objectSpread({}, pendingPayload.customer), {}, {
|
|
218
|
+
linkToExistingCustomerId
|
|
219
|
+
})
|
|
220
|
+
}) : pendingPayload;
|
|
221
|
+
performSubmit(payloadToSubmit);
|
|
222
|
+
}
|
|
223
|
+
setIsEmailConflictModalShown(false);
|
|
224
|
+
setPendingPayload(null);
|
|
225
|
+
setEmailConflictData(null);
|
|
226
|
+
};
|
|
227
|
+
const handleCancelLink = () => {
|
|
228
|
+
if (pendingPayload) {
|
|
229
|
+
performSubmit(pendingPayload);
|
|
230
|
+
}
|
|
231
|
+
setIsEmailConflictModalShown(false);
|
|
232
|
+
setPendingPayload(null);
|
|
233
|
+
setEmailConflictData(null);
|
|
234
|
+
};
|
|
94
235
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
95
236
|
className: (0, _helpers__.withStyle)('vh-100')
|
|
96
237
|
}, ' ', /*#__PURE__*/_react.default.createElement(_internal.InternalCancelDossierEdit, null), /*#__PURE__*/_react.default.createElement(_Header.default, {
|
|
@@ -117,11 +258,27 @@ const InternalAppointmentPage = () => {
|
|
|
117
258
|
}, /*#__PURE__*/_react.default.createElement(_InternalAppointmentForm.default, {
|
|
118
259
|
onSubmit: handleSubmit,
|
|
119
260
|
isError: isCreatePlannedAppointmentError || isUpdateAppointmentError || isCreateAppointmentRequestError || isUpdateAppointmentRequestError,
|
|
120
|
-
isLoading: isUpdatingAppointment || isCreatingPlannedAppointment || isCreatingAppointmentRequest || isUpdatingAppointmentRequest,
|
|
261
|
+
isLoading: isUpdatingAppointment || isCreatingPlannedAppointment || isCreatingAppointmentRequest || isUpdatingAppointmentRequest || isCheckingEmail,
|
|
121
262
|
isSuccess: isCreatePlannedAppointmentSuccess || isCreateAppointmentRequestSuccess || isUpdateAppointmentSuccess || isUpdateAppointmentRequestSuccess,
|
|
122
263
|
entityId: createdEntityId || existingDossierId
|
|
123
264
|
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
124
265
|
className: (0, _helpers__.withStyle)("sidebar col col-xxl-4 pt-5")
|
|
125
|
-
}, /*#__PURE__*/_react.default.createElement(_ProductCartSide.default, null))))))
|
|
266
|
+
}, /*#__PURE__*/_react.default.createElement(_ProductCartSide.default, null))))), anchorEl && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement(_Modal.default, {
|
|
267
|
+
isOpen: isEmailConflictModalShown,
|
|
268
|
+
title: "Contact koppelen?",
|
|
269
|
+
onClose: () => {
|
|
270
|
+
setIsEmailConflictModalShown(false);
|
|
271
|
+
setPendingPayload(null);
|
|
272
|
+
setEmailConflictData(null);
|
|
273
|
+
},
|
|
274
|
+
primaryButtonText: "Ja, koppel contact",
|
|
275
|
+
secondaryButtonText: "Annuleren",
|
|
276
|
+
onPrimaryButtonClicked: handleLinkContact,
|
|
277
|
+
onSecondaryButtonClicked: handleCancelLink
|
|
278
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
279
|
+
className: (0, _helpers__.withStyle)('text-center')
|
|
280
|
+
}, /*#__PURE__*/_react.default.createElement("p", {
|
|
281
|
+
className: "mb-2"
|
|
282
|
+
}, "Dit mail adres is al in gebruik, wilt u dit contact koppelen aan de al bestaande customer?"))), anchorEl));
|
|
126
283
|
};
|
|
127
284
|
var _default = exports.default = InternalAppointmentPage;
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.promise.js");
|
|
4
|
+
require("core-js/modules/es.string.trim.js");
|
|
5
|
+
require("core-js/modules/es.weak-map.js");
|
|
6
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
7
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
8
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
4
9
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
10
|
+
require("core-js/modules/es.weak-map.js");
|
|
11
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
12
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
13
|
+
require("core-js/modules/esnext.iterator.for-each.js");
|
|
5
14
|
Object.defineProperty(exports, "__esModule", {
|
|
6
15
|
value: true
|
|
7
16
|
});
|
|
8
17
|
exports.default = void 0;
|
|
9
18
|
require("core-js/modules/es.promise.js");
|
|
19
|
+
require("core-js/modules/es.string.trim.js");
|
|
10
20
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
11
|
-
var _react =
|
|
21
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
22
|
+
var _reactDom = require("react-dom");
|
|
12
23
|
var _mutations = require("../../__api__/mutations");
|
|
24
|
+
var _queries = require("../../__api__/queries");
|
|
13
25
|
var _Header = _interopRequireDefault(require("../../__components__/Header"));
|
|
26
|
+
var _Modal = _interopRequireDefault(require("../../__components__/Modal"));
|
|
14
27
|
var _NavigationSteps = _interopRequireDefault(require("../../__components__/NavigationSteps"));
|
|
15
28
|
var _constants__ = require("../../__constants__");
|
|
16
29
|
var _internal = require("../../__containers__/internal");
|
|
@@ -19,17 +32,106 @@ var _QuotationSuccessModal = _interopRequireDefault(require("../../__containers_
|
|
|
19
32
|
var _FormulaContext = require("../../__context__/FormulaContext");
|
|
20
33
|
var _OrderSessionContext = require("../../__context__/OrderSessionContext");
|
|
21
34
|
var _helpers__ = require("../../__helpers__");
|
|
35
|
+
var _useCheckEmailExists = require("../../__hooks__/useCheckEmailExists");
|
|
22
36
|
function _interopRequireDefault(e) {
|
|
23
37
|
return e && e.__esModule ? e : {
|
|
24
38
|
default: e
|
|
25
39
|
};
|
|
26
40
|
}
|
|
41
|
+
function _getRequireWildcardCache(e) {
|
|
42
|
+
if ("function" != typeof WeakMap) return null;
|
|
43
|
+
var r = new WeakMap(),
|
|
44
|
+
t = new WeakMap();
|
|
45
|
+
return (_getRequireWildcardCache = function _getRequireWildcardCache(e) {
|
|
46
|
+
return e ? t : r;
|
|
47
|
+
})(e);
|
|
48
|
+
}
|
|
49
|
+
function _interopRequireWildcard(e, r) {
|
|
50
|
+
if (!r && e && e.__esModule) return e;
|
|
51
|
+
if (null === e || "object" != typeof e && "function" != typeof e) return {
|
|
52
|
+
default: e
|
|
53
|
+
};
|
|
54
|
+
var t = _getRequireWildcardCache(r);
|
|
55
|
+
if (t && t.has(e)) return t.get(e);
|
|
56
|
+
var n = {
|
|
57
|
+
__proto__: null
|
|
58
|
+
},
|
|
59
|
+
a = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
60
|
+
for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) {
|
|
61
|
+
var i = a ? Object.getOwnPropertyDescriptor(e, u) : null;
|
|
62
|
+
i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u];
|
|
63
|
+
}
|
|
64
|
+
return n.default = e, t && t.set(e, n), n;
|
|
65
|
+
}
|
|
66
|
+
function ownKeys(e, r) {
|
|
67
|
+
var t = Object.keys(e);
|
|
68
|
+
if (Object.getOwnPropertySymbols) {
|
|
69
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
70
|
+
r && (o = o.filter(function (r) {
|
|
71
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
72
|
+
})), t.push.apply(t, o);
|
|
73
|
+
}
|
|
74
|
+
return t;
|
|
75
|
+
}
|
|
76
|
+
function _objectSpread(e) {
|
|
77
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
78
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
79
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
|
|
80
|
+
_defineProperty(e, r, t[r]);
|
|
81
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
|
|
82
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return e;
|
|
86
|
+
}
|
|
87
|
+
function _defineProperty(e, r, t) {
|
|
88
|
+
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
89
|
+
value: t,
|
|
90
|
+
enumerable: !0,
|
|
91
|
+
configurable: !0,
|
|
92
|
+
writable: !0
|
|
93
|
+
}) : e[r] = t, e;
|
|
94
|
+
}
|
|
95
|
+
function _toPropertyKey(t) {
|
|
96
|
+
var i = _toPrimitive(t, "string");
|
|
97
|
+
return "symbol" == typeof i ? i : i + "";
|
|
98
|
+
}
|
|
99
|
+
function _toPrimitive(t, r) {
|
|
100
|
+
if ("object" != typeof t || !t) return t;
|
|
101
|
+
var e = t[Symbol.toPrimitive];
|
|
102
|
+
if (void 0 !== e) {
|
|
103
|
+
var i = e.call(t, r || "default");
|
|
104
|
+
if ("object" != typeof i) return i;
|
|
105
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
106
|
+
}
|
|
107
|
+
return ("string" === r ? String : Number)(t);
|
|
108
|
+
}
|
|
27
109
|
const InternalQuotationPage = () => {
|
|
28
110
|
const formula = (0, _FormulaContext.useFormula)();
|
|
29
111
|
const [{
|
|
30
112
|
existingDossierId
|
|
31
113
|
}] = (0, _OrderSessionContext.useOrderSession)();
|
|
32
114
|
const [createdEntityId, setCreatedEntityId] = _react.default.useState(null);
|
|
115
|
+
const [isEmailConflictModalShown, setIsEmailConflictModalShown] = (0, _react.useState)(false);
|
|
116
|
+
const [pendingPayload, setPendingPayload] = (0, _react.useState)(null);
|
|
117
|
+
const [emailConflictData, setEmailConflictData] = (0, _react.useState)(null);
|
|
118
|
+
const [anchorEl, setAnchorEl] = (0, _react.useState)();
|
|
119
|
+
(0, _react.useEffect)(() => {
|
|
120
|
+
if (typeof window !== 'undefined') {
|
|
121
|
+
const appEl = window.document.getElementsByTagName('main');
|
|
122
|
+
setAnchorEl(appEl === null || appEl === void 0 ? void 0 : appEl[0]);
|
|
123
|
+
}
|
|
124
|
+
}, []);
|
|
125
|
+
const {
|
|
126
|
+
checkEmailExists,
|
|
127
|
+
isChecking: isCheckingEmail
|
|
128
|
+
} = (0, _useCheckEmailExists.useCheckEmailExists)();
|
|
129
|
+
const {
|
|
130
|
+
dossierById
|
|
131
|
+
} = (0, _queries.usePrivateDossierByTypeAndIdQuery)({
|
|
132
|
+
dossierId: existingDossierId,
|
|
133
|
+
dossierType: _constants__.DOSSIER_TYPES.Quotation
|
|
134
|
+
});
|
|
33
135
|
const {
|
|
34
136
|
createQuotation,
|
|
35
137
|
isCreateQuotationSuccess,
|
|
@@ -44,7 +146,7 @@ const InternalQuotationPage = () => {
|
|
|
44
146
|
isUpdatingQuotation,
|
|
45
147
|
data: updateQuotationData
|
|
46
148
|
} = (0, _mutations.useUpdatePrivateQuotationByIdMutation)(existingDossierId);
|
|
47
|
-
const
|
|
149
|
+
const performSubmit = async payload => {
|
|
48
150
|
var _response$data2;
|
|
49
151
|
if (existingDossierId) {
|
|
50
152
|
var _response$data;
|
|
@@ -59,6 +161,44 @@ const InternalQuotationPage = () => {
|
|
|
59
161
|
setCreatedEntityId(response.data.data.entityId);
|
|
60
162
|
}
|
|
61
163
|
};
|
|
164
|
+
const handleSubmit = async payload => {
|
|
165
|
+
var _dossierById$klant, _payload$customer;
|
|
166
|
+
const originalEmail = (dossierById === null || dossierById === void 0 || (_dossierById$klant = dossierById.klant) === null || _dossierById$klant === void 0 ? void 0 : _dossierById$klant.email2) || '';
|
|
167
|
+
const normalizedOriginalEmail = originalEmail.trim().toLowerCase();
|
|
168
|
+
const normalizedCurrentEmail = (((_payload$customer = payload.customer) === null || _payload$customer === void 0 ? void 0 : _payload$customer.email) || '').trim().toLowerCase();
|
|
169
|
+
if (normalizedCurrentEmail && normalizedCurrentEmail !== normalizedOriginalEmail) {
|
|
170
|
+
const emailCheckResult = await checkEmailExists(payload.customer.email);
|
|
171
|
+
if (emailCheckResult.status === 'success' && emailCheckResult.emailExists) {
|
|
172
|
+
setPendingPayload(payload);
|
|
173
|
+
setEmailConflictData(emailCheckResult);
|
|
174
|
+
setIsEmailConflictModalShown(true);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
await performSubmit(payload);
|
|
179
|
+
};
|
|
180
|
+
const handleLinkContact = () => {
|
|
181
|
+
if (pendingPayload) {
|
|
182
|
+
const linkToExistingCustomerId = emailConflictData === null || emailConflictData === void 0 ? void 0 : emailConflictData.existingCustomerId;
|
|
183
|
+
const payloadToSubmit = linkToExistingCustomerId ? _objectSpread(_objectSpread({}, pendingPayload), {}, {
|
|
184
|
+
customer: _objectSpread(_objectSpread({}, pendingPayload.customer), {}, {
|
|
185
|
+
linkToExistingCustomerId
|
|
186
|
+
})
|
|
187
|
+
}) : pendingPayload;
|
|
188
|
+
performSubmit(payloadToSubmit);
|
|
189
|
+
}
|
|
190
|
+
setIsEmailConflictModalShown(false);
|
|
191
|
+
setPendingPayload(null);
|
|
192
|
+
setEmailConflictData(null);
|
|
193
|
+
};
|
|
194
|
+
const handleCancelLink = () => {
|
|
195
|
+
if (pendingPayload) {
|
|
196
|
+
performSubmit(pendingPayload);
|
|
197
|
+
}
|
|
198
|
+
setIsEmailConflictModalShown(false);
|
|
199
|
+
setPendingPayload(null);
|
|
200
|
+
setEmailConflictData(null);
|
|
201
|
+
};
|
|
62
202
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
63
203
|
className: (0, _helpers__.withStyle)('vh-100')
|
|
64
204
|
}, /*#__PURE__*/_react.default.createElement(_internal.InternalCancelDossierEdit, null), " ", /*#__PURE__*/_react.default.createElement(_Header.default, null), ' ', /*#__PURE__*/_react.default.createElement(_QuotationSuccessModal.default, {
|
|
@@ -86,9 +226,25 @@ const InternalQuotationPage = () => {
|
|
|
86
226
|
}, /*#__PURE__*/_react.default.createElement(_InternalQuotationForm.default, {
|
|
87
227
|
onSubmit: handleSubmit,
|
|
88
228
|
isError: isCreateQuotationError || isUpdateQuotationError,
|
|
89
|
-
isLoading: isUpdatingQuotation || isCreatingQuotation,
|
|
229
|
+
isLoading: isUpdatingQuotation || isCreatingQuotation || isCheckingEmail,
|
|
90
230
|
isSuccess: isCreateQuotationSuccess || isUpdateQuotationSuccess,
|
|
91
231
|
entityId: createdEntityId || existingDossierId
|
|
92
|
-
}))))))
|
|
232
|
+
}))))), anchorEl && /*#__PURE__*/(0, _reactDom.createPortal)(/*#__PURE__*/_react.default.createElement(_Modal.default, {
|
|
233
|
+
isOpen: isEmailConflictModalShown,
|
|
234
|
+
title: "Contact koppelen?",
|
|
235
|
+
onClose: () => {
|
|
236
|
+
setIsEmailConflictModalShown(false);
|
|
237
|
+
setPendingPayload(null);
|
|
238
|
+
setEmailConflictData(null);
|
|
239
|
+
},
|
|
240
|
+
primaryButtonText: "Ja, koppel contact",
|
|
241
|
+
secondaryButtonText: "Annuleren",
|
|
242
|
+
onPrimaryButtonClicked: handleLinkContact,
|
|
243
|
+
onSecondaryButtonClicked: handleCancelLink
|
|
244
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
245
|
+
className: (0, _helpers__.withStyle)('text-center')
|
|
246
|
+
}, /*#__PURE__*/_react.default.createElement("p", {
|
|
247
|
+
className: "mb-2"
|
|
248
|
+
}, "Dit mail adres is al in gebruik, wilt u dit contact koppelen aan de al bestaande customer?"))), anchorEl));
|
|
93
249
|
};
|
|
94
250
|
var _default = exports.default = InternalQuotationPage;
|