@mychoice/mychoice-sdk-store 2.2.23 → 2.2.25

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.
Files changed (46) hide show
  1. package/dist/cjs/handlers/dataHandlers/QuoterPhoneDataHandler/QuoterPhoneDataHandler.d.ts +4 -0
  2. package/dist/cjs/handlers/dataHandlers/QuoterPhoneDataHandler/index.d.ts +1 -0
  3. package/dist/cjs/handlers/dataHandlers/QuoterPhoneDataHandler/interfaces.d.ts +4 -0
  4. package/dist/cjs/handlers/dataHandlers/index.d.ts +1 -0
  5. package/dist/cjs/index.js +486 -69
  6. package/dist/cjs/index.js.map +1 -1
  7. package/dist/cjs/states/reducers/states/formStates/FormCarState/DiscountState/actions.d.ts +2 -0
  8. package/dist/cjs/states/reducers/states/formStates/FormCarState/DiscountState/interfaces.d.ts +19 -0
  9. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverInsuranceState/actions.d.ts +5 -1
  10. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverInsuranceState/interfaces.d.ts +24 -0
  11. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverLicenceState/actions.d.ts +2 -0
  12. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverLicenceState/interfaces.d.ts +12 -0
  13. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverTicketState/actions.d.ts +1 -0
  14. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverTicketState/interfaces.d.ts +7 -0
  15. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/initialState.d.ts +1 -0
  16. package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/interfaces.d.ts +9 -0
  17. package/dist/cjs/states/reducers/states/formStates/FormCarState/VehicleState/actions.d.ts +1 -0
  18. package/dist/cjs/states/reducers/states/formStates/FormCarState/VehicleState/interfaces.d.ts +8 -1
  19. package/dist/cjs/states/reducers/states/formStates/FormHomeState/DiscountState/actions.d.ts +1 -0
  20. package/dist/cjs/states/reducers/states/formStates/FormHomeState/DiscountState/interfaces.d.ts +8 -0
  21. package/dist/cjs/states/reducers/states/formStates/FormLifeState/ApplicantState/actions.d.ts +1 -0
  22. package/dist/cjs/states/reducers/states/formStates/FormLifeState/ApplicantState/interfaces.d.ts +8 -0
  23. package/dist/esm/handlers/dataHandlers/QuoterPhoneDataHandler/QuoterPhoneDataHandler.d.ts +4 -0
  24. package/dist/esm/handlers/dataHandlers/QuoterPhoneDataHandler/index.d.ts +1 -0
  25. package/dist/esm/handlers/dataHandlers/QuoterPhoneDataHandler/interfaces.d.ts +4 -0
  26. package/dist/esm/handlers/dataHandlers/index.d.ts +1 -0
  27. package/dist/esm/index.js +485 -71
  28. package/dist/esm/index.js.map +1 -1
  29. package/dist/esm/states/reducers/states/formStates/FormCarState/DiscountState/actions.d.ts +2 -0
  30. package/dist/esm/states/reducers/states/formStates/FormCarState/DiscountState/interfaces.d.ts +19 -0
  31. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverInsuranceState/actions.d.ts +5 -1
  32. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverInsuranceState/interfaces.d.ts +24 -0
  33. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverLicenceState/actions.d.ts +2 -0
  34. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverLicenceState/interfaces.d.ts +12 -0
  35. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverTicketState/actions.d.ts +1 -0
  36. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverTicketState/interfaces.d.ts +7 -0
  37. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/initialState.d.ts +1 -0
  38. package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/interfaces.d.ts +9 -0
  39. package/dist/esm/states/reducers/states/formStates/FormCarState/VehicleState/actions.d.ts +1 -0
  40. package/dist/esm/states/reducers/states/formStates/FormCarState/VehicleState/interfaces.d.ts +8 -1
  41. package/dist/esm/states/reducers/states/formStates/FormHomeState/DiscountState/actions.d.ts +1 -0
  42. package/dist/esm/states/reducers/states/formStates/FormHomeState/DiscountState/interfaces.d.ts +8 -0
  43. package/dist/esm/states/reducers/states/formStates/FormLifeState/ApplicantState/actions.d.ts +1 -0
  44. package/dist/esm/states/reducers/states/formStates/FormLifeState/ApplicantState/interfaces.d.ts +8 -0
  45. package/dist/index.d.ts +118 -4
  46. package/package.json +3 -3
package/dist/cjs/index.js CHANGED
@@ -474,7 +474,7 @@ const vehicleItemInitialState = {
474
474
  winterTires: true,
475
475
  parkingLocation: 'garage',
476
476
  primaryUse: mychoiceSdkComponents.VehiclePrimaryUseTypes.Personal,
477
- distanceDaily: 0,
477
+ distanceDaily: undefined,
478
478
  distanceBusiness: 0,
479
479
  distanceYearly: 0,
480
480
  comprehensive: { ...vehicleComprehensiveInitialState },
@@ -527,6 +527,7 @@ exports.StoreFormCarVehicleActionTypes = void 0;
527
527
  StoreFormCarVehicleActionTypes["FormCarParkingLocationSelect"] = "FormCarParkingLocationSelect";
528
528
  StoreFormCarVehicleActionTypes["FormCarDailyDistanceSelect"] = "FormCarDailyDistanceSelect";
529
529
  StoreFormCarVehicleActionTypes["FormCarBusinessDistanceSelect"] = "FormCarBusinessDistanceSelect";
530
+ StoreFormCarVehicleActionTypes["FormCarBusinessUsePercentSelect"] = "FormCarBusinessUsePercentSelect";
530
531
  StoreFormCarVehicleActionTypes["FormCarYearlyDistanceSelect"] = "FormCarYearlyDistanceSelect";
531
532
  StoreFormCarVehicleActionTypes["FormCarComprehensiveCoverageSelect"] = "FormCarComprehensiveCoverageSelect";
532
533
  StoreFormCarVehicleActionTypes["FormCarComprehensiveDeductibleSelect"] = "FormCarComprehensiveDeductibleSelect";
@@ -690,6 +691,8 @@ const formCarVehicleStateReducer = (state = { ...carFormVehicleInitialState }, a
690
691
  return setLocalVehicles(action.localIndex, setItemProperty(state, 'distanceDaily', action.payload.distanceDaily));
691
692
  case exports.StoreFormCarVehicleActionTypes.FormCarBusinessDistanceSelect:
692
693
  return setLocalVehicles(action.localIndex, setItemProperty(state, 'distanceBusiness', action.payload.distanceBusiness));
694
+ case exports.StoreFormCarVehicleActionTypes.FormCarBusinessUsePercentSelect:
695
+ return setLocalVehicles(action.localIndex, setItemProperty(state, 'businessUsePercent', action.payload.businessUsePercent));
693
696
  case exports.StoreFormCarVehicleActionTypes.FormCarYearlyDistanceSelect:
694
697
  return setLocalVehicles(action.localIndex, setItemProperty(state, 'distanceYearly', action.payload.distanceYearly));
695
698
  case exports.StoreFormCarVehicleActionTypes.FormCarComprehensiveCoverageSelect:
@@ -774,6 +777,10 @@ exports.StoreFormCarDriverInsuranceActionTypes = void 0;
774
777
  StoreFormCarDriverInsuranceActionTypes["FormCarDriverListedMonthSelect"] = "FormCarDriverListedMonthSelect";
775
778
  StoreFormCarDriverInsuranceActionTypes["FormCarDriverInsuredSelect"] = "FormCarDriverInsuredSelect";
776
779
  StoreFormCarDriverInsuranceActionTypes["FormCarDriverInsuredDateSelect"] = "FormCarDriverInsuredDateSelect";
780
+ StoreFormCarDriverInsuranceActionTypes["FormCarDriverNotCurrentlyInsuredSelect"] = "FormCarDriverNotCurrentlyInsuredSelect";
781
+ StoreFormCarDriverInsuranceActionTypes["FormCarDriverLastPolicyEndYearSelect"] = "FormCarDriverLastPolicyEndYearSelect";
782
+ StoreFormCarDriverInsuranceActionTypes["FormCarDriverLastPolicyEndMonthSelect"] = "FormCarDriverLastPolicyEndMonthSelect";
783
+ StoreFormCarDriverInsuranceActionTypes["FormCarDriverLastPolicyCancelReasonSelect"] = "FormCarDriverLastPolicyCancelReasonSelect";
777
784
  })(exports.StoreFormCarDriverInsuranceActionTypes || (exports.StoreFormCarDriverInsuranceActionTypes = {}));
778
785
 
779
786
  exports.StoreFormCarDriverLicenceActionTypes = void 0;
@@ -788,6 +795,8 @@ exports.StoreFormCarDriverLicenceActionTypes = void 0;
788
795
  StoreFormCarDriverLicenceActionTypes["FormCarDriverG1LicenceMaxSelect"] = "FormCarDriverG1LicenceMaxSelect";
789
796
  StoreFormCarDriverLicenceActionTypes["FormCarDriverTrainingSelect"] = "FormCarDriverTrainingSelect";
790
797
  StoreFormCarDriverLicenceActionTypes["FormCarDriverPreviousLicenceSelect"] = "FormCarDriverPreviousLicenceSelect";
798
+ StoreFormCarDriverLicenceActionTypes["FormCarDriverReceivedG2Select"] = "FormCarDriverReceivedG2Select";
799
+ StoreFormCarDriverLicenceActionTypes["FormCarDriverReceivedGSelect"] = "FormCarDriverReceivedGSelect";
791
800
  StoreFormCarDriverLicenceActionTypes["FormCarDriverLicenceYearSelect"] = "FormCarDriverLicenceYearSelect";
792
801
  StoreFormCarDriverLicenceActionTypes["FormCarDriverLicenceMonthSelect"] = "FormCarDriverLicenceMonthSelect";
793
802
  })(exports.StoreFormCarDriverLicenceActionTypes || (exports.StoreFormCarDriverLicenceActionTypes = {}));
@@ -810,6 +819,7 @@ exports.StoreFormCarDriverTicketActionTypes = void 0;
810
819
  StoreFormCarDriverTicketActionTypes["FormCarDriverTrafficTicketReasonSelect"] = "FormCarDriverTrafficTicketReasonSelect";
811
820
  StoreFormCarDriverTicketActionTypes["FormCarDriverTrafficTicketYearSelect"] = "FormCarDriverTrafficTicketYearSelect";
812
821
  StoreFormCarDriverTicketActionTypes["FormCarDriverTrafficTicketMonthSelect"] = "FormCarDriverTrafficTicketMonthSelect";
822
+ StoreFormCarDriverTicketActionTypes["FormCarDriverTrafficTicketSpeedSelect"] = "FormCarDriverTrafficTicketSpeedSelect";
813
823
  StoreFormCarDriverTicketActionTypes["FormCarDriverTrafficTicketAdd"] = "FormCarDriverTrafficTicketAdd";
814
824
  StoreFormCarDriverTicketActionTypes["FormCarDriverTrafficTicketDelete"] = "FormCarDriverTrafficTicketDelete";
815
825
  })(exports.StoreFormCarDriverTicketActionTypes || (exports.StoreFormCarDriverTicketActionTypes = {}));
@@ -909,6 +919,10 @@ const driverItemInitialState = {
909
919
  listedMonth: '',
910
920
  insured: true,
911
921
  insuredDate: '',
922
+ notCurrentlyInsured: false,
923
+ lastPolicyEndYear: '',
924
+ lastPolicyEndMonth: '',
925
+ lastPolicyCancelReason: '',
912
926
  insuranceCancellation: false,
913
927
  insuranceCancellationList: [{ ...driverCancellationItemInitialState }],
914
928
  licenceSuspension: false,
@@ -1069,37 +1083,32 @@ const setDriverLicenceInfoDate = (state, type, payload) => {
1069
1083
  const { licenceType } = newState.items[newState.activeIndex].licenceInfo;
1070
1084
  const { birthDay } = newState.items[newState.activeIndex];
1071
1085
  const currentDate = mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd');
1072
- if (!(licenceType === mychoiceSdkComponents.DriverLicenceTypes.G && (currentLicenceType === mychoiceSdkComponents.DriverLicenceTypes.G2))) {
1073
- switch (type) {
1074
- case mychoiceSdkComponents.DateTypes.Year:
1075
- newState.items[newState.activeIndex].licenceInfo[`${licenceType}LicenceYear`] = value;
1076
- break;
1077
- case mychoiceSdkComponents.DateTypes.Month:
1078
- newState.items[newState.activeIndex].licenceInfo[`${licenceType}LicenceMonth`] = value;
1079
- break;
1080
- }
1081
- if (licenceType === mychoiceSdkComponents.DriverLicenceTypes.G2) {
1082
- const { minMaxDates } = newState.items[newState.activeIndex];
1083
- if (minMaxDates) {
1084
- minMaxDates.gTwoMax = currentDate;
1085
- }
1086
- }
1086
+ // When the picker explicitly targets a different slot (e.g. G1 driver entering G2/G date),
1087
+ // write to that slot rather than the store's current licenceType.
1088
+ const targetSlot = currentLicenceType && currentLicenceType !== licenceType
1089
+ ? currentLicenceType
1090
+ : licenceType;
1091
+ switch (type) {
1092
+ case mychoiceSdkComponents.DateTypes.Year:
1093
+ newState.items[newState.activeIndex].licenceInfo[`${targetSlot}LicenceYear`] = value;
1094
+ break;
1095
+ case mychoiceSdkComponents.DateTypes.Month:
1096
+ newState.items[newState.activeIndex].licenceInfo[`${targetSlot}LicenceMonth`] = value;
1097
+ break;
1087
1098
  }
1088
- else {
1089
- switch (type) {
1090
- case mychoiceSdkComponents.DateTypes.Year:
1091
- newState.items[newState.activeIndex].licenceInfo.g2LicenceYear = value;
1092
- break;
1093
- case mychoiceSdkComponents.DateTypes.Month:
1094
- newState.items[newState.activeIndex].licenceInfo.g2LicenceMonth = value;
1095
- break;
1099
+ if (targetSlot === mychoiceSdkComponents.DriverLicenceTypes.G2) {
1100
+ const { minMaxDates } = newState.items[newState.activeIndex];
1101
+ if (minMaxDates) {
1102
+ minMaxDates.gTwoMax = currentDate;
1096
1103
  }
1104
+ }
1105
+ // Non-Ontario G driver entering G2 date: recompute the G min date (existing behaviour).
1106
+ if (licenceType === mychoiceSdkComponents.DriverLicenceTypes.G && targetSlot === mychoiceSdkComponents.DriverLicenceTypes.G2) {
1097
1107
  const { g2LicenceMonth, g2LicenceYear } = newState.items[newState.activeIndex].licenceInfo;
1098
1108
  if (g2LicenceMonth && g2LicenceYear && config) {
1099
1109
  const g2Date = mychoiceSdkComponents.addDaysToDate(`${g2LicenceYear}-${g2LicenceMonth}-01`, birthDay ? +birthDay + 1 : 1);
1100
1110
  const gMinDefaultDate = mychoiceSdkComponents.getLicenceMinDate(licenceType, g2Date, config);
1101
- const gMinDate = mychoiceSdkComponents.compareDates(gMinDefaultDate, currentDate) > 0
1102
- ? currentDate : gMinDefaultDate;
1111
+ const gMinDate = mychoiceSdkComponents.compareDates(gMinDefaultDate, currentDate) > 0 ? currentDate : gMinDefaultDate;
1103
1112
  const { minMaxDates } = newState.items[newState.activeIndex];
1104
1113
  if (minMaxDates) {
1105
1114
  minMaxDates.gMin = gMinDate;
@@ -1353,6 +1362,14 @@ const formCarDriverInsuranceStateReducer = (state = { ...carFormDriverInitialSta
1353
1362
  return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'insured', action.payload.insured));
1354
1363
  case exports.StoreFormCarDriverInsuranceActionTypes.FormCarDriverInsuredDateSelect:
1355
1364
  return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'insuredDate', action.payload.insuredDate));
1365
+ case exports.StoreFormCarDriverInsuranceActionTypes.FormCarDriverNotCurrentlyInsuredSelect:
1366
+ return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'notCurrentlyInsured', action.payload.notCurrentlyInsured));
1367
+ case exports.StoreFormCarDriverInsuranceActionTypes.FormCarDriverLastPolicyEndYearSelect:
1368
+ return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'lastPolicyEndYear', action.payload.lastPolicyEndYear));
1369
+ case exports.StoreFormCarDriverInsuranceActionTypes.FormCarDriverLastPolicyEndMonthSelect:
1370
+ return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'lastPolicyEndMonth', action.payload.lastPolicyEndMonth));
1371
+ case exports.StoreFormCarDriverInsuranceActionTypes.FormCarDriverLastPolicyCancelReasonSelect:
1372
+ return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'lastPolicyCancelReason', action.payload.lastPolicyCancelReason));
1356
1373
  default:
1357
1374
  return state;
1358
1375
  }
@@ -1372,6 +1389,10 @@ const formCarDriverLicenceStateReducer = (state = { ...carFormDriverInitialState
1372
1389
  return setLocalDrivers(action?.localIndex, setDriverLicenceInfo(state, 'passedDriverTraining', action.payload.training));
1373
1390
  case exports.StoreFormCarDriverLicenceActionTypes.FormCarDriverPreviousLicenceSelect:
1374
1391
  return setLocalDrivers(action?.localIndex, setDriverLicenceInfo(state, 'previousLicence', action.payload.previousLicence));
1392
+ case exports.StoreFormCarDriverLicenceActionTypes.FormCarDriverReceivedG2Select:
1393
+ return setLocalDrivers(action?.localIndex, setDriverLicenceInfo(state, 'receivedG2', action.payload.receivedG2));
1394
+ case exports.StoreFormCarDriverLicenceActionTypes.FormCarDriverReceivedGSelect:
1395
+ return setLocalDrivers(action?.localIndex, setDriverLicenceInfo(state, 'receivedG', action.payload.receivedG));
1375
1396
  case exports.StoreFormCarDriverLicenceActionTypes.FormCarDriverGLicenceMinSelect:
1376
1397
  return setLocalDrivers(action?.localIndex, setDriverLicenceMinMaxDates(state, 'gMin', action.payload.gMin));
1377
1398
  case exports.StoreFormCarDriverLicenceActionTypes.FormCarDriverG1LicenceMinSelect:
@@ -1466,6 +1487,8 @@ const formCarDriverTicketStateReducer = (state = { ...carFormDriverInitialState
1466
1487
  return setLocalDrivers(action?.localIndex, setDriverListItemProperty(state, 'ticketList', action.payload.index, 'ticketYear', action.payload.ticketYear));
1467
1488
  case exports.StoreFormCarDriverTicketActionTypes.FormCarDriverTrafficTicketMonthSelect:
1468
1489
  return setLocalDrivers(action?.localIndex, setDriverListItemProperty(state, 'ticketList', action.payload.index, 'ticketMonth', action.payload.ticketMonth));
1490
+ case exports.StoreFormCarDriverTicketActionTypes.FormCarDriverTrafficTicketSpeedSelect:
1491
+ return setLocalDrivers(action?.localIndex, setDriverListItemProperty(state, 'ticketList', action.payload.index, 'speed', action.payload.speed));
1469
1492
  default:
1470
1493
  return state;
1471
1494
  }
@@ -1859,6 +1882,7 @@ const discountQuoterInfoInitialState = {
1859
1882
  firstName: '',
1860
1883
  lastName: '',
1861
1884
  phone: '',
1885
+ phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Initial,
1862
1886
  recalculate: false,
1863
1887
  utmSource: '',
1864
1888
  utmCampaign: '',
@@ -1889,6 +1913,7 @@ const formCarDiscountStateInitialState = {
1889
1913
  priority: mychoiceSdkComponents.DriverPriorityTypes.Prn,
1890
1914
  vehicleIndex: 0,
1891
1915
  }],
1916
+ occVehlinks: [],
1892
1917
  inValidation: false,
1893
1918
  isValid: false,
1894
1919
  };
@@ -1906,10 +1931,12 @@ exports.StoreFormCarDiscountActionTypes = void 0;
1906
1931
  StoreFormCarDiscountActionTypes["FormCarDiscountQuoterFirstNameSet"] = "FormCarDiscountQuoterFirstNameSet";
1907
1932
  StoreFormCarDiscountActionTypes["FormCarDiscountQuoterLastNameSet"] = "FormCarDiscountQuoterLastNameSet";
1908
1933
  StoreFormCarDiscountActionTypes["FormCarDiscountQuoterPhoneSet"] = "FormCarDiscountQuoterPhoneSet";
1934
+ StoreFormCarDiscountActionTypes["FormCarDiscountQuoterPhoneStatusSet"] = "FormCarDiscountQuoterPhoneStatusSet";
1909
1935
  StoreFormCarDiscountActionTypes["FormCarDiscountVehlinkAdd"] = "FormCarDiscountVehlinkAdd";
1910
1936
  StoreFormCarDiscountActionTypes["FormCarDiscountVehlinkSelect"] = "FormCarDiscountVehlinkSelect";
1911
1937
  StoreFormCarDiscountActionTypes["FormCarDiscountVehlinkByVehicleDelete"] = "FormCarDiscountVehlinkByVehicleDelete";
1912
1938
  StoreFormCarDiscountActionTypes["FormCarDiscountVehlinkByDriverDelete"] = "FormCarDiscountVehlinkByDriverDelete";
1939
+ StoreFormCarDiscountActionTypes["FormCarDiscountOccVehlinkSelect"] = "FormCarDiscountOccVehlinkSelect";
1913
1940
  StoreFormCarDiscountActionTypes["FormCarDiscountQuoterEmailStatusSet"] = "FormCarDiscountQuoterEmailStatusSet";
1914
1941
  StoreFormCarDiscountActionTypes["FormCarDiscountValidate"] = "FormCarDiscountValidate";
1915
1942
  StoreFormCarDiscountActionTypes["FormCarDiscountValidateSet"] = "FormCarDiscountValidateSet";
@@ -2027,6 +2054,14 @@ const formCarDiscountStateReducer = (state = { ...formCarDiscountStateInitialSta
2027
2054
  return setLocalDiscounts$1(action.localIndex, deleteVehlinkByDriver(state, action.payload.driverIndex));
2028
2055
  case exports.StoreFormCarDiscountActionTypes.FormCarDiscountVehlinkSelect:
2029
2056
  return setLocalDiscounts$1(action.localIndex, selectDriverForVehicle(state, action.payload.driverIndex, action.payload.vehicleIndex));
2057
+ case exports.StoreFormCarDiscountActionTypes.FormCarDiscountOccVehlinkSelect: {
2058
+ const { driverIndex, vehicleIndex } = action.payload;
2059
+ const filtered = state.occVehlinks.filter((l) => l.driverIndex !== driverIndex);
2060
+ const updated = vehicleIndex >= 0
2061
+ ? [...filtered, { driverIndex, vehicleIndex }]
2062
+ : filtered;
2063
+ return setLocalDiscounts$1(action.localIndex, { ...state, occVehlinks: updated });
2064
+ }
2030
2065
  case exports.StoreFormCarDiscountActionTypes.FormCarDiscountMultiplePoliciesSelect:
2031
2066
  return setLocalDiscounts$1(action.localIndex, setDiscountStateProperty(state, 'multiplePoliciesDiscount', action.payload.multiplePoliciesDiscount));
2032
2067
  case exports.StoreFormCarDiscountActionTypes.FormCarDiscountCaaMemberSelect:
@@ -2047,6 +2082,10 @@ const formCarDiscountStateReducer = (state = { ...formCarDiscountStateInitialSta
2047
2082
  return setLocalDiscounts$1(action.localIndex, setDiscountQuoterProperty(state, 'lastName', action.payload.lastName));
2048
2083
  case exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterPhoneSet:
2049
2084
  return setLocalDiscounts$1(action.localIndex, setDiscountQuoterProperty(state, 'phone', action.payload.phone));
2085
+ case exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterPhoneStatusSet: {
2086
+ const phoneState = setDiscountQuoterProperty(state, 'phone', action.payload.phone);
2087
+ return setLocalDiscounts$1(action.localIndex, setDiscountQuoterProperty(phoneState, 'phoneStatus', action.payload.phoneStatus));
2088
+ }
2050
2089
  case exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterUtmSourceSet:
2051
2090
  return setLocalDiscounts$1(action.localIndex, setDiscountQuoterProperty(state, 'utmSource', action.payload.utmSource));
2052
2091
  case exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterUtmCampaignSet:
@@ -2861,6 +2900,7 @@ const formHomeDiscountStateInitialState = {
2861
2900
  firstName: '',
2862
2901
  lastName: '',
2863
2902
  phone: '',
2903
+ phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Initial,
2864
2904
  recalculate: false,
2865
2905
  utmCampaign: '',
2866
2906
  utmSource: '',
@@ -2896,6 +2936,7 @@ exports.StoreFormHomeDiscountActionTypes = void 0;
2896
2936
  StoreFormHomeDiscountActionTypes["FormHomeQuoterFirstNameSet"] = "FormHomeQuoterFirstNameSet";
2897
2937
  StoreFormHomeDiscountActionTypes["FormHomeQuoterLastNameSet"] = "FormHomeQuoterLastNameSet";
2898
2938
  StoreFormHomeDiscountActionTypes["FormHomeQuoterPhoneSet"] = "FormHomeQuoterPhoneSet";
2939
+ StoreFormHomeDiscountActionTypes["FormHomeQuoterPhoneStatusSet"] = "FormHomeQuoterPhoneStatusSet";
2899
2940
  StoreFormHomeDiscountActionTypes["FormHomeUtmCampaignSet"] = "FormHomeUtmCampaignSet";
2900
2941
  StoreFormHomeDiscountActionTypes["FormHomeUtmSourceSet"] = "FormHomeUtmSourceSet";
2901
2942
  StoreFormHomeDiscountActionTypes["FormHomeUtmProducerSet"] = "FormHomeUtmProducerSet";
@@ -2956,6 +2997,11 @@ const formHomeDiscountStateReducer = (state = { ...formHomeDiscountStateInitialS
2956
2997
  return setLocalDiscounts(action.localIndex, setStateProperty(state, 'lastName', action.payload.lastName, 'quoterInfo'));
2957
2998
  case exports.StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneSet:
2958
2999
  return setLocalDiscounts(action.localIndex, setStateProperty(state, 'phone', action.payload.phone, 'quoterInfo'));
3000
+ case exports.StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneStatusSet:
3001
+ return setLocalDiscounts(action.localIndex, {
3002
+ ...state,
3003
+ quoterInfo: { ...state.quoterInfo, ...{ phone: action.payload.phone, phoneStatus: action.payload.phoneStatus } },
3004
+ });
2959
3005
  case exports.StoreFormHomeDiscountActionTypes.FormHomeUtmSourceSet:
2960
3006
  return setLocalDiscounts(action.localIndex, setStateProperty(state, 'utmSource', action.payload.utmSource, 'quoterInfo'));
2961
3007
  case exports.StoreFormHomeDiscountActionTypes.FormHomeUtmCampaignSet:
@@ -3112,6 +3158,7 @@ const lifeFormApplicantInitialState = {
3112
3158
  firstName: '',
3113
3159
  lastName: '',
3114
3160
  phone: '',
3161
+ phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Initial,
3115
3162
  recalculate: false,
3116
3163
  utmCampaign: '',
3117
3164
  utmSource: '',
@@ -3147,6 +3194,7 @@ exports.StoreFormLifeApplicantActionTypes = void 0;
3147
3194
  StoreFormLifeApplicantActionTypes["FormLifeQuoterFirstNameSet"] = "FormLifeQuoterFirstNameSet";
3148
3195
  StoreFormLifeApplicantActionTypes["FormLifeQuoterLastNameSet"] = "FormLifeQuoterLastNameSet";
3149
3196
  StoreFormLifeApplicantActionTypes["FormLifeQuoterPhoneSet"] = "FormLifeQuoterPhoneSet";
3197
+ StoreFormLifeApplicantActionTypes["FormLifeQuoterPhoneStatusSet"] = "FormLifeQuoterPhoneStatusSet";
3150
3198
  StoreFormLifeApplicantActionTypes["FormLifeUtmCampaignSet"] = "FormLifeUtmCampaignSet";
3151
3199
  StoreFormLifeApplicantActionTypes["FormLifeUtmSourceSet"] = "FormLifeUtmSourceSet";
3152
3200
  StoreFormLifeApplicantActionTypes["FormLifeUtmProducerSet"] = "FormLifeUtmProducerSet";
@@ -3183,6 +3231,11 @@ const formLifeApplicantStateReducer = (state = { ...lifeFormApplicantInitialStat
3183
3231
  return setLocalApplicant(action?.localIndex, setStateProperty(state, 'lastName', action.payload.lastName, 'quoterInfo'));
3184
3232
  case exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneSet:
3185
3233
  return setLocalApplicant(action?.localIndex, setStateProperty(state, 'phone', action.payload.phone, 'quoterInfo'));
3234
+ case exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneStatusSet:
3235
+ return setLocalApplicant(action?.localIndex, {
3236
+ ...state,
3237
+ quoterInfo: { ...state.quoterInfo, ...{ phone: action.payload.phone, phoneStatus: action.payload.phoneStatus } },
3238
+ });
3186
3239
  case exports.StoreFormLifeApplicantActionTypes.FormLifeUtmSourceSet:
3187
3240
  return setLocalApplicant(action?.localIndex, setStateProperty(state, 'utmSource', action.payload.utmSource, 'quoterInfo'));
3188
3241
  case exports.StoreFormLifeApplicantActionTypes.FormLifeUtmCampaignSet:
@@ -5060,6 +5113,190 @@ const useHandlerLifeQuoterEmail = () => {
5060
5113
  };
5061
5114
  };
5062
5115
 
5116
+ const useHandlerCarQuoterPhone = () => {
5117
+ const [requestState, setRequestState] = react.useReducer(dataHandlerReducer, {
5118
+ ...initialHandlerRequestState,
5119
+ });
5120
+ const { dispatchDiscountState } = useStoreFormCarDiscount();
5121
+ const { cancelToken } = useCancelToken();
5122
+ const { status, successMessage, responseData, errorMessage, isFirstRequest, responseError, } = requestState;
5123
+ const validatePhone = async (phone) => {
5124
+ dispatchDiscountState({
5125
+ type: exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterPhoneStatusSet,
5126
+ payload: {
5127
+ phone,
5128
+ phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Loading,
5129
+ },
5130
+ });
5131
+ if (phone) {
5132
+ try {
5133
+ const response = await httpRequest({
5134
+ url: `${mychoiceSdkComponents.API_AUTH.GET_PHONE_VALIDATION}?phone=${encodeURIComponent(phone)}`,
5135
+ method: mychoiceSdkComponents.RequestTypes.Get,
5136
+ withoutToken: true,
5137
+ cancelToken,
5138
+ });
5139
+ if (response.data.valid) {
5140
+ dispatchDiscountState({
5141
+ type: exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterPhoneStatusSet,
5142
+ payload: {
5143
+ phone,
5144
+ phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Approved,
5145
+ },
5146
+ });
5147
+ }
5148
+ else {
5149
+ dispatchDiscountState({
5150
+ type: exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterPhoneStatusSet,
5151
+ payload: {
5152
+ phone,
5153
+ phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined,
5154
+ },
5155
+ });
5156
+ setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid phone number.' });
5157
+ }
5158
+ }
5159
+ catch (error) {
5160
+ dispatchDiscountState({
5161
+ type: exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterPhoneStatusSet,
5162
+ payload: {
5163
+ phone,
5164
+ phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined,
5165
+ },
5166
+ });
5167
+ setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid phone number.' });
5168
+ }
5169
+ }
5170
+ else {
5171
+ dispatchDiscountState({
5172
+ type: exports.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterPhoneStatusSet,
5173
+ payload: {
5174
+ phone,
5175
+ phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined,
5176
+ },
5177
+ });
5178
+ setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'This field may not be blank.' });
5179
+ }
5180
+ };
5181
+ return {
5182
+ status,
5183
+ validatePhone,
5184
+ successMessage,
5185
+ responseData,
5186
+ errorMessage,
5187
+ isFirstRequest,
5188
+ responseError,
5189
+ };
5190
+ };
5191
+ const useHandlerHomeQuoterPhone = () => {
5192
+ const [requestState, setRequestState] = react.useReducer(dataHandlerReducer, {
5193
+ ...initialHandlerRequestState,
5194
+ });
5195
+ const { dispatchDiscountState } = useStoreFormHomeDiscount();
5196
+ const { cancelToken } = useCancelToken();
5197
+ const { status, successMessage, responseData, errorMessage, isFirstRequest, responseError, } = requestState;
5198
+ const validatePhone = async (phone) => {
5199
+ dispatchDiscountState({
5200
+ type: exports.StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneStatusSet,
5201
+ payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Loading },
5202
+ });
5203
+ if (phone) {
5204
+ try {
5205
+ const response = await httpRequest({
5206
+ url: `${mychoiceSdkComponents.API_AUTH.GET_PHONE_VALIDATION}?phone=${encodeURIComponent(phone)}`,
5207
+ method: mychoiceSdkComponents.RequestTypes.Get,
5208
+ withoutToken: true,
5209
+ cancelToken,
5210
+ });
5211
+ if (response.data.valid) {
5212
+ dispatchDiscountState({
5213
+ type: exports.StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneStatusSet,
5214
+ payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Approved },
5215
+ });
5216
+ }
5217
+ else {
5218
+ dispatchDiscountState({
5219
+ type: exports.StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneStatusSet,
5220
+ payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined },
5221
+ });
5222
+ setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid phone number.' });
5223
+ }
5224
+ }
5225
+ catch (error) {
5226
+ dispatchDiscountState({
5227
+ type: exports.StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneStatusSet,
5228
+ payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined },
5229
+ });
5230
+ setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid phone number.' });
5231
+ }
5232
+ }
5233
+ else {
5234
+ dispatchDiscountState({
5235
+ type: exports.StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneStatusSet,
5236
+ payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined },
5237
+ });
5238
+ setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'This field may not be blank.' });
5239
+ }
5240
+ };
5241
+ return {
5242
+ status, validatePhone, successMessage, responseData, errorMessage, isFirstRequest, responseError,
5243
+ };
5244
+ };
5245
+ const useHandlerLifeQuoterPhone = () => {
5246
+ const [requestState, setRequestState] = react.useReducer(dataHandlerReducer, {
5247
+ ...initialHandlerRequestState,
5248
+ });
5249
+ const { dispatchApplicantState } = useStoreFormLifeApplicant();
5250
+ const { cancelToken } = useCancelToken();
5251
+ const { status, successMessage, responseData, errorMessage, isFirstRequest, responseError, } = requestState;
5252
+ const validatePhone = async (phone) => {
5253
+ dispatchApplicantState({
5254
+ type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneStatusSet,
5255
+ payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Loading },
5256
+ });
5257
+ if (phone) {
5258
+ try {
5259
+ const response = await httpRequest({
5260
+ url: `${mychoiceSdkComponents.API_AUTH.GET_PHONE_VALIDATION}?phone=${encodeURIComponent(phone)}`,
5261
+ method: mychoiceSdkComponents.RequestTypes.Get,
5262
+ withoutToken: true,
5263
+ cancelToken,
5264
+ });
5265
+ if (response.data.valid) {
5266
+ dispatchApplicantState({
5267
+ type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneStatusSet,
5268
+ payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Approved },
5269
+ });
5270
+ }
5271
+ else {
5272
+ dispatchApplicantState({
5273
+ type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneStatusSet,
5274
+ payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined },
5275
+ });
5276
+ setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid phone number.' });
5277
+ }
5278
+ }
5279
+ catch (error) {
5280
+ dispatchApplicantState({
5281
+ type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneStatusSet,
5282
+ payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined },
5283
+ });
5284
+ setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'Enter a valid phone number.' });
5285
+ }
5286
+ }
5287
+ else {
5288
+ dispatchApplicantState({
5289
+ type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneStatusSet,
5290
+ payload: { phone, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Declined },
5291
+ });
5292
+ setRequestState({ type: DataHandlerActionTypes.SetError, payload: 'This field may not be blank.' });
5293
+ }
5294
+ };
5295
+ return {
5296
+ status, validatePhone, successMessage, responseData, errorMessage, isFirstRequest, responseError,
5297
+ };
5298
+ };
5299
+
5063
5300
  const CarQuoteDataHandler = () => {
5064
5301
  const { configState } = useStoreFormCarConfig();
5065
5302
  const { vehicleState } = useStoreFormCarVehicle();
@@ -5157,9 +5394,6 @@ const CarQuoteDataHandler = () => {
5157
5394
  if (driver.applicantRelationship === '') {
5158
5395
  delete driver.applicantRelationship;
5159
5396
  }
5160
- if (driver.gender === mychoiceSdkComponents.GenderTypes.Other) {
5161
- driver.gender = mychoiceSdkComponents.GenderTypes.Male;
5162
- }
5163
5397
  // ==================================
5164
5398
  // thebig additional properties
5165
5399
  if (appConfigState.appType === mychoiceSdkComponents.AppTypes.TheBig) {
@@ -5211,9 +5445,20 @@ const CarQuoteDataHandler = () => {
5211
5445
  delete driver.insuredYear;
5212
5446
  delete driver.insuredDate;
5213
5447
  }
5448
+ // "Not currently insured": build the open-ended lapse incident.
5449
+ // IncidentDate uses the selected month/year with the day defaulted to the 1st (History 1-4).
5450
+ if (driver.notCurrentlyInsured && driver.lastPolicyEndYear && driver.lastPolicyEndMonth) {
5451
+ driver.lastPolicyEndDate = addDayToDate(`${driver.lastPolicyEndYear}-${driver.lastPolicyEndMonth}`, 1);
5452
+ }
5453
+ else {
5454
+ driver.notCurrentlyInsured = false;
5455
+ delete driver.lastPolicyEndDate;
5456
+ delete driver.lastPolicyCancelReason;
5457
+ }
5458
+ delete driver.lastPolicyEndYear;
5459
+ delete driver.lastPolicyEndMonth;
5214
5460
  const defaultMinDate = driver.dateOfBirth && driver.licenceInfo.firstLicenceAge
5215
- ? mychoiceSdkComponents.addYearsToDate(driver.dateOfBirth, +driver.licenceInfo.firstLicenceAge)
5216
- : '';
5461
+ ? mychoiceSdkComponents.addYearsToDate(driver.dateOfBirth, +driver.licenceInfo.firstLicenceAge) : '';
5217
5462
  const isOnlyG = mychoiceSdkComponents.compareDates(defaultMinDate, configState.minDates.g.specialDate) < 0;
5218
5463
  // licence
5219
5464
  const deleteLicenceDates = () => {
@@ -5224,8 +5469,73 @@ const CarQuoteDataHandler = () => {
5224
5469
  delete driver.licenceInfo.g2LicenceYear;
5225
5470
  delete driver.licenceInfo.g2LicenceMonth;
5226
5471
  };
5227
- const { g1LicenceMonth, g1LicenceYear, g2LicenceMonth, g2LicenceYear, gLicenceYear, gLicenceMonth } = licenceInfo;
5228
- if (isOnlyG) {
5472
+ const { g1LicenceMonth, g1LicenceYear, g2LicenceMonth, g2LicenceYear, gLicenceYear, gLicenceMonth, } = licenceInfo;
5473
+ const isOntarioMyChoiceLicence = requestBody.provinceCode === 'ON' && mychoiceSdkComponents.isMyChoiceLike(appConfigState.appType);
5474
+ if (isOntarioMyChoiceLicence) {
5475
+ // Ontario new flow: licenceType = first class received (Q2).
5476
+ // receivedG2/receivedG flags determine the full progression.
5477
+ // Q1 date is stored in the slot matching licenceType.
5478
+ const { receivedG2, receivedG } = driver.licenceInfo;
5479
+ const firstClass = driver.licenceInfo.licenceType;
5480
+ // isOnlyG must use the actual Q1 date the user entered, not DOB+firstLicenceAge.
5481
+ // DOB+16 can predate 1994 for older drivers (e.g. born 1966 → 1982), which falsely
5482
+ // triggers the G-Full path even when the user's actual first licence is much later.
5483
+ const getOntarioQ1Slot = () => {
5484
+ if (firstClass === mychoiceSdkComponents.DriverLicenceTypes.G2)
5485
+ return { year: g2LicenceYear, month: g2LicenceMonth };
5486
+ if (firstClass === mychoiceSdkComponents.DriverLicenceTypes.G)
5487
+ return { year: gLicenceYear, month: gLicenceMonth };
5488
+ return { year: g1LicenceYear, month: g1LicenceMonth };
5489
+ };
5490
+ const { year: ontarioQ1Year, month: ontarioQ1Month } = getOntarioQ1Slot();
5491
+ const ontarioQ1DateStr = ontarioQ1Year && ontarioQ1Month
5492
+ ? `${ontarioQ1Year}-${ontarioQ1Month}-01` : '';
5493
+ const ontarioIsOnlyG = !!ontarioQ1DateStr
5494
+ && mychoiceSdkComponents.compareDates(configState.minDates.g.specialDate, ontarioQ1DateStr) >= 0;
5495
+ // Determine which dates to send and final licence_type for the API.
5496
+ // The backend always requires g1_licence_date as the first licence date.
5497
+ if (ontarioIsOnlyG || firstClass === mychoiceSdkComponents.DriverLicenceTypes.G) {
5498
+ // G Full path: Q1 date is in gLicenceYear/Month slot
5499
+ driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
5500
+ driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G;
5501
+ delete driver.licenceInfo.passedDriverTraining;
5502
+ }
5503
+ else if (firstClass === mychoiceSdkComponents.DriverLicenceTypes.G1) {
5504
+ // G1 path: Q1 date is in g1LicenceYear/Month
5505
+ driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, +birthDay + 1);
5506
+ if (receivedG2) {
5507
+ driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, +birthDay + 1);
5508
+ if (receivedG) {
5509
+ driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
5510
+ driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G;
5511
+ }
5512
+ else {
5513
+ driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G2;
5514
+ }
5515
+ }
5516
+ else if (receivedG) {
5517
+ driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
5518
+ driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G;
5519
+ }
5520
+ else {
5521
+ driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G1;
5522
+ }
5523
+ }
5524
+ else if (firstClass === mychoiceSdkComponents.DriverLicenceTypes.G2) {
5525
+ // G2 path: Q1 (first licence) date is in g2LicenceYear/Month.
5526
+ driver.licenceInfo.g1LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, +birthDay + 1);
5527
+ driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, +birthDay + 1);
5528
+ if (receivedG) {
5529
+ driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
5530
+ driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G;
5531
+ }
5532
+ else {
5533
+ driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G2;
5534
+ }
5535
+ }
5536
+ deleteLicenceDates();
5537
+ }
5538
+ else if (isOnlyG) {
5229
5539
  if (driver.licenceInfo.licenceType === mychoiceSdkComponents.DriverLicenceTypes.G) {
5230
5540
  driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
5231
5541
  delete driver.licenceInfo.g1LicenceDate;
@@ -5255,6 +5565,51 @@ const CarQuoteDataHandler = () => {
5255
5565
  deleteLicenceDates();
5256
5566
  }
5257
5567
  }
5568
+ if (isOntarioMyChoiceLicence) {
5569
+ const { receivedG2, receivedG } = driver.licenceInfo;
5570
+ const g1Date = driver.licenceInfo.g1LicenceDate;
5571
+ const g2Date = driver.licenceInfo.g2LicenceDate;
5572
+ const gDate = driver.licenceInfo.gLicenceDate;
5573
+ const training = !!driver.licenceInfo.passedDriverTraining;
5574
+ const hasG1 = driver.licenceInfo.licenceType === mychoiceSdkComponents.DriverLicenceTypes.G1 || !!g1Date;
5575
+ const hasG2 = !!g2Date || receivedG2;
5576
+ const hasG = !!gDate || receivedG;
5577
+ let outside = false;
5578
+ if (hasG1 && hasG2 && g1Date && g2Date) {
5579
+ const monthsG1toG2 = mychoiceSdkComponents.getDifferenceInMonths(g2Date, g1Date);
5580
+ if (!training && monthsG1toG2 < 12)
5581
+ outside = true;
5582
+ if (training && monthsG1toG2 < 8)
5583
+ outside = true;
5584
+ }
5585
+ if (hasG1 && hasG && g1Date && gDate) {
5586
+ const monthsG1toG = mychoiceSdkComponents.getDifferenceInMonths(gDate, g1Date);
5587
+ if (!training && monthsG1toG < 24)
5588
+ outside = true;
5589
+ if (training && monthsG1toG < 20)
5590
+ outside = true;
5591
+ }
5592
+ if (hasG2 && hasG && g2Date && gDate) {
5593
+ const monthsG2toG = mychoiceSdkComponents.getDifferenceInMonths(gDate, g2Date);
5594
+ if (monthsG2toG < 12)
5595
+ outside = true;
5596
+ }
5597
+ if (receivedG2 === undefined && !!g2Date)
5598
+ outside = true;
5599
+ if (hasG1 && hasG && !hasG2)
5600
+ outside = true;
5601
+ driver.licenceInfo.outsideExp = outside;
5602
+ delete driver.licenceInfo.receivedG2;
5603
+ delete driver.licenceInfo.receivedG;
5604
+ // API only accepts passed_driver_training for G2 licence type
5605
+ if (driver.licenceInfo.licenceType !== mychoiceSdkComponents.DriverLicenceTypes.G2) {
5606
+ delete driver.licenceInfo.passedDriverTraining;
5607
+ }
5608
+ }
5609
+ else {
5610
+ driver.licenceInfo.outsideExp = !!driver.licenceInfo.previousLicence;
5611
+ }
5612
+ delete driver.licenceInfo.previousLicence;
5258
5613
  delete driver.birthYear;
5259
5614
  delete driver.birthMonth;
5260
5615
  delete driver.birthDay;
@@ -5302,27 +5657,68 @@ const CarQuoteDataHandler = () => {
5302
5657
  }
5303
5658
  return driver;
5304
5659
  });
5305
- const localVehlinks = [];
5660
+ // Build a complete set of vehlinks combining primary assignments + occasional assignments
5661
+ const buildVehlinks = () => {
5662
+ const driverCount = requestBody.drivers.length;
5663
+ const vehicleCount = requestBody.vehicles.length;
5664
+ const result = [];
5665
+ for (let vehicleIndex = 0; vehicleIndex < vehicleCount; vehicleIndex++) {
5666
+ const primaryDriverIndex = requestBody.vehlinks[vehicleIndex]?.driverIndex ?? 0;
5667
+ // Primary driver for this vehicle
5668
+ result.push({
5669
+ driverIndex: Number(primaryDriverIndex + 1),
5670
+ vehicleIndex: Number(vehicleIndex + 1),
5671
+ priority: mychoiceSdkComponents.DriverPriorityTypes.Prn,
5672
+ });
5673
+ if (driverCount > 1) {
5674
+ for (let driverIndex = 0; driverIndex < driverCount; driverIndex++) {
5675
+ if (driverIndex === primaryDriverIndex)
5676
+ continue;
5677
+ if (vehicleCount === 1) {
5678
+ // f) All non-primary drivers are occasional on the only vehicle
5679
+ result.push({
5680
+ driverIndex: Number(driverIndex + 1),
5681
+ vehicleIndex: Number(vehicleIndex + 1),
5682
+ priority: mychoiceSdkComponents.DriverPriorityTypes.Occ,
5683
+ });
5684
+ }
5685
+ else {
5686
+ // g-k) Use user-selected vehicle for extra drivers; skip if they are primary on another vehicle
5687
+ const isPrimaryElsewhere = requestBody.vehlinks.some((l) => l.driverIndex === driverIndex + 1 && l.vehicleIndex !== vehicleIndex);
5688
+ if (isPrimaryElsewhere)
5689
+ continue;
5690
+ const occAssignment = discount.occVehlinks?.find((l) => l.driverIndex === driverIndex);
5691
+ const occVehicleIndex = occAssignment ? occAssignment.vehicleIndex : 0;
5692
+ if (occVehicleIndex === vehicleIndex) {
5693
+ result.push({
5694
+ driverIndex: Number(driverIndex + 1),
5695
+ vehicleIndex: Number(vehicleIndex + 1),
5696
+ priority: mychoiceSdkComponents.DriverPriorityTypes.Occ,
5697
+ });
5698
+ }
5699
+ }
5700
+ }
5701
+ }
5702
+ }
5703
+ return result;
5704
+ };
5306
5705
  // vehicle
5307
- requestBody.vehicles = requestBody.vehicles.map((vehicleItem, vehicleIndex) => {
5706
+ requestBody.vehicles = requestBody.vehicles.map((vehicleItem) => {
5308
5707
  const vehicle = { ...vehicleItem, ...postalState.item };
5309
5708
  if (!vehicle.redirectURL) {
5310
5709
  delete vehicle.redirectURL;
5311
5710
  }
5312
- const vehlink = requestBody.drivers.map((_, driverIndex) => ({
5313
- driverIndex: Number(driverIndex + 1),
5314
- vehicleIndex: Number(vehicleIndex + 1),
5315
- priority: requestBody.vehlinks[vehicleIndex].driverIndex === driverIndex
5316
- ? mychoiceSdkComponents.DriverPriorityTypes.Prn
5317
- : mychoiceSdkComponents.DriverPriorityTypes.Occ,
5318
- }));
5319
- localVehlinks.push(...vehlink);
5320
5711
  vehicle.purchaseDate = addDayToDate(`${vehicle.purchaseYear}-${vehicle.purchaseMonth}`);
5321
5712
  delete vehicle.purchaseYear;
5322
5713
  delete vehicle.purchaseMonth;
5323
5714
  delete vehicle.purchaseDay;
5324
5715
  if (vehicle.primaryUse === mychoiceSdkComponents.VehiclePrimaryUseTypes.Personal) {
5325
5716
  delete vehicle.distanceBusiness;
5717
+ delete vehicle.businessUsePercent;
5718
+ }
5719
+ else if (vehicle.businessUsePercent) {
5720
+ // Send business_use_percent to the API; backend computes distance_business
5721
+ delete vehicle.distanceBusiness;
5326
5722
  }
5327
5723
  if (!vehicle.collision.coverage) {
5328
5724
  vehicle.collision.deductible = 1000;
@@ -5352,7 +5748,7 @@ const CarQuoteDataHandler = () => {
5352
5748
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
5353
5749
  return transformedVehicle;
5354
5750
  });
5355
- requestBody.vehlinks = localVehlinks;
5751
+ requestBody.vehlinks = buildVehlinks();
5356
5752
  return {
5357
5753
  ...requestBody,
5358
5754
  };
@@ -5945,6 +6341,7 @@ const useValidationVehicle = () => {
5945
6341
  'distanceDaily',
5946
6342
  'distanceBusiness',
5947
6343
  'distanceYearly',
6344
+ 'businessUsePercent',
5948
6345
  'purchaseYear',
5949
6346
  'purchaseMonth',
5950
6347
  ];
@@ -5955,8 +6352,10 @@ const useValidationVehicle = () => {
5955
6352
  });
5956
6353
  vehicleState.items.forEach((item) => {
5957
6354
  Object.keys(item).map((key) => {
5958
- if (checkableKeys.includes(key) && !item[key]) {
5959
- if (!(item.primaryUse === mychoiceSdkComponents.VehiclePrimaryUseTypes.Personal && key === 'distanceBusiness')) {
6355
+ const isEmpty = key === 'distanceDaily' ? item[key] === undefined || item[key] === null : !item[key];
6356
+ if (checkableKeys.includes(key) && isEmpty) {
6357
+ if (!(key === 'distanceBusiness' && (item.primaryUse === mychoiceSdkComponents.VehiclePrimaryUseTypes.Personal || item.businessUsePercent))
6358
+ && !(key === 'businessUsePercent' && item.primaryUse !== mychoiceSdkComponents.VehiclePrimaryUseTypes.Business)) {
5960
6359
  errors.push(key);
5961
6360
  }
5962
6361
  }
@@ -6015,6 +6414,7 @@ const useValidationDriver = () => {
6015
6414
  const { discountState } = useStoreFormCarDiscount();
6016
6415
  const { inValidation: driverFormIsInValidation = false, isValid: driverFormIsValid = false, } = driverState;
6017
6416
  const { appConfigState } = useStoreAppConfig();
6417
+ const { appType } = appConfigState;
6018
6418
  const { dispatchAppModalState } = useStoreAppModal();
6019
6419
  const navigate = reactRouterDom.useNavigate();
6020
6420
  const driverFormValidate = (isRedirect = true) => {
@@ -6029,6 +6429,9 @@ const useValidationDriver = () => {
6029
6429
  'listedYear',
6030
6430
  'listedMonth',
6031
6431
  'insuredDate',
6432
+ 'lastPolicyEndYear',
6433
+ 'lastPolicyEndMonth',
6434
+ 'lastPolicyCancelReason',
6032
6435
  // 'insuredYear',
6033
6436
  // 'insuredMonth',
6034
6437
  ];
@@ -6061,30 +6464,32 @@ const useValidationDriver = () => {
6061
6464
  type: exports.StoreFormCarDriverBaseActionTypes.FormCarDriverValidate,
6062
6465
  payload: { inValidation: true },
6063
6466
  });
6064
- Object.keys(discountState).forEach((key) => {
6065
- // checking errors in discountState
6066
- if (discountKeys.includes(key) && !discountState[key]) {
6067
- errors.push(key);
6467
+ const showPolicyStart = appType !== mychoiceSdkComponents.AppTypes.TheBig && !mychoiceSdkComponents.isMyChoiceLike(appType);
6468
+ if (showPolicyStart) {
6469
+ Object.keys(discountState).forEach((key) => {
6470
+ // checking errors in discountState
6471
+ if (discountKeys.includes(key) && !discountState[key]) {
6472
+ errors.push(key);
6473
+ }
6474
+ });
6475
+ const { policyStartYear = 0, policyStartMonth = 0, policyStartDay = 0 } = discountState;
6476
+ const policyDate = `${policyStartYear}-${policyStartMonth}-${policyStartDay}`;
6477
+ const currentDate = mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd');
6478
+ if (mychoiceSdkComponents.compareDates(currentDate, policyDate) >= 0) {
6479
+ errors.push('policyStartYear');
6480
+ errors.push('policyStartMonth');
6481
+ errors.push('policyStartDay');
6068
6482
  }
6069
- });
6070
- const { policyStartYear = 0, policyStartMonth = 0, policyStartDay = 0 } = discountState;
6071
- const policyDate = `${policyStartYear}-${policyStartMonth}-${policyStartDay}`;
6072
- // const currentDay = new Date().getUTCDate();
6073
- // const currentMonth = new Date().getUTCMonth();
6074
- // const currentYear = new Date().getUTCFullYear();
6075
- const currentDate = mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd');
6076
- if (mychoiceSdkComponents.compareDates(currentDate, policyDate) >= 0) {
6077
- errors.push('policyStartYear');
6078
- errors.push('policyStartMonth');
6079
- errors.push('policyStartDay');
6080
6483
  }
6081
6484
  driverState.items.forEach((item, index) => {
6082
6485
  Object.keys(item).forEach((key) => {
6083
6486
  // checking errors in driverState
6084
6487
  if (keys.includes(key) && !item[key]) {
6085
6488
  if ((!item.listed
6086
- && (key === 'listedYear' || key === 'listedMonth' || key === 'insuredDate'))
6489
+ && (key === 'listedYear' || key === 'listedMonth' || key === 'insuredDate'
6490
+ || key === 'lastPolicyEndYear' || key === 'lastPolicyEndMonth' || key === 'lastPolicyCancelReason'))
6087
6491
  || (!item.insured && item.listed && (key === 'insuredDate'))
6492
+ || (item.insured && (key === 'lastPolicyEndYear' || key === 'lastPolicyEndMonth' || key === 'lastPolicyCancelReason'))
6088
6493
  || (index === 0 && key === 'applicantRelationship')) {
6089
6494
  return;
6090
6495
  }
@@ -6172,6 +6577,7 @@ const useValidationCarDiscount = () => {
6172
6577
  'phone',
6173
6578
  'email',
6174
6579
  'emailStatus',
6580
+ 'phoneStatus',
6175
6581
  ];
6176
6582
  const errors = [];
6177
6583
  dispatchDiscountState({
@@ -6185,11 +6591,14 @@ const useValidationCarDiscount = () => {
6185
6591
  errors.push(objectKey);
6186
6592
  }
6187
6593
  });
6188
- if (discountState.emailTo.emailStatus !== mychoiceSdkComponents.ValidationStatusTypes.Approved) {
6189
- errors.push('email');
6190
- }
6191
6594
  }
6192
6595
  });
6596
+ if (discountState.emailTo.emailStatus !== mychoiceSdkComponents.ValidationStatusTypes.Approved) {
6597
+ errors.push('email');
6598
+ }
6599
+ if (discountState.quoterInfo.phoneStatus !== mychoiceSdkComponents.ValidationStatusTypes.Approved) {
6600
+ errors.push('phone');
6601
+ }
6193
6602
  if (!errors.length) {
6194
6603
  dispatchDiscountState({
6195
6604
  type: exports.StoreFormCarDiscountActionTypes.FormCarDiscountValidate,
@@ -6590,7 +6999,6 @@ const useValidationHomeDiscount = () => {
6590
6999
  const discountKeys = [
6591
7000
  'firstName',
6592
7001
  'lastName',
6593
- 'phone',
6594
7002
  ];
6595
7003
  const errors = [];
6596
7004
  dispatchDiscountState({
@@ -6613,6 +7021,9 @@ const useValidationHomeDiscount = () => {
6613
7021
  if (discountState.emailTo.emailStatus !== mychoiceSdkComponents.ValidationStatusTypes.Approved) {
6614
7022
  errors.push('email');
6615
7023
  }
7024
+ if (quoterInfo?.phoneStatus !== mychoiceSdkComponents.ValidationStatusTypes.Approved) {
7025
+ errors.push('phone');
7026
+ }
6616
7027
  if (!errors.length) {
6617
7028
  dispatchDiscountState({
6618
7029
  type: exports.StoreFormHomeDiscountActionTypes.FormHomeDiscountValidate,
@@ -6730,7 +7141,6 @@ const useValidationLifeApplicant = () => {
6730
7141
  const quoterInfoKeys = [
6731
7142
  'firstName',
6732
7143
  'lastName',
6733
- 'phone',
6734
7144
  ];
6735
7145
  const errors = [];
6736
7146
  dispatchApplicantState({
@@ -6745,6 +7155,9 @@ const useValidationLifeApplicant = () => {
6745
7155
  if (applicantState.emailTo.emailStatus !== mychoiceSdkComponents.ValidationStatusTypes.Approved) {
6746
7156
  errors.push('email');
6747
7157
  }
7158
+ if (quoterInfo?.phoneStatus !== mychoiceSdkComponents.ValidationStatusTypes.Approved) {
7159
+ errors.push('phone');
7160
+ }
6748
7161
  if (quoterInfo) {
6749
7162
  Object.keys(quoterInfo).forEach((key) => {
6750
7163
  if (quoterInfoKeys.includes(key) && !quoterInfo?.[key]) {
@@ -7489,12 +7902,13 @@ const useAutofillLifeForm = (options) => {
7489
7902
  },
7490
7903
  });
7491
7904
  }
7492
- // Dispatch quoter info - phone
7905
+ // Dispatch quoter info - phone (pre-approved since it comes from a trusted autofill source)
7493
7906
  if (applicantData.quoterInfo.phone) {
7494
7907
  dispatchApplicantState({
7495
- type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneSet,
7908
+ type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneStatusSet,
7496
7909
  payload: {
7497
7910
  phone: applicantData.quoterInfo.phone,
7911
+ phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Approved,
7498
7912
  },
7499
7913
  });
7500
7914
  }
@@ -7565,8 +7979,11 @@ exports.useHandlerAuth = useHandlerAuth;
7565
7979
  exports.useHandlerCarMake = useHandlerCarMake;
7566
7980
  exports.useHandlerCarModel = useHandlerCarModel;
7567
7981
  exports.useHandlerCarQuoterEmail = useHandlerCarQuoterEmail;
7982
+ exports.useHandlerCarQuoterPhone = useHandlerCarQuoterPhone;
7568
7983
  exports.useHandlerHomeQuoterEmail = useHandlerHomeQuoterEmail;
7984
+ exports.useHandlerHomeQuoterPhone = useHandlerHomeQuoterPhone;
7569
7985
  exports.useHandlerLifeQuoterEmail = useHandlerLifeQuoterEmail;
7986
+ exports.useHandlerLifeQuoterPhone = useHandlerLifeQuoterPhone;
7570
7987
  exports.useHandlerPartner = useHandlerPartner;
7571
7988
  exports.useHandlerPostal = useHandlerPostal;
7572
7989
  exports.useProvince = useProvince;