@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
|
@@ -14,6 +14,7 @@ export declare enum StoreFormCarDiscountActionTypes {
|
|
|
14
14
|
FormCarDiscountVehlinkSelect = "FormCarDiscountVehlinkSelect",
|
|
15
15
|
FormCarDiscountVehlinkByVehicleDelete = "FormCarDiscountVehlinkByVehicleDelete",
|
|
16
16
|
FormCarDiscountVehlinkByDriverDelete = "FormCarDiscountVehlinkByDriverDelete",
|
|
17
|
+
FormCarDiscountOccVehlinkSelect = "FormCarDiscountOccVehlinkSelect",
|
|
17
18
|
FormCarDiscountQuoterEmailStatusSet = "FormCarDiscountQuoterEmailStatusSet",
|
|
18
19
|
FormCarDiscountValidate = "FormCarDiscountValidate",
|
|
19
20
|
FormCarDiscountValidateSet = "FormCarDiscountValidateSet",
|
package/dist/cjs/states/reducers/states/formStates/FormCarState/DiscountState/interfaces.d.ts
CHANGED
|
@@ -38,6 +38,10 @@ export interface FormCarDiscountStateInterface extends StateBaseInterface {
|
|
|
38
38
|
policyStartYear?: string;
|
|
39
39
|
quoterInfo: DiscountQuoterInfoInterface;
|
|
40
40
|
vehlinks: DiscountVehLinkInterface[];
|
|
41
|
+
occVehlinks: {
|
|
42
|
+
driverIndex: number;
|
|
43
|
+
vehicleIndex: number;
|
|
44
|
+
}[];
|
|
41
45
|
}
|
|
42
46
|
export type FormCarDiscountStateActionType = {
|
|
43
47
|
type: StoreFormCarDiscountActionTypes.FormCarDiscountValidate;
|
|
@@ -78,6 +82,13 @@ export type FormCarDiscountStateActionType = {
|
|
|
78
82
|
driverIndex: number;
|
|
79
83
|
};
|
|
80
84
|
localIndex?: string;
|
|
85
|
+
} | {
|
|
86
|
+
type: StoreFormCarDiscountActionTypes.FormCarDiscountOccVehlinkSelect;
|
|
87
|
+
payload: {
|
|
88
|
+
driverIndex: number;
|
|
89
|
+
vehicleIndex: number;
|
|
90
|
+
};
|
|
91
|
+
localIndex?: string;
|
|
81
92
|
} | {
|
|
82
93
|
type: StoreFormCarDiscountActionTypes.FormCarDiscountMultiplePoliciesSelect;
|
|
83
94
|
payload: {
|
|
@@ -3,5 +3,9 @@ export declare enum StoreFormCarDriverInsuranceActionTypes {
|
|
|
3
3
|
FormCarDriverListedYearSelect = "FormCarDriverListedYearSelect",
|
|
4
4
|
FormCarDriverListedMonthSelect = "FormCarDriverListedMonthSelect",
|
|
5
5
|
FormCarDriverInsuredSelect = "FormCarDriverInsuredSelect",
|
|
6
|
-
FormCarDriverInsuredDateSelect = "FormCarDriverInsuredDateSelect"
|
|
6
|
+
FormCarDriverInsuredDateSelect = "FormCarDriverInsuredDateSelect",
|
|
7
|
+
FormCarDriverNotCurrentlyInsuredSelect = "FormCarDriverNotCurrentlyInsuredSelect",
|
|
8
|
+
FormCarDriverLastPolicyEndYearSelect = "FormCarDriverLastPolicyEndYearSelect",
|
|
9
|
+
FormCarDriverLastPolicyEndMonthSelect = "FormCarDriverLastPolicyEndMonthSelect",
|
|
10
|
+
FormCarDriverLastPolicyCancelReasonSelect = "FormCarDriverLastPolicyCancelReasonSelect"
|
|
7
11
|
}
|
|
@@ -30,6 +30,30 @@ export type FormCarDriverInsuranceStateActionType = {
|
|
|
30
30
|
insuredDate: string;
|
|
31
31
|
};
|
|
32
32
|
localIndex?: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: StoreFormCarDriverInsuranceActionTypes.FormCarDriverNotCurrentlyInsuredSelect;
|
|
35
|
+
payload: {
|
|
36
|
+
notCurrentlyInsured: boolean;
|
|
37
|
+
};
|
|
38
|
+
localIndex?: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: StoreFormCarDriverInsuranceActionTypes.FormCarDriverLastPolicyEndYearSelect;
|
|
41
|
+
payload: {
|
|
42
|
+
lastPolicyEndYear: string;
|
|
43
|
+
};
|
|
44
|
+
localIndex?: string;
|
|
45
|
+
} | {
|
|
46
|
+
type: StoreFormCarDriverInsuranceActionTypes.FormCarDriverLastPolicyEndMonthSelect;
|
|
47
|
+
payload: {
|
|
48
|
+
lastPolicyEndMonth: string;
|
|
49
|
+
};
|
|
50
|
+
localIndex?: string;
|
|
51
|
+
} | {
|
|
52
|
+
type: StoreFormCarDriverInsuranceActionTypes.FormCarDriverLastPolicyCancelReasonSelect;
|
|
53
|
+
payload: {
|
|
54
|
+
lastPolicyCancelReason: string;
|
|
55
|
+
};
|
|
56
|
+
localIndex?: string;
|
|
33
57
|
};
|
|
34
58
|
export type FormCarDriverInsuranceStateReducerInterface = (state: FormCarDriverStateInterface, action: FormCarDriverInsuranceStateActionType) => FormCarDriverStateInterface;
|
|
35
59
|
export interface FormCarDriverInsuranceHookInterface {
|
|
@@ -9,6 +9,8 @@ export declare enum StoreFormCarDriverLicenceActionTypes {
|
|
|
9
9
|
FormCarDriverG1LicenceMaxSelect = "FormCarDriverG1LicenceMaxSelect",
|
|
10
10
|
FormCarDriverTrainingSelect = "FormCarDriverTrainingSelect",
|
|
11
11
|
FormCarDriverPreviousLicenceSelect = "FormCarDriverPreviousLicenceSelect",
|
|
12
|
+
FormCarDriverReceivedG2Select = "FormCarDriverReceivedG2Select",
|
|
13
|
+
FormCarDriverReceivedGSelect = "FormCarDriverReceivedGSelect",
|
|
12
14
|
FormCarDriverLicenceYearSelect = "FormCarDriverLicenceYearSelect",
|
|
13
15
|
FormCarDriverLicenceMonthSelect = "FormCarDriverLicenceMonthSelect"
|
|
14
16
|
}
|
|
@@ -36,6 +36,18 @@ export type FormCarDriverLicenceStateActionType = {
|
|
|
36
36
|
previousLicence: boolean;
|
|
37
37
|
};
|
|
38
38
|
localIndex?: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: StoreFormCarDriverLicenceActionTypes.FormCarDriverReceivedG2Select;
|
|
41
|
+
payload: {
|
|
42
|
+
receivedG2: boolean;
|
|
43
|
+
};
|
|
44
|
+
localIndex?: string;
|
|
45
|
+
} | {
|
|
46
|
+
type: StoreFormCarDriverLicenceActionTypes.FormCarDriverReceivedGSelect;
|
|
47
|
+
payload: {
|
|
48
|
+
receivedG: boolean;
|
|
49
|
+
};
|
|
50
|
+
localIndex?: string;
|
|
39
51
|
} | {
|
|
40
52
|
type: StoreFormCarDriverLicenceActionTypes.FormCarDriverGLicenceMinSelect;
|
|
41
53
|
payload: {
|
|
@@ -3,6 +3,7 @@ export declare enum StoreFormCarDriverTicketActionTypes {
|
|
|
3
3
|
FormCarDriverTrafficTicketReasonSelect = "FormCarDriverTrafficTicketReasonSelect",
|
|
4
4
|
FormCarDriverTrafficTicketYearSelect = "FormCarDriverTrafficTicketYearSelect",
|
|
5
5
|
FormCarDriverTrafficTicketMonthSelect = "FormCarDriverTrafficTicketMonthSelect",
|
|
6
|
+
FormCarDriverTrafficTicketSpeedSelect = "FormCarDriverTrafficTicketSpeedSelect",
|
|
6
7
|
FormCarDriverTrafficTicketAdd = "FormCarDriverTrafficTicketAdd",
|
|
7
8
|
FormCarDriverTrafficTicketDelete = "FormCarDriverTrafficTicketDelete"
|
|
8
9
|
}
|
|
@@ -37,6 +37,13 @@ export type FormCarDriverTicketStateActionType = {
|
|
|
37
37
|
index: number;
|
|
38
38
|
};
|
|
39
39
|
localIndex?: string;
|
|
40
|
+
} | {
|
|
41
|
+
type: StoreFormCarDriverTicketActionTypes.FormCarDriverTrafficTicketSpeedSelect;
|
|
42
|
+
payload: {
|
|
43
|
+
speed: number;
|
|
44
|
+
index: number;
|
|
45
|
+
};
|
|
46
|
+
localIndex?: string;
|
|
40
47
|
};
|
|
41
48
|
export type FormCarDriverTicketStateReducerInterface = (state: FormCarDriverStateInterface, action: FormCarDriverTicketStateActionType) => FormCarDriverStateInterface;
|
|
42
49
|
export interface FormCarDriverTicketHookInterface {
|
|
@@ -15,6 +15,9 @@ export interface DriverLicenceInterface {
|
|
|
15
15
|
gLicenceMonth?: string;
|
|
16
16
|
passedDriverTraining?: boolean;
|
|
17
17
|
previousLicence?: boolean;
|
|
18
|
+
outsideExp?: boolean;
|
|
19
|
+
receivedG2?: boolean;
|
|
20
|
+
receivedG?: boolean;
|
|
18
21
|
}
|
|
19
22
|
export interface DriverCancellationItemInterface {
|
|
20
23
|
reason: string;
|
|
@@ -47,6 +50,7 @@ export interface TicketItemInterface {
|
|
|
47
50
|
ticketDate: string;
|
|
48
51
|
ticketYear?: string;
|
|
49
52
|
ticketMonth?: string;
|
|
53
|
+
speed?: number;
|
|
50
54
|
}
|
|
51
55
|
export type DriverListItemType = DriverCancellationItemInterface | SuspensionItemInterface | AccidentItemInterface | TicketItemInterface;
|
|
52
56
|
export interface DriverMinMaxDates {
|
|
@@ -82,6 +86,11 @@ export interface DriverItemInterface {
|
|
|
82
86
|
insured: boolean;
|
|
83
87
|
insuredDate?: string;
|
|
84
88
|
insuredYear?: string;
|
|
89
|
+
notCurrentlyInsured?: boolean;
|
|
90
|
+
lastPolicyEndYear?: string;
|
|
91
|
+
lastPolicyEndMonth?: string;
|
|
92
|
+
lastPolicyEndDate?: string;
|
|
93
|
+
lastPolicyCancelReason?: string;
|
|
85
94
|
insuranceCancellation: boolean;
|
|
86
95
|
insuranceCancellationList?: DriverCancellationItemInterface[];
|
|
87
96
|
licenceSuspension: boolean;
|
|
@@ -19,6 +19,7 @@ export declare enum StoreFormCarVehicleActionTypes {
|
|
|
19
19
|
FormCarParkingLocationSelect = "FormCarParkingLocationSelect",
|
|
20
20
|
FormCarDailyDistanceSelect = "FormCarDailyDistanceSelect",
|
|
21
21
|
FormCarBusinessDistanceSelect = "FormCarBusinessDistanceSelect",
|
|
22
|
+
FormCarBusinessUsePercentSelect = "FormCarBusinessUsePercentSelect",
|
|
22
23
|
FormCarYearlyDistanceSelect = "FormCarYearlyDistanceSelect",
|
|
23
24
|
FormCarComprehensiveCoverageSelect = "FormCarComprehensiveCoverageSelect",
|
|
24
25
|
FormCarComprehensiveDeductibleSelect = "FormCarComprehensiveDeductibleSelect",
|
package/dist/cjs/states/reducers/states/formStates/FormCarState/VehicleState/interfaces.d.ts
CHANGED
|
@@ -44,6 +44,7 @@ export interface VehicleItemInterface {
|
|
|
44
44
|
primaryUse: string;
|
|
45
45
|
distanceDaily: number;
|
|
46
46
|
distanceBusiness?: number;
|
|
47
|
+
businessUsePercent?: string;
|
|
47
48
|
distanceYearly: number;
|
|
48
49
|
comprehensive: VehicleComprehensiveInterface;
|
|
49
50
|
collision: VehicleCollisionInterface;
|
|
@@ -182,6 +183,12 @@ export type FormCarVehicleStateActionType = {
|
|
|
182
183
|
distanceBusiness: string;
|
|
183
184
|
};
|
|
184
185
|
localIndex?: string;
|
|
186
|
+
} | {
|
|
187
|
+
type: StoreFormCarVehicleActionTypes.FormCarBusinessUsePercentSelect;
|
|
188
|
+
payload: {
|
|
189
|
+
businessUsePercent: string;
|
|
190
|
+
};
|
|
191
|
+
localIndex?: string;
|
|
185
192
|
} | {
|
|
186
193
|
type: StoreFormCarVehicleActionTypes.FormCarYearlyDistanceSelect;
|
|
187
194
|
payload: {
|
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:
|
|
@@ -5148,9 +5177,6 @@ const CarQuoteDataHandler = () => {
|
|
|
5148
5177
|
if (driver.applicantRelationship === '') {
|
|
5149
5178
|
delete driver.applicantRelationship;
|
|
5150
5179
|
}
|
|
5151
|
-
if (driver.gender === GenderTypes.Other) {
|
|
5152
|
-
driver.gender = GenderTypes.Male;
|
|
5153
|
-
}
|
|
5154
5180
|
// ==================================
|
|
5155
5181
|
// thebig additional properties
|
|
5156
5182
|
if (appConfigState.appType === AppTypes.TheBig) {
|
|
@@ -5203,8 +5229,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5203
5229
|
delete driver.insuredDate;
|
|
5204
5230
|
}
|
|
5205
5231
|
const defaultMinDate = driver.dateOfBirth && driver.licenceInfo.firstLicenceAge
|
|
5206
|
-
? addYearsToDate(driver.dateOfBirth, +driver.licenceInfo.firstLicenceAge)
|
|
5207
|
-
: '';
|
|
5232
|
+
? addYearsToDate(driver.dateOfBirth, +driver.licenceInfo.firstLicenceAge) : '';
|
|
5208
5233
|
const isOnlyG = compareDates(defaultMinDate, configState.minDates.g.specialDate) < 0;
|
|
5209
5234
|
// licence
|
|
5210
5235
|
const deleteLicenceDates = () => {
|
|
@@ -5215,8 +5240,73 @@ const CarQuoteDataHandler = () => {
|
|
|
5215
5240
|
delete driver.licenceInfo.g2LicenceYear;
|
|
5216
5241
|
delete driver.licenceInfo.g2LicenceMonth;
|
|
5217
5242
|
};
|
|
5218
|
-
const { g1LicenceMonth, g1LicenceYear, g2LicenceMonth, g2LicenceYear, gLicenceYear, gLicenceMonth } = licenceInfo;
|
|
5219
|
-
|
|
5243
|
+
const { g1LicenceMonth, g1LicenceYear, g2LicenceMonth, g2LicenceYear, gLicenceYear, gLicenceMonth, } = licenceInfo;
|
|
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) {
|
|
5220
5310
|
if (driver.licenceInfo.licenceType === DriverLicenceTypes.G) {
|
|
5221
5311
|
driver.licenceInfo.gLicenceDate = addDayToDate(`${gLicenceYear}-${gLicenceMonth}`, +birthDay + 1);
|
|
5222
5312
|
delete driver.licenceInfo.g1LicenceDate;
|
|
@@ -5246,6 +5336,51 @@ const CarQuoteDataHandler = () => {
|
|
|
5246
5336
|
deleteLicenceDates();
|
|
5247
5337
|
}
|
|
5248
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;
|
|
5249
5384
|
delete driver.birthYear;
|
|
5250
5385
|
delete driver.birthMonth;
|
|
5251
5386
|
delete driver.birthDay;
|
|
@@ -5289,30 +5424,67 @@ const CarQuoteDataHandler = () => {
|
|
|
5289
5424
|
driver.ticketList = driver.ticketList?.map((listItem) => ({
|
|
5290
5425
|
reason: listItem.ticketReason,
|
|
5291
5426
|
ticketDate: addDayToDate(`${listItem.ticketYear}-${listItem.ticketMonth}`, +birthDay + 1),
|
|
5427
|
+
...(listItem.speed !== undefined ? { speed: listItem.speed } : {}),
|
|
5292
5428
|
}));
|
|
5293
5429
|
}
|
|
5294
5430
|
return driver;
|
|
5295
5431
|
});
|
|
5296
|
-
|
|
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
|
+
};
|
|
5297
5477
|
// vehicle
|
|
5298
|
-
requestBody.vehicles = requestBody.vehicles.map((vehicleItem
|
|
5478
|
+
requestBody.vehicles = requestBody.vehicles.map((vehicleItem) => {
|
|
5299
5479
|
const vehicle = { ...vehicleItem, ...postalState.item };
|
|
5300
5480
|
if (!vehicle.redirectURL) {
|
|
5301
5481
|
delete vehicle.redirectURL;
|
|
5302
5482
|
}
|
|
5303
|
-
const vehlink = requestBody.drivers.map((_, driverIndex) => ({
|
|
5304
|
-
driverIndex: Number(driverIndex + 1),
|
|
5305
|
-
vehicleIndex: Number(vehicleIndex + 1),
|
|
5306
|
-
priority: requestBody.vehlinks[vehicleIndex].driverIndex === driverIndex
|
|
5307
|
-
? DriverPriorityTypes.Prn
|
|
5308
|
-
: DriverPriorityTypes.Occ,
|
|
5309
|
-
}));
|
|
5310
|
-
localVehlinks.push(...vehlink);
|
|
5311
5483
|
vehicle.purchaseDate = addDayToDate(`${vehicle.purchaseYear}-${vehicle.purchaseMonth}`);
|
|
5312
5484
|
delete vehicle.purchaseYear;
|
|
5313
5485
|
delete vehicle.purchaseMonth;
|
|
5314
5486
|
delete vehicle.purchaseDay;
|
|
5315
|
-
if (vehicle.primaryUse === VehiclePrimaryUseTypes.Personal) {
|
|
5487
|
+
if (vehicle.primaryUse === VehiclePrimaryUseTypes.Personal || vehicle.businessUsePercent) {
|
|
5316
5488
|
delete vehicle.distanceBusiness;
|
|
5317
5489
|
}
|
|
5318
5490
|
if (!vehicle.collision.coverage) {
|
|
@@ -5343,7 +5515,7 @@ const CarQuoteDataHandler = () => {
|
|
|
5343
5515
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5344
5516
|
return transformedVehicle;
|
|
5345
5517
|
});
|
|
5346
|
-
requestBody.vehlinks =
|
|
5518
|
+
requestBody.vehlinks = buildVehlinks();
|
|
5347
5519
|
return {
|
|
5348
5520
|
...requestBody,
|
|
5349
5521
|
};
|
|
@@ -5947,7 +6119,7 @@ const useValidationVehicle = () => {
|
|
|
5947
6119
|
vehicleState.items.forEach((item) => {
|
|
5948
6120
|
Object.keys(item).map((key) => {
|
|
5949
6121
|
if (checkableKeys.includes(key) && !item[key]) {
|
|
5950
|
-
if (!(item.primaryUse === VehiclePrimaryUseTypes.Personal
|
|
6122
|
+
if (!(key === 'distanceBusiness' && (item.primaryUse === VehiclePrimaryUseTypes.Personal || item.businessUsePercent))) {
|
|
5951
6123
|
errors.push(key);
|
|
5952
6124
|
}
|
|
5953
6125
|
}
|