@mychoice/mychoice-sdk-store 2.2.22 → 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 +224 -49
- 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 +225 -50
- 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/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import { defaultLocalIndex, HttpRequestHeaderTypes, RequestTypes, ModalTypes, DeviceTypes, ScreenBPTypes, DeviceTypeWidthList, ScreenBPList, AppTypes, InsuranceTypes, VehicleConditionTypes, VehiclePrimaryUseTypes, deepClone, CoverageTypes, getFormattedDate, GenderTypes, OccupationTypes, addDaysToDate, compareDates, DriverLicenceTypes, DateTypes, getLicenceMinDate, addYearsToDate, subMonthsFromDate, getDifferenceInYears, DriverListTypes, addMonthsToDate, ValidationStatusTypes, DriverPriorityTypes, defaultBrokerPhone, subYearsFromDate, ApplicantListTypes, useEffectOnce, getInsuranceType as getInsuranceType$2, API_AUTH, RequestStatusTypes, PROFILE_API, getDaysOfMonth, getDifferenceInHours, MAX_LOCAL_STORAGE_HOURS_THEBIG, MAX_LOCAL_STORAGE_HOURS, API_APP, API_FORM_CAR, supportedProvinceCodes, API_FORM_HOME, API_FORM_LIFE } from '@mychoice/mychoice-sdk-components';
|
|
2
|
+
import { defaultLocalIndex, HttpRequestHeaderTypes, RequestTypes, ModalTypes, DeviceTypes, ScreenBPTypes, DeviceTypeWidthList, ScreenBPList, AppTypes, InsuranceTypes, VehicleConditionTypes, VehiclePrimaryUseTypes, deepClone, CoverageTypes, getFormattedDate, GenderTypes, OccupationTypes, addDaysToDate, compareDates, DriverLicenceTypes, DateTypes, getLicenceMinDate, addYearsToDate, subMonthsFromDate, getDifferenceInYears, DriverListTypes, addMonthsToDate, ValidationStatusTypes, DriverPriorityTypes, defaultBrokerPhone, subYearsFromDate, ApplicantListTypes, useEffectOnce, getInsuranceType as getInsuranceType$2, API_AUTH, RequestStatusTypes, PROFILE_API, getDaysOfMonth, getDifferenceInHours, MAX_LOCAL_STORAGE_HOURS_THEBIG, MAX_LOCAL_STORAGE_HOURS, API_APP, API_FORM_CAR, supportedProvinceCodes, API_FORM_HOME, API_FORM_LIFE, isMyChoiceLike, getDifferenceInMonths } from '@mychoice/mychoice-sdk-components';
|
|
3
3
|
import { useMemo, useReducer, useState, useRef, useEffect } from 'react';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
5
5
|
import { Provider, useSelector, useDispatch } from 'react-redux';
|
|
@@ -518,6 +518,7 @@ var StoreFormCarVehicleActionTypes;
|
|
|
518
518
|
StoreFormCarVehicleActionTypes["FormCarParkingLocationSelect"] = "FormCarParkingLocationSelect";
|
|
519
519
|
StoreFormCarVehicleActionTypes["FormCarDailyDistanceSelect"] = "FormCarDailyDistanceSelect";
|
|
520
520
|
StoreFormCarVehicleActionTypes["FormCarBusinessDistanceSelect"] = "FormCarBusinessDistanceSelect";
|
|
521
|
+
StoreFormCarVehicleActionTypes["FormCarBusinessUsePercentSelect"] = "FormCarBusinessUsePercentSelect";
|
|
521
522
|
StoreFormCarVehicleActionTypes["FormCarYearlyDistanceSelect"] = "FormCarYearlyDistanceSelect";
|
|
522
523
|
StoreFormCarVehicleActionTypes["FormCarComprehensiveCoverageSelect"] = "FormCarComprehensiveCoverageSelect";
|
|
523
524
|
StoreFormCarVehicleActionTypes["FormCarComprehensiveDeductibleSelect"] = "FormCarComprehensiveDeductibleSelect";
|
|
@@ -681,6 +682,8 @@ const formCarVehicleStateReducer = (state = { ...carFormVehicleInitialState }, a
|
|
|
681
682
|
return setLocalVehicles(action.localIndex, setItemProperty(state, 'distanceDaily', action.payload.distanceDaily));
|
|
682
683
|
case StoreFormCarVehicleActionTypes.FormCarBusinessDistanceSelect:
|
|
683
684
|
return setLocalVehicles(action.localIndex, setItemProperty(state, 'distanceBusiness', action.payload.distanceBusiness));
|
|
685
|
+
case StoreFormCarVehicleActionTypes.FormCarBusinessUsePercentSelect:
|
|
686
|
+
return setLocalVehicles(action.localIndex, setItemProperty(state, 'businessUsePercent', action.payload.businessUsePercent));
|
|
684
687
|
case StoreFormCarVehicleActionTypes.FormCarYearlyDistanceSelect:
|
|
685
688
|
return setLocalVehicles(action.localIndex, setItemProperty(state, 'distanceYearly', action.payload.distanceYearly));
|
|
686
689
|
case StoreFormCarVehicleActionTypes.FormCarComprehensiveCoverageSelect:
|
|
@@ -765,6 +768,10 @@ var StoreFormCarDriverInsuranceActionTypes;
|
|
|
765
768
|
StoreFormCarDriverInsuranceActionTypes["FormCarDriverListedMonthSelect"] = "FormCarDriverListedMonthSelect";
|
|
766
769
|
StoreFormCarDriverInsuranceActionTypes["FormCarDriverInsuredSelect"] = "FormCarDriverInsuredSelect";
|
|
767
770
|
StoreFormCarDriverInsuranceActionTypes["FormCarDriverInsuredDateSelect"] = "FormCarDriverInsuredDateSelect";
|
|
771
|
+
StoreFormCarDriverInsuranceActionTypes["FormCarDriverNotCurrentlyInsuredSelect"] = "FormCarDriverNotCurrentlyInsuredSelect";
|
|
772
|
+
StoreFormCarDriverInsuranceActionTypes["FormCarDriverLastPolicyEndYearSelect"] = "FormCarDriverLastPolicyEndYearSelect";
|
|
773
|
+
StoreFormCarDriverInsuranceActionTypes["FormCarDriverLastPolicyEndMonthSelect"] = "FormCarDriverLastPolicyEndMonthSelect";
|
|
774
|
+
StoreFormCarDriverInsuranceActionTypes["FormCarDriverLastPolicyCancelReasonSelect"] = "FormCarDriverLastPolicyCancelReasonSelect";
|
|
768
775
|
})(StoreFormCarDriverInsuranceActionTypes || (StoreFormCarDriverInsuranceActionTypes = {}));
|
|
769
776
|
|
|
770
777
|
var StoreFormCarDriverLicenceActionTypes;
|
|
@@ -779,6 +786,8 @@ var StoreFormCarDriverLicenceActionTypes;
|
|
|
779
786
|
StoreFormCarDriverLicenceActionTypes["FormCarDriverG1LicenceMaxSelect"] = "FormCarDriverG1LicenceMaxSelect";
|
|
780
787
|
StoreFormCarDriverLicenceActionTypes["FormCarDriverTrainingSelect"] = "FormCarDriverTrainingSelect";
|
|
781
788
|
StoreFormCarDriverLicenceActionTypes["FormCarDriverPreviousLicenceSelect"] = "FormCarDriverPreviousLicenceSelect";
|
|
789
|
+
StoreFormCarDriverLicenceActionTypes["FormCarDriverReceivedG2Select"] = "FormCarDriverReceivedG2Select";
|
|
790
|
+
StoreFormCarDriverLicenceActionTypes["FormCarDriverReceivedGSelect"] = "FormCarDriverReceivedGSelect";
|
|
782
791
|
StoreFormCarDriverLicenceActionTypes["FormCarDriverLicenceYearSelect"] = "FormCarDriverLicenceYearSelect";
|
|
783
792
|
StoreFormCarDriverLicenceActionTypes["FormCarDriverLicenceMonthSelect"] = "FormCarDriverLicenceMonthSelect";
|
|
784
793
|
})(StoreFormCarDriverLicenceActionTypes || (StoreFormCarDriverLicenceActionTypes = {}));
|
|
@@ -801,6 +810,7 @@ var StoreFormCarDriverTicketActionTypes;
|
|
|
801
810
|
StoreFormCarDriverTicketActionTypes["FormCarDriverTrafficTicketReasonSelect"] = "FormCarDriverTrafficTicketReasonSelect";
|
|
802
811
|
StoreFormCarDriverTicketActionTypes["FormCarDriverTrafficTicketYearSelect"] = "FormCarDriverTrafficTicketYearSelect";
|
|
803
812
|
StoreFormCarDriverTicketActionTypes["FormCarDriverTrafficTicketMonthSelect"] = "FormCarDriverTrafficTicketMonthSelect";
|
|
813
|
+
StoreFormCarDriverTicketActionTypes["FormCarDriverTrafficTicketSpeedSelect"] = "FormCarDriverTrafficTicketSpeedSelect";
|
|
804
814
|
StoreFormCarDriverTicketActionTypes["FormCarDriverTrafficTicketAdd"] = "FormCarDriverTrafficTicketAdd";
|
|
805
815
|
StoreFormCarDriverTicketActionTypes["FormCarDriverTrafficTicketDelete"] = "FormCarDriverTrafficTicketDelete";
|
|
806
816
|
})(StoreFormCarDriverTicketActionTypes || (StoreFormCarDriverTicketActionTypes = {}));
|
|
@@ -1060,37 +1070,32 @@ const setDriverLicenceInfoDate = (state, type, payload) => {
|
|
|
1060
1070
|
const { licenceType } = newState.items[newState.activeIndex].licenceInfo;
|
|
1061
1071
|
const { birthDay } = newState.items[newState.activeIndex];
|
|
1062
1072
|
const currentDate = getFormattedDate('', 'yyyy-MM-dd');
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
minMaxDates.gTwoMax = currentDate;
|
|
1076
|
-
}
|
|
1077
|
-
}
|
|
1073
|
+
// When the picker explicitly targets a different slot (e.g. G1 driver entering G2/G date),
|
|
1074
|
+
// write to that slot rather than the store's current licenceType.
|
|
1075
|
+
const targetSlot = currentLicenceType && currentLicenceType !== licenceType
|
|
1076
|
+
? currentLicenceType
|
|
1077
|
+
: licenceType;
|
|
1078
|
+
switch (type) {
|
|
1079
|
+
case DateTypes.Year:
|
|
1080
|
+
newState.items[newState.activeIndex].licenceInfo[`${targetSlot}LicenceYear`] = value;
|
|
1081
|
+
break;
|
|
1082
|
+
case DateTypes.Month:
|
|
1083
|
+
newState.items[newState.activeIndex].licenceInfo[`${targetSlot}LicenceMonth`] = value;
|
|
1084
|
+
break;
|
|
1078
1085
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
break;
|
|
1084
|
-
case DateTypes.Month:
|
|
1085
|
-
newState.items[newState.activeIndex].licenceInfo.g2LicenceMonth = value;
|
|
1086
|
-
break;
|
|
1086
|
+
if (targetSlot === DriverLicenceTypes.G2) {
|
|
1087
|
+
const { minMaxDates } = newState.items[newState.activeIndex];
|
|
1088
|
+
if (minMaxDates) {
|
|
1089
|
+
minMaxDates.gTwoMax = currentDate;
|
|
1087
1090
|
}
|
|
1091
|
+
}
|
|
1092
|
+
// Non-Ontario G driver entering G2 date: recompute the G min date (existing behaviour).
|
|
1093
|
+
if (licenceType === DriverLicenceTypes.G && targetSlot === DriverLicenceTypes.G2) {
|
|
1088
1094
|
const { g2LicenceMonth, g2LicenceYear } = newState.items[newState.activeIndex].licenceInfo;
|
|
1089
1095
|
if (g2LicenceMonth && g2LicenceYear && config) {
|
|
1090
1096
|
const g2Date = addDaysToDate(`${g2LicenceYear}-${g2LicenceMonth}-01`, birthDay ? +birthDay + 1 : 1);
|
|
1091
1097
|
const gMinDefaultDate = getLicenceMinDate(licenceType, g2Date, config);
|
|
1092
|
-
const gMinDate = compareDates(gMinDefaultDate, currentDate) > 0
|
|
1093
|
-
? currentDate : gMinDefaultDate;
|
|
1098
|
+
const gMinDate = compareDates(gMinDefaultDate, currentDate) > 0 ? currentDate : gMinDefaultDate;
|
|
1094
1099
|
const { minMaxDates } = newState.items[newState.activeIndex];
|
|
1095
1100
|
if (minMaxDates) {
|
|
1096
1101
|
minMaxDates.gMin = gMinDate;
|
|
@@ -1344,6 +1349,14 @@ const formCarDriverInsuranceStateReducer = (state = { ...carFormDriverInitialSta
|
|
|
1344
1349
|
return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'insured', action.payload.insured));
|
|
1345
1350
|
case StoreFormCarDriverInsuranceActionTypes.FormCarDriverInsuredDateSelect:
|
|
1346
1351
|
return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'insuredDate', action.payload.insuredDate));
|
|
1352
|
+
case StoreFormCarDriverInsuranceActionTypes.FormCarDriverNotCurrentlyInsuredSelect:
|
|
1353
|
+
return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'notCurrentlyInsured', action.payload.notCurrentlyInsured));
|
|
1354
|
+
case StoreFormCarDriverInsuranceActionTypes.FormCarDriverLastPolicyEndYearSelect:
|
|
1355
|
+
return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'lastPolicyEndYear', action.payload.lastPolicyEndYear));
|
|
1356
|
+
case StoreFormCarDriverInsuranceActionTypes.FormCarDriverLastPolicyEndMonthSelect:
|
|
1357
|
+
return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'lastPolicyEndMonth', action.payload.lastPolicyEndMonth));
|
|
1358
|
+
case StoreFormCarDriverInsuranceActionTypes.FormCarDriverLastPolicyCancelReasonSelect:
|
|
1359
|
+
return setLocalDrivers(action?.localIndex, setDriverItemProperty(state, 'lastPolicyCancelReason', action.payload.lastPolicyCancelReason));
|
|
1347
1360
|
default:
|
|
1348
1361
|
return state;
|
|
1349
1362
|
}
|
|
@@ -1363,6 +1376,10 @@ const formCarDriverLicenceStateReducer = (state = { ...carFormDriverInitialState
|
|
|
1363
1376
|
return setLocalDrivers(action?.localIndex, setDriverLicenceInfo(state, 'passedDriverTraining', action.payload.training));
|
|
1364
1377
|
case StoreFormCarDriverLicenceActionTypes.FormCarDriverPreviousLicenceSelect:
|
|
1365
1378
|
return setLocalDrivers(action?.localIndex, setDriverLicenceInfo(state, 'previousLicence', action.payload.previousLicence));
|
|
1379
|
+
case StoreFormCarDriverLicenceActionTypes.FormCarDriverReceivedG2Select:
|
|
1380
|
+
return setLocalDrivers(action?.localIndex, setDriverLicenceInfo(state, 'receivedG2', action.payload.receivedG2));
|
|
1381
|
+
case StoreFormCarDriverLicenceActionTypes.FormCarDriverReceivedGSelect:
|
|
1382
|
+
return setLocalDrivers(action?.localIndex, setDriverLicenceInfo(state, 'receivedG', action.payload.receivedG));
|
|
1366
1383
|
case StoreFormCarDriverLicenceActionTypes.FormCarDriverGLicenceMinSelect:
|
|
1367
1384
|
return setLocalDrivers(action?.localIndex, setDriverLicenceMinMaxDates(state, 'gMin', action.payload.gMin));
|
|
1368
1385
|
case StoreFormCarDriverLicenceActionTypes.FormCarDriverG1LicenceMinSelect:
|
|
@@ -1457,6 +1474,8 @@ const formCarDriverTicketStateReducer = (state = { ...carFormDriverInitialState
|
|
|
1457
1474
|
return setLocalDrivers(action?.localIndex, setDriverListItemProperty(state, 'ticketList', action.payload.index, 'ticketYear', action.payload.ticketYear));
|
|
1458
1475
|
case StoreFormCarDriverTicketActionTypes.FormCarDriverTrafficTicketMonthSelect:
|
|
1459
1476
|
return setLocalDrivers(action?.localIndex, setDriverListItemProperty(state, 'ticketList', action.payload.index, 'ticketMonth', action.payload.ticketMonth));
|
|
1477
|
+
case StoreFormCarDriverTicketActionTypes.FormCarDriverTrafficTicketSpeedSelect:
|
|
1478
|
+
return setLocalDrivers(action?.localIndex, setDriverListItemProperty(state, 'ticketList', action.payload.index, 'speed', action.payload.speed));
|
|
1460
1479
|
default:
|
|
1461
1480
|
return state;
|
|
1462
1481
|
}
|
|
@@ -1880,6 +1899,7 @@ const formCarDiscountStateInitialState = {
|
|
|
1880
1899
|
priority: DriverPriorityTypes.Prn,
|
|
1881
1900
|
vehicleIndex: 0,
|
|
1882
1901
|
}],
|
|
1902
|
+
occVehlinks: [],
|
|
1883
1903
|
inValidation: false,
|
|
1884
1904
|
isValid: false,
|
|
1885
1905
|
};
|
|
@@ -1901,6 +1921,7 @@ var StoreFormCarDiscountActionTypes;
|
|
|
1901
1921
|
StoreFormCarDiscountActionTypes["FormCarDiscountVehlinkSelect"] = "FormCarDiscountVehlinkSelect";
|
|
1902
1922
|
StoreFormCarDiscountActionTypes["FormCarDiscountVehlinkByVehicleDelete"] = "FormCarDiscountVehlinkByVehicleDelete";
|
|
1903
1923
|
StoreFormCarDiscountActionTypes["FormCarDiscountVehlinkByDriverDelete"] = "FormCarDiscountVehlinkByDriverDelete";
|
|
1924
|
+
StoreFormCarDiscountActionTypes["FormCarDiscountOccVehlinkSelect"] = "FormCarDiscountOccVehlinkSelect";
|
|
1904
1925
|
StoreFormCarDiscountActionTypes["FormCarDiscountQuoterEmailStatusSet"] = "FormCarDiscountQuoterEmailStatusSet";
|
|
1905
1926
|
StoreFormCarDiscountActionTypes["FormCarDiscountValidate"] = "FormCarDiscountValidate";
|
|
1906
1927
|
StoreFormCarDiscountActionTypes["FormCarDiscountValidateSet"] = "FormCarDiscountValidateSet";
|
|
@@ -2018,6 +2039,14 @@ const formCarDiscountStateReducer = (state = { ...formCarDiscountStateInitialSta
|
|
|
2018
2039
|
return setLocalDiscounts$1(action.localIndex, deleteVehlinkByDriver(state, action.payload.driverIndex));
|
|
2019
2040
|
case StoreFormCarDiscountActionTypes.FormCarDiscountVehlinkSelect:
|
|
2020
2041
|
return setLocalDiscounts$1(action.localIndex, selectDriverForVehicle(state, action.payload.driverIndex, action.payload.vehicleIndex));
|
|
2042
|
+
case StoreFormCarDiscountActionTypes.FormCarDiscountOccVehlinkSelect: {
|
|
2043
|
+
const { driverIndex, vehicleIndex } = action.payload;
|
|
2044
|
+
const filtered = state.occVehlinks.filter((l) => l.driverIndex !== driverIndex);
|
|
2045
|
+
const updated = vehicleIndex >= 0
|
|
2046
|
+
? [...filtered, { driverIndex, vehicleIndex }]
|
|
2047
|
+
: filtered;
|
|
2048
|
+
return setLocalDiscounts$1(action.localIndex, { ...state, occVehlinks: updated });
|
|
2049
|
+
}
|
|
2021
2050
|
case StoreFormCarDiscountActionTypes.FormCarDiscountMultiplePoliciesSelect:
|
|
2022
2051
|
return setLocalDiscounts$1(action.localIndex, setDiscountStateProperty(state, 'multiplePoliciesDiscount', action.payload.multiplePoliciesDiscount));
|
|
2023
2052
|
case StoreFormCarDiscountActionTypes.FormCarDiscountCaaMemberSelect:
|
|
@@ -5064,7 +5093,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5064
5093
|
const navigate = useNavigate();
|
|
5065
5094
|
const { checkIsExpired, checkIsExpiredWithModal } = ClearFormDataHandler();
|
|
5066
5095
|
const [requestState, setRequestState] = useReducer(dataHandlerReducer, { ...initialHandlerRequestState });
|
|
5067
|
-
const { status, successMessage, responseData, errorMessage, isFirstRequest, responseError
|
|
5096
|
+
const { status, successMessage, responseData, errorMessage, isFirstRequest, responseError } = requestState;
|
|
5068
5097
|
const { cancelToken } = useCancelToken();
|
|
5069
5098
|
const openLoader = (loaderDescription = '') => {
|
|
5070
5099
|
dispatchAppLoaderState({
|
|
@@ -5110,11 +5139,12 @@ const CarQuoteDataHandler = () => {
|
|
|
5110
5139
|
provinceName: postal.provinceName,
|
|
5111
5140
|
};
|
|
5112
5141
|
requestBody.quoterInfo.recalculate = isRecalc;
|
|
5142
|
+
requestBody.quoterInfo.initial = !isRecalc;
|
|
5113
5143
|
const isAbReformEligible = requestBody.provinceCode === 'ON' && policyStartDate >= '2026-07-01';
|
|
5114
5144
|
// Flag if any Accident Benefits buy-ups are selected (Ontario only)
|
|
5115
5145
|
if (isRecalc && isAbReformEligible) {
|
|
5116
|
-
const hasAbChanges = vehicles.some((v) => v.accidentbenefits?.baseCoverage !== 'minimum_required'
|
|
5117
|
-
|
|
5146
|
+
const hasAbChanges = vehicles.some((v) => v.accidentbenefits?.baseCoverage !== 'minimum_required' ||
|
|
5147
|
+
v.accidentbenefits?.additionalCoverages?.length > 0);
|
|
5118
5148
|
requestBody.quoterInfo.accidentBenefitsChanged = hasAbChanges;
|
|
5119
5149
|
}
|
|
5120
5150
|
delete requestBody.isValid;
|
|
@@ -5141,15 +5171,12 @@ const CarQuoteDataHandler = () => {
|
|
|
5141
5171
|
}
|
|
5142
5172
|
// driver
|
|
5143
5173
|
requestBody.drivers = requestBody.drivers.map((driverItem) => {
|
|
5144
|
-
const { birthYear, birthMonth, birthDay = '01', licenceInfo
|
|
5174
|
+
const { birthYear, birthMonth, birthDay = '01', licenceInfo } = driverItem;
|
|
5145
5175
|
const driver = { ...driverItem };
|
|
5146
5176
|
driver.dateOfBirth = `${birthYear}-${birthMonth}-${birthDay}`;
|
|
5147
5177
|
if (driver.applicantRelationship === '') {
|
|
5148
5178
|
delete driver.applicantRelationship;
|
|
5149
5179
|
}
|
|
5150
|
-
if (driver.gender === GenderTypes.Other) {
|
|
5151
|
-
driver.gender = GenderTypes.Male;
|
|
5152
|
-
}
|
|
5153
5180
|
// ==================================
|
|
5154
5181
|
// thebig additional properties
|
|
5155
5182
|
if (appConfigState.appType === AppTypes.TheBig) {
|
|
@@ -5214,7 +5241,72 @@ const CarQuoteDataHandler = () => {
|
|
|
5214
5241
|
delete driver.licenceInfo.g2LicenceMonth;
|
|
5215
5242
|
};
|
|
5216
5243
|
const { g1LicenceMonth, g1LicenceYear, g2LicenceMonth, g2LicenceYear, gLicenceYear, gLicenceMonth, } = licenceInfo;
|
|
5217
|
-
|
|
5244
|
+
const isOntarioMyChoiceLicence = requestBody.provinceCode === 'ON' && isMyChoiceLike(appConfigState.appType);
|
|
5245
|
+
if (isOntarioMyChoiceLicence) {
|
|
5246
|
+
// Ontario new flow: licenceType = first class received (Q2).
|
|
5247
|
+
// receivedG2/receivedG flags determine the full progression.
|
|
5248
|
+
// Q1 date is stored in the slot matching licenceType.
|
|
5249
|
+
const { receivedG2, receivedG } = driver.licenceInfo;
|
|
5250
|
+
const firstClass = driver.licenceInfo.licenceType;
|
|
5251
|
+
// isOnlyG must use the actual Q1 date the user entered, not DOB+firstLicenceAge.
|
|
5252
|
+
// DOB+16 can predate 1994 for older drivers (e.g. born 1966 → 1982), which falsely
|
|
5253
|
+
// triggers the G-Full path even when the user's actual first licence is much later.
|
|
5254
|
+
const getOntarioQ1Slot = () => {
|
|
5255
|
+
if (firstClass === DriverLicenceTypes.G2)
|
|
5256
|
+
return { year: g2LicenceYear, month: g2LicenceMonth };
|
|
5257
|
+
if (firstClass === DriverLicenceTypes.G)
|
|
5258
|
+
return { year: gLicenceYear, month: gLicenceMonth };
|
|
5259
|
+
return { year: g1LicenceYear, month: g1LicenceMonth };
|
|
5260
|
+
};
|
|
5261
|
+
const { year: ontarioQ1Year, month: ontarioQ1Month } = getOntarioQ1Slot();
|
|
5262
|
+
const ontarioQ1DateStr = ontarioQ1Year && ontarioQ1Month
|
|
5263
|
+
? `${ontarioQ1Year}-${ontarioQ1Month}-01` : '';
|
|
5264
|
+
const ontarioIsOnlyG = !!ontarioQ1DateStr
|
|
5265
|
+
&& compareDates(configState.minDates.g.specialDate, ontarioQ1DateStr) >= 0;
|
|
5266
|
+
// Determine which dates to send and final licence_type for the API.
|
|
5267
|
+
// The backend always requires g1_licence_date as the first licence date.
|
|
5268
|
+
if (ontarioIsOnlyG || firstClass === DriverLicenceTypes.G) {
|
|
5269
|
+
// G Full path: Q1 date is in gLicenceYear/Month slot
|
|
5270
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
|
|
5271
|
+
driver.licenceInfo.licenceType = DriverLicenceTypes.G;
|
|
5272
|
+
delete driver.licenceInfo.passedDriverTraining;
|
|
5273
|
+
}
|
|
5274
|
+
else if (firstClass === DriverLicenceTypes.G1) {
|
|
5275
|
+
// G1 path: Q1 date is in g1LicenceYear/Month
|
|
5276
|
+
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g1LicenceYear}-${g1LicenceMonth}`, +birthDay + 1);
|
|
5277
|
+
if (receivedG2) {
|
|
5278
|
+
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, +birthDay + 1);
|
|
5279
|
+
if (receivedG) {
|
|
5280
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
|
|
5281
|
+
driver.licenceInfo.licenceType = DriverLicenceTypes.G;
|
|
5282
|
+
}
|
|
5283
|
+
else {
|
|
5284
|
+
driver.licenceInfo.licenceType = DriverLicenceTypes.G2;
|
|
5285
|
+
}
|
|
5286
|
+
}
|
|
5287
|
+
else if (receivedG) {
|
|
5288
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
|
|
5289
|
+
driver.licenceInfo.licenceType = DriverLicenceTypes.G;
|
|
5290
|
+
}
|
|
5291
|
+
else {
|
|
5292
|
+
driver.licenceInfo.licenceType = DriverLicenceTypes.G1;
|
|
5293
|
+
}
|
|
5294
|
+
}
|
|
5295
|
+
else if (firstClass === DriverLicenceTypes.G2) {
|
|
5296
|
+
// G2 path: Q1 (first licence) date is in g2LicenceYear/Month.
|
|
5297
|
+
driver.licenceInfo.g1LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, +birthDay + 1);
|
|
5298
|
+
driver.licenceInfo.g2LicenceDate = addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, +birthDay + 1);
|
|
5299
|
+
if (receivedG) {
|
|
5300
|
+
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
|
|
5301
|
+
driver.licenceInfo.licenceType = DriverLicenceTypes.G;
|
|
5302
|
+
}
|
|
5303
|
+
else {
|
|
5304
|
+
driver.licenceInfo.licenceType = DriverLicenceTypes.G2;
|
|
5305
|
+
}
|
|
5306
|
+
}
|
|
5307
|
+
deleteLicenceDates();
|
|
5308
|
+
}
|
|
5309
|
+
else if (isOnlyG) {
|
|
5218
5310
|
if (driver.licenceInfo.licenceType === DriverLicenceTypes.G) {
|
|
5219
5311
|
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
|
|
5220
5312
|
delete driver.licenceInfo.g1LicenceDate;
|
|
@@ -5244,6 +5336,51 @@ const CarQuoteDataHandler = () => {
|
|
|
5244
5336
|
deleteLicenceDates();
|
|
5245
5337
|
}
|
|
5246
5338
|
}
|
|
5339
|
+
if (isOntarioMyChoiceLicence) {
|
|
5340
|
+
const { receivedG2, receivedG } = driver.licenceInfo;
|
|
5341
|
+
const g1Date = driver.licenceInfo.g1LicenceDate;
|
|
5342
|
+
const g2Date = driver.licenceInfo.g2LicenceDate;
|
|
5343
|
+
const gDate = driver.licenceInfo.gLicenceDate;
|
|
5344
|
+
const training = !!driver.licenceInfo.passedDriverTraining;
|
|
5345
|
+
const hasG1 = driver.licenceInfo.licenceType === DriverLicenceTypes.G1 || !!g1Date;
|
|
5346
|
+
const hasG2 = !!g2Date || receivedG2;
|
|
5347
|
+
const hasG = !!gDate || receivedG;
|
|
5348
|
+
let outside = false;
|
|
5349
|
+
if (hasG1 && hasG2 && g1Date && g2Date) {
|
|
5350
|
+
const monthsG1toG2 = getDifferenceInMonths(g2Date, g1Date);
|
|
5351
|
+
if (!training && monthsG1toG2 < 12)
|
|
5352
|
+
outside = true;
|
|
5353
|
+
if (training && monthsG1toG2 < 8)
|
|
5354
|
+
outside = true;
|
|
5355
|
+
}
|
|
5356
|
+
if (hasG1 && hasG && g1Date && gDate) {
|
|
5357
|
+
const monthsG1toG = getDifferenceInMonths(gDate, g1Date);
|
|
5358
|
+
if (!training && monthsG1toG < 24)
|
|
5359
|
+
outside = true;
|
|
5360
|
+
if (training && monthsG1toG < 20)
|
|
5361
|
+
outside = true;
|
|
5362
|
+
}
|
|
5363
|
+
if (hasG2 && hasG && g2Date && gDate) {
|
|
5364
|
+
const monthsG2toG = getDifferenceInMonths(gDate, g2Date);
|
|
5365
|
+
if (monthsG2toG < 12)
|
|
5366
|
+
outside = true;
|
|
5367
|
+
}
|
|
5368
|
+
if (receivedG2 === undefined && !!g2Date)
|
|
5369
|
+
outside = true;
|
|
5370
|
+
if (hasG1 && hasG && !hasG2)
|
|
5371
|
+
outside = true;
|
|
5372
|
+
driver.licenceInfo.outsideExp = outside;
|
|
5373
|
+
delete driver.licenceInfo.receivedG2;
|
|
5374
|
+
delete driver.licenceInfo.receivedG;
|
|
5375
|
+
// API only accepts passed_driver_training for G2 licence type
|
|
5376
|
+
if (driver.licenceInfo.licenceType !== DriverLicenceTypes.G2) {
|
|
5377
|
+
delete driver.licenceInfo.passedDriverTraining;
|
|
5378
|
+
}
|
|
5379
|
+
}
|
|
5380
|
+
else {
|
|
5381
|
+
driver.licenceInfo.outsideExp = !!driver.licenceInfo.previousLicence;
|
|
5382
|
+
}
|
|
5383
|
+
delete driver.licenceInfo.previousLicence;
|
|
5247
5384
|
delete driver.birthYear;
|
|
5248
5385
|
delete driver.birthMonth;
|
|
5249
5386
|
delete driver.birthDay;
|
|
@@ -5287,29 +5424,67 @@ const CarQuoteDataHandler = () => {
|
|
|
5287
5424
|
driver.ticketList = driver.ticketList?.map((listItem) => ({
|
|
5288
5425
|
reason: listItem.ticketReason,
|
|
5289
5426
|
ticketDate: addDayToDate(`${listItem.ticketYear}-${listItem.ticketMonth}`, +birthDay + 1),
|
|
5427
|
+
...(listItem.speed !== undefined ? { speed: listItem.speed } : {}),
|
|
5290
5428
|
}));
|
|
5291
5429
|
}
|
|
5292
5430
|
return driver;
|
|
5293
5431
|
});
|
|
5294
|
-
|
|
5432
|
+
// Build a complete set of vehlinks combining primary assignments + occasional assignments
|
|
5433
|
+
const buildVehlinks = () => {
|
|
5434
|
+
const driverCount = requestBody.drivers.length;
|
|
5435
|
+
const vehicleCount = requestBody.vehicles.length;
|
|
5436
|
+
const result = [];
|
|
5437
|
+
for (let vehicleIndex = 0; vehicleIndex < vehicleCount; vehicleIndex++) {
|
|
5438
|
+
const primaryDriverIndex = requestBody.vehlinks[vehicleIndex]?.driverIndex ?? 0;
|
|
5439
|
+
// Primary driver for this vehicle
|
|
5440
|
+
result.push({
|
|
5441
|
+
driverIndex: Number(primaryDriverIndex + 1),
|
|
5442
|
+
vehicleIndex: Number(vehicleIndex + 1),
|
|
5443
|
+
priority: DriverPriorityTypes.Prn,
|
|
5444
|
+
});
|
|
5445
|
+
if (driverCount > 1) {
|
|
5446
|
+
for (let driverIndex = 0; driverIndex < driverCount; driverIndex++) {
|
|
5447
|
+
if (driverIndex === primaryDriverIndex)
|
|
5448
|
+
continue;
|
|
5449
|
+
if (vehicleCount === 1) {
|
|
5450
|
+
// f) All non-primary drivers are occasional on the only vehicle
|
|
5451
|
+
result.push({
|
|
5452
|
+
driverIndex: Number(driverIndex + 1),
|
|
5453
|
+
vehicleIndex: Number(vehicleIndex + 1),
|
|
5454
|
+
priority: DriverPriorityTypes.Occ,
|
|
5455
|
+
});
|
|
5456
|
+
}
|
|
5457
|
+
else {
|
|
5458
|
+
// g-k) Use user-selected vehicle for extra drivers; skip if they are primary on another vehicle
|
|
5459
|
+
const isPrimaryElsewhere = requestBody.vehlinks.some((l) => l.driverIndex === driverIndex && l.vehicleIndex !== vehicleIndex);
|
|
5460
|
+
if (isPrimaryElsewhere)
|
|
5461
|
+
continue;
|
|
5462
|
+
const occAssignment = discount.occVehlinks?.find((l) => l.driverIndex === driverIndex);
|
|
5463
|
+
const occVehicleIndex = occAssignment ? occAssignment.vehicleIndex : 0;
|
|
5464
|
+
if (occVehicleIndex === vehicleIndex) {
|
|
5465
|
+
result.push({
|
|
5466
|
+
driverIndex: Number(driverIndex + 1),
|
|
5467
|
+
vehicleIndex: Number(vehicleIndex + 1),
|
|
5468
|
+
priority: DriverPriorityTypes.Occ,
|
|
5469
|
+
});
|
|
5470
|
+
}
|
|
5471
|
+
}
|
|
5472
|
+
}
|
|
5473
|
+
}
|
|
5474
|
+
}
|
|
5475
|
+
return result;
|
|
5476
|
+
};
|
|
5295
5477
|
// vehicle
|
|
5296
|
-
requestBody.vehicles = requestBody.vehicles.map((vehicleItem
|
|
5478
|
+
requestBody.vehicles = requestBody.vehicles.map((vehicleItem) => {
|
|
5297
5479
|
const vehicle = { ...vehicleItem, ...postalState.item };
|
|
5298
5480
|
if (!vehicle.redirectURL) {
|
|
5299
5481
|
delete vehicle.redirectURL;
|
|
5300
5482
|
}
|
|
5301
|
-
const vehlink = requestBody.drivers.map((_, driverIndex) => ({
|
|
5302
|
-
driverIndex: Number(driverIndex + 1),
|
|
5303
|
-
vehicleIndex: Number(vehicleIndex + 1),
|
|
5304
|
-
priority: requestBody.vehlinks[vehicleIndex].driverIndex === driverIndex
|
|
5305
|
-
? DriverPriorityTypes.Prn : DriverPriorityTypes.Occ,
|
|
5306
|
-
}));
|
|
5307
|
-
localVehlinks.push(...vehlink);
|
|
5308
5483
|
vehicle.purchaseDate = addDayToDate(`${vehicle.purchaseYear}-${vehicle.purchaseMonth}`);
|
|
5309
5484
|
delete vehicle.purchaseYear;
|
|
5310
5485
|
delete vehicle.purchaseMonth;
|
|
5311
5486
|
delete vehicle.purchaseDay;
|
|
5312
|
-
if (vehicle.primaryUse === VehiclePrimaryUseTypes.Personal) {
|
|
5487
|
+
if (vehicle.primaryUse === VehiclePrimaryUseTypes.Personal || vehicle.businessUsePercent) {
|
|
5313
5488
|
delete vehicle.distanceBusiness;
|
|
5314
5489
|
}
|
|
5315
5490
|
if (!vehicle.collision.coverage) {
|
|
@@ -5330,8 +5505,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5330
5505
|
const transformedVehicle = { ...vehiclePayload };
|
|
5331
5506
|
if (accidentbenefits) {
|
|
5332
5507
|
const { baseCoverage, additionalCoverages } = accidentbenefits;
|
|
5333
|
-
if (isAbReformEligible
|
|
5334
|
-
&& (baseCoverage !== 'minimum_required' || additionalCoverages.length > 0)) {
|
|
5508
|
+
if (isAbReformEligible && (baseCoverage !== 'minimum_required' || additionalCoverages.length > 0)) {
|
|
5335
5509
|
transformedVehicle.accidentBenefits = {
|
|
5336
5510
|
baseCoverage,
|
|
5337
5511
|
additionalCoverages,
|
|
@@ -5341,7 +5515,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5341
5515
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5342
5516
|
return transformedVehicle;
|
|
5343
5517
|
});
|
|
5344
|
-
requestBody.vehlinks =
|
|
5518
|
+
requestBody.vehlinks = buildVehlinks();
|
|
5345
5519
|
return {
|
|
5346
5520
|
...requestBody,
|
|
5347
5521
|
};
|
|
@@ -5486,7 +5660,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5486
5660
|
});
|
|
5487
5661
|
dispatchAppLoaderState({ type: StoreConfigAppLoaderActionTypes.AppLoaderClose });
|
|
5488
5662
|
};
|
|
5489
|
-
return
|
|
5663
|
+
return {
|
|
5490
5664
|
status,
|
|
5491
5665
|
successMessage,
|
|
5492
5666
|
responseData,
|
|
@@ -5496,7 +5670,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5496
5670
|
postRequestQuoteOnliaUrl,
|
|
5497
5671
|
postRequestQuote,
|
|
5498
5672
|
postPerformLeadsAction,
|
|
5499
|
-
}
|
|
5673
|
+
};
|
|
5500
5674
|
};
|
|
5501
5675
|
|
|
5502
5676
|
const HomeQuoteDataHandler = () => {
|
|
@@ -5627,6 +5801,7 @@ const HomeQuoteDataHandler = () => {
|
|
|
5627
5801
|
quoterInfo: discount.quoterInfo || {},
|
|
5628
5802
|
};
|
|
5629
5803
|
requestBody.quoterInfo.recalculate = isRecalc;
|
|
5804
|
+
requestBody.quoterInfo.initial = !isRecalc;
|
|
5630
5805
|
if (requestBody.quoterInfo?.utmSource === '') {
|
|
5631
5806
|
delete requestBody.quoterInfo.utmSource;
|
|
5632
5807
|
}
|
|
@@ -5944,7 +6119,7 @@ const useValidationVehicle = () => {
|
|
|
5944
6119
|
vehicleState.items.forEach((item) => {
|
|
5945
6120
|
Object.keys(item).map((key) => {
|
|
5946
6121
|
if (checkableKeys.includes(key) && !item[key]) {
|
|
5947
|
-
if (!(item.primaryUse === VehiclePrimaryUseTypes.Personal
|
|
6122
|
+
if (!(key === 'distanceBusiness' && (item.primaryUse === VehiclePrimaryUseTypes.Personal || item.businessUsePercent))) {
|
|
5948
6123
|
errors.push(key);
|
|
5949
6124
|
}
|
|
5950
6125
|
}
|