thm-p3-configurator 0.0.277 → 0.0.279

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.
@@ -342,7 +342,7 @@ const InternalAppointmentForm = _ref => {
342
342
  const handleSubmit = async function handleSubmit() {
343
343
  let appointmentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _constants__.DOSSIER_TYPES.PlannedAppointment;
344
344
  try {
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;
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
346
  setErrors({});
347
347
  if (!model) {
348
348
  // Note: this does not throw on error.
@@ -425,8 +425,7 @@ const InternalAppointmentForm = _ref => {
425
425
  appointment,
426
426
  appointmentType,
427
427
  channel,
428
- licensePlate: licensePlate ? licensePlate.replace(/-/g, '') : undefined,
429
- licensePlateBrandModel: !licensePlate && model && (_licensePlate || licensePlateBrandModel) ? (_licensePlate || licensePlateBrandModel).replace(/-/g, '') : undefined,
428
+ licensePlate: (_ref2 = licensePlate || _licensePlate) === null || _ref2 === void 0 ? void 0 : _ref2.replace(/-/g, ''),
430
429
  model,
431
430
  chassisNumber,
432
431
  priceCalculationDate,
@@ -724,12 +723,12 @@ const InternalAppointmentForm = _ref => {
724
723
  placeholder: "Maak een keuze",
725
724
  errorMessage: (errors === null || errors === void 0 ? void 0 : errors['channelType']) || (errors === null || errors === void 0 ? void 0 : errors['channelId']),
726
725
  initialValue: initialChannel,
727
- onChange: _ref2 => {
726
+ onChange: _ref3 => {
728
727
  var _value$kanaalType;
729
728
  let {
730
729
  label,
731
730
  value
732
- } = _ref2;
731
+ } = _ref3;
733
732
  return dispatch({
734
733
  type: _OrderSessionContext.orderSessionActions.SET_MARKETING_CHANNEL,
735
734
  payload: {
@@ -1383,10 +1382,10 @@ const InternalAppointmentForm = _ref => {
1383
1382
  placeholder: "Selecteer een land",
1384
1383
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['countryId'],
1385
1384
  initialValue: (countryOptions === null || countryOptions === void 0 ? void 0 : countryOptions.find(option => option.value === (customer === null || customer === void 0 ? void 0 : customer.countryId))) || null,
1386
- onChange: _ref3 => {
1385
+ onChange: _ref4 => {
1387
1386
  let {
1388
1387
  value
1389
- } = _ref3;
1388
+ } = _ref4;
1390
1389
  return dispatch({
1391
1390
  type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
1392
1391
  payload: {
@@ -1487,10 +1486,10 @@ const InternalAppointmentForm = _ref => {
1487
1486
  placeholder: "Selecteer een land",
1488
1487
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['countryId'],
1489
1488
  initialValue: (countryOptions === null || countryOptions === void 0 ? void 0 : countryOptions.find(option => option.value === (customer === null || customer === void 0 ? void 0 : customer.countryId))) || null,
1490
- onChange: _ref4 => {
1489
+ onChange: _ref5 => {
1491
1490
  let {
1492
1491
  value
1493
- } = _ref4;
1492
+ } = _ref5;
1494
1493
  return dispatch({
1495
1494
  type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
1496
1495
  payload: {
@@ -1605,10 +1604,10 @@ const InternalAppointmentForm = _ref => {
1605
1604
  placeholder: "Selecteer een land",
1606
1605
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['countryId'],
1607
1606
  initialValue: (countryOptions === null || countryOptions === void 0 ? void 0 : countryOptions.find(option => option.value === (customer === null || customer === void 0 ? void 0 : customer.countryId))) || null,
1608
- onChange: _ref5 => {
1607
+ onChange: _ref6 => {
1609
1608
  let {
1610
1609
  value
1611
- } = _ref5;
1610
+ } = _ref6;
1612
1611
  return dispatch({
1613
1612
  type: _OrderSessionContext.orderSessionActions.SET_CUSTOMER_COUNTRY_ID,
1614
1613
  payload: {
@@ -1654,27 +1653,37 @@ const InternalAppointmentForm = _ref => {
1654
1653
  },
1655
1654
  label: "Goedkeuringsnummer onbekend",
1656
1655
  isDisabled: !!(vehicle !== null && vehicle !== void 0 && vehicle.leaseNumber)
1657
- })), licensePlate && /*#__PURE__*/_react.default.createElement(_TextInput.default, {
1656
+ })), !model ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !licensePlate && !licensePlateBrandModel && /*#__PURE__*/_react.default.createElement(_TextInput.default, {
1657
+ key: "licensePlate",
1658
+ placeholder: "",
1659
+ value: _licensePlate,
1660
+ name: "licensePlate",
1661
+ onChange: value => _setLicensePlate(value),
1662
+ isRequired: false,
1663
+ form: "quotation",
1664
+ label: "Kenteken:",
1665
+ errorMessage: errors === null || errors === void 0 ? void 0 : errors['licensePlate']
1666
+ }), (licensePlate || licensePlateBrandModel) && /*#__PURE__*/_react.default.createElement(_TextInput.default, {
1658
1667
  key: "licensePlateReadOnly",
1659
1668
  placeholder: "",
1660
- value: licensePlate,
1669
+ value: licensePlate || licensePlateBrandModel || '',
1661
1670
  name: "licensePlateReadOnly",
1662
1671
  onChange: () => {},
1663
1672
  isRequired: false,
1664
1673
  form: "quotation",
1665
1674
  label: "Kenteken:",
1666
1675
  isDisabled: true
1667
- }), !licensePlate && /*#__PURE__*/_react.default.createElement(_TextInput.default, {
1676
+ })) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_TextInput.default, {
1668
1677
  key: "licensePlate",
1669
1678
  placeholder: "",
1670
- value: _licensePlate !== undefined ? _licensePlate : licensePlateBrandModel || '',
1679
+ value: _licensePlate || licensePlateBrandModel || '',
1671
1680
  name: "licensePlate",
1672
1681
  onChange: value => _setLicensePlate(value),
1673
1682
  isRequired: false,
1674
1683
  form: "quotation",
1675
1684
  label: "Kenteken:",
1676
1685
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['licensePlate']
1677
- }), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
1686
+ })), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
1678
1687
  key: "chassisNumber",
1679
1688
  placeholder: "",
1680
1689
  value: vehicle === null || vehicle === void 0 ? void 0 : vehicle.chassisNumber,
@@ -194,7 +194,7 @@ const InternalQuotationForm = _ref => {
194
194
  const [errors, setErrors] = (0, _react.useState)({});
195
195
  const [companySearchTerm, setCompanySearchTerm] = (0, _react.useState)('');
196
196
  const [isCompanyInputFocused, setIsCompanyInputFocused] = (0, _react.useState)(false);
197
- const [_licensePlate, _setLicensePlate] = (0, _react.useState)();
197
+ const [_licensePlate, _setLicensePlate] = (0, _react.useState)(licensePlate);
198
198
  const isTmg = (0, _useIsTmg.useIsTmg)();
199
199
  const {
200
200
  branchTypes
@@ -309,7 +309,7 @@ const InternalQuotationForm = _ref => {
309
309
  */
310
310
  const handleSubmit = async () => {
311
311
  try {
312
- 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;
312
+ 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, _ref2;
313
313
  setErrors(null);
314
314
  if (!model) {
315
315
  // Note: this does not throw on error.
@@ -367,8 +367,7 @@ const InternalQuotationForm = _ref => {
367
367
  })),
368
368
  chassisNumber: chassisNumber !== null && chassisNumber !== void 0 ? chassisNumber : undefined,
369
369
  channel,
370
- licensePlate: licensePlate ? licensePlate.replace(/-/g, '') : undefined,
371
- licensePlateBrandModel: !licensePlate && model && (_licensePlate || licensePlateBrandModel) ? (_licensePlate || licensePlateBrandModel).replace(/-/g, '') : undefined,
370
+ licensePlate: (_ref2 = licensePlate || _licensePlate) === null || _ref2 === void 0 ? void 0 : _ref2.replace(/-/g, ''),
372
371
  model,
373
372
  answers: (0, _helpers__.removeNullishProps)({
374
373
  duration: durationAnswer,
@@ -529,12 +528,12 @@ const InternalQuotationForm = _ref => {
529
528
  placeholder: "Maak een keuze",
530
529
  errorMessage: (errors === null || errors === void 0 ? void 0 : errors['channelId']) || (errors === null || errors === void 0 ? void 0 : errors['channelType']),
531
530
  initialValue: initialChannel,
532
- onChange: _ref2 => {
531
+ onChange: _ref3 => {
533
532
  var _value$kanaalType;
534
533
  let {
535
534
  label,
536
535
  value
537
- } = _ref2;
536
+ } = _ref3;
538
537
  return dispatch({
539
538
  type: _OrderSessionContext.orderSessionActions.SET_MARKETING_CHANNEL,
540
539
  payload: {
@@ -950,26 +949,35 @@ const InternalQuotationForm = _ref => {
950
949
  },
951
950
  label: "Goedkeuringsnummer onbekend",
952
951
  isDisabled: !!(vehicle !== null && vehicle !== void 0 && vehicle.leaseNumber)
953
- })), licensePlate && /*#__PURE__*/_react.default.createElement(_TextInput.default, {
952
+ })), !model ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !licensePlate && !licensePlateBrandModel && /*#__PURE__*/_react.default.createElement(_TextInput.default, {
953
+ placeholder: "",
954
+ value: _licensePlate,
955
+ name: "licensePlate",
956
+ onChange: value => _setLicensePlate(value),
957
+ isRequired: false,
958
+ form: "quotation",
959
+ label: "Kenteken:",
960
+ errorMessage: errors === null || errors === void 0 ? void 0 : errors['licensePlate']
961
+ }), (licensePlate || licensePlateBrandModel) && /*#__PURE__*/_react.default.createElement(_TextInput.default, {
954
962
  key: "licensePlateReadOnly",
955
963
  placeholder: "",
956
- value: licensePlate,
964
+ value: licensePlate || licensePlateBrandModel || '',
957
965
  name: "licensePlateReadOnly",
958
966
  onChange: () => {},
959
967
  isRequired: false,
960
968
  form: "quotation",
961
969
  label: "Kenteken:",
962
970
  isDisabled: true
963
- }), !licensePlate && /*#__PURE__*/_react.default.createElement(_TextInput.default, {
971
+ })) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_TextInput.default, {
964
972
  placeholder: "",
965
- value: _licensePlate !== undefined ? _licensePlate : licensePlateBrandModel || '',
973
+ value: _licensePlate || licensePlateBrandModel || '',
966
974
  name: "licensePlate",
967
975
  onChange: value => _setLicensePlate(value),
968
976
  isRequired: false,
969
977
  form: "quotation",
970
978
  label: "Kenteken:",
971
979
  errorMessage: errors === null || errors === void 0 ? void 0 : errors['licensePlate']
972
- }), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
980
+ })), /*#__PURE__*/_react.default.createElement(_TextInput.default, {
973
981
  placeholder: "",
974
982
  value: vehicle === null || vehicle === void 0 ? void 0 : vehicle.chassisNumber,
975
983
  name: "chassisNumber",
@@ -14,7 +14,12 @@ var _react = require("react");
14
14
  var _authenticatedProxyApi = require("../__api__/authenticatedProxyApi");
15
15
  const useCheckEmailExists = () => {
16
16
  const [isChecking, setIsChecking] = (0, _react.useState)(false);
17
- const checkEmailExists = async email => {
17
+ const checkEmailExists = async function checkEmailExists(email) {
18
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
19
+ const {
20
+ excludeDossierId,
21
+ excludeCustomerId
22
+ } = options;
18
23
  if (!email || !email.trim()) {
19
24
  return {
20
25
  status: 'error',
@@ -30,12 +35,24 @@ const useCheckEmailExists = () => {
30
35
  limit: 1
31
36
  });
32
37
  if (response.status === 200 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.results) {
33
- var _matchingDossier$klan, _matchingDossier$klan2;
38
+ var _matchingDossier6, _matchingDossier7, _matchingDossier8;
34
39
  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;
40
+ let matchingDossier = hasMatchingDossier ? response.data.results[0] : null;
41
+
42
+ // Filter out self-matches if exclusion options are provided
43
+ if (matchingDossier) {
44
+ var _matchingDossier, _matchingDossier2, _matchingDossier3, _matchingDossier4, _matchingDossier5;
45
+ const matchingDossierId = ((_matchingDossier = matchingDossier) === null || _matchingDossier === void 0 ? void 0 : _matchingDossier.entityId) || ((_matchingDossier2 = matchingDossier) === null || _matchingDossier2 === void 0 ? void 0 : _matchingDossier2.dossierId) || null;
46
+ const matchingCustomerId = ((_matchingDossier3 = matchingDossier) === null || _matchingDossier3 === void 0 || (_matchingDossier3 = _matchingDossier3.klant) === null || _matchingDossier3 === void 0 ? void 0 : _matchingDossier3.entityId) || ((_matchingDossier4 = matchingDossier) === null || _matchingDossier4 === void 0 || (_matchingDossier4 = _matchingDossier4.klant) === null || _matchingDossier4 === void 0 ? void 0 : _matchingDossier4.id) || ((_matchingDossier5 = matchingDossier) === null || _matchingDossier5 === void 0 ? void 0 : _matchingDossier5.klant) || null;
47
+
48
+ // Skip if this is a self-match
49
+ if (excludeDossierId && matchingDossierId === excludeDossierId || excludeCustomerId && matchingCustomerId === excludeCustomerId) {
50
+ matchingDossier = null;
51
+ }
52
+ }
53
+ const matchingCustomerId = matchingDossier ? ((_matchingDossier6 = matchingDossier) === null || _matchingDossier6 === void 0 || (_matchingDossier6 = _matchingDossier6.klant) === null || _matchingDossier6 === void 0 ? void 0 : _matchingDossier6.entityId) || ((_matchingDossier7 = matchingDossier) === null || _matchingDossier7 === void 0 || (_matchingDossier7 = _matchingDossier7.klant) === null || _matchingDossier7 === void 0 ? void 0 : _matchingDossier7.id) || ((_matchingDossier8 = matchingDossier) === null || _matchingDossier8 === void 0 ? void 0 : _matchingDossier8.klant) || null : null;
37
54
  setIsChecking(false);
38
- if (hasMatchingDossier) {
55
+ if (matchingDossier) {
39
56
  return {
40
57
  status: 'success',
41
58
  emailExists: true,
@@ -195,12 +195,17 @@ const InternalAppointmentPage = () => {
195
195
  }
196
196
  };
197
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) || '';
198
+ var _dossierById$klant, _dossierById$klant2, _payload$customer;
199
+ const originalEmail = (dossierById === null || dossierById === void 0 ? void 0 : dossierById.email2) || (dossierById === null || dossierById === void 0 ? void 0 : dossierById.email1) || (dossierById === null || dossierById === void 0 || (_dossierById$klant = dossierById.klant) === null || _dossierById$klant === void 0 ? void 0 : _dossierById$klant.email2) || (dossierById === null || dossierById === void 0 || (_dossierById$klant2 = dossierById.klant) === null || _dossierById$klant2 === void 0 ? void 0 : _dossierById$klant2.email1) || '';
200
200
  const normalizedOriginalEmail = originalEmail.trim().toLowerCase();
201
201
  const normalizedCurrentEmail = (((_payload$customer = payload.customer) === null || _payload$customer === void 0 ? void 0 : _payload$customer.email) || '').trim().toLowerCase();
202
202
  if (normalizedCurrentEmail && normalizedCurrentEmail !== normalizedOriginalEmail) {
203
- const emailCheckResult = await checkEmailExists(payload.customer.email);
203
+ var _dossierById$klant3, _dossierById$klant4;
204
+ const currentCustomerId = (dossierById === null || dossierById === void 0 || (_dossierById$klant3 = dossierById.klant) === null || _dossierById$klant3 === void 0 ? void 0 : _dossierById$klant3.entityId) || (dossierById === null || dossierById === void 0 || (_dossierById$klant4 = dossierById.klant) === null || _dossierById$klant4 === void 0 ? void 0 : _dossierById$klant4.id) || (dossierById === null || dossierById === void 0 ? void 0 : dossierById.klant) || null;
205
+ const emailCheckResult = await checkEmailExists(payload.customer.email, {
206
+ excludeDossierId: existingDossierId,
207
+ excludeCustomerId: currentCustomerId
208
+ });
204
209
  if (emailCheckResult.status === 'success' && emailCheckResult.emailExists) {
205
210
  setPendingPayload(payload);
206
211
  setEmailConflictData(emailCheckResult);
@@ -162,12 +162,17 @@ const InternalQuotationPage = () => {
162
162
  }
163
163
  };
164
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) || '';
165
+ var _dossierById$klant, _dossierById$klant2, _payload$customer;
166
+ const originalEmail = (dossierById === null || dossierById === void 0 ? void 0 : dossierById.email2) || (dossierById === null || dossierById === void 0 ? void 0 : dossierById.email1) || (dossierById === null || dossierById === void 0 || (_dossierById$klant = dossierById.klant) === null || _dossierById$klant === void 0 ? void 0 : _dossierById$klant.email2) || (dossierById === null || dossierById === void 0 || (_dossierById$klant2 = dossierById.klant) === null || _dossierById$klant2 === void 0 ? void 0 : _dossierById$klant2.email1) || '';
167
167
  const normalizedOriginalEmail = originalEmail.trim().toLowerCase();
168
168
  const normalizedCurrentEmail = (((_payload$customer = payload.customer) === null || _payload$customer === void 0 ? void 0 : _payload$customer.email) || '').trim().toLowerCase();
169
169
  if (normalizedCurrentEmail && normalizedCurrentEmail !== normalizedOriginalEmail) {
170
- const emailCheckResult = await checkEmailExists(payload.customer.email);
170
+ var _dossierById$klant3, _dossierById$klant4;
171
+ const currentCustomerId = (dossierById === null || dossierById === void 0 || (_dossierById$klant3 = dossierById.klant) === null || _dossierById$klant3 === void 0 ? void 0 : _dossierById$klant3.entityId) || (dossierById === null || dossierById === void 0 || (_dossierById$klant4 = dossierById.klant) === null || _dossierById$klant4 === void 0 ? void 0 : _dossierById$klant4.id) || (dossierById === null || dossierById === void 0 ? void 0 : dossierById.klant) || null;
172
+ const emailCheckResult = await checkEmailExists(payload.customer.email, {
173
+ excludeDossierId: existingDossierId,
174
+ excludeCustomerId: currentCustomerId
175
+ });
171
176
  if (emailCheckResult.status === 'success' && emailCheckResult.emailExists) {
172
177
  setPendingPayload(payload);
173
178
  setEmailConflictData(emailCheckResult);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thm-p3-configurator",
3
- "version": "0.0.277",
3
+ "version": "0.0.279",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "EnoRm.",