@mychoice/mychoice-sdk-store 2.2.10 → 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 +1 -0
- package/dist/cjs/handlers/autofill/types.d.ts +26 -0
- package/dist/cjs/handlers/autofill/useAutofillLifeForm.d.ts +8 -0
- package/dist/cjs/handlers/autofill/utils.d.ts +48 -0
- package/dist/cjs/index.js +258 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/handlers/autofill/index.d.ts +1 -0
- package/dist/esm/handlers/autofill/types.d.ts +26 -0
- package/dist/esm/handlers/autofill/useAutofillLifeForm.d.ts +8 -0
- package/dist/esm/handlers/autofill/utils.d.ts +48 -0
- package/dist/esm/index.js +253 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +85 -3
- package/package.json +2 -2
|
@@ -74,3 +74,29 @@ export interface MappedAutofillData {
|
|
|
74
74
|
postalData: any;
|
|
75
75
|
configData: any;
|
|
76
76
|
}
|
|
77
|
+
export interface LifeAutofillQuoterInfo {
|
|
78
|
+
phone: number;
|
|
79
|
+
last_name: string;
|
|
80
|
+
first_name: string;
|
|
81
|
+
utm_source: string | null;
|
|
82
|
+
recalculate: boolean;
|
|
83
|
+
utm_campaign: string | null;
|
|
84
|
+
}
|
|
85
|
+
export interface LifeAutofillData {
|
|
86
|
+
Sex: string;
|
|
87
|
+
uuid: string;
|
|
88
|
+
City: string;
|
|
89
|
+
State: string;
|
|
90
|
+
Health: string;
|
|
91
|
+
Smoker: string;
|
|
92
|
+
Birthday: string;
|
|
93
|
+
ModeUsed: string;
|
|
94
|
+
email_to: string;
|
|
95
|
+
BirthYear: string;
|
|
96
|
+
BirthMonth: string;
|
|
97
|
+
FaceAmount: number;
|
|
98
|
+
IsUsaQuote: boolean;
|
|
99
|
+
PostalCode: string;
|
|
100
|
+
NewCategory: string;
|
|
101
|
+
quoter_info: LifeAutofillQuoterInfo;
|
|
102
|
+
}
|
|
@@ -92,3 +92,51 @@ export declare const mapToDriverState: (autofillData: AutofillData) => {
|
|
|
92
92
|
export declare const mapToConfigState: (autofillData: AutofillData) => {
|
|
93
93
|
province: string;
|
|
94
94
|
};
|
|
95
|
+
/**
|
|
96
|
+
* Parse URL-encoded JSON from query parameter for life insurance
|
|
97
|
+
*/
|
|
98
|
+
export declare const parseLifeAutofillParam: (urlEncodedJson: string) => any;
|
|
99
|
+
/**
|
|
100
|
+
* Get province code from state number
|
|
101
|
+
*/
|
|
102
|
+
export declare const getProvinceCodeFromState: (stateNumber: string) => string;
|
|
103
|
+
/**
|
|
104
|
+
* Map life autofill data to coverage state format
|
|
105
|
+
*/
|
|
106
|
+
export declare const mapToLifeCoverageState: (autofillData: any) => {
|
|
107
|
+
province: string;
|
|
108
|
+
type: any;
|
|
109
|
+
coverage: string;
|
|
110
|
+
postalCode: any;
|
|
111
|
+
city: any;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Map life autofill data to applicant state format
|
|
115
|
+
*/
|
|
116
|
+
export declare const mapToLifeApplicantState: (autofillData: any) => {
|
|
117
|
+
birthYear: any;
|
|
118
|
+
birthMonth: any;
|
|
119
|
+
birthDay: any;
|
|
120
|
+
gender: any;
|
|
121
|
+
smoker: boolean;
|
|
122
|
+
emailTo: {
|
|
123
|
+
email: any;
|
|
124
|
+
};
|
|
125
|
+
quoterInfo: {
|
|
126
|
+
firstName: any;
|
|
127
|
+
lastName: any;
|
|
128
|
+
phone: string;
|
|
129
|
+
utmSource: any;
|
|
130
|
+
utmCampaign: any;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Map life autofill data to postal state format
|
|
135
|
+
*/
|
|
136
|
+
export declare const mapToLifePostalState: (autofillData: any) => {
|
|
137
|
+
postalCode: any;
|
|
138
|
+
provinceCode: string;
|
|
139
|
+
provinceName: string;
|
|
140
|
+
city: any;
|
|
141
|
+
locationIndex: string;
|
|
142
|
+
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -6832,6 +6832,83 @@ const mapToConfigState = (autofillData) => {
|
|
|
6832
6832
|
province: autofillData.province_code || '',
|
|
6833
6833
|
};
|
|
6834
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
|
+
};
|
|
6835
6912
|
|
|
6836
6913
|
/**
|
|
6837
6914
|
* Hook to initialize car insurance form with autofill data from query parameter
|
|
@@ -7177,6 +7254,181 @@ const useAutofillCarForm = (options) => {
|
|
|
7177
7254
|
]);
|
|
7178
7255
|
};
|
|
7179
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
|
+
|
|
7180
7432
|
exports.CarQuoteDataHandler = CarQuoteDataHandler;
|
|
7181
7433
|
exports.ClearFormDataHandler = ClearFormDataHandler;
|
|
7182
7434
|
exports.HomeQuoteDataHandler = HomeQuoteDataHandler;
|
|
@@ -7192,17 +7444,23 @@ exports.formHomeReducer = formHomeReducer;
|
|
|
7192
7444
|
exports.formLifeReducer = formLifeReducer;
|
|
7193
7445
|
exports.formTenantDwellingInitialState = formTenantDwellingInitialState;
|
|
7194
7446
|
exports.getDwellingInitialState = getDwellingInitialState;
|
|
7447
|
+
exports.getProvinceCodeFromState = getProvinceCodeFromState;
|
|
7195
7448
|
exports.getProvinceName = getProvinceName;
|
|
7196
7449
|
exports.globalStateReducer = globalStateReducer;
|
|
7197
7450
|
exports.initHttpResponse = initHttpResponse;
|
|
7198
7451
|
exports.mapToConfigState = mapToConfigState;
|
|
7199
7452
|
exports.mapToDriverState = mapToDriverState;
|
|
7453
|
+
exports.mapToLifeApplicantState = mapToLifeApplicantState;
|
|
7454
|
+
exports.mapToLifeCoverageState = mapToLifeCoverageState;
|
|
7455
|
+
exports.mapToLifePostalState = mapToLifePostalState;
|
|
7200
7456
|
exports.mapToPostalState = mapToPostalState;
|
|
7201
7457
|
exports.mapToVehicleState = mapToVehicleState;
|
|
7202
7458
|
exports.parseAutofillParam = parseAutofillParam;
|
|
7459
|
+
exports.parseLifeAutofillParam = parseLifeAutofillParam;
|
|
7203
7460
|
exports.reducers = reducers;
|
|
7204
7461
|
exports.token = default_1;
|
|
7205
7462
|
exports.useAutofillCarForm = useAutofillCarForm;
|
|
7463
|
+
exports.useAutofillLifeForm = useAutofillLifeForm;
|
|
7206
7464
|
exports.useHandlerAuth = useHandlerAuth;
|
|
7207
7465
|
exports.useHandlerCarMake = useHandlerCarMake;
|
|
7208
7466
|
exports.useHandlerCarModel = useHandlerCarModel;
|