@mychoice/mychoice-sdk-store 2.2.9 → 2.2.10
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/handlers/autofill/index.d.ts +3 -0
- package/dist/cjs/handlers/autofill/types.d.ts +76 -0
- package/dist/cjs/handlers/autofill/useAutofillCarForm.d.ts +8 -0
- package/dist/cjs/handlers/autofill/utils.d.ts +94 -0
- package/dist/cjs/handlers/index.d.ts +1 -0
- package/dist/cjs/index.js +472 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/handlers/autofill/index.d.ts +3 -0
- package/dist/esm/handlers/autofill/types.d.ts +76 -0
- package/dist/esm/handlers/autofill/useAutofillCarForm.d.ts +8 -0
- package/dist/esm/handlers/autofill/utils.d.ts +94 -0
- package/dist/esm/handlers/index.d.ts +1 -0
- package/dist/esm/index.js +467 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +180 -1
- package/package.json +2 -2
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export interface AutofillDriver {
|
|
2
|
+
gender: string;
|
|
3
|
+
listed: boolean;
|
|
4
|
+
ticket: boolean;
|
|
5
|
+
insured: boolean;
|
|
6
|
+
accident: boolean;
|
|
7
|
+
first_name: string;
|
|
8
|
+
occupation: number;
|
|
9
|
+
listed_year?: string;
|
|
10
|
+
insured_year?: string;
|
|
11
|
+
licence_info: {
|
|
12
|
+
licence_type: string;
|
|
13
|
+
g_licence_date?: string;
|
|
14
|
+
g1_licence_date?: string;
|
|
15
|
+
g2_licence_date?: string;
|
|
16
|
+
first_licence_age: number;
|
|
17
|
+
};
|
|
18
|
+
date_of_birth: string;
|
|
19
|
+
marital_status: string;
|
|
20
|
+
licence_suspension: boolean;
|
|
21
|
+
insurance_cancellation: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface AutofillVehicleCoverage {
|
|
24
|
+
coverage: boolean;
|
|
25
|
+
deductible?: number;
|
|
26
|
+
limit?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface AutofillVehicle {
|
|
29
|
+
city: string;
|
|
30
|
+
make: string;
|
|
31
|
+
year: number;
|
|
32
|
+
model: string;
|
|
33
|
+
leased: boolean;
|
|
34
|
+
condition: string;
|
|
35
|
+
liability: AutofillVehicleCoverage;
|
|
36
|
+
collision: AutofillVehicleCoverage;
|
|
37
|
+
lossofuse: AutofillVehicleCoverage;
|
|
38
|
+
comprehensive: AutofillVehicleCoverage;
|
|
39
|
+
liabilityfordamage: AutofillVehicleCoverage;
|
|
40
|
+
limitedwaiverofdepreciation: AutofillVehicleCoverage;
|
|
41
|
+
postal_code: string;
|
|
42
|
+
primary_use: string;
|
|
43
|
+
winter_tires: boolean;
|
|
44
|
+
purchase_date: string;
|
|
45
|
+
distance_daily: number;
|
|
46
|
+
distance_yearly: number;
|
|
47
|
+
parking_location: string;
|
|
48
|
+
distance_business: number;
|
|
49
|
+
location_index: number;
|
|
50
|
+
bodytype: string;
|
|
51
|
+
ext_vicc: string;
|
|
52
|
+
vicc_code: string;
|
|
53
|
+
}
|
|
54
|
+
export interface AutofillVehLink {
|
|
55
|
+
priority: string;
|
|
56
|
+
driver_index: number;
|
|
57
|
+
vehicle_index: number;
|
|
58
|
+
}
|
|
59
|
+
export interface AutofillData {
|
|
60
|
+
uuid: string;
|
|
61
|
+
drivers: AutofillDriver[];
|
|
62
|
+
vehicles: AutofillVehicle[];
|
|
63
|
+
vehlinks: AutofillVehLink[];
|
|
64
|
+
email_to: string;
|
|
65
|
+
policy_start: string;
|
|
66
|
+
province_code: string;
|
|
67
|
+
caa_member_discount: boolean;
|
|
68
|
+
app_install_discount: boolean;
|
|
69
|
+
multiple_policies_discount: boolean;
|
|
70
|
+
}
|
|
71
|
+
export interface MappedAutofillData {
|
|
72
|
+
drivers: any[];
|
|
73
|
+
vehicles: any[];
|
|
74
|
+
postalData: any;
|
|
75
|
+
configData: any;
|
|
76
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { AutofillData } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Parse URL-encoded JSON from query parameter
|
|
4
|
+
*/
|
|
5
|
+
export declare const parseAutofillParam: (urlEncodedJson: string) => AutofillData;
|
|
6
|
+
/**
|
|
7
|
+
* Get province name from code
|
|
8
|
+
*/
|
|
9
|
+
export declare const getProvinceName: (code: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Map autofill data to postal state format
|
|
12
|
+
*/
|
|
13
|
+
export declare const mapToPostalState: (autofillData: AutofillData) => {
|
|
14
|
+
city: string;
|
|
15
|
+
postalCode: string;
|
|
16
|
+
locationIndex: string;
|
|
17
|
+
provinceCode: string;
|
|
18
|
+
provinceName: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Map autofill data to vehicle state format
|
|
22
|
+
*/
|
|
23
|
+
export declare const mapToVehicleState: (autofillData: AutofillData) => {
|
|
24
|
+
year: string;
|
|
25
|
+
make: string;
|
|
26
|
+
model: string;
|
|
27
|
+
condition: string;
|
|
28
|
+
leased: boolean;
|
|
29
|
+
purchaseDate: string;
|
|
30
|
+
winterTires: boolean;
|
|
31
|
+
parkingLocation: string;
|
|
32
|
+
primaryUse: string;
|
|
33
|
+
distanceDaily: number;
|
|
34
|
+
distanceBusiness: number;
|
|
35
|
+
distanceYearly: number;
|
|
36
|
+
comprehensive: {
|
|
37
|
+
coverage: boolean;
|
|
38
|
+
deductible: number;
|
|
39
|
+
};
|
|
40
|
+
collision: {
|
|
41
|
+
coverage: boolean;
|
|
42
|
+
deductible: number;
|
|
43
|
+
};
|
|
44
|
+
liability: {
|
|
45
|
+
coverage: boolean;
|
|
46
|
+
limit: number;
|
|
47
|
+
};
|
|
48
|
+
lossofuse: {
|
|
49
|
+
coverage: boolean;
|
|
50
|
+
limit: number;
|
|
51
|
+
};
|
|
52
|
+
liabilityfordamage: {
|
|
53
|
+
coverage: boolean;
|
|
54
|
+
limit: number;
|
|
55
|
+
};
|
|
56
|
+
limitedwaiverofdepreciation: {
|
|
57
|
+
coverage: boolean;
|
|
58
|
+
limit: number;
|
|
59
|
+
};
|
|
60
|
+
postalCode: string;
|
|
61
|
+
locationIndex: string;
|
|
62
|
+
city: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Map autofill data to driver state format
|
|
66
|
+
*/
|
|
67
|
+
export declare const mapToDriverState: (autofillData: AutofillData) => {
|
|
68
|
+
firstName: string;
|
|
69
|
+
dateOfBirth: string;
|
|
70
|
+
maritalStatus: string;
|
|
71
|
+
gender: string;
|
|
72
|
+
occupation: number;
|
|
73
|
+
listed: boolean;
|
|
74
|
+
listedYear: string;
|
|
75
|
+
insured: boolean;
|
|
76
|
+
insuredYear: string;
|
|
77
|
+
ticket: boolean;
|
|
78
|
+
accident: boolean;
|
|
79
|
+
licenceSuspension: boolean;
|
|
80
|
+
insuranceCancellation: boolean;
|
|
81
|
+
licenceInfo: {
|
|
82
|
+
licenceType: string;
|
|
83
|
+
firstLicenceAge: number;
|
|
84
|
+
gLicenceDate: string;
|
|
85
|
+
g1LicenceDate: string;
|
|
86
|
+
g2LicenceDate: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Map autofill data to config state format
|
|
91
|
+
*/
|
|
92
|
+
export declare const mapToConfigState: (autofillData: AutofillData) => {
|
|
93
|
+
province: string;
|
|
94
|
+
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
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';
|
|
3
|
-
import { useMemo, useReducer, useState } from 'react';
|
|
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';
|
|
6
6
|
import { combineReducers, createStore, applyMiddleware } from 'redux';
|
|
@@ -6703,5 +6703,470 @@ const useValidationLifeApplicant = () => {
|
|
|
6703
6703
|
};
|
|
6704
6704
|
};
|
|
6705
6705
|
|
|
6706
|
-
|
|
6706
|
+
// Province code to name mapping
|
|
6707
|
+
const PROVINCE_NAME_MAP = {
|
|
6708
|
+
ON: 'Ontario',
|
|
6709
|
+
AB: 'Alberta',
|
|
6710
|
+
NS: 'Nova Scotia',
|
|
6711
|
+
NF: 'Newfoundland',
|
|
6712
|
+
NB: 'New Brunswick',
|
|
6713
|
+
BC: 'British Columbia',
|
|
6714
|
+
SK: 'Saskatchewan',
|
|
6715
|
+
MB: 'Manitoba',
|
|
6716
|
+
};
|
|
6717
|
+
/**
|
|
6718
|
+
* Parse URL-encoded JSON from query parameter
|
|
6719
|
+
*/
|
|
6720
|
+
const parseAutofillParam = (urlEncodedJson) => {
|
|
6721
|
+
const decoded = decodeURIComponent(urlEncodedJson);
|
|
6722
|
+
return JSON.parse(decoded);
|
|
6723
|
+
};
|
|
6724
|
+
/**
|
|
6725
|
+
* Get province name from code
|
|
6726
|
+
*/
|
|
6727
|
+
const getProvinceName = (code) => {
|
|
6728
|
+
return PROVINCE_NAME_MAP[code] || code;
|
|
6729
|
+
};
|
|
6730
|
+
/**
|
|
6731
|
+
* Map autofill data to postal state format
|
|
6732
|
+
*/
|
|
6733
|
+
const mapToPostalState = (autofillData) => {
|
|
6734
|
+
const firstVehicle = autofillData.vehicles[0];
|
|
6735
|
+
return {
|
|
6736
|
+
city: firstVehicle.city || '',
|
|
6737
|
+
postalCode: firstVehicle.postal_code || '',
|
|
6738
|
+
locationIndex: String(firstVehicle.location_index || ''),
|
|
6739
|
+
provinceCode: autofillData.province_code || '',
|
|
6740
|
+
provinceName: getProvinceName(autofillData.province_code || ''),
|
|
6741
|
+
};
|
|
6742
|
+
};
|
|
6743
|
+
/**
|
|
6744
|
+
* Map autofill data to vehicle state format
|
|
6745
|
+
*/
|
|
6746
|
+
const mapToVehicleState = (autofillData) => {
|
|
6747
|
+
const firstVehicle = autofillData.vehicles[0];
|
|
6748
|
+
return {
|
|
6749
|
+
year: String(firstVehicle.year || ''),
|
|
6750
|
+
make: firstVehicle.make || '',
|
|
6751
|
+
model: firstVehicle.model || '',
|
|
6752
|
+
condition: firstVehicle.condition || 'N',
|
|
6753
|
+
leased: firstVehicle.leased || false,
|
|
6754
|
+
purchaseDate: firstVehicle.purchase_date || '',
|
|
6755
|
+
winterTires: firstVehicle.winter_tires || false,
|
|
6756
|
+
parkingLocation: firstVehicle.parking_location || 'driveway',
|
|
6757
|
+
primaryUse: firstVehicle.primary_use || 'Personal',
|
|
6758
|
+
distanceDaily: firstVehicle.distance_daily || 0,
|
|
6759
|
+
distanceBusiness: firstVehicle.distance_business || 0,
|
|
6760
|
+
distanceYearly: firstVehicle.distance_yearly || 0,
|
|
6761
|
+
comprehensive: {
|
|
6762
|
+
coverage: firstVehicle.comprehensive?.coverage ?? true,
|
|
6763
|
+
deductible: firstVehicle.comprehensive?.deductible ?? 1000,
|
|
6764
|
+
},
|
|
6765
|
+
collision: {
|
|
6766
|
+
coverage: firstVehicle.collision?.coverage ?? true,
|
|
6767
|
+
deductible: firstVehicle.collision?.deductible ?? 1000,
|
|
6768
|
+
},
|
|
6769
|
+
liability: {
|
|
6770
|
+
coverage: firstVehicle.liability?.coverage ?? true,
|
|
6771
|
+
limit: firstVehicle.liability?.limit ?? 1000000,
|
|
6772
|
+
},
|
|
6773
|
+
lossofuse: {
|
|
6774
|
+
coverage: firstVehicle.lossofuse?.coverage ?? true,
|
|
6775
|
+
limit: firstVehicle.lossofuse?.limit ?? 2000,
|
|
6776
|
+
},
|
|
6777
|
+
liabilityfordamage: {
|
|
6778
|
+
coverage: firstVehicle.liabilityfordamage?.coverage ?? true,
|
|
6779
|
+
limit: firstVehicle.liabilityfordamage?.limit ?? 50000,
|
|
6780
|
+
},
|
|
6781
|
+
limitedwaiverofdepreciation: {
|
|
6782
|
+
coverage: firstVehicle.limitedwaiverofdepreciation?.coverage ?? true,
|
|
6783
|
+
limit: firstVehicle.limitedwaiverofdepreciation?.limit ?? 1,
|
|
6784
|
+
},
|
|
6785
|
+
postalCode: firstVehicle.postal_code || '',
|
|
6786
|
+
locationIndex: String(firstVehicle.location_index || ''),
|
|
6787
|
+
city: firstVehicle.city || '',
|
|
6788
|
+
};
|
|
6789
|
+
};
|
|
6790
|
+
/**
|
|
6791
|
+
* Map autofill data to driver state format
|
|
6792
|
+
*/
|
|
6793
|
+
const mapToDriverState = (autofillData) => {
|
|
6794
|
+
const firstDriver = autofillData.drivers[0];
|
|
6795
|
+
return {
|
|
6796
|
+
firstName: firstDriver.first_name || '',
|
|
6797
|
+
dateOfBirth: firstDriver.date_of_birth || '',
|
|
6798
|
+
maritalStatus: firstDriver.marital_status || '',
|
|
6799
|
+
gender: firstDriver.gender || '',
|
|
6800
|
+
occupation: firstDriver.occupation || 0,
|
|
6801
|
+
listed: firstDriver.listed || false,
|
|
6802
|
+
listedYear: firstDriver.listed_year || '',
|
|
6803
|
+
insured: firstDriver.insured || false,
|
|
6804
|
+
insuredYear: firstDriver.insured_year || '',
|
|
6805
|
+
ticket: firstDriver.ticket || false,
|
|
6806
|
+
accident: firstDriver.accident || false,
|
|
6807
|
+
licenceSuspension: firstDriver.licence_suspension || false,
|
|
6808
|
+
insuranceCancellation: firstDriver.insurance_cancellation || false,
|
|
6809
|
+
licenceInfo: {
|
|
6810
|
+
licenceType: (firstDriver.licence_info?.licence_type || '').toLowerCase(),
|
|
6811
|
+
firstLicenceAge: firstDriver.licence_info?.first_licence_age || 0,
|
|
6812
|
+
gLicenceDate: firstDriver.licence_info?.g_licence_date || '',
|
|
6813
|
+
g1LicenceDate: firstDriver.licence_info?.g1_licence_date || '',
|
|
6814
|
+
g2LicenceDate: firstDriver.licence_info?.g2_licence_date || '',
|
|
6815
|
+
},
|
|
6816
|
+
};
|
|
6817
|
+
};
|
|
6818
|
+
/**
|
|
6819
|
+
* Map autofill data to config state format
|
|
6820
|
+
*/
|
|
6821
|
+
const mapToConfigState = (autofillData) => {
|
|
6822
|
+
return {
|
|
6823
|
+
province: autofillData.province_code || '',
|
|
6824
|
+
};
|
|
6825
|
+
};
|
|
6826
|
+
|
|
6827
|
+
/**
|
|
6828
|
+
* Hook to initialize car insurance form with autofill data from query parameter
|
|
6829
|
+
*/
|
|
6830
|
+
const useAutofillCarForm = (options) => {
|
|
6831
|
+
const { dispatchPostalState } = useStoreFormCarPostal();
|
|
6832
|
+
const { dispatchVehicleState } = useStoreFormCarVehicle();
|
|
6833
|
+
const { configState, dispatchConfigState } = useStoreFormCarConfig();
|
|
6834
|
+
const { dispatchDriverInfoState } = useStoreFormCarDriverInfo();
|
|
6835
|
+
const { dispatchDriverLicenceState } = useStoreFormCarDriverLicence();
|
|
6836
|
+
const { dispatchDriverInsuranceState } = useStoreFormCarDriverInsurance();
|
|
6837
|
+
const { dispatchDriverSuspensionState } = useStoreFormCarDriverSuspension();
|
|
6838
|
+
const { dispatchDriverCancellationState } = useStoreFormCarDriverCancellation();
|
|
6839
|
+
const { dispatchDriverAccidentState } = useStoreFormCarDriverAccident();
|
|
6840
|
+
const { dispatchDriverTicketState } = useStoreFormCarDriverTicket();
|
|
6841
|
+
const { getVehicleMake } = useHandlerCarMake();
|
|
6842
|
+
const { getVehicleModel } = useHandlerCarModel();
|
|
6843
|
+
const { dispatchAppModalState } = useStoreAppModal();
|
|
6844
|
+
const autofillProcessedRef = useRef(false);
|
|
6845
|
+
useEffect(() => {
|
|
6846
|
+
// Prevent double execution in development strict mode
|
|
6847
|
+
if (autofillProcessedRef.current) {
|
|
6848
|
+
return;
|
|
6849
|
+
}
|
|
6850
|
+
try {
|
|
6851
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
6852
|
+
const autofillParam = urlParams.get('autofill');
|
|
6853
|
+
if (!autofillParam) {
|
|
6854
|
+
return;
|
|
6855
|
+
}
|
|
6856
|
+
// Parse the autofill data
|
|
6857
|
+
const autofillData = parseAutofillParam(autofillParam);
|
|
6858
|
+
// Dispatch postal state
|
|
6859
|
+
const postalData = mapToPostalState(autofillData);
|
|
6860
|
+
dispatchPostalState({
|
|
6861
|
+
type: StoreFormCarPostalActionTypes.FormCarPostalSet,
|
|
6862
|
+
payload: postalData,
|
|
6863
|
+
});
|
|
6864
|
+
// Close the postal modal since we have postal data from autofill
|
|
6865
|
+
dispatchAppModalState({
|
|
6866
|
+
type: StoreConfigAppModalActionTypes.AppModalClose,
|
|
6867
|
+
});
|
|
6868
|
+
// Dispatch config state
|
|
6869
|
+
const configData = mapToConfigState(autofillData);
|
|
6870
|
+
dispatchConfigState({
|
|
6871
|
+
type: StoreFormCarConfigActionTypes.FormCarConfigSet,
|
|
6872
|
+
payload: configData,
|
|
6873
|
+
});
|
|
6874
|
+
// Dispatch vehicle state with mapped data
|
|
6875
|
+
const vehicleData = mapToVehicleState(autofillData);
|
|
6876
|
+
// Update the first vehicle in the form with autofill data
|
|
6877
|
+
dispatchVehicleState({
|
|
6878
|
+
type: StoreFormCarVehicleActionTypes.FormCarVehicleYearSet,
|
|
6879
|
+
payload: {
|
|
6880
|
+
year: vehicleData.year,
|
|
6881
|
+
},
|
|
6882
|
+
});
|
|
6883
|
+
// Update make
|
|
6884
|
+
dispatchVehicleState({
|
|
6885
|
+
type: StoreFormCarVehicleActionTypes.FormCarVehicleMakeSet,
|
|
6886
|
+
payload: {
|
|
6887
|
+
make: vehicleData.make,
|
|
6888
|
+
},
|
|
6889
|
+
});
|
|
6890
|
+
// Update model
|
|
6891
|
+
dispatchVehicleState({
|
|
6892
|
+
type: StoreFormCarVehicleActionTypes.FormCarVehicleModelSet,
|
|
6893
|
+
payload: {
|
|
6894
|
+
model: vehicleData.model,
|
|
6895
|
+
},
|
|
6896
|
+
});
|
|
6897
|
+
// Update condition
|
|
6898
|
+
dispatchVehicleState({
|
|
6899
|
+
type: StoreFormCarVehicleActionTypes.FormCarVehicleConditionSelect,
|
|
6900
|
+
payload: {
|
|
6901
|
+
condition: vehicleData.condition,
|
|
6902
|
+
},
|
|
6903
|
+
});
|
|
6904
|
+
// Update leased status
|
|
6905
|
+
dispatchVehicleState({
|
|
6906
|
+
type: StoreFormCarVehicleActionTypes.FormCarVehicleCarStatusSelect,
|
|
6907
|
+
payload: {
|
|
6908
|
+
leased: vehicleData.leased,
|
|
6909
|
+
},
|
|
6910
|
+
});
|
|
6911
|
+
// Update purchase year
|
|
6912
|
+
if (vehicleData.purchaseDate) {
|
|
6913
|
+
const [year, month, day] = vehicleData.purchaseDate.split('-');
|
|
6914
|
+
dispatchVehicleState({
|
|
6915
|
+
type: StoreFormCarVehicleActionTypes.FormCarVehiclePurchaseYearSelect,
|
|
6916
|
+
payload: {
|
|
6917
|
+
purchaseYear: year,
|
|
6918
|
+
},
|
|
6919
|
+
});
|
|
6920
|
+
dispatchVehicleState({
|
|
6921
|
+
type: StoreFormCarVehicleActionTypes.FormCarVehiclePurchaseMonthSelect,
|
|
6922
|
+
payload: {
|
|
6923
|
+
purchaseMonth: month,
|
|
6924
|
+
},
|
|
6925
|
+
});
|
|
6926
|
+
dispatchVehicleState({
|
|
6927
|
+
type: StoreFormCarVehicleActionTypes.FormCarVehiclePurchaseDaySelect,
|
|
6928
|
+
payload: {
|
|
6929
|
+
purchaseDay: day,
|
|
6930
|
+
},
|
|
6931
|
+
});
|
|
6932
|
+
}
|
|
6933
|
+
// Update winter tires
|
|
6934
|
+
dispatchVehicleState({
|
|
6935
|
+
type: StoreFormCarVehicleActionTypes.FormCarVehicleWinterTiresSelect,
|
|
6936
|
+
payload: {
|
|
6937
|
+
winterTires: vehicleData.winterTires,
|
|
6938
|
+
},
|
|
6939
|
+
});
|
|
6940
|
+
// Update primary use
|
|
6941
|
+
dispatchVehicleState({
|
|
6942
|
+
type: StoreFormCarVehicleActionTypes.FormCarVehicleUsageSelect,
|
|
6943
|
+
payload: {
|
|
6944
|
+
primaryUse: vehicleData.primaryUse,
|
|
6945
|
+
},
|
|
6946
|
+
});
|
|
6947
|
+
// Update parking location
|
|
6948
|
+
dispatchVehicleState({
|
|
6949
|
+
type: StoreFormCarVehicleActionTypes.FormCarParkingLocationSelect,
|
|
6950
|
+
payload: {
|
|
6951
|
+
parkingLocation: vehicleData.parkingLocation,
|
|
6952
|
+
},
|
|
6953
|
+
});
|
|
6954
|
+
// Update distances
|
|
6955
|
+
dispatchVehicleState({
|
|
6956
|
+
type: StoreFormCarVehicleActionTypes.FormCarDailyDistanceSelect,
|
|
6957
|
+
payload: {
|
|
6958
|
+
distanceDaily: String(vehicleData.distanceDaily),
|
|
6959
|
+
},
|
|
6960
|
+
});
|
|
6961
|
+
dispatchVehicleState({
|
|
6962
|
+
type: StoreFormCarVehicleActionTypes.FormCarBusinessDistanceSelect,
|
|
6963
|
+
payload: {
|
|
6964
|
+
distanceBusiness: String(vehicleData.distanceBusiness),
|
|
6965
|
+
},
|
|
6966
|
+
});
|
|
6967
|
+
dispatchVehicleState({
|
|
6968
|
+
type: StoreFormCarVehicleActionTypes.FormCarYearlyDistanceSelect,
|
|
6969
|
+
payload: {
|
|
6970
|
+
distanceYearly: String(vehicleData.distanceYearly),
|
|
6971
|
+
},
|
|
6972
|
+
});
|
|
6973
|
+
// Update coverages and deductibles
|
|
6974
|
+
dispatchVehicleState({
|
|
6975
|
+
type: StoreFormCarVehicleActionTypes.FormCarComprehensiveCoverageSelect,
|
|
6976
|
+
payload: {
|
|
6977
|
+
coverage: vehicleData.comprehensive.coverage,
|
|
6978
|
+
deductible: vehicleData.comprehensive.deductible,
|
|
6979
|
+
},
|
|
6980
|
+
});
|
|
6981
|
+
dispatchVehicleState({
|
|
6982
|
+
type: StoreFormCarVehicleActionTypes.FormCarCollisionCoverageSelect,
|
|
6983
|
+
payload: {
|
|
6984
|
+
coverage: vehicleData.collision.coverage,
|
|
6985
|
+
deductible: vehicleData.collision.deductible,
|
|
6986
|
+
},
|
|
6987
|
+
});
|
|
6988
|
+
dispatchVehicleState({
|
|
6989
|
+
type: StoreFormCarVehicleActionTypes.FormCarLiabilityCoverageSelect,
|
|
6990
|
+
payload: {
|
|
6991
|
+
coverage: vehicleData.liability.coverage,
|
|
6992
|
+
limit: vehicleData.liability.limit,
|
|
6993
|
+
},
|
|
6994
|
+
});
|
|
6995
|
+
dispatchVehicleState({
|
|
6996
|
+
type: StoreFormCarVehicleActionTypes.FormCarLossOfUseCoverageSelect,
|
|
6997
|
+
payload: {
|
|
6998
|
+
coverage: vehicleData.lossofuse.coverage,
|
|
6999
|
+
limit: vehicleData.lossofuse.limit,
|
|
7000
|
+
},
|
|
7001
|
+
});
|
|
7002
|
+
dispatchVehicleState({
|
|
7003
|
+
type: StoreFormCarVehicleActionTypes.FormCarLiabilityForDamageCoverageSelect,
|
|
7004
|
+
payload: {
|
|
7005
|
+
coverage: vehicleData.liabilityfordamage.coverage,
|
|
7006
|
+
limit: vehicleData.liabilityfordamage.limit,
|
|
7007
|
+
},
|
|
7008
|
+
});
|
|
7009
|
+
dispatchVehicleState({
|
|
7010
|
+
type: StoreFormCarVehicleActionTypes.FormCarLimitedWaiverOfDepreciationCoverageSelect,
|
|
7011
|
+
payload: {
|
|
7012
|
+
coverage: vehicleData.limitedwaiverofdepreciation.coverage,
|
|
7013
|
+
limit: vehicleData.limitedwaiverofdepreciation.limit,
|
|
7014
|
+
},
|
|
7015
|
+
});
|
|
7016
|
+
// Dispatch driver state
|
|
7017
|
+
const driverData = mapToDriverState(autofillData);
|
|
7018
|
+
// Update driver basic info
|
|
7019
|
+
dispatchDriverInfoState({
|
|
7020
|
+
type: StoreFormCarDriverInfoActionTypes.FormCarDriverNameSet,
|
|
7021
|
+
payload: {
|
|
7022
|
+
firstName: driverData.firstName,
|
|
7023
|
+
},
|
|
7024
|
+
});
|
|
7025
|
+
dispatchDriverInfoState({
|
|
7026
|
+
type: StoreFormCarDriverInfoActionTypes.FormCarDriverMaritalStatusSelect,
|
|
7027
|
+
payload: {
|
|
7028
|
+
maritalStatus: driverData.maritalStatus,
|
|
7029
|
+
},
|
|
7030
|
+
});
|
|
7031
|
+
dispatchDriverInfoState({
|
|
7032
|
+
type: StoreFormCarDriverInfoActionTypes.FormCarDriverGenderSelect,
|
|
7033
|
+
payload: {
|
|
7034
|
+
gender: driverData.gender,
|
|
7035
|
+
},
|
|
7036
|
+
});
|
|
7037
|
+
dispatchDriverInfoState({
|
|
7038
|
+
type: StoreFormCarDriverInfoActionTypes.FormCarDriverOccupationSelect,
|
|
7039
|
+
payload: {
|
|
7040
|
+
occupation: driverData.occupation,
|
|
7041
|
+
},
|
|
7042
|
+
});
|
|
7043
|
+
// Update driver birth date
|
|
7044
|
+
if (driverData.dateOfBirth) {
|
|
7045
|
+
const [year, month, day] = driverData.dateOfBirth.split('-');
|
|
7046
|
+
dispatchDriverInfoState({
|
|
7047
|
+
type: StoreFormCarDriverInfoActionTypes.FormCarDriverBirthYearSelect,
|
|
7048
|
+
payload: { birthYear: year, config: configState },
|
|
7049
|
+
});
|
|
7050
|
+
dispatchDriverInfoState({
|
|
7051
|
+
type: StoreFormCarDriverInfoActionTypes.FormCarDriverBirthMonthSelect,
|
|
7052
|
+
payload: { birthMonth: month, config: configState },
|
|
7053
|
+
});
|
|
7054
|
+
dispatchDriverInfoState({
|
|
7055
|
+
type: StoreFormCarDriverInfoActionTypes.FormCarDriverBirthDaySelect,
|
|
7056
|
+
payload: { birthDay: day, config: configState },
|
|
7057
|
+
});
|
|
7058
|
+
}
|
|
7059
|
+
// Update driver licence info
|
|
7060
|
+
dispatchDriverLicenceState({
|
|
7061
|
+
type: StoreFormCarDriverLicenceActionTypes.FormCarDriverLicenceAgeSelect,
|
|
7062
|
+
payload: {
|
|
7063
|
+
firstLicenceAge: String(driverData.licenceInfo.firstLicenceAge),
|
|
7064
|
+
config: configState,
|
|
7065
|
+
},
|
|
7066
|
+
});
|
|
7067
|
+
if (driverData.licenceInfo.licenceType) {
|
|
7068
|
+
dispatchDriverLicenceState({
|
|
7069
|
+
type: StoreFormCarDriverLicenceActionTypes.FormCarDriverLicenceTypeSelect,
|
|
7070
|
+
payload: {
|
|
7071
|
+
licenceType: driverData.licenceInfo.licenceType,
|
|
7072
|
+
config: configState,
|
|
7073
|
+
},
|
|
7074
|
+
});
|
|
7075
|
+
}
|
|
7076
|
+
// Update driver insurance info
|
|
7077
|
+
dispatchDriverInsuranceState({
|
|
7078
|
+
type: StoreFormCarDriverInsuranceActionTypes.FormCarDriverListedSelect,
|
|
7079
|
+
payload: {
|
|
7080
|
+
listed: driverData.listed,
|
|
7081
|
+
},
|
|
7082
|
+
});
|
|
7083
|
+
if (driverData.listedYear) {
|
|
7084
|
+
const [year, month] = driverData.listedYear.split('-');
|
|
7085
|
+
if (year) {
|
|
7086
|
+
dispatchDriverInsuranceState({
|
|
7087
|
+
type: StoreFormCarDriverInsuranceActionTypes.FormCarDriverListedYearSelect,
|
|
7088
|
+
payload: { listedYear: year },
|
|
7089
|
+
});
|
|
7090
|
+
}
|
|
7091
|
+
if (month) {
|
|
7092
|
+
dispatchDriverInsuranceState({
|
|
7093
|
+
type: StoreFormCarDriverInsuranceActionTypes.FormCarDriverListedMonthSelect,
|
|
7094
|
+
payload: { listedMonth: month },
|
|
7095
|
+
});
|
|
7096
|
+
}
|
|
7097
|
+
}
|
|
7098
|
+
dispatchDriverInsuranceState({
|
|
7099
|
+
type: StoreFormCarDriverInsuranceActionTypes.FormCarDriverInsuredSelect,
|
|
7100
|
+
payload: {
|
|
7101
|
+
insured: driverData.insured,
|
|
7102
|
+
},
|
|
7103
|
+
});
|
|
7104
|
+
if (driverData.insuredYear) {
|
|
7105
|
+
dispatchDriverInsuranceState({
|
|
7106
|
+
type: StoreFormCarDriverInsuranceActionTypes.FormCarDriverInsuredDateSelect,
|
|
7107
|
+
payload: { insuredDate: driverData.insuredYear },
|
|
7108
|
+
});
|
|
7109
|
+
}
|
|
7110
|
+
// Update driver suspension and cancellation status
|
|
7111
|
+
dispatchDriverSuspensionState({
|
|
7112
|
+
type: StoreFormCarDriverSuspensionActionTypes.FormCarDriverLicenceSuspensionSelect,
|
|
7113
|
+
payload: {
|
|
7114
|
+
licenceSuspension: driverData.licenceSuspension,
|
|
7115
|
+
},
|
|
7116
|
+
});
|
|
7117
|
+
dispatchDriverCancellationState({
|
|
7118
|
+
type: StoreFormCarDriverCancellationActionTypes.FormCarDriverInsuranceCancellationSelect,
|
|
7119
|
+
payload: {
|
|
7120
|
+
insuranceCancellation: driverData.insuranceCancellation,
|
|
7121
|
+
},
|
|
7122
|
+
});
|
|
7123
|
+
// Update accident and ticket status
|
|
7124
|
+
dispatchDriverAccidentState({
|
|
7125
|
+
type: StoreFormCarDriverAccidentActionTypes.FormCarDriverAccidentSelect,
|
|
7126
|
+
payload: {
|
|
7127
|
+
accident: driverData.accident,
|
|
7128
|
+
},
|
|
7129
|
+
});
|
|
7130
|
+
dispatchDriverTicketState({
|
|
7131
|
+
type: StoreFormCarDriverTicketActionTypes.FormCarDriverTrafficTicketSelect,
|
|
7132
|
+
payload: {
|
|
7133
|
+
ticket: driverData.ticket,
|
|
7134
|
+
},
|
|
7135
|
+
});
|
|
7136
|
+
// Pre-fetch vehicle makes for the year
|
|
7137
|
+
if (vehicleData.year) {
|
|
7138
|
+
getVehicleMake(vehicleData.year);
|
|
7139
|
+
}
|
|
7140
|
+
// Pre-fetch vehicle models for year + make
|
|
7141
|
+
if (vehicleData.year && vehicleData.make) {
|
|
7142
|
+
getVehicleModel(vehicleData.year, vehicleData.make);
|
|
7143
|
+
}
|
|
7144
|
+
autofillProcessedRef.current = true;
|
|
7145
|
+
if (options?.onComplete) {
|
|
7146
|
+
options.onComplete();
|
|
7147
|
+
}
|
|
7148
|
+
}
|
|
7149
|
+
catch (error) {
|
|
7150
|
+
// Silently fail - let the app continue with normal flow
|
|
7151
|
+
console.error('Autofill initialization error:', error);
|
|
7152
|
+
}
|
|
7153
|
+
}, [
|
|
7154
|
+
configState,
|
|
7155
|
+
dispatchPostalState,
|
|
7156
|
+
dispatchVehicleState,
|
|
7157
|
+
dispatchConfigState,
|
|
7158
|
+
dispatchDriverInfoState,
|
|
7159
|
+
dispatchDriverLicenceState,
|
|
7160
|
+
dispatchDriverInsuranceState,
|
|
7161
|
+
dispatchDriverSuspensionState,
|
|
7162
|
+
dispatchDriverCancellationState,
|
|
7163
|
+
dispatchDriverAccidentState,
|
|
7164
|
+
dispatchDriverTicketState,
|
|
7165
|
+
dispatchAppModalState,
|
|
7166
|
+
getVehicleMake,
|
|
7167
|
+
getVehicleModel,
|
|
7168
|
+
]);
|
|
7169
|
+
};
|
|
7170
|
+
|
|
7171
|
+
export { CarBrokerTypeEnum, CarQuoteDataHandler, ClearFormDataHandler, HomeBrokerTypeEnum, HomeQuoteDataHandler, LifeQuoteDataHandler, StoreClientActionTypes, StoreConfigAppConfigActionTypes, StoreConfigAppDeviceActionTypes, StoreConfigAppLoaderActionTypes, StoreConfigAppModalActionTypes, StoreFormCarConfigActionTypes, StoreFormCarDiscountActionTypes, StoreFormCarDriverAccidentActionTypes, StoreFormCarDriverBaseActionTypes, StoreFormCarDriverCancellationActionTypes, StoreFormCarDriverInfoActionTypes, StoreFormCarDriverInsuranceActionTypes, StoreFormCarDriverLicenceActionTypes, StoreFormCarDriverSuspensionActionTypes, StoreFormCarDriverTicketActionTypes, StoreFormCarPostalActionTypes, StoreFormCarQuoteActionTypes, StoreFormCarVehicleActionTypes, StoreFormHomeApplicantBaseActionTypes, StoreFormHomeApplicantCancellationActionTypes, StoreFormHomeApplicantClaimActionTypes, StoreFormHomeApplicantInfoActionTypes, StoreFormHomeApplicantInsuranceActionTypes, StoreFormHomeDiscountActionTypes, StoreFormHomeDwellingActionTypes, StoreFormHomePostalActionTypes, StoreFormHomeQuoteActionTypes, StoreFormLifeApplicantActionTypes, StoreFormLifeCoverageActionTypes, StoreFormLifePostalActionTypes, StoreFormLifeQuoteActionTypes, StorePartnerActionTypes, StoreProvider, addDayToDate, configStateReducer, differenceInHoursFromNow, formCarReducer, formCondoDwellingInitialState, formHomeDwellingInitialState, formHomeReducer, formLifeReducer, formTenantDwellingInitialState, getDwellingInitialState, getProvinceName, globalStateReducer, initHttpResponse, mapToConfigState, mapToDriverState, mapToPostalState, mapToVehicleState, parseAutofillParam, reducers, default_1 as token, useAutofillCarForm, useHandlerAuth, useHandlerCarMake, useHandlerCarModel, useHandlerCarQuoterEmail, useHandlerHomeQuoterEmail, useHandlerLifeQuoterEmail, useHandlerPartner, useHandlerPostal, useProvince, useStoreAppConfig, useStoreAppDevice, useStoreAppLoader, useStoreAppModal, useStoreClient, useStoreClientLoggedIn, useStoreClientProfile, useStoreClientToken, useStoreDeviceBP, useStoreDeviceType, useStoreFormCarConfig, useStoreFormCarDiscount, useStoreFormCarDriverAccident, useStoreFormCarDriverBase, useStoreFormCarDriverCancellation, useStoreFormCarDriverInfo, useStoreFormCarDriverInsurance, useStoreFormCarDriverLicence, useStoreFormCarDriverSuspension, useStoreFormCarDriverTicket, useStoreFormCarPostal, useStoreFormCarQuote, useStoreFormCarVehicle, useStoreFormHomeApplicantBase, useStoreFormHomeApplicantCancellation, useStoreFormHomeApplicantClaim, useStoreFormHomeApplicantInfo, useStoreFormHomeApplicantInsurance, useStoreFormHomeDiscount, useStoreFormHomeDwelling, useStoreFormHomePostal, useStoreFormHomeQuote, useStoreFormLifeApplicant, useStoreFormLifeCoverage, useStoreFormLifePostal, useStoreFormLifeQuote, useStorePartner, useValidationAddress, useValidationApplicant, useValidationCarDiscount, useValidationCoverage, useValidationDriver, useValidationDwelling, useValidationHomeDiscount, useValidationLifeApplicant, useValidationVehicle };
|
|
6707
7172
|
//# sourceMappingURL=index.js.map
|