@mychoice/mychoice-sdk-store 2.2.23 → 2.2.24
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/cjs/index.js +217 -45
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/states/reducers/states/formStates/FormCarState/DiscountState/actions.d.ts +1 -0
- package/dist/cjs/states/reducers/states/formStates/FormCarState/DiscountState/interfaces.d.ts +11 -0
- package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverInsuranceState/actions.d.ts +5 -1
- package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverInsuranceState/interfaces.d.ts +24 -0
- package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverLicenceState/actions.d.ts +2 -0
- package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverLicenceState/interfaces.d.ts +12 -0
- package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverTicketState/actions.d.ts +1 -0
- package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/DriverTicketState/interfaces.d.ts +7 -0
- package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/initialState.d.ts +1 -0
- package/dist/cjs/states/reducers/states/formStates/FormCarState/DriverState/interfaces.d.ts +9 -0
- package/dist/cjs/states/reducers/states/formStates/FormCarState/VehicleState/actions.d.ts +1 -0
- package/dist/cjs/states/reducers/states/formStates/FormCarState/VehicleState/interfaces.d.ts +7 -0
- package/dist/esm/index.js +218 -46
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/states/reducers/states/formStates/FormCarState/DiscountState/actions.d.ts +1 -0
- package/dist/esm/states/reducers/states/formStates/FormCarState/DiscountState/interfaces.d.ts +11 -0
- package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverInsuranceState/actions.d.ts +5 -1
- package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverInsuranceState/interfaces.d.ts +24 -0
- package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverLicenceState/actions.d.ts +2 -0
- package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverLicenceState/interfaces.d.ts +12 -0
- package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverTicketState/actions.d.ts +1 -0
- package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/DriverTicketState/interfaces.d.ts +7 -0
- package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/initialState.d.ts +1 -0
- package/dist/esm/states/reducers/states/formStates/FormCarState/DriverState/interfaces.d.ts +9 -0
- package/dist/esm/states/reducers/states/formStates/FormCarState/VehicleState/actions.d.ts +1 -0
- package/dist/esm/states/reducers/states/formStates/FormCarState/VehicleState/interfaces.d.ts +7 -0
- package/dist/index.d.ts +80 -1
- package/package.json +3 -3
package/dist/cjs/index.js
CHANGED
|
@@ -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 = {}));
|
|
@@ -1069,37 +1079,32 @@ const setDriverLicenceInfoDate = (state, type, payload) => {
|
|
|
1069
1079
|
const { licenceType } = newState.items[newState.activeIndex].licenceInfo;
|
|
1070
1080
|
const { birthDay } = newState.items[newState.activeIndex];
|
|
1071
1081
|
const currentDate = mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd');
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
minMaxDates.gTwoMax = currentDate;
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1082
|
+
// When the picker explicitly targets a different slot (e.g. G1 driver entering G2/G date),
|
|
1083
|
+
// write to that slot rather than the store's current licenceType.
|
|
1084
|
+
const targetSlot = currentLicenceType && currentLicenceType !== licenceType
|
|
1085
|
+
? currentLicenceType
|
|
1086
|
+
: licenceType;
|
|
1087
|
+
switch (type) {
|
|
1088
|
+
case mychoiceSdkComponents.DateTypes.Year:
|
|
1089
|
+
newState.items[newState.activeIndex].licenceInfo[`${targetSlot}LicenceYear`] = value;
|
|
1090
|
+
break;
|
|
1091
|
+
case mychoiceSdkComponents.DateTypes.Month:
|
|
1092
|
+
newState.items[newState.activeIndex].licenceInfo[`${targetSlot}LicenceMonth`] = value;
|
|
1093
|
+
break;
|
|
1087
1094
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
break;
|
|
1093
|
-
case mychoiceSdkComponents.DateTypes.Month:
|
|
1094
|
-
newState.items[newState.activeIndex].licenceInfo.g2LicenceMonth = value;
|
|
1095
|
-
break;
|
|
1095
|
+
if (targetSlot === mychoiceSdkComponents.DriverLicenceTypes.G2) {
|
|
1096
|
+
const { minMaxDates } = newState.items[newState.activeIndex];
|
|
1097
|
+
if (minMaxDates) {
|
|
1098
|
+
minMaxDates.gTwoMax = currentDate;
|
|
1096
1099
|
}
|
|
1100
|
+
}
|
|
1101
|
+
// Non-Ontario G driver entering G2 date: recompute the G min date (existing behaviour).
|
|
1102
|
+
if (licenceType === mychoiceSdkComponents.DriverLicenceTypes.G && targetSlot === mychoiceSdkComponents.DriverLicenceTypes.G2) {
|
|
1097
1103
|
const { g2LicenceMonth, g2LicenceYear } = newState.items[newState.activeIndex].licenceInfo;
|
|
1098
1104
|
if (g2LicenceMonth && g2LicenceYear && config) {
|
|
1099
1105
|
const g2Date = mychoiceSdkComponents.addDaysToDate(`${g2LicenceYear}-${g2LicenceMonth}-01`, birthDay ? +birthDay + 1 : 1);
|
|
1100
1106
|
const gMinDefaultDate = mychoiceSdkComponents.getLicenceMinDate(licenceType, g2Date, config);
|
|
1101
|
-
const gMinDate = mychoiceSdkComponents.compareDates(gMinDefaultDate, currentDate) > 0
|
|
1102
|
-
? currentDate : gMinDefaultDate;
|
|
1107
|
+
const gMinDate = mychoiceSdkComponents.compareDates(gMinDefaultDate, currentDate) > 0 ? currentDate : gMinDefaultDate;
|
|
1103
1108
|
const { minMaxDates } = newState.items[newState.activeIndex];
|
|
1104
1109
|
if (minMaxDates) {
|
|
1105
1110
|
minMaxDates.gMin = gMinDate;
|
|
@@ -1353,6 +1358,14 @@ const formCarDriverInsuranceStateReducer = (state = { ...carFormDriverInitialSta
|
|
|
1353
1358
|
return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'insured', action.payload.insured));
|
|
1354
1359
|
case exports.StoreFormCarDriverInsuranceActionTypes.FormCarDriverInsuredDateSelect:
|
|
1355
1360
|
return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'insuredDate', action.payload.insuredDate));
|
|
1361
|
+
case exports.StoreFormCarDriverInsuranceActionTypes.FormCarDriverNotCurrentlyInsuredSelect:
|
|
1362
|
+
return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'notCurrentlyInsured', action.payload.notCurrentlyInsured));
|
|
1363
|
+
case exports.StoreFormCarDriverInsuranceActionTypes.FormCarDriverLastPolicyEndYearSelect:
|
|
1364
|
+
return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'lastPolicyEndYear', action.payload.lastPolicyEndYear));
|
|
1365
|
+
case exports.StoreFormCarDriverInsuranceActionTypes.FormCarDriverLastPolicyEndMonthSelect:
|
|
1366
|
+
return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'lastPolicyEndMonth', action.payload.lastPolicyEndMonth));
|
|
1367
|
+
case exports.StoreFormCarDriverInsuranceActionTypes.FormCarDriverLastPolicyCancelReasonSelect:
|
|
1368
|
+
return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'lastPolicyCancelReason', action.payload.lastPolicyCancelReason));
|
|
1356
1369
|
default:
|
|
1357
1370
|
return state;
|
|
1358
1371
|
}
|
|
@@ -1372,6 +1385,10 @@ const formCarDriverLicenceStateReducer = (state = { ...carFormDriverInitialState
|
|
|
1372
1385
|
return setLocalDrivers(action?.localIndex, setDriverLicenceInfo(state, 'passedDriverTraining', action.payload.training));
|
|
1373
1386
|
case exports.StoreFormCarDriverLicenceActionTypes.FormCarDriverPreviousLicenceSelect:
|
|
1374
1387
|
return setLocalDrivers(action?.localIndex, setDriverLicenceInfo(state, 'previousLicence', action.payload.previousLicence));
|
|
1388
|
+
case exports.StoreFormCarDriverLicenceActionTypes.FormCarDriverReceivedG2Select:
|
|
1389
|
+
return setLocalDrivers(action?.localIndex, setDriverLicenceInfo(state, 'receivedG2', action.payload.receivedG2));
|
|
1390
|
+
case exports.StoreFormCarDriverLicenceActionTypes.FormCarDriverReceivedGSelect:
|
|
1391
|
+
return setLocalDrivers(action?.localIndex, setDriverLicenceInfo(state, 'receivedG', action.payload.receivedG));
|
|
1375
1392
|
case exports.StoreFormCarDriverLicenceActionTypes.FormCarDriverGLicenceMinSelect:
|
|
1376
1393
|
return setLocalDrivers(action?.localIndex, setDriverLicenceMinMaxDates(state, 'gMin', action.payload.gMin));
|
|
1377
1394
|
case exports.StoreFormCarDriverLicenceActionTypes.FormCarDriverG1LicenceMinSelect:
|
|
@@ -1466,6 +1483,8 @@ const formCarDriverTicketStateReducer = (state = { ...carFormDriverInitialState
|
|
|
1466
1483
|
return setLocalDrivers(action?.localIndex, setDriverListItemProperty(state, 'ticketList', action.payload.index, 'ticketYear', action.payload.ticketYear));
|
|
1467
1484
|
case exports.StoreFormCarDriverTicketActionTypes.FormCarDriverTrafficTicketMonthSelect:
|
|
1468
1485
|
return setLocalDrivers(action?.localIndex, setDriverListItemProperty(state, 'ticketList', action.payload.index, 'ticketMonth', action.payload.ticketMonth));
|
|
1486
|
+
case exports.StoreFormCarDriverTicketActionTypes.FormCarDriverTrafficTicketSpeedSelect:
|
|
1487
|
+
return setLocalDrivers(action?.localIndex, setDriverListItemProperty(state, 'ticketList', action.payload.index, 'speed', action.payload.speed));
|
|
1469
1488
|
default:
|
|
1470
1489
|
return state;
|
|
1471
1490
|
}
|
|
@@ -1889,6 +1908,7 @@ const formCarDiscountStateInitialState = {
|
|
|
1889
1908
|
priority: mychoiceSdkComponents.DriverPriorityTypes.Prn,
|
|
1890
1909
|
vehicleIndex: 0,
|
|
1891
1910
|
}],
|
|
1911
|
+
occVehlinks: [],
|
|
1892
1912
|
inValidation: false,
|
|
1893
1913
|
isValid: false,
|
|
1894
1914
|
};
|
|
@@ -1910,6 +1930,7 @@ exports.StoreFormCarDiscountActionTypes = void 0;
|
|
|
1910
1930
|
StoreFormCarDiscountActionTypes["FormCarDiscountVehlinkSelect"] = "FormCarDiscountVehlinkSelect";
|
|
1911
1931
|
StoreFormCarDiscountActionTypes["FormCarDiscountVehlinkByVehicleDelete"] = "FormCarDiscountVehlinkByVehicleDelete";
|
|
1912
1932
|
StoreFormCarDiscountActionTypes["FormCarDiscountVehlinkByDriverDelete"] = "FormCarDiscountVehlinkByDriverDelete";
|
|
1933
|
+
StoreFormCarDiscountActionTypes["FormCarDiscountOccVehlinkSelect"] = "FormCarDiscountOccVehlinkSelect";
|
|
1913
1934
|
StoreFormCarDiscountActionTypes["FormCarDiscountQuoterEmailStatusSet"] = "FormCarDiscountQuoterEmailStatusSet";
|
|
1914
1935
|
StoreFormCarDiscountActionTypes["FormCarDiscountValidate"] = "FormCarDiscountValidate";
|
|
1915
1936
|
StoreFormCarDiscountActionTypes["FormCarDiscountValidateSet"] = "FormCarDiscountValidateSet";
|
|
@@ -2027,6 +2048,14 @@ const formCarDiscountStateReducer = (state = { ...formCarDiscountStateInitialSta
|
|
|
2027
2048
|
return setLocalDiscounts$1(action.localIndex, deleteVehlinkByDriver(state, action.payload.driverIndex));
|
|
2028
2049
|
case exports.StoreFormCarDiscountActionTypes.FormCarDiscountVehlinkSelect:
|
|
2029
2050
|
return setLocalDiscounts$1(action.localIndex, selectDriverForVehicle(state, action.payload.driverIndex, action.payload.vehicleIndex));
|
|
2051
|
+
case exports.StoreFormCarDiscountActionTypes.FormCarDiscountOccVehlinkSelect: {
|
|
2052
|
+
const { driverIndex, vehicleIndex } = action.payload;
|
|
2053
|
+
const filtered = state.occVehlinks.filter((l) => l.driverIndex !== driverIndex);
|
|
2054
|
+
const updated = vehicleIndex >= 0
|
|
2055
|
+
? [...filtered, { driverIndex, vehicleIndex }]
|
|
2056
|
+
: filtered;
|
|
2057
|
+
return setLocalDiscounts$1(action.localIndex, { ...state, occVehlinks: updated });
|
|
2058
|
+
}
|
|
2030
2059
|
case exports.StoreFormCarDiscountActionTypes.FormCarDiscountMultiplePoliciesSelect:
|
|
2031
2060
|
return setLocalDiscounts$1(action.localIndex, setDiscountStateProperty(state, 'multiplePoliciesDiscount', action.payload.multiplePoliciesDiscount));
|
|
2032
2061
|
case exports.StoreFormCarDiscountActionTypes.FormCarDiscountCaaMemberSelect:
|
|
@@ -5157,9 +5186,6 @@ const CarQuoteDataHandler = () => {
|
|
|
5157
5186
|
if (driver.applicantRelationship === '') {
|
|
5158
5187
|
delete driver.applicantRelationship;
|
|
5159
5188
|
}
|
|
5160
|
-
if (driver.gender === mychoiceSdkComponents.GenderTypes.Other) {
|
|
5161
|
-
driver.gender = mychoiceSdkComponents.GenderTypes.Male;
|
|
5162
|
-
}
|
|
5163
5189
|
// ==================================
|
|
5164
5190
|
// thebig additional properties
|
|
5165
5191
|
if (appConfigState.appType === mychoiceSdkComponents.AppTypes.TheBig) {
|
|
@@ -5212,8 +5238,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5212
5238
|
delete driver.insuredDate;
|
|
5213
5239
|
}
|
|
5214
5240
|
const defaultMinDate = driver.dateOfBirth && driver.licenceInfo.firstLicenceAge
|
|
5215
|
-
? mychoiceSdkComponents.addYearsToDate(driver.dateOfBirth, +driver.licenceInfo.firstLicenceAge)
|
|
5216
|
-
: '';
|
|
5241
|
+
? mychoiceSdkComponents.addYearsToDate(driver.dateOfBirth, +driver.licenceInfo.firstLicenceAge) : '';
|
|
5217
5242
|
const isOnlyG = mychoiceSdkComponents.compareDates(defaultMinDate, configState.minDates.g.specialDate) < 0;
|
|
5218
5243
|
// licence
|
|
5219
5244
|
const deleteLicenceDates = () => {
|
|
@@ -5224,8 +5249,73 @@ const CarQuoteDataHandler = () => {
|
|
|
5224
5249
|
delete driver.licenceInfo.g2LicenceYear;
|
|
5225
5250
|
delete driver.licenceInfo.g2LicenceMonth;
|
|
5226
5251
|
};
|
|
5227
|
-
const { g1LicenceMonth, g1LicenceYear, g2LicenceMonth, g2LicenceYear, gLicenceYear, gLicenceMonth } = licenceInfo;
|
|
5228
|
-
|
|
5252
|
+
const { g1LicenceMonth, g1LicenceYear, g2LicenceMonth, g2LicenceYear, gLicenceYear, gLicenceMonth, } = licenceInfo;
|
|
5253
|
+
const isOntarioMyChoiceLicence = requestBody.provinceCode === 'ON' && mychoiceSdkComponents.isMyChoiceLike(appConfigState.appType);
|
|
5254
|
+
if (isOntarioMyChoiceLicence) {
|
|
5255
|
+
// Ontario new flow: licenceType = first class received (Q2).
|
|
5256
|
+
// receivedG2/receivedG flags determine the full progression.
|
|
5257
|
+
// Q1 date is stored in the slot matching licenceType.
|
|
5258
|
+
const { receivedG2, receivedG } = driver.licenceInfo;
|
|
5259
|
+
const firstClass = driver.licenceInfo.licenceType;
|
|
5260
|
+
// isOnlyG must use the actual Q1 date the user entered, not DOB+firstLicenceAge.
|
|
5261
|
+
// DOB+16 can predate 1994 for older drivers (e.g. born 1966 → 1982), which falsely
|
|
5262
|
+
// triggers the G-Full path even when the user's actual first licence is much later.
|
|
5263
|
+
const getOntarioQ1Slot = () => {
|
|
5264
|
+
if (firstClass === mychoiceSdkComponents.DriverLicenceTypes.G2)
|
|
5265
|
+
return { year: g2LicenceYear, month: g2LicenceMonth };
|
|
5266
|
+
if (firstClass === mychoiceSdkComponents.DriverLicenceTypes.G)
|
|
5267
|
+
return { year: gLicenceYear, month: gLicenceMonth };
|
|
5268
|
+
return { year: g1LicenceYear, month: g1LicenceMonth };
|
|
5269
|
+
};
|
|
5270
|
+
const { year: ontarioQ1Year, month: ontarioQ1Month } = getOntarioQ1Slot();
|
|
5271
|
+
const ontarioQ1DateStr = ontarioQ1Year && ontarioQ1Month
|
|
5272
|
+
? `${ontarioQ1Year}-${ontarioQ1Month}-01` : '';
|
|
5273
|
+
const ontarioIsOnlyG = !!ontarioQ1DateStr
|
|
5274
|
+
&& mychoiceSdkComponents.compareDates(configState.minDates.g.specialDate, ontarioQ1DateStr) >= 0;
|
|
5275
|
+
// Determine which dates to send and final licence_type for the API.
|
|
5276
|
+
// The backend always requires g1_licence_date as the first licence date.
|
|
5277
|
+
if (ontarioIsOnlyG || firstClass === mychoiceSdkComponents.DriverLicenceTypes.G) {
|
|
5278
|
+
// G Full path: Q1 date is in gLicenceYear/Month slot
|
|
5279
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
|
|
5280
|
+
driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G;
|
|
5281
|
+
delete driver.licenceInfo.passedDriverTraining;
|
|
5282
|
+
}
|
|
5283
|
+
else if (firstClass === mychoiceSdkComponents.DriverLicenceTypes.G1) {
|
|
5284
|
+
// G1 path: Q1 date is in g1LicenceYear/Month
|
|
5285
|
+
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, +birthDay + 1);
|
|
5286
|
+
if (receivedG2) {
|
|
5287
|
+
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, +birthDay + 1);
|
|
5288
|
+
if (receivedG) {
|
|
5289
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
|
|
5290
|
+
driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G;
|
|
5291
|
+
}
|
|
5292
|
+
else {
|
|
5293
|
+
driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G2;
|
|
5294
|
+
}
|
|
5295
|
+
}
|
|
5296
|
+
else if (receivedG) {
|
|
5297
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
|
|
5298
|
+
driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G;
|
|
5299
|
+
}
|
|
5300
|
+
else {
|
|
5301
|
+
driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G1;
|
|
5302
|
+
}
|
|
5303
|
+
}
|
|
5304
|
+
else if (firstClass === mychoiceSdkComponents.DriverLicenceTypes.G2) {
|
|
5305
|
+
// G2 path: Q1 (first licence) date is in g2LicenceYear/Month.
|
|
5306
|
+
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, +birthDay + 1);
|
|
5307
|
+
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, +birthDay + 1);
|
|
5308
|
+
if (receivedG) {
|
|
5309
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
|
|
5310
|
+
driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G;
|
|
5311
|
+
}
|
|
5312
|
+
else {
|
|
5313
|
+
driver.licenceInfo.licenceType = mychoiceSdkComponents.DriverLicenceTypes.G2;
|
|
5314
|
+
}
|
|
5315
|
+
}
|
|
5316
|
+
deleteLicenceDates();
|
|
5317
|
+
}
|
|
5318
|
+
else if (isOnlyG) {
|
|
5229
5319
|
if (driver.licenceInfo.licenceType === mychoiceSdkComponents.DriverLicenceTypes.G) {
|
|
5230
5320
|
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
|
|
5231
5321
|
delete driver.licenceInfo.g1LicenceDate;
|
|
@@ -5255,6 +5345,51 @@ const CarQuoteDataHandler = () => {
|
|
|
5255
5345
|
deleteLicenceDates();
|
|
5256
5346
|
}
|
|
5257
5347
|
}
|
|
5348
|
+
if (isOntarioMyChoiceLicence) {
|
|
5349
|
+
const { receivedG2, receivedG } = driver.licenceInfo;
|
|
5350
|
+
const g1Date = driver.licenceInfo.g1LicenceDate;
|
|
5351
|
+
const g2Date = driver.licenceInfo.g2LicenceDate;
|
|
5352
|
+
const gDate = driver.licenceInfo.gLicenceDate;
|
|
5353
|
+
const training = !!driver.licenceInfo.passedDriverTraining;
|
|
5354
|
+
const hasG1 = driver.licenceInfo.licenceType === mychoiceSdkComponents.DriverLicenceTypes.G1 || !!g1Date;
|
|
5355
|
+
const hasG2 = !!g2Date || receivedG2;
|
|
5356
|
+
const hasG = !!gDate || receivedG;
|
|
5357
|
+
let outside = false;
|
|
5358
|
+
if (hasG1 && hasG2 && g1Date && g2Date) {
|
|
5359
|
+
const monthsG1toG2 = mychoiceSdkComponents.getDifferenceInMonths(g2Date, g1Date);
|
|
5360
|
+
if (!training && monthsG1toG2 < 12)
|
|
5361
|
+
outside = true;
|
|
5362
|
+
if (training && monthsG1toG2 < 8)
|
|
5363
|
+
outside = true;
|
|
5364
|
+
}
|
|
5365
|
+
if (hasG1 && hasG && g1Date && gDate) {
|
|
5366
|
+
const monthsG1toG = mychoiceSdkComponents.getDifferenceInMonths(gDate, g1Date);
|
|
5367
|
+
if (!training && monthsG1toG < 24)
|
|
5368
|
+
outside = true;
|
|
5369
|
+
if (training && monthsG1toG < 20)
|
|
5370
|
+
outside = true;
|
|
5371
|
+
}
|
|
5372
|
+
if (hasG2 && hasG && g2Date && gDate) {
|
|
5373
|
+
const monthsG2toG = mychoiceSdkComponents.getDifferenceInMonths(gDate, g2Date);
|
|
5374
|
+
if (monthsG2toG < 12)
|
|
5375
|
+
outside = true;
|
|
5376
|
+
}
|
|
5377
|
+
if (receivedG2 === undefined && !!g2Date)
|
|
5378
|
+
outside = true;
|
|
5379
|
+
if (hasG1 && hasG && !hasG2)
|
|
5380
|
+
outside = true;
|
|
5381
|
+
driver.licenceInfo.outsideExp = outside;
|
|
5382
|
+
delete driver.licenceInfo.receivedG2;
|
|
5383
|
+
delete driver.licenceInfo.receivedG;
|
|
5384
|
+
// API only accepts passed_driver_training for G2 licence type
|
|
5385
|
+
if (driver.licenceInfo.licenceType !== mychoiceSdkComponents.DriverLicenceTypes.G2) {
|
|
5386
|
+
delete driver.licenceInfo.passedDriverTraining;
|
|
5387
|
+
}
|
|
5388
|
+
}
|
|
5389
|
+
else {
|
|
5390
|
+
driver.licenceInfo.outsideExp = !!driver.licenceInfo.previousLicence;
|
|
5391
|
+
}
|
|
5392
|
+
delete driver.licenceInfo.previousLicence;
|
|
5258
5393
|
delete driver.birthYear;
|
|
5259
5394
|
delete driver.birthMonth;
|
|
5260
5395
|
delete driver.birthDay;
|
|
@@ -5298,30 +5433,67 @@ const CarQuoteDataHandler = () => {
|
|
|
5298
5433
|
driver.ticketList = driver.ticketList?.map((listItem) => ({
|
|
5299
5434
|
reason: listItem.ticketReason,
|
|
5300
5435
|
ticketDate: addDayToDate(`${listItem.ticketYear}-${listItem.ticketMonth}`, +birthDay + 1),
|
|
5436
|
+
...(listItem.speed !== undefined ? { speed: listItem.speed } : {}),
|
|
5301
5437
|
}));
|
|
5302
5438
|
}
|
|
5303
5439
|
return driver;
|
|
5304
5440
|
});
|
|
5305
|
-
|
|
5441
|
+
// Build a complete set of vehlinks combining primary assignments + occasional assignments
|
|
5442
|
+
const buildVehlinks = () => {
|
|
5443
|
+
const driverCount = requestBody.drivers.length;
|
|
5444
|
+
const vehicleCount = requestBody.vehicles.length;
|
|
5445
|
+
const result = [];
|
|
5446
|
+
for (let vehicleIndex = 0; vehicleIndex < vehicleCount; vehicleIndex++) {
|
|
5447
|
+
const primaryDriverIndex = requestBody.vehlinks[vehicleIndex]?.driverIndex ?? 0;
|
|
5448
|
+
// Primary driver for this vehicle
|
|
5449
|
+
result.push({
|
|
5450
|
+
driverIndex: Number(primaryDriverIndex + 1),
|
|
5451
|
+
vehicleIndex: Number(vehicleIndex + 1),
|
|
5452
|
+
priority: mychoiceSdkComponents.DriverPriorityTypes.Prn,
|
|
5453
|
+
});
|
|
5454
|
+
if (driverCount > 1) {
|
|
5455
|
+
for (let driverIndex = 0; driverIndex < driverCount; driverIndex++) {
|
|
5456
|
+
if (driverIndex === primaryDriverIndex)
|
|
5457
|
+
continue;
|
|
5458
|
+
if (vehicleCount === 1) {
|
|
5459
|
+
// f) All non-primary drivers are occasional on the only vehicle
|
|
5460
|
+
result.push({
|
|
5461
|
+
driverIndex: Number(driverIndex + 1),
|
|
5462
|
+
vehicleIndex: Number(vehicleIndex + 1),
|
|
5463
|
+
priority: mychoiceSdkComponents.DriverPriorityTypes.Occ,
|
|
5464
|
+
});
|
|
5465
|
+
}
|
|
5466
|
+
else {
|
|
5467
|
+
// g-k) Use user-selected vehicle for extra drivers; skip if they are primary on another vehicle
|
|
5468
|
+
const isPrimaryElsewhere = requestBody.vehlinks.some((l) => l.driverIndex === driverIndex && l.vehicleIndex !== vehicleIndex);
|
|
5469
|
+
if (isPrimaryElsewhere)
|
|
5470
|
+
continue;
|
|
5471
|
+
const occAssignment = discount.occVehlinks?.find((l) => l.driverIndex === driverIndex);
|
|
5472
|
+
const occVehicleIndex = occAssignment ? occAssignment.vehicleIndex : 0;
|
|
5473
|
+
if (occVehicleIndex === vehicleIndex) {
|
|
5474
|
+
result.push({
|
|
5475
|
+
driverIndex: Number(driverIndex + 1),
|
|
5476
|
+
vehicleIndex: Number(vehicleIndex + 1),
|
|
5477
|
+
priority: mychoiceSdkComponents.DriverPriorityTypes.Occ,
|
|
5478
|
+
});
|
|
5479
|
+
}
|
|
5480
|
+
}
|
|
5481
|
+
}
|
|
5482
|
+
}
|
|
5483
|
+
}
|
|
5484
|
+
return result;
|
|
5485
|
+
};
|
|
5306
5486
|
// vehicle
|
|
5307
|
-
requestBody.vehicles = requestBody.vehicles.map((vehicleItem
|
|
5487
|
+
requestBody.vehicles = requestBody.vehicles.map((vehicleItem) => {
|
|
5308
5488
|
const vehicle = { ...vehicleItem, ...postalState.item };
|
|
5309
5489
|
if (!vehicle.redirectURL) {
|
|
5310
5490
|
delete vehicle.redirectURL;
|
|
5311
5491
|
}
|
|
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
5492
|
vehicle.purchaseDate = addDayToDate(`${vehicle.purchaseYear}-${vehicle.purchaseMonth}`);
|
|
5321
5493
|
delete vehicle.purchaseYear;
|
|
5322
5494
|
delete vehicle.purchaseMonth;
|
|
5323
5495
|
delete vehicle.purchaseDay;
|
|
5324
|
-
if (vehicle.primaryUse === mychoiceSdkComponents.VehiclePrimaryUseTypes.Personal) {
|
|
5496
|
+
if (vehicle.primaryUse === mychoiceSdkComponents.VehiclePrimaryUseTypes.Personal || vehicle.businessUsePercent) {
|
|
5325
5497
|
delete vehicle.distanceBusiness;
|
|
5326
5498
|
}
|
|
5327
5499
|
if (!vehicle.collision.coverage) {
|
|
@@ -5352,7 +5524,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5352
5524
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5353
5525
|
return transformedVehicle;
|
|
5354
5526
|
});
|
|
5355
|
-
requestBody.vehlinks =
|
|
5527
|
+
requestBody.vehlinks = buildVehlinks();
|
|
5356
5528
|
return {
|
|
5357
5529
|
...requestBody,
|
|
5358
5530
|
};
|
|
@@ -5956,7 +6128,7 @@ const useValidationVehicle = () => {
|
|
|
5956
6128
|
vehicleState.items.forEach((item) => {
|
|
5957
6129
|
Object.keys(item).map((key) => {
|
|
5958
6130
|
if (checkableKeys.includes(key) && !item[key]) {
|
|
5959
|
-
if (!(item.primaryUse === mychoiceSdkComponents.VehiclePrimaryUseTypes.Personal
|
|
6131
|
+
if (!(key === 'distanceBusiness' && (item.primaryUse === mychoiceSdkComponents.VehiclePrimaryUseTypes.Personal || item.businessUsePercent))) {
|
|
5960
6132
|
errors.push(key);
|
|
5961
6133
|
}
|
|
5962
6134
|
}
|