@mychoice/mychoice-sdk-store 2.2.9 → 2.2.11
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 +4 -0
- package/dist/cjs/handlers/autofill/types.d.ts +102 -0
- package/dist/cjs/handlers/autofill/useAutofillCarForm.d.ts +8 -0
- package/dist/cjs/handlers/autofill/useAutofillLifeForm.d.ts +8 -0
- package/dist/cjs/handlers/autofill/utils.d.ts +142 -0
- package/dist/cjs/handlers/index.d.ts +1 -0
- package/dist/cjs/index.js +730 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/handlers/autofill/index.d.ts +4 -0
- package/dist/esm/handlers/autofill/types.d.ts +102 -0
- package/dist/esm/handlers/autofill/useAutofillCarForm.d.ts +8 -0
- package/dist/esm/handlers/autofill/useAutofillLifeForm.d.ts +8 -0
- package/dist/esm/handlers/autofill/utils.d.ts +142 -0
- package/dist/esm/handlers/index.d.ts +1 -0
- package/dist/esm/index.js +719 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +262 -1
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -6712,6 +6712,723 @@ const useValidationLifeApplicant = () => {
|
|
|
6712
6712
|
};
|
|
6713
6713
|
};
|
|
6714
6714
|
|
|
6715
|
+
// Province code to name mapping
|
|
6716
|
+
const PROVINCE_NAME_MAP = {
|
|
6717
|
+
ON: 'Ontario',
|
|
6718
|
+
AB: 'Alberta',
|
|
6719
|
+
NS: 'Nova Scotia',
|
|
6720
|
+
NF: 'Newfoundland',
|
|
6721
|
+
NB: 'New Brunswick',
|
|
6722
|
+
BC: 'British Columbia',
|
|
6723
|
+
SK: 'Saskatchewan',
|
|
6724
|
+
MB: 'Manitoba',
|
|
6725
|
+
};
|
|
6726
|
+
/**
|
|
6727
|
+
* Parse URL-encoded JSON from query parameter
|
|
6728
|
+
*/
|
|
6729
|
+
const parseAutofillParam = (urlEncodedJson) => {
|
|
6730
|
+
const decoded = decodeURIComponent(urlEncodedJson);
|
|
6731
|
+
return JSON.parse(decoded);
|
|
6732
|
+
};
|
|
6733
|
+
/**
|
|
6734
|
+
* Get province name from code
|
|
6735
|
+
*/
|
|
6736
|
+
const getProvinceName = (code) => {
|
|
6737
|
+
return PROVINCE_NAME_MAP[code] || code;
|
|
6738
|
+
};
|
|
6739
|
+
/**
|
|
6740
|
+
* Map autofill data to postal state format
|
|
6741
|
+
*/
|
|
6742
|
+
const mapToPostalState = (autofillData) => {
|
|
6743
|
+
const firstVehicle = autofillData.vehicles[0];
|
|
6744
|
+
return {
|
|
6745
|
+
city: firstVehicle.city || '',
|
|
6746
|
+
postalCode: firstVehicle.postal_code || '',
|
|
6747
|
+
locationIndex: String(firstVehicle.location_index || ''),
|
|
6748
|
+
provinceCode: autofillData.province_code || '',
|
|
6749
|
+
provinceName: getProvinceName(autofillData.province_code || ''),
|
|
6750
|
+
};
|
|
6751
|
+
};
|
|
6752
|
+
/**
|
|
6753
|
+
* Map autofill data to vehicle state format
|
|
6754
|
+
*/
|
|
6755
|
+
const mapToVehicleState = (autofillData) => {
|
|
6756
|
+
const firstVehicle = autofillData.vehicles[0];
|
|
6757
|
+
return {
|
|
6758
|
+
year: String(firstVehicle.year || ''),
|
|
6759
|
+
make: firstVehicle.make || '',
|
|
6760
|
+
model: firstVehicle.model || '',
|
|
6761
|
+
condition: firstVehicle.condition || 'N',
|
|
6762
|
+
leased: firstVehicle.leased || false,
|
|
6763
|
+
purchaseDate: firstVehicle.purchase_date || '',
|
|
6764
|
+
winterTires: firstVehicle.winter_tires || false,
|
|
6765
|
+
parkingLocation: firstVehicle.parking_location || 'driveway',
|
|
6766
|
+
primaryUse: firstVehicle.primary_use || 'Personal',
|
|
6767
|
+
distanceDaily: firstVehicle.distance_daily || 0,
|
|
6768
|
+
distanceBusiness: firstVehicle.distance_business || 0,
|
|
6769
|
+
distanceYearly: firstVehicle.distance_yearly || 0,
|
|
6770
|
+
comprehensive: {
|
|
6771
|
+
coverage: firstVehicle.comprehensive?.coverage ?? true,
|
|
6772
|
+
deductible: firstVehicle.comprehensive?.deductible ?? 1000,
|
|
6773
|
+
},
|
|
6774
|
+
collision: {
|
|
6775
|
+
coverage: firstVehicle.collision?.coverage ?? true,
|
|
6776
|
+
deductible: firstVehicle.collision?.deductible ?? 1000,
|
|
6777
|
+
},
|
|
6778
|
+
liability: {
|
|
6779
|
+
coverage: firstVehicle.liability?.coverage ?? true,
|
|
6780
|
+
limit: firstVehicle.liability?.limit ?? 1000000,
|
|
6781
|
+
},
|
|
6782
|
+
lossofuse: {
|
|
6783
|
+
coverage: firstVehicle.lossofuse?.coverage ?? true,
|
|
6784
|
+
limit: firstVehicle.lossofuse?.limit ?? 2000,
|
|
6785
|
+
},
|
|
6786
|
+
liabilityfordamage: {
|
|
6787
|
+
coverage: firstVehicle.liabilityfordamage?.coverage ?? true,
|
|
6788
|
+
limit: firstVehicle.liabilityfordamage?.limit ?? 50000,
|
|
6789
|
+
},
|
|
6790
|
+
limitedwaiverofdepreciation: {
|
|
6791
|
+
coverage: firstVehicle.limitedwaiverofdepreciation?.coverage ?? true,
|
|
6792
|
+
limit: firstVehicle.limitedwaiverofdepreciation?.limit ?? 1,
|
|
6793
|
+
},
|
|
6794
|
+
postalCode: firstVehicle.postal_code || '',
|
|
6795
|
+
locationIndex: String(firstVehicle.location_index || ''),
|
|
6796
|
+
city: firstVehicle.city || '',
|
|
6797
|
+
};
|
|
6798
|
+
};
|
|
6799
|
+
/**
|
|
6800
|
+
* Map autofill data to driver state format
|
|
6801
|
+
*/
|
|
6802
|
+
const mapToDriverState = (autofillData) => {
|
|
6803
|
+
const firstDriver = autofillData.drivers[0];
|
|
6804
|
+
return {
|
|
6805
|
+
firstName: firstDriver.first_name || '',
|
|
6806
|
+
dateOfBirth: firstDriver.date_of_birth || '',
|
|
6807
|
+
maritalStatus: firstDriver.marital_status || '',
|
|
6808
|
+
gender: firstDriver.gender || '',
|
|
6809
|
+
occupation: firstDriver.occupation || 0,
|
|
6810
|
+
listed: firstDriver.listed || false,
|
|
6811
|
+
listedYear: firstDriver.listed_year || '',
|
|
6812
|
+
insured: firstDriver.insured || false,
|
|
6813
|
+
insuredYear: firstDriver.insured_year || '',
|
|
6814
|
+
ticket: firstDriver.ticket || false,
|
|
6815
|
+
accident: firstDriver.accident || false,
|
|
6816
|
+
licenceSuspension: firstDriver.licence_suspension || false,
|
|
6817
|
+
insuranceCancellation: firstDriver.insurance_cancellation || false,
|
|
6818
|
+
licenceInfo: {
|
|
6819
|
+
licenceType: (firstDriver.licence_info?.licence_type || '').toLowerCase(),
|
|
6820
|
+
firstLicenceAge: firstDriver.licence_info?.first_licence_age || 0,
|
|
6821
|
+
gLicenceDate: firstDriver.licence_info?.g_licence_date || '',
|
|
6822
|
+
g1LicenceDate: firstDriver.licence_info?.g1_licence_date || '',
|
|
6823
|
+
g2LicenceDate: firstDriver.licence_info?.g2_licence_date || '',
|
|
6824
|
+
},
|
|
6825
|
+
};
|
|
6826
|
+
};
|
|
6827
|
+
/**
|
|
6828
|
+
* Map autofill data to config state format
|
|
6829
|
+
*/
|
|
6830
|
+
const mapToConfigState = (autofillData) => {
|
|
6831
|
+
return {
|
|
6832
|
+
province: autofillData.province_code || '',
|
|
6833
|
+
};
|
|
6834
|
+
};
|
|
6835
|
+
// Life insurance autofill utilities
|
|
6836
|
+
// State number to province code mapping (reverse of stateMapper in LifeQuoteDataHandler)
|
|
6837
|
+
const STATE_TO_PROVINCE_CODE_MAP = {
|
|
6838
|
+
'1': 'AB',
|
|
6839
|
+
'2': 'BC',
|
|
6840
|
+
'3': 'MB',
|
|
6841
|
+
'4': 'NB',
|
|
6842
|
+
'5': 'NF',
|
|
6843
|
+
'6': 'NS',
|
|
6844
|
+
'7': 'NT',
|
|
6845
|
+
'9': 'ON',
|
|
6846
|
+
'10': 'PE',
|
|
6847
|
+
'11': 'QC',
|
|
6848
|
+
'12': 'SK',
|
|
6849
|
+
'13': 'YT',
|
|
6850
|
+
};
|
|
6851
|
+
/**
|
|
6852
|
+
* Parse URL-encoded JSON from query parameter for life insurance
|
|
6853
|
+
*/
|
|
6854
|
+
const parseLifeAutofillParam = (urlEncodedJson) => {
|
|
6855
|
+
const decoded = decodeURIComponent(urlEncodedJson);
|
|
6856
|
+
return JSON.parse(decoded);
|
|
6857
|
+
};
|
|
6858
|
+
/**
|
|
6859
|
+
* Get province code from state number
|
|
6860
|
+
*/
|
|
6861
|
+
const getProvinceCodeFromState = (stateNumber) => {
|
|
6862
|
+
return STATE_TO_PROVINCE_CODE_MAP[stateNumber] || '';
|
|
6863
|
+
};
|
|
6864
|
+
/**
|
|
6865
|
+
* Map life autofill data to coverage state format
|
|
6866
|
+
*/
|
|
6867
|
+
const mapToLifeCoverageState = (autofillData) => {
|
|
6868
|
+
const provinceCode = getProvinceCodeFromState(autofillData.State || '');
|
|
6869
|
+
return {
|
|
6870
|
+
province: provinceCode,
|
|
6871
|
+
type: autofillData.NewCategory || '',
|
|
6872
|
+
coverage: String(autofillData.FaceAmount || ''),
|
|
6873
|
+
postalCode: autofillData.PostalCode || '',
|
|
6874
|
+
city: autofillData.City || '',
|
|
6875
|
+
};
|
|
6876
|
+
};
|
|
6877
|
+
/**
|
|
6878
|
+
* Map life autofill data to applicant state format
|
|
6879
|
+
*/
|
|
6880
|
+
const mapToLifeApplicantState = (autofillData) => {
|
|
6881
|
+
return {
|
|
6882
|
+
birthYear: autofillData.BirthYear || '',
|
|
6883
|
+
birthMonth: autofillData.BirthMonth || '',
|
|
6884
|
+
birthDay: autofillData.Birthday || '',
|
|
6885
|
+
gender: autofillData.Sex || 'M',
|
|
6886
|
+
smoker: autofillData.Smoker === 'Y',
|
|
6887
|
+
emailTo: {
|
|
6888
|
+
email: autofillData.email_to || '',
|
|
6889
|
+
},
|
|
6890
|
+
quoterInfo: {
|
|
6891
|
+
firstName: autofillData.quoter_info?.first_name || '',
|
|
6892
|
+
lastName: autofillData.quoter_info?.last_name || '',
|
|
6893
|
+
phone: autofillData.quoter_info?.phone ? String(autofillData.quoter_info.phone) : '',
|
|
6894
|
+
utmSource: autofillData.quoter_info?.utm_source || '',
|
|
6895
|
+
utmCampaign: autofillData.quoter_info?.utm_campaign || '',
|
|
6896
|
+
},
|
|
6897
|
+
};
|
|
6898
|
+
};
|
|
6899
|
+
/**
|
|
6900
|
+
* Map life autofill data to postal state format
|
|
6901
|
+
*/
|
|
6902
|
+
const mapToLifePostalState = (autofillData) => {
|
|
6903
|
+
const provinceCode = getProvinceCodeFromState(autofillData.State || '');
|
|
6904
|
+
return {
|
|
6905
|
+
postalCode: autofillData.PostalCode || '',
|
|
6906
|
+
provinceCode,
|
|
6907
|
+
provinceName: getProvinceName(provinceCode),
|
|
6908
|
+
city: autofillData.City || '',
|
|
6909
|
+
locationIndex: '',
|
|
6910
|
+
};
|
|
6911
|
+
};
|
|
6912
|
+
|
|
6913
|
+
/**
|
|
6914
|
+
* Hook to initialize car insurance form with autofill data from query parameter
|
|
6915
|
+
*/
|
|
6916
|
+
const useAutofillCarForm = (options) => {
|
|
6917
|
+
const { dispatchPostalState } = useStoreFormCarPostal();
|
|
6918
|
+
const { dispatchVehicleState } = useStoreFormCarVehicle();
|
|
6919
|
+
const { configState, dispatchConfigState } = useStoreFormCarConfig();
|
|
6920
|
+
const { dispatchDriverInfoState } = useStoreFormCarDriverInfo();
|
|
6921
|
+
const { dispatchDriverLicenceState } = useStoreFormCarDriverLicence();
|
|
6922
|
+
const { dispatchDriverInsuranceState } = useStoreFormCarDriverInsurance();
|
|
6923
|
+
const { dispatchDriverSuspensionState } = useStoreFormCarDriverSuspension();
|
|
6924
|
+
const { dispatchDriverCancellationState } = useStoreFormCarDriverCancellation();
|
|
6925
|
+
const { dispatchDriverAccidentState } = useStoreFormCarDriverAccident();
|
|
6926
|
+
const { dispatchDriverTicketState } = useStoreFormCarDriverTicket();
|
|
6927
|
+
const { getVehicleMake } = useHandlerCarMake();
|
|
6928
|
+
const { getVehicleModel } = useHandlerCarModel();
|
|
6929
|
+
const { dispatchAppModalState } = useStoreAppModal();
|
|
6930
|
+
const autofillProcessedRef = react.useRef(false);
|
|
6931
|
+
react.useEffect(() => {
|
|
6932
|
+
// Prevent double execution in development strict mode
|
|
6933
|
+
if (autofillProcessedRef.current) {
|
|
6934
|
+
return;
|
|
6935
|
+
}
|
|
6936
|
+
try {
|
|
6937
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
6938
|
+
const autofillParam = urlParams.get('autofill');
|
|
6939
|
+
if (!autofillParam) {
|
|
6940
|
+
return;
|
|
6941
|
+
}
|
|
6942
|
+
// Parse the autofill data
|
|
6943
|
+
const autofillData = parseAutofillParam(autofillParam);
|
|
6944
|
+
// Dispatch postal state
|
|
6945
|
+
const postalData = mapToPostalState(autofillData);
|
|
6946
|
+
dispatchPostalState({
|
|
6947
|
+
type: exports.StoreFormCarPostalActionTypes.FormCarPostalSet,
|
|
6948
|
+
payload: postalData,
|
|
6949
|
+
});
|
|
6950
|
+
// Close the postal modal since we have postal data from autofill
|
|
6951
|
+
dispatchAppModalState({
|
|
6952
|
+
type: exports.StoreConfigAppModalActionTypes.AppModalClose,
|
|
6953
|
+
});
|
|
6954
|
+
// Dispatch config state
|
|
6955
|
+
const configData = mapToConfigState(autofillData);
|
|
6956
|
+
dispatchConfigState({
|
|
6957
|
+
type: exports.StoreFormCarConfigActionTypes.FormCarConfigSet,
|
|
6958
|
+
payload: configData,
|
|
6959
|
+
});
|
|
6960
|
+
// Dispatch vehicle state with mapped data
|
|
6961
|
+
const vehicleData = mapToVehicleState(autofillData);
|
|
6962
|
+
// Update the first vehicle in the form with autofill data
|
|
6963
|
+
dispatchVehicleState({
|
|
6964
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarVehicleYearSet,
|
|
6965
|
+
payload: {
|
|
6966
|
+
year: vehicleData.year,
|
|
6967
|
+
},
|
|
6968
|
+
});
|
|
6969
|
+
// Update make
|
|
6970
|
+
dispatchVehicleState({
|
|
6971
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarVehicleMakeSet,
|
|
6972
|
+
payload: {
|
|
6973
|
+
make: vehicleData.make,
|
|
6974
|
+
},
|
|
6975
|
+
});
|
|
6976
|
+
// Update model
|
|
6977
|
+
dispatchVehicleState({
|
|
6978
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarVehicleModelSet,
|
|
6979
|
+
payload: {
|
|
6980
|
+
model: vehicleData.model,
|
|
6981
|
+
},
|
|
6982
|
+
});
|
|
6983
|
+
// Update condition
|
|
6984
|
+
dispatchVehicleState({
|
|
6985
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarVehicleConditionSelect,
|
|
6986
|
+
payload: {
|
|
6987
|
+
condition: vehicleData.condition,
|
|
6988
|
+
},
|
|
6989
|
+
});
|
|
6990
|
+
// Update leased status
|
|
6991
|
+
dispatchVehicleState({
|
|
6992
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarVehicleCarStatusSelect,
|
|
6993
|
+
payload: {
|
|
6994
|
+
leased: vehicleData.leased,
|
|
6995
|
+
},
|
|
6996
|
+
});
|
|
6997
|
+
// Update purchase year
|
|
6998
|
+
if (vehicleData.purchaseDate) {
|
|
6999
|
+
const [year, month, day] = vehicleData.purchaseDate.split('-');
|
|
7000
|
+
dispatchVehicleState({
|
|
7001
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarVehiclePurchaseYearSelect,
|
|
7002
|
+
payload: {
|
|
7003
|
+
purchaseYear: year,
|
|
7004
|
+
},
|
|
7005
|
+
});
|
|
7006
|
+
dispatchVehicleState({
|
|
7007
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarVehiclePurchaseMonthSelect,
|
|
7008
|
+
payload: {
|
|
7009
|
+
purchaseMonth: month,
|
|
7010
|
+
},
|
|
7011
|
+
});
|
|
7012
|
+
dispatchVehicleState({
|
|
7013
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarVehiclePurchaseDaySelect,
|
|
7014
|
+
payload: {
|
|
7015
|
+
purchaseDay: day,
|
|
7016
|
+
},
|
|
7017
|
+
});
|
|
7018
|
+
}
|
|
7019
|
+
// Update winter tires
|
|
7020
|
+
dispatchVehicleState({
|
|
7021
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarVehicleWinterTiresSelect,
|
|
7022
|
+
payload: {
|
|
7023
|
+
winterTires: vehicleData.winterTires,
|
|
7024
|
+
},
|
|
7025
|
+
});
|
|
7026
|
+
// Update primary use
|
|
7027
|
+
dispatchVehicleState({
|
|
7028
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarVehicleUsageSelect,
|
|
7029
|
+
payload: {
|
|
7030
|
+
primaryUse: vehicleData.primaryUse,
|
|
7031
|
+
},
|
|
7032
|
+
});
|
|
7033
|
+
// Update parking location
|
|
7034
|
+
dispatchVehicleState({
|
|
7035
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarParkingLocationSelect,
|
|
7036
|
+
payload: {
|
|
7037
|
+
parkingLocation: vehicleData.parkingLocation,
|
|
7038
|
+
},
|
|
7039
|
+
});
|
|
7040
|
+
// Update distances
|
|
7041
|
+
dispatchVehicleState({
|
|
7042
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarDailyDistanceSelect,
|
|
7043
|
+
payload: {
|
|
7044
|
+
distanceDaily: String(vehicleData.distanceDaily),
|
|
7045
|
+
},
|
|
7046
|
+
});
|
|
7047
|
+
dispatchVehicleState({
|
|
7048
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarBusinessDistanceSelect,
|
|
7049
|
+
payload: {
|
|
7050
|
+
distanceBusiness: String(vehicleData.distanceBusiness),
|
|
7051
|
+
},
|
|
7052
|
+
});
|
|
7053
|
+
dispatchVehicleState({
|
|
7054
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarYearlyDistanceSelect,
|
|
7055
|
+
payload: {
|
|
7056
|
+
distanceYearly: String(vehicleData.distanceYearly),
|
|
7057
|
+
},
|
|
7058
|
+
});
|
|
7059
|
+
// Update coverages and deductibles
|
|
7060
|
+
dispatchVehicleState({
|
|
7061
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarComprehensiveCoverageSelect,
|
|
7062
|
+
payload: {
|
|
7063
|
+
coverage: vehicleData.comprehensive.coverage,
|
|
7064
|
+
deductible: vehicleData.comprehensive.deductible,
|
|
7065
|
+
},
|
|
7066
|
+
});
|
|
7067
|
+
dispatchVehicleState({
|
|
7068
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarCollisionCoverageSelect,
|
|
7069
|
+
payload: {
|
|
7070
|
+
coverage: vehicleData.collision.coverage,
|
|
7071
|
+
deductible: vehicleData.collision.deductible,
|
|
7072
|
+
},
|
|
7073
|
+
});
|
|
7074
|
+
dispatchVehicleState({
|
|
7075
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarLiabilityCoverageSelect,
|
|
7076
|
+
payload: {
|
|
7077
|
+
coverage: vehicleData.liability.coverage,
|
|
7078
|
+
limit: vehicleData.liability.limit,
|
|
7079
|
+
},
|
|
7080
|
+
});
|
|
7081
|
+
dispatchVehicleState({
|
|
7082
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarLossOfUseCoverageSelect,
|
|
7083
|
+
payload: {
|
|
7084
|
+
coverage: vehicleData.lossofuse.coverage,
|
|
7085
|
+
limit: vehicleData.lossofuse.limit,
|
|
7086
|
+
},
|
|
7087
|
+
});
|
|
7088
|
+
dispatchVehicleState({
|
|
7089
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarLiabilityForDamageCoverageSelect,
|
|
7090
|
+
payload: {
|
|
7091
|
+
coverage: vehicleData.liabilityfordamage.coverage,
|
|
7092
|
+
limit: vehicleData.liabilityfordamage.limit,
|
|
7093
|
+
},
|
|
7094
|
+
});
|
|
7095
|
+
dispatchVehicleState({
|
|
7096
|
+
type: exports.StoreFormCarVehicleActionTypes.FormCarLimitedWaiverOfDepreciationCoverageSelect,
|
|
7097
|
+
payload: {
|
|
7098
|
+
coverage: vehicleData.limitedwaiverofdepreciation.coverage,
|
|
7099
|
+
limit: vehicleData.limitedwaiverofdepreciation.limit,
|
|
7100
|
+
},
|
|
7101
|
+
});
|
|
7102
|
+
// Dispatch driver state
|
|
7103
|
+
const driverData = mapToDriverState(autofillData);
|
|
7104
|
+
// Update driver basic info
|
|
7105
|
+
dispatchDriverInfoState({
|
|
7106
|
+
type: exports.StoreFormCarDriverInfoActionTypes.FormCarDriverNameSet,
|
|
7107
|
+
payload: {
|
|
7108
|
+
firstName: driverData.firstName,
|
|
7109
|
+
},
|
|
7110
|
+
});
|
|
7111
|
+
dispatchDriverInfoState({
|
|
7112
|
+
type: exports.StoreFormCarDriverInfoActionTypes.FormCarDriverMaritalStatusSelect,
|
|
7113
|
+
payload: {
|
|
7114
|
+
maritalStatus: driverData.maritalStatus,
|
|
7115
|
+
},
|
|
7116
|
+
});
|
|
7117
|
+
dispatchDriverInfoState({
|
|
7118
|
+
type: exports.StoreFormCarDriverInfoActionTypes.FormCarDriverGenderSelect,
|
|
7119
|
+
payload: {
|
|
7120
|
+
gender: driverData.gender,
|
|
7121
|
+
},
|
|
7122
|
+
});
|
|
7123
|
+
dispatchDriverInfoState({
|
|
7124
|
+
type: exports.StoreFormCarDriverInfoActionTypes.FormCarDriverOccupationSelect,
|
|
7125
|
+
payload: {
|
|
7126
|
+
occupation: driverData.occupation,
|
|
7127
|
+
},
|
|
7128
|
+
});
|
|
7129
|
+
// Update driver birth date
|
|
7130
|
+
if (driverData.dateOfBirth) {
|
|
7131
|
+
const [year, month, day] = driverData.dateOfBirth.split('-');
|
|
7132
|
+
dispatchDriverInfoState({
|
|
7133
|
+
type: exports.StoreFormCarDriverInfoActionTypes.FormCarDriverBirthYearSelect,
|
|
7134
|
+
payload: { birthYear: year, config: configState },
|
|
7135
|
+
});
|
|
7136
|
+
dispatchDriverInfoState({
|
|
7137
|
+
type: exports.StoreFormCarDriverInfoActionTypes.FormCarDriverBirthMonthSelect,
|
|
7138
|
+
payload: { birthMonth: month, config: configState },
|
|
7139
|
+
});
|
|
7140
|
+
dispatchDriverInfoState({
|
|
7141
|
+
type: exports.StoreFormCarDriverInfoActionTypes.FormCarDriverBirthDaySelect,
|
|
7142
|
+
payload: { birthDay: day, config: configState },
|
|
7143
|
+
});
|
|
7144
|
+
}
|
|
7145
|
+
// Update driver licence info
|
|
7146
|
+
dispatchDriverLicenceState({
|
|
7147
|
+
type: exports.StoreFormCarDriverLicenceActionTypes.FormCarDriverLicenceAgeSelect,
|
|
7148
|
+
payload: {
|
|
7149
|
+
firstLicenceAge: String(driverData.licenceInfo.firstLicenceAge),
|
|
7150
|
+
config: configState,
|
|
7151
|
+
},
|
|
7152
|
+
});
|
|
7153
|
+
if (driverData.licenceInfo.licenceType) {
|
|
7154
|
+
dispatchDriverLicenceState({
|
|
7155
|
+
type: exports.StoreFormCarDriverLicenceActionTypes.FormCarDriverLicenceTypeSelect,
|
|
7156
|
+
payload: {
|
|
7157
|
+
licenceType: driverData.licenceInfo.licenceType,
|
|
7158
|
+
config: configState,
|
|
7159
|
+
},
|
|
7160
|
+
});
|
|
7161
|
+
}
|
|
7162
|
+
// Update driver insurance info
|
|
7163
|
+
dispatchDriverInsuranceState({
|
|
7164
|
+
type: exports.StoreFormCarDriverInsuranceActionTypes.FormCarDriverListedSelect,
|
|
7165
|
+
payload: {
|
|
7166
|
+
listed: driverData.listed,
|
|
7167
|
+
},
|
|
7168
|
+
});
|
|
7169
|
+
if (driverData.listedYear) {
|
|
7170
|
+
const [year, month] = driverData.listedYear.split('-');
|
|
7171
|
+
if (year) {
|
|
7172
|
+
dispatchDriverInsuranceState({
|
|
7173
|
+
type: exports.StoreFormCarDriverInsuranceActionTypes.FormCarDriverListedYearSelect,
|
|
7174
|
+
payload: { listedYear: year },
|
|
7175
|
+
});
|
|
7176
|
+
}
|
|
7177
|
+
if (month) {
|
|
7178
|
+
dispatchDriverInsuranceState({
|
|
7179
|
+
type: exports.StoreFormCarDriverInsuranceActionTypes.FormCarDriverListedMonthSelect,
|
|
7180
|
+
payload: { listedMonth: month },
|
|
7181
|
+
});
|
|
7182
|
+
}
|
|
7183
|
+
}
|
|
7184
|
+
dispatchDriverInsuranceState({
|
|
7185
|
+
type: exports.StoreFormCarDriverInsuranceActionTypes.FormCarDriverInsuredSelect,
|
|
7186
|
+
payload: {
|
|
7187
|
+
insured: driverData.insured,
|
|
7188
|
+
},
|
|
7189
|
+
});
|
|
7190
|
+
if (driverData.insuredYear) {
|
|
7191
|
+
dispatchDriverInsuranceState({
|
|
7192
|
+
type: exports.StoreFormCarDriverInsuranceActionTypes.FormCarDriverInsuredDateSelect,
|
|
7193
|
+
payload: { insuredDate: driverData.insuredYear },
|
|
7194
|
+
});
|
|
7195
|
+
}
|
|
7196
|
+
// Update driver suspension and cancellation status
|
|
7197
|
+
dispatchDriverSuspensionState({
|
|
7198
|
+
type: exports.StoreFormCarDriverSuspensionActionTypes.FormCarDriverLicenceSuspensionSelect,
|
|
7199
|
+
payload: {
|
|
7200
|
+
licenceSuspension: driverData.licenceSuspension,
|
|
7201
|
+
},
|
|
7202
|
+
});
|
|
7203
|
+
dispatchDriverCancellationState({
|
|
7204
|
+
type: exports.StoreFormCarDriverCancellationActionTypes.FormCarDriverInsuranceCancellationSelect,
|
|
7205
|
+
payload: {
|
|
7206
|
+
insuranceCancellation: driverData.insuranceCancellation,
|
|
7207
|
+
},
|
|
7208
|
+
});
|
|
7209
|
+
// Update accident and ticket status
|
|
7210
|
+
dispatchDriverAccidentState({
|
|
7211
|
+
type: exports.StoreFormCarDriverAccidentActionTypes.FormCarDriverAccidentSelect,
|
|
7212
|
+
payload: {
|
|
7213
|
+
accident: driverData.accident,
|
|
7214
|
+
},
|
|
7215
|
+
});
|
|
7216
|
+
dispatchDriverTicketState({
|
|
7217
|
+
type: exports.StoreFormCarDriverTicketActionTypes.FormCarDriverTrafficTicketSelect,
|
|
7218
|
+
payload: {
|
|
7219
|
+
ticket: driverData.ticket,
|
|
7220
|
+
},
|
|
7221
|
+
});
|
|
7222
|
+
// Pre-fetch vehicle makes for the year
|
|
7223
|
+
if (vehicleData.year) {
|
|
7224
|
+
getVehicleMake(vehicleData.year);
|
|
7225
|
+
}
|
|
7226
|
+
// Pre-fetch vehicle models for year + make
|
|
7227
|
+
if (vehicleData.year && vehicleData.make) {
|
|
7228
|
+
getVehicleModel(vehicleData.year, vehicleData.make);
|
|
7229
|
+
}
|
|
7230
|
+
autofillProcessedRef.current = true;
|
|
7231
|
+
if (options?.onComplete) {
|
|
7232
|
+
options.onComplete();
|
|
7233
|
+
}
|
|
7234
|
+
}
|
|
7235
|
+
catch (error) {
|
|
7236
|
+
// Silently fail - let the app continue with normal flow
|
|
7237
|
+
console.error('Autofill initialization error:', error);
|
|
7238
|
+
}
|
|
7239
|
+
}, [
|
|
7240
|
+
configState,
|
|
7241
|
+
dispatchPostalState,
|
|
7242
|
+
dispatchVehicleState,
|
|
7243
|
+
dispatchConfigState,
|
|
7244
|
+
dispatchDriverInfoState,
|
|
7245
|
+
dispatchDriverLicenceState,
|
|
7246
|
+
dispatchDriverInsuranceState,
|
|
7247
|
+
dispatchDriverSuspensionState,
|
|
7248
|
+
dispatchDriverCancellationState,
|
|
7249
|
+
dispatchDriverAccidentState,
|
|
7250
|
+
dispatchDriverTicketState,
|
|
7251
|
+
dispatchAppModalState,
|
|
7252
|
+
getVehicleMake,
|
|
7253
|
+
getVehicleModel,
|
|
7254
|
+
]);
|
|
7255
|
+
};
|
|
7256
|
+
|
|
7257
|
+
/**
|
|
7258
|
+
* Hook to initialize life insurance form with autofill data from query parameter
|
|
7259
|
+
*/
|
|
7260
|
+
const useAutofillLifeForm = (options) => {
|
|
7261
|
+
const { dispatchPostalState } = useStoreFormLifePostal();
|
|
7262
|
+
const { dispatchCoverageState } = useStoreFormLifeCoverage();
|
|
7263
|
+
const { dispatchApplicantState } = useStoreFormLifeApplicant();
|
|
7264
|
+
const { dispatchAppModalState } = useStoreAppModal();
|
|
7265
|
+
const autofillProcessedRef = react.useRef(false);
|
|
7266
|
+
react.useEffect(() => {
|
|
7267
|
+
// Prevent double execution in development strict mode
|
|
7268
|
+
if (autofillProcessedRef.current) {
|
|
7269
|
+
return;
|
|
7270
|
+
}
|
|
7271
|
+
try {
|
|
7272
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
7273
|
+
const autofillParam = urlParams.get('autofill');
|
|
7274
|
+
if (!autofillParam) {
|
|
7275
|
+
return;
|
|
7276
|
+
}
|
|
7277
|
+
// Parse the autofill data
|
|
7278
|
+
const autofillData = parseLifeAutofillParam(autofillParam);
|
|
7279
|
+
// Map and dispatch postal state
|
|
7280
|
+
const postalData = mapToLifePostalState(autofillData);
|
|
7281
|
+
dispatchPostalState({
|
|
7282
|
+
type: exports.StoreFormLifePostalActionTypes.FormLifePostalSet,
|
|
7283
|
+
payload: postalData,
|
|
7284
|
+
});
|
|
7285
|
+
// Close the postal modal since we have postal data from autofill
|
|
7286
|
+
dispatchAppModalState({
|
|
7287
|
+
type: exports.StoreConfigAppModalActionTypes.AppModalClose,
|
|
7288
|
+
});
|
|
7289
|
+
// Map and dispatch coverage state
|
|
7290
|
+
const coverageData = mapToLifeCoverageState(autofillData);
|
|
7291
|
+
// Dispatch province
|
|
7292
|
+
dispatchCoverageState({
|
|
7293
|
+
type: exports.StoreFormLifeCoverageActionTypes.FormLifeProvinceSelect,
|
|
7294
|
+
payload: {
|
|
7295
|
+
province: coverageData.province,
|
|
7296
|
+
},
|
|
7297
|
+
});
|
|
7298
|
+
// Dispatch coverage type
|
|
7299
|
+
dispatchCoverageState({
|
|
7300
|
+
type: exports.StoreFormLifeCoverageActionTypes.FormLifeCoverageTypeSelect,
|
|
7301
|
+
payload: {
|
|
7302
|
+
type: coverageData.type,
|
|
7303
|
+
},
|
|
7304
|
+
});
|
|
7305
|
+
// Dispatch coverage amount
|
|
7306
|
+
dispatchCoverageState({
|
|
7307
|
+
type: exports.StoreFormLifeCoverageActionTypes.FormLifeCoverageSelect,
|
|
7308
|
+
payload: {
|
|
7309
|
+
coverage: coverageData.coverage,
|
|
7310
|
+
},
|
|
7311
|
+
});
|
|
7312
|
+
// Dispatch postal code
|
|
7313
|
+
dispatchCoverageState({
|
|
7314
|
+
type: exports.StoreFormLifeCoverageActionTypes.FormLifePostalCodeSelect,
|
|
7315
|
+
payload: {
|
|
7316
|
+
postalCode: coverageData.postalCode,
|
|
7317
|
+
},
|
|
7318
|
+
});
|
|
7319
|
+
// Dispatch city
|
|
7320
|
+
if (coverageData.city) {
|
|
7321
|
+
dispatchCoverageState({
|
|
7322
|
+
type: exports.StoreFormLifeCoverageActionTypes.FormLifeCitySelect,
|
|
7323
|
+
payload: {
|
|
7324
|
+
city: coverageData.city,
|
|
7325
|
+
},
|
|
7326
|
+
});
|
|
7327
|
+
}
|
|
7328
|
+
// Map and dispatch applicant state
|
|
7329
|
+
const applicantData = mapToLifeApplicantState(autofillData);
|
|
7330
|
+
// Dispatch birth year
|
|
7331
|
+
dispatchApplicantState({
|
|
7332
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeApplicantBirthYearSelect,
|
|
7333
|
+
payload: {
|
|
7334
|
+
birthYear: applicantData.birthYear,
|
|
7335
|
+
},
|
|
7336
|
+
});
|
|
7337
|
+
// Dispatch birth month
|
|
7338
|
+
dispatchApplicantState({
|
|
7339
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeApplicantBirthMonthSelect,
|
|
7340
|
+
payload: {
|
|
7341
|
+
birthMonth: applicantData.birthMonth,
|
|
7342
|
+
},
|
|
7343
|
+
});
|
|
7344
|
+
// Dispatch birth day
|
|
7345
|
+
dispatchApplicantState({
|
|
7346
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeApplicantBirthDaySelect,
|
|
7347
|
+
payload: {
|
|
7348
|
+
birthDay: applicantData.birthDay,
|
|
7349
|
+
},
|
|
7350
|
+
});
|
|
7351
|
+
// Dispatch gender
|
|
7352
|
+
dispatchApplicantState({
|
|
7353
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeApplicantGenderSelect,
|
|
7354
|
+
payload: {
|
|
7355
|
+
gender: applicantData.gender,
|
|
7356
|
+
},
|
|
7357
|
+
});
|
|
7358
|
+
// Dispatch smoker status
|
|
7359
|
+
dispatchApplicantState({
|
|
7360
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeApplicantSmokerSelect,
|
|
7361
|
+
payload: {
|
|
7362
|
+
smoker: applicantData.smoker,
|
|
7363
|
+
},
|
|
7364
|
+
});
|
|
7365
|
+
// Dispatch email
|
|
7366
|
+
if (applicantData.emailTo.email) {
|
|
7367
|
+
dispatchApplicantState({
|
|
7368
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeApplicantEmailSet,
|
|
7369
|
+
payload: {
|
|
7370
|
+
email: applicantData.emailTo.email,
|
|
7371
|
+
emailStatus: mychoiceSdkComponents.ValidationStatusTypes.Approved,
|
|
7372
|
+
},
|
|
7373
|
+
});
|
|
7374
|
+
}
|
|
7375
|
+
// Dispatch quoter info - first name
|
|
7376
|
+
if (applicantData.quoterInfo.firstName) {
|
|
7377
|
+
dispatchApplicantState({
|
|
7378
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterFirstNameSet,
|
|
7379
|
+
payload: {
|
|
7380
|
+
firstName: applicantData.quoterInfo.firstName,
|
|
7381
|
+
},
|
|
7382
|
+
});
|
|
7383
|
+
}
|
|
7384
|
+
// Dispatch quoter info - last name
|
|
7385
|
+
if (applicantData.quoterInfo.lastName) {
|
|
7386
|
+
dispatchApplicantState({
|
|
7387
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterLastNameSet,
|
|
7388
|
+
payload: {
|
|
7389
|
+
lastName: applicantData.quoterInfo.lastName,
|
|
7390
|
+
},
|
|
7391
|
+
});
|
|
7392
|
+
}
|
|
7393
|
+
// Dispatch quoter info - phone
|
|
7394
|
+
if (applicantData.quoterInfo.phone) {
|
|
7395
|
+
dispatchApplicantState({
|
|
7396
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneSet,
|
|
7397
|
+
payload: {
|
|
7398
|
+
phone: applicantData.quoterInfo.phone,
|
|
7399
|
+
},
|
|
7400
|
+
});
|
|
7401
|
+
}
|
|
7402
|
+
// Dispatch quoter info - utm source
|
|
7403
|
+
if (applicantData.quoterInfo.utmSource) {
|
|
7404
|
+
dispatchApplicantState({
|
|
7405
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeUtmSourceSet,
|
|
7406
|
+
payload: {
|
|
7407
|
+
utmSource: applicantData.quoterInfo.utmSource,
|
|
7408
|
+
},
|
|
7409
|
+
});
|
|
7410
|
+
}
|
|
7411
|
+
// Dispatch quoter info - utm campaign
|
|
7412
|
+
if (applicantData.quoterInfo.utmCampaign) {
|
|
7413
|
+
dispatchApplicantState({
|
|
7414
|
+
type: exports.StoreFormLifeApplicantActionTypes.FormLifeUtmCampaignSet,
|
|
7415
|
+
payload: {
|
|
7416
|
+
utmCampaign: applicantData.quoterInfo.utmCampaign,
|
|
7417
|
+
},
|
|
7418
|
+
});
|
|
7419
|
+
}
|
|
7420
|
+
autofillProcessedRef.current = true;
|
|
7421
|
+
if (options?.onComplete) {
|
|
7422
|
+
options.onComplete();
|
|
7423
|
+
}
|
|
7424
|
+
}
|
|
7425
|
+
catch (error) {
|
|
7426
|
+
// Silently fail - let the app continue with normal flow
|
|
7427
|
+
console.error('Life autofill initialization error:', error);
|
|
7428
|
+
}
|
|
7429
|
+
}, [dispatchPostalState, dispatchCoverageState, dispatchApplicantState, dispatchAppModalState]);
|
|
7430
|
+
};
|
|
7431
|
+
|
|
6715
7432
|
exports.CarQuoteDataHandler = CarQuoteDataHandler;
|
|
6716
7433
|
exports.ClearFormDataHandler = ClearFormDataHandler;
|
|
6717
7434
|
exports.HomeQuoteDataHandler = HomeQuoteDataHandler;
|
|
@@ -6727,10 +7444,23 @@ exports.formHomeReducer = formHomeReducer;
|
|
|
6727
7444
|
exports.formLifeReducer = formLifeReducer;
|
|
6728
7445
|
exports.formTenantDwellingInitialState = formTenantDwellingInitialState;
|
|
6729
7446
|
exports.getDwellingInitialState = getDwellingInitialState;
|
|
7447
|
+
exports.getProvinceCodeFromState = getProvinceCodeFromState;
|
|
7448
|
+
exports.getProvinceName = getProvinceName;
|
|
6730
7449
|
exports.globalStateReducer = globalStateReducer;
|
|
6731
7450
|
exports.initHttpResponse = initHttpResponse;
|
|
7451
|
+
exports.mapToConfigState = mapToConfigState;
|
|
7452
|
+
exports.mapToDriverState = mapToDriverState;
|
|
7453
|
+
exports.mapToLifeApplicantState = mapToLifeApplicantState;
|
|
7454
|
+
exports.mapToLifeCoverageState = mapToLifeCoverageState;
|
|
7455
|
+
exports.mapToLifePostalState = mapToLifePostalState;
|
|
7456
|
+
exports.mapToPostalState = mapToPostalState;
|
|
7457
|
+
exports.mapToVehicleState = mapToVehicleState;
|
|
7458
|
+
exports.parseAutofillParam = parseAutofillParam;
|
|
7459
|
+
exports.parseLifeAutofillParam = parseLifeAutofillParam;
|
|
6732
7460
|
exports.reducers = reducers;
|
|
6733
7461
|
exports.token = default_1;
|
|
7462
|
+
exports.useAutofillCarForm = useAutofillCarForm;
|
|
7463
|
+
exports.useAutofillLifeForm = useAutofillLifeForm;
|
|
6734
7464
|
exports.useHandlerAuth = useHandlerAuth;
|
|
6735
7465
|
exports.useHandlerCarMake = useHandlerCarMake;
|
|
6736
7466
|
exports.useHandlerCarModel = useHandlerCarModel;
|