@mychoice/mychoice-sdk-modules 2.2.22 → 2.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +376 -111
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +377 -112
- package/dist/esm/index.js.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.js
CHANGED
|
@@ -209,9 +209,11 @@ const capitalize = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
|
209
209
|
const BlockVehLinks = () => {
|
|
210
210
|
const { vehicleState: { items: vehicles } } = mychoiceSdkStore.useStoreFormCarVehicle();
|
|
211
211
|
const { driverState: { items: drivers } } = mychoiceSdkStore.useStoreFormCarDriverBase();
|
|
212
|
-
const { discountState: { vehlinks }, dispatchDiscountState } = mychoiceSdkStore.useStoreFormCarDiscount();
|
|
213
|
-
|
|
214
|
-
|
|
212
|
+
const { discountState: { vehlinks, occVehlinks }, dispatchDiscountState } = mychoiceSdkStore.useStoreFormCarDiscount();
|
|
213
|
+
if (drivers.length <= 1) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
const handlePrimaryDriverChange = (vehicleIndex) => ({ value }) => {
|
|
215
217
|
dispatchDiscountState({
|
|
216
218
|
type: mychoiceSdkStore.StoreFormCarDiscountActionTypes.FormCarDiscountVehlinkSelect,
|
|
217
219
|
payload: {
|
|
@@ -220,14 +222,41 @@ const BlockVehLinks = () => {
|
|
|
220
222
|
},
|
|
221
223
|
});
|
|
222
224
|
};
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
225
|
+
const handleOccDriverChange = (driverIndex) => ({ value }) => {
|
|
226
|
+
dispatchDiscountState({
|
|
227
|
+
type: mychoiceSdkStore.StoreFormCarDiscountActionTypes.FormCarDiscountOccVehlinkSelect,
|
|
228
|
+
payload: {
|
|
229
|
+
driverIndex,
|
|
230
|
+
vehicleIndex: value,
|
|
231
|
+
},
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
// Drivers that are NOT assigned as primary for any vehicle
|
|
235
|
+
const primaryDriverIndices = vehlinks
|
|
236
|
+
.filter((l) => l.priority === mychoiceSdkComponents.DriverPriorityTypes.Prn)
|
|
237
|
+
.map((l) => l.driverIndex);
|
|
238
|
+
const unassignedDrivers = drivers
|
|
239
|
+
.map((driver, index) => ({ driver, index }))
|
|
240
|
+
.filter(({ index }) => !primaryDriverIndices.includes(index));
|
|
241
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(LabelFormBox, { title: "Since there are multiple drivers in this quote, please tell us who drives which vehicle the most. Please provide an answer that most accurately describes your situation." }), vehicles.map((vehicle, vehicleIndex) => {
|
|
242
|
+
const { year, make, model } = vehicle;
|
|
243
|
+
const selectedPrimary = vehlinks.find((l) => l.vehicleIndex === vehicleIndex && l.priority === mychoiceSdkComponents.DriverPriorityTypes.Prn);
|
|
244
|
+
const allDriverOptions = drivers
|
|
245
|
+
.map((driver, driverIndex) => ({ name: driver.firstName, value: driverIndex }));
|
|
246
|
+
const filteredOptions = allDriverOptions.filter(({ value }) => {
|
|
247
|
+
const assignedVehicle = vehlinks.find((l) => l.driverIndex === value && l.priority === mychoiceSdkComponents.DriverPriorityTypes.Prn);
|
|
248
|
+
return !assignedVehicle || assignedVehicle.vehicleIndex === vehicleIndex;
|
|
249
|
+
});
|
|
250
|
+
const availablePrimaryOptions = filteredOptions.length > 0 ? filteredOptions : allDriverOptions;
|
|
251
|
+
return (jsxRuntime.jsx(SelectFormBox, { title: `Who drives the ${year} ${make} ${model} the most?`, onChange: handlePrimaryDriverChange(vehicleIndex), options: availablePrimaryOptions, defaultValue: selectedPrimary?.driverIndex ?? 0, name: `vehlink-${vehicleIndex}` }, `vehlink-${vehicleIndex}`));
|
|
252
|
+
}), drivers.length > vehicles.length && unassignedDrivers.map(({ driver, index: driverIndex }) => {
|
|
253
|
+
const selectedVehicle = occVehlinks.find((l) => l.driverIndex === driverIndex);
|
|
254
|
+
const vehicleOptions = vehicles.map((vehicle, vehicleIndex) => ({
|
|
255
|
+
name: `${vehicle.year} ${vehicle.make} ${vehicle.model}`,
|
|
256
|
+
value: vehicleIndex,
|
|
257
|
+
}));
|
|
258
|
+
return (jsxRuntime.jsx(SelectFormBox, { title: `Which vehicle does ${driver.firstName} drive the most?`, onChange: handleOccDriverChange(driverIndex), options: vehicleOptions, defaultValue: selectedVehicle?.vehicleIndex ?? 0, name: `occ-vehlink-${driverIndex}` }, `occ-vehlink-${driverIndex}`));
|
|
259
|
+
})] }));
|
|
231
260
|
};
|
|
232
261
|
|
|
233
262
|
const BlockNextPageInfo$2 = () => {
|
|
@@ -793,9 +822,9 @@ const BlockCarConditionInfo = () => {
|
|
|
793
822
|
});
|
|
794
823
|
}
|
|
795
824
|
};
|
|
796
|
-
const { year, condition, leased, winterTires, parkingLocation, primaryUse, distanceDaily, distanceBusiness, distanceYearly, purchaseYear, purchaseMonth, purchaseDay, } = vehicleState.items[vehicleState.activeIndex];
|
|
825
|
+
const { year, condition, leased, winterTires, parkingLocation, primaryUse, distanceDaily, distanceBusiness, distanceYearly, businessUsePercent, purchaseYear, purchaseMonth, purchaseDay, } = vehicleState.items[vehicleState.activeIndex];
|
|
797
826
|
// eslint-disable-next-line max-len
|
|
798
|
-
const primaryUseHintMessage = primaryUse === 'business' ? 'Please choose "Business"
|
|
827
|
+
const primaryUseHintMessage = primaryUse === 'business' ? 'Please choose "Business" if your vehicle is used for any work purposes (sales representatives, realtors, consultants, etc.). If you only drive back and forth to work, please choose "Personal" and select your commute distance.' : '';
|
|
799
828
|
const defaultPurchaseDate = {
|
|
800
829
|
day: purchaseDay,
|
|
801
830
|
month: purchaseMonth,
|
|
@@ -856,33 +885,32 @@ const BlockCarConditionInfo = () => {
|
|
|
856
885
|
type: mychoiceSdkStore.StoreFormCarVehicleActionTypes.FormCarDailyDistanceSelect,
|
|
857
886
|
payload: { distanceDaily: value },
|
|
858
887
|
});
|
|
888
|
+
const yearlyDefault = Number(value) === 0
|
|
889
|
+
? '5000'
|
|
890
|
+
: `${getRecommendedRange(value, primaryUse === mychoiceSdkComponents.VehiclePrimaryUseTypes.Business ? distanceBusiness : 1)}`;
|
|
859
891
|
dispatchVehicleState({
|
|
860
892
|
type: mychoiceSdkStore.StoreFormCarVehicleActionTypes.FormCarYearlyDistanceSelect,
|
|
861
|
-
payload: { distanceYearly:
|
|
893
|
+
payload: { distanceYearly: yearlyDefault },
|
|
862
894
|
});
|
|
863
895
|
};
|
|
864
|
-
const
|
|
865
|
-
dispatchVehicleState({
|
|
866
|
-
type: mychoiceSdkStore.StoreFormCarVehicleActionTypes.FormCarBusinessDistanceSelect,
|
|
867
|
-
payload: { distanceBusiness: value },
|
|
868
|
-
});
|
|
896
|
+
const handleCarYearlyDistanceChange = ({ value }) => {
|
|
869
897
|
dispatchVehicleState({
|
|
870
898
|
type: mychoiceSdkStore.StoreFormCarVehicleActionTypes.FormCarYearlyDistanceSelect,
|
|
871
|
-
payload: { distanceYearly:
|
|
899
|
+
payload: { distanceYearly: value },
|
|
872
900
|
});
|
|
873
901
|
};
|
|
874
|
-
const
|
|
902
|
+
const handleBusinessUsePercentChange = ({ value }) => {
|
|
875
903
|
dispatchVehicleState({
|
|
876
|
-
type: mychoiceSdkStore.StoreFormCarVehicleActionTypes.
|
|
877
|
-
payload: {
|
|
904
|
+
type: mychoiceSdkStore.StoreFormCarVehicleActionTypes.FormCarBusinessUsePercentSelect,
|
|
905
|
+
payload: { businessUsePercent: value },
|
|
878
906
|
});
|
|
879
907
|
};
|
|
880
908
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.carCondition, onChange: handleConditionChange, name: "condition", defaultValue: getSelectedOption(mychoiceSdkComponents.carCondition, condition), description: "Used cars are usually cheaper to insure than new ones because of the depreciation. The cost to replace this vehicle is typically less expensive and insurers will account for the condition of the car when giving you a rate.", title: "Was this car new or used when you bought it?" }), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.carStatus, onChange: handleLeasedChange, name: "leased", defaultValue: getSelectedOption(mychoiceSdkComponents.carStatus, leased), description: "You can own or lease a car. Ownership means that you bought the vehicle or are currently financing it. Leasing is renting it under a long-term contract. In this case, the leasing company maintains ownership of the vehicle, which you will see clearly on your insurance policy.", title: "Is this car owned/financed or leased?" }), jsxRuntime.jsx(DateSelectFormBox, { name: "purchaseDate", dateNames: ['purchaseYear', 'purchaseMonth'], onDateChange: handlePurchaseDateChange, defaultValue: defaultPurchaseDate, title: "When did you buy this car?", description: "Car insurers in Ontario ask for your vehicle purchase date because it is a key factor that can affect its value, depreciation, and condition, which can impact the likelihood and cost of repairs or replacement. This information helps insurers assess the level of risk and calculate an appropriate premium.", errorMessage: getDateErrorMessage([
|
|
881
909
|
purchaseDay || '',
|
|
882
910
|
purchaseMonth || '',
|
|
883
911
|
purchaseYear || '',
|
|
884
|
-
], vehicleState.inValidation), error: vehicleState.inValidation, minDate: year ? `${Number(year) - 1}-01-01` : mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd'), maxDate: mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd') }), !(isAlbertaProvince && isTheBig) && (jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.carWinterTiresCheck, onChange: handleWinterTiresChange, name: "winterTires", defaultValue: getSelectedOption(mychoiceSdkComponents.carWinterTiresCheck, winterTires), description: "Snow. Ice. Freezing temperatures. Winter tires protect you from all these winter weather conditions, and more. It also protects your wallet. Investing in winter tires can save you $50 to $100 on your insurance.", title: "Does your car have winter tires?" })), jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.carKeepPlace, name: "parkingLocation", onChange: handleCarParkingLocationChange, defaultValue: getSelectedOption(mychoiceSdkComponents.carKeepPlace, parkingLocation), title: "Where do you keep your car overnight?", placeholder: "Select from the list", description: "For many of us, the answer is \u201Cat home.\u201D If you park your car in various locations throughout the year, then select the most frequently parking spot. Be honest\u2014some insurers will use your overnight parking location to calculate a quote, which could affect your claims in the future.", autoSelectIfValueIsOutOfOptions: false, error: !parkingLocation && vehicleState.inValidation, errorMessage: getErrorMessage(parkingLocation, vehicleState.inValidation) }), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.carUsagePurpose, onChange: handleCarUsageChange, name: "primaryUse", defaultValue: getSelectedOption(mychoiceSdkComponents.carUsagePurpose, primaryUse) || mychoiceSdkComponents.carUsagePurpose[0].value, hintMessage: primaryUseHintMessage, description: "The way you use your vehicle is a primary factor that insurers use in your policy terms and fees, whether it be personal or business.\n \u2022 Personal is driving from work or school to home.\n \u2022 Business considers other uses like sales calls, pick-ups or deliveries, or other business errands.", title: "What do you
|
|
885
|
-
${mychoiceSdkComponents.numberWithCommas(getRecommendedRange(distanceDaily, primaryUse === mychoiceSdkComponents.VehiclePrimaryUseTypes.Business ? distanceBusiness : 1))} for your yearly driven kilometers` : '', autoSelectIfValueIsOutOfOptions: false, error: !distanceYearly && vehicleState.inValidation, errorMessage: getErrorMessage(distanceYearly, vehicleState.inValidation) }), showPolicyStartOnVehiclePage && (jsxRuntime.jsx(DateSelectFormBox, { name: "policyStart", dateNames: ['policyStartYear', 'policyStartMonth', 'policyStartDay'], onDateChange: handlePolicyStartDateChange, defaultValue: defaultPolicyStartDate, title: "What is the ideal start date for your new insurance policy?", description: "Select your preferred date for the beginning of your new insurance policy. For instance, you may set the start date for the day that your current insurance expires to ensure that you're continuously covered. Alternatively, select today's date for a quote or new policy.", minDate: mychoiceSdkComponents.addDaysToDate('', 1), maxDate: mychoiceSdkComponents.addDaysToDate('', 90), isDay: true }))] }));
|
|
912
|
+
], vehicleState.inValidation), error: vehicleState.inValidation, minDate: year ? `${Number(year) - 1}-01-01` : mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd'), maxDate: mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd') }), !(isAlbertaProvince && isTheBig) && (jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.carWinterTiresCheck, onChange: handleWinterTiresChange, name: "winterTires", defaultValue: getSelectedOption(mychoiceSdkComponents.carWinterTiresCheck, winterTires), description: "Snow. Ice. Freezing temperatures. Winter tires protect you from all these winter weather conditions, and more. It also protects your wallet. Investing in winter tires can save you $50 to $100 on your insurance.", title: "Does your car have winter tires?" })), jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.carKeepPlace, name: "parkingLocation", onChange: handleCarParkingLocationChange, defaultValue: getSelectedOption(mychoiceSdkComponents.carKeepPlace, parkingLocation), title: "Where do you keep your car overnight?", placeholder: "Select from the list", description: "For many of us, the answer is \u201Cat home.\u201D If you park your car in various locations throughout the year, then select the most frequently parking spot. Be honest\u2014some insurers will use your overnight parking location to calculate a quote, which could affect your claims in the future.", autoSelectIfValueIsOutOfOptions: false, error: !parkingLocation && vehicleState.inValidation, errorMessage: getErrorMessage(parkingLocation, vehicleState.inValidation) }), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.carUsagePurpose, onChange: handleCarUsageChange, name: "primaryUse", defaultValue: getSelectedOption(mychoiceSdkComponents.carUsagePurpose, primaryUse) || mychoiceSdkComponents.carUsagePurpose[0].value, hintMessage: primaryUseHintMessage, description: "The way you use your vehicle is a primary factor that insurers use in your policy terms and fees, whether it be personal or business.\n \u2022 Personal is driving from work or school to home.\n \u2022 Business considers other uses like sales calls, pick-ups or deliveries, or other business errands.", title: "What do you use your car for?" }), jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.firstDriveDistanceList, name: "distanceDaily", onChange: handleCarDailyDistanceChange, defaultValue: getSelectedOption(mychoiceSdkComponents.firstDriveDistanceList, distanceDaily), title: "How far is your 1-way commute to work or school?", placeholder: "Select", description: "The distance you drive to work or school would be an example of your daily commute. It is one of the most important factors when determining coverage options since it exposes you to traffic each day. The shorter your commute, the less risk you carry of an accident.", autoSelectIfValueIsOutOfOptions: false, error: distanceDaily === undefined && vehicleState.inValidation, errorMessage: getErrorMessage(distanceDaily, vehicleState.inValidation) }), jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.yearlyDriveDistanceList, name: "distanceYearly", onChange: handleCarYearlyDistanceChange, defaultValue: getSelectedOption(mychoiceSdkComponents.yearlyDriveDistanceList, distanceYearly), title: "How many total kilometers are driven each year?", placeholder: "Select", hintMessage: distanceDaily ? `Based on your daily driven kilometers, we recommend
|
|
913
|
+
${mychoiceSdkComponents.numberWithCommas(getRecommendedRange(distanceDaily, primaryUse === mychoiceSdkComponents.VehiclePrimaryUseTypes.Business ? distanceBusiness : 1))} for your yearly driven kilometers` : '', autoSelectIfValueIsOutOfOptions: false, error: !distanceYearly && vehicleState.inValidation, errorMessage: getErrorMessage(distanceYearly, vehicleState.inValidation) }), primaryUse === 'business' && (jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.businessUsePercentOptions, name: "businessUsePercent", onChange: handleBusinessUsePercentChange, defaultValue: getSelectedOption(mychoiceSdkComponents.businessUsePercentOptions, businessUsePercent), title: "What percentage of your total kilometers are driven for business purposes?", placeholder: "Select", autoSelectIfValueIsOutOfOptions: false, error: !businessUsePercent && vehicleState.inValidation, errorMessage: getErrorMessage(businessUsePercent, vehicleState.inValidation) })), showPolicyStartOnVehiclePage && (jsxRuntime.jsx(DateSelectFormBox, { name: "policyStart", dateNames: ['policyStartYear', 'policyStartMonth', 'policyStartDay'], onDateChange: handlePolicyStartDateChange, defaultValue: defaultPolicyStartDate, title: "What is the ideal start date for your new insurance policy?", description: "Select your preferred date for the beginning of your new insurance policy. For instance, you may set the start date for the day that your current insurance expires to ensure that you're continuously covered. Alternatively, select today's date for a quote or new policy.", minDate: mychoiceSdkComponents.addDaysToDate('', 1), maxDate: mychoiceSdkComponents.addDaysToDate('', 90), isDay: true }))] }));
|
|
886
914
|
};
|
|
887
915
|
|
|
888
916
|
const VehicleSectionMain = () => {
|
|
@@ -1211,96 +1239,174 @@ const SectionDriverInfo = () => {
|
|
|
1211
1239
|
return (jsxRuntime.jsxs("div", { className: `form-section ${mychoiceCls}`, children: [mychoiceCls && jsxRuntime.jsx("h2", { className: "section-title", children: "Time for a micro autobiography \u2013 tell us about you." }), jsxRuntime.jsx(InputFormBox, { name: "firstName", title: "What is your legal first name?", onChange: handleFirstNameChange, defaultValue: firstName, description: "The name on a policy should match the one on your official driver\u2019s licence.", placeholder: "Driver First Name", error: !firstName && driverState.inValidation, errorMessage: getErrorMessage(firstName, driverState.inValidation) }), jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.maritalStatusOptions, name: "maritalStatus", onChange: handleMaritalStatusChange, defaultValue: getSelectedOption(mychoiceSdkComponents.maritalStatusOptions, maritalStatus), title: "What is your marital status?", placeholder: "Select from the list", description: "If you are married, it may have a positive effect on your car insurance premiums and coverage. In some provinces, the law now considers same-sex partners to have a common-law marriage, so you will need to check your local regulations. If you are divorced or widowed, select single.", autoSelectIfValueIsOutOfOptions: false, error: !maritalStatus && driverState.inValidation, errorMessage: getErrorMessage(maritalStatus, driverState.inValidation) }), jsxRuntime.jsx(DateSelectFormBox, { name: "dateOfBirth", dateNames: ['birthYear', 'birthMonth', 'birthDay'], onDateChange: handleDateOfBirthChange, defaultValue: defaultDateOfBirth, title: "When were you born?", description: "Insurers generally consider your age and driving experience when calculating a vehicle insurance quote. The safest drivers are often those who are over thirty, but each insurer will have their own parameters. The youngest and oldest drivers have the greatest liability reflected in their premiums due to inexperience or health complications, respectively.", errorMessage: getDateErrorMessage([birthDay || '', birthMonth || '', birthYear || ''], driverState.inValidation), error: driverState.inValidation, maxDate: mychoiceSdkComponents.subYearsFromDate('', configState.licenceConfig.minLicenceAge || 16), isDay: true }), jsxRuntime.jsx(SwitchButtonBox, { name: "occupation", items: mychoiceSdkComponents.occupationOptions, onChange: handleOccupationChange, defaultValue: getSelectedOption(mychoiceSdkComponents.occupationOptions, occupation), title: "Are you currently employed or unemployed?", description: "Your employment status reflects your driving frequency, and insurers consider this in your policy." }), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.genderOptions, onChange: handleGenderChange, name: "gender", defaultValue: getSelectedOption(mychoiceSdkComponents.genderOptions, gender), title: "What is your gender?", description: "The gender on the policy should match your official driver\u2019s licence. Some insurers analyze a driver's sex when creating a policy. Men are typically considered higher risk than female drivers, but the statistics supporting this idea vary from province to province. On average, men and women pay roughly the same for insurance, though." }), driverState.activeIndex > 0 && (jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.applicantRelationshipOptions, name: "applicantRelationship", onChange: handleApplicantRelationshipChange, defaultValue: getSelectedOption(mychoiceSdkComponents.applicantRelationshipOptions, applicantRelationship), title: "Relationship to applicant", placeholder: "Select...", autoSelectIfValueIsOutOfOptions: false, error: !applicantRelationship && driverState.inValidation, errorMessage: getErrorMessage(applicantRelationship, driverState.inValidation) }))] }));
|
|
1212
1240
|
};
|
|
1213
1241
|
|
|
1242
|
+
// Max months between consecutive Ontario GDL licence classes (spec 1-2 e/f)
|
|
1243
|
+
const ON_MAX_MONTHS_BETWEEN_CLASSES = 60;
|
|
1214
1244
|
const SectionDriverLicence = () => {
|
|
1215
1245
|
const { appConfigState: { appType }, } = mychoiceSdkStore.useStoreAppConfig();
|
|
1216
1246
|
const [driverEducation, setDriverEducation] = React.useState(false);
|
|
1217
1247
|
const { configState } = mychoiceSdkStore.useStoreFormCarConfig();
|
|
1218
1248
|
const { driverState, dispatchDriverLicenceState } = mychoiceSdkStore.useStoreFormCarDriverLicence();
|
|
1219
|
-
const { isAlbertaProvince } = mychoiceSdkStore.useProvince();
|
|
1249
|
+
const { isAlbertaProvince, isOntarioProvince } = mychoiceSdkStore.useProvince();
|
|
1220
1250
|
const mychoiceCls = mychoiceSdkComponents.isMyChoiceLike(appType) ? 'mychoice' : '';
|
|
1221
|
-
const
|
|
1251
|
+
const isTheBig = appType === mychoiceSdkComponents.AppTypes.TheBig;
|
|
1252
|
+
// Ontario flow applies only for MyChoice-like (WL/MC) quoters, not TheBig
|
|
1253
|
+
const useOntarioFlow = isOntarioProvince && !isTheBig;
|
|
1254
|
+
const { firstName, birthDay, birthMonth, birthYear, licenceInfo: { firstLicenceAge, licenceType, g1LicenceYear, g1LicenceMonth, gLicenceYear, gLicenceMonth, g2LicenceYear, g2LicenceMonth, passedDriverTraining, previousLicence, receivedG2, receivedG, }, minMaxDates, } = driverState.items[driverState.activeIndex];
|
|
1222
1255
|
const { gMax = mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd'), gMin = '1922-01-01', gOneMax = mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd'), gOneMin = '1922-01-01', gTwoMax = mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd'), gTwoMin = '1922-01-01', gBlock = false, gTwoBlock = false, gOneBlock = false, licenceAgeMax = 16, } = minMaxDates ?? {};
|
|
1223
1256
|
const maxLicenceAge = licenceAgeMax;
|
|
1224
1257
|
const driverNameDefault = `Driver ${driverState.activeIndex + 1}`;
|
|
1225
1258
|
const birthDate = birthYear && birthMonth && birthDay ? `${birthYear}-${birthMonth}-${birthDay}` : '';
|
|
1226
1259
|
const defaultMinDate = birthDate && firstLicenceAge ? mychoiceSdkComponents.addYearsToDate(birthDate, +firstLicenceAge) : '';
|
|
1227
|
-
const
|
|
1228
|
-
|
|
1260
|
+
const getOntarioQ1YearMonth = () => {
|
|
1261
|
+
if (licenceType === mychoiceSdkComponents.DriverLicenceTypes.G2)
|
|
1262
|
+
return { year: g2LicenceYear, month: g2LicenceMonth };
|
|
1263
|
+
if (licenceType === mychoiceSdkComponents.DriverLicenceTypes.G)
|
|
1264
|
+
return { year: gLicenceYear, month: gLicenceMonth };
|
|
1265
|
+
return { year: g1LicenceYear, month: g1LicenceMonth };
|
|
1266
|
+
};
|
|
1267
|
+
const { year: ontarioQ1Year, month: ontarioQ1Month } = getOntarioQ1YearMonth();
|
|
1268
|
+
const ontarioQ1Date = ontarioQ1Year && ontarioQ1Month ? `${ontarioQ1Year}-${ontarioQ1Month}-01` : '';
|
|
1269
|
+
const isOnlyG = useOntarioFlow
|
|
1270
|
+
? (!!ontarioQ1Date && mychoiceSdkComponents.checkDateIsSpecial(ontarioQ1Date, configState.minDates.g.specialDate))
|
|
1271
|
+
: mychoiceSdkComponents.checkDateIsSpecial(defaultMinDate, configState.minDates.g.specialDate);
|
|
1272
|
+
const driverName = firstName || driverNameDefault;
|
|
1273
|
+
const today = mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd');
|
|
1229
1274
|
const { g, g1, g2, minLicenceAge } = configState.licenceConfig;
|
|
1230
1275
|
const licenceTypeOptions = [
|
|
1231
1276
|
{ value: g.name, name: g.title },
|
|
1232
1277
|
{ value: g1.name, name: g1.title },
|
|
1233
1278
|
{ value: g2.name, name: g2.title },
|
|
1234
1279
|
];
|
|
1280
|
+
// Ontario class dropdown options
|
|
1281
|
+
const ontarioFirstClassOptions = [
|
|
1282
|
+
{ value: mychoiceSdkComponents.DriverLicenceTypes.G1, name: 'G1 Beginner' },
|
|
1283
|
+
{ value: mychoiceSdkComponents.DriverLicenceTypes.G2, name: 'G2 Intermediate' },
|
|
1284
|
+
{ value: mychoiceSdkComponents.DriverLicenceTypes.G, name: 'G Full or equivalent' },
|
|
1285
|
+
];
|
|
1286
|
+
// Ontario "before 1994" — only G available, shown as disabled single option
|
|
1287
|
+
const ontarioOnlyGOptions = [
|
|
1288
|
+
{ value: mychoiceSdkComponents.DriverLicenceTypes.G, name: 'G Full or equivalent' },
|
|
1289
|
+
];
|
|
1290
|
+
// Legacy non-Ontario education effect
|
|
1235
1291
|
React.useEffect(() => {
|
|
1236
|
-
if (!
|
|
1237
|
-
if (
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1292
|
+
if (!useOntarioFlow) {
|
|
1293
|
+
if (!gOneBlock && !gTwoBlock) {
|
|
1294
|
+
if (licenceType !== mychoiceSdkComponents.DriverLicenceTypes.G1) {
|
|
1295
|
+
const g2Date = mychoiceSdkStore.addDayToDate(`${g2LicenceYear}-${g2LicenceMonth}`, birthDay ? +birthDay + 1 : 1);
|
|
1296
|
+
if (mychoiceSdkComponents.getDifferenceInYears('', g2Date) <= 3) {
|
|
1297
|
+
setDriverEducation(true);
|
|
1298
|
+
}
|
|
1299
|
+
else {
|
|
1300
|
+
setDriverEducation(false);
|
|
1301
|
+
}
|
|
1241
1302
|
}
|
|
1242
1303
|
else {
|
|
1243
1304
|
setDriverEducation(false);
|
|
1244
1305
|
}
|
|
1245
1306
|
}
|
|
1246
|
-
else {
|
|
1247
|
-
setDriverEducation(false);
|
|
1248
|
-
}
|
|
1249
1307
|
}
|
|
1250
|
-
}, [g2LicenceYear, g2LicenceMonth, licenceType]);
|
|
1308
|
+
}, [g2LicenceYear, g2LicenceMonth, licenceType, useOntarioFlow]);
|
|
1309
|
+
// If the user picks their birth month in their 16th year and birthDay > 1,
|
|
1310
|
+
// selecting that month would imply a date before their actual birthday (since dates are assumed
|
|
1311
|
+
// as the 1st). Auto-advance the Q1 month to birthMonth + 1.
|
|
1312
|
+
React.useEffect(() => {
|
|
1313
|
+
if (!useOntarioFlow || !birthDate || !ontarioQ1Year || !ontarioQ1Month)
|
|
1314
|
+
return;
|
|
1315
|
+
const birthDayNum = parseInt(birthDay || '1', 10);
|
|
1316
|
+
if (birthDayNum <= 1)
|
|
1317
|
+
return;
|
|
1318
|
+
const birthYearNum = parseInt(birthYear || '0', 10);
|
|
1319
|
+
if (parseInt(ontarioQ1Year, 10) !== birthYearNum + 16 || ontarioQ1Month !== birthMonth)
|
|
1320
|
+
return;
|
|
1321
|
+
const q1SlotForCorrection = licenceType || mychoiceSdkComponents.DriverLicenceTypes.G1;
|
|
1322
|
+
let correctedMonth = parseInt(birthMonth || '1', 10) + 1;
|
|
1323
|
+
let correctedYear = birthYearNum + 16;
|
|
1324
|
+
if (correctedMonth > 12) {
|
|
1325
|
+
correctedMonth = 1;
|
|
1326
|
+
correctedYear += 1;
|
|
1327
|
+
}
|
|
1328
|
+
dispatchDriverLicenceState({
|
|
1329
|
+
type: mychoiceSdkStore.StoreFormCarDriverLicenceActionTypes.FormCarDriverLicenceMonthSelect,
|
|
1330
|
+
payload: { value: String(correctedMonth).padStart(2, '0'), config: configState, type: q1SlotForCorrection },
|
|
1331
|
+
});
|
|
1332
|
+
if (correctedYear !== birthYearNum + 16) {
|
|
1333
|
+
dispatchDriverLicenceState({
|
|
1334
|
+
type: mychoiceSdkStore.StoreFormCarDriverLicenceActionTypes.FormCarDriverLicenceYearSelect,
|
|
1335
|
+
payload: { value: String(correctedYear), config: configState, type: q1SlotForCorrection },
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
}, [ontarioQ1Year, ontarioQ1Month]);
|
|
1339
|
+
// ── helpers ────────────────────────────────────────────────
|
|
1251
1340
|
const getMinDate = (type) => {
|
|
1252
1341
|
switch (type) {
|
|
1253
|
-
case mychoiceSdkComponents.DriverLicenceTypes.G:
|
|
1254
|
-
|
|
1255
|
-
case mychoiceSdkComponents.DriverLicenceTypes.
|
|
1256
|
-
|
|
1257
|
-
case mychoiceSdkComponents.DriverLicenceTypes.G2:
|
|
1258
|
-
return gTwoMin;
|
|
1259
|
-
default:
|
|
1260
|
-
return '';
|
|
1342
|
+
case mychoiceSdkComponents.DriverLicenceTypes.G: return gMin;
|
|
1343
|
+
case mychoiceSdkComponents.DriverLicenceTypes.G1: return gOneMin;
|
|
1344
|
+
case mychoiceSdkComponents.DriverLicenceTypes.G2: return gTwoMin;
|
|
1345
|
+
default: return '';
|
|
1261
1346
|
}
|
|
1262
1347
|
};
|
|
1263
1348
|
const getMaxDate = (type) => {
|
|
1264
1349
|
switch (type) {
|
|
1265
|
-
case mychoiceSdkComponents.DriverLicenceTypes.G:
|
|
1266
|
-
|
|
1267
|
-
case mychoiceSdkComponents.DriverLicenceTypes.
|
|
1268
|
-
|
|
1269
|
-
case mychoiceSdkComponents.DriverLicenceTypes.G2:
|
|
1270
|
-
return gTwoMax;
|
|
1271
|
-
default:
|
|
1272
|
-
return '';
|
|
1350
|
+
case mychoiceSdkComponents.DriverLicenceTypes.G: return gMax;
|
|
1351
|
+
case mychoiceSdkComponents.DriverLicenceTypes.G1: return gOneMax;
|
|
1352
|
+
case mychoiceSdkComponents.DriverLicenceTypes.G2: return gTwoMax;
|
|
1353
|
+
default: return '';
|
|
1273
1354
|
}
|
|
1274
1355
|
};
|
|
1275
1356
|
const getLicenceYear = (type) => {
|
|
1276
1357
|
switch (type) {
|
|
1277
|
-
case mychoiceSdkComponents.DriverLicenceTypes.G:
|
|
1278
|
-
|
|
1279
|
-
case mychoiceSdkComponents.DriverLicenceTypes.
|
|
1280
|
-
|
|
1281
|
-
case mychoiceSdkComponents.DriverLicenceTypes.G2:
|
|
1282
|
-
return g2LicenceYear;
|
|
1283
|
-
default:
|
|
1284
|
-
return '';
|
|
1358
|
+
case mychoiceSdkComponents.DriverLicenceTypes.G: return gLicenceYear;
|
|
1359
|
+
case mychoiceSdkComponents.DriverLicenceTypes.G1: return g1LicenceYear;
|
|
1360
|
+
case mychoiceSdkComponents.DriverLicenceTypes.G2: return g2LicenceYear;
|
|
1361
|
+
default: return '';
|
|
1285
1362
|
}
|
|
1286
1363
|
};
|
|
1287
1364
|
const getLicenceMonth = (type) => {
|
|
1288
1365
|
switch (type) {
|
|
1289
|
-
case mychoiceSdkComponents.DriverLicenceTypes.G:
|
|
1290
|
-
|
|
1291
|
-
case mychoiceSdkComponents.DriverLicenceTypes.
|
|
1292
|
-
|
|
1293
|
-
case mychoiceSdkComponents.DriverLicenceTypes.G2:
|
|
1294
|
-
return g2LicenceMonth;
|
|
1295
|
-
default:
|
|
1296
|
-
return '';
|
|
1366
|
+
case mychoiceSdkComponents.DriverLicenceTypes.G: return gLicenceMonth;
|
|
1367
|
+
case mychoiceSdkComponents.DriverLicenceTypes.G1: return g1LicenceMonth;
|
|
1368
|
+
case mychoiceSdkComponents.DriverLicenceTypes.G2: return g2LicenceMonth;
|
|
1369
|
+
default: return '';
|
|
1297
1370
|
}
|
|
1298
1371
|
};
|
|
1299
1372
|
const getDefaultLicenceDate = (type) => ({
|
|
1300
1373
|
year: getLicenceYear(type),
|
|
1301
1374
|
month: getLicenceMonth(type),
|
|
1302
|
-
day:
|
|
1375
|
+
day: '01',
|
|
1303
1376
|
});
|
|
1377
|
+
// Build a YYYY-MM-01 string from stored year/month, returns '' if either missing
|
|
1378
|
+
const toDate = (year, month) => (year && month ? `${year}-${month}-01` : '');
|
|
1379
|
+
const validateLicenceDate = (year, month, minDate) => {
|
|
1380
|
+
const dateStr = toDate(year, month);
|
|
1381
|
+
if (!dateStr)
|
|
1382
|
+
return '';
|
|
1383
|
+
if (mychoiceSdkComponents.compareDates(dateStr, today) > 0)
|
|
1384
|
+
return 'License dates cannot be in the future';
|
|
1385
|
+
if (minDate && mychoiceSdkComponents.compareDates(dateStr, minDate) < 0) {
|
|
1386
|
+
return 'This license date must be equal or later than the prior license date. Please check your selection';
|
|
1387
|
+
}
|
|
1388
|
+
return '';
|
|
1389
|
+
};
|
|
1390
|
+
const validate60Months = (earlierYear, earlierMonth, laterYear, laterMonth) => {
|
|
1391
|
+
const earlier = toDate(earlierYear, earlierMonth);
|
|
1392
|
+
const later = toDate(laterYear, laterMonth);
|
|
1393
|
+
if (!earlier || !later)
|
|
1394
|
+
return '';
|
|
1395
|
+
const months = mychoiceSdkComponents.getDifferenceInMonths(later, earlier);
|
|
1396
|
+
if (months > ON_MAX_MONTHS_BETWEEN_CLASSES) {
|
|
1397
|
+
return "Ontario's graduated license program must be completed within 5 years. Please check your selection";
|
|
1398
|
+
}
|
|
1399
|
+
return '';
|
|
1400
|
+
};
|
|
1401
|
+
// In the Ontario flow, firstLicenceAge is never entered, so gOneMin is stale/empty.
|
|
1402
|
+
// Compute min from DOB + 16, capped to today so minDate never exceeds maxDate.
|
|
1403
|
+
const getG1MinDate = () => {
|
|
1404
|
+
if (useOntarioFlow && birthDate) {
|
|
1405
|
+
const computed = mychoiceSdkComponents.addYearsToDate(birthDate, 16);
|
|
1406
|
+
return mychoiceSdkComponents.compareDates(computed, today) > 0 ? today : computed;
|
|
1407
|
+
}
|
|
1408
|
+
return gOneMin;
|
|
1409
|
+
};
|
|
1304
1410
|
const handleLicenceAgeChange = ({ value }) => {
|
|
1305
1411
|
dispatchDriverLicenceState({
|
|
1306
1412
|
type: mychoiceSdkStore.StoreFormCarDriverLicenceActionTypes.FormCarDriverLicenceAgeSelect,
|
|
@@ -1325,6 +1431,18 @@ const SectionDriverLicence = () => {
|
|
|
1325
1431
|
payload: { previousLicence: value },
|
|
1326
1432
|
});
|
|
1327
1433
|
};
|
|
1434
|
+
const handleReceivedG2Change = ({ value }) => {
|
|
1435
|
+
dispatchDriverLicenceState({
|
|
1436
|
+
type: mychoiceSdkStore.StoreFormCarDriverLicenceActionTypes.FormCarDriverReceivedG2Select,
|
|
1437
|
+
payload: { receivedG2: value },
|
|
1438
|
+
});
|
|
1439
|
+
};
|
|
1440
|
+
const handleReceivedGChange = ({ value }) => {
|
|
1441
|
+
dispatchDriverLicenceState({
|
|
1442
|
+
type: mychoiceSdkStore.StoreFormCarDriverLicenceActionTypes.FormCarDriverReceivedGSelect,
|
|
1443
|
+
payload: { receivedG: value },
|
|
1444
|
+
});
|
|
1445
|
+
};
|
|
1328
1446
|
const handleLicenceDateChange = (type) => (dateType) => ({ value }) => {
|
|
1329
1447
|
if (dateType === mychoiceSdkComponents.DateTypes.Month) {
|
|
1330
1448
|
dispatchDriverLicenceState({
|
|
@@ -1344,23 +1462,87 @@ const SectionDriverLicence = () => {
|
|
|
1344
1462
|
const licenceMinDate = getMinDate(currentType);
|
|
1345
1463
|
const licenceTypeTitle = configState.licenceConfig[currentType].title;
|
|
1346
1464
|
const formattedMinDate = `${mychoiceSdkComponents.getFormattedDate(licenceMinDate, 'MMMM yyyy')}`;
|
|
1347
|
-
const defaultHintMessage = `${formattedMinDate} would be your earliest ${licenceTypeTitle}
|
|
1348
|
-
licence date based on your first licenced age and date of birth`;
|
|
1465
|
+
const defaultHintMessage = `${formattedMinDate} would be your earliest ${licenceTypeTitle} licence date based on your first licenced age and date of birth`;
|
|
1349
1466
|
return currentType === mychoiceSdkComponents.DriverLicenceTypes.G2
|
|
1350
|
-
? `${defaultHintMessage}
|
|
1351
|
-
if you completed a driver education course`
|
|
1467
|
+
? `${defaultHintMessage} if you completed a driver education course`
|
|
1352
1468
|
: defaultHintMessage;
|
|
1353
1469
|
};
|
|
1354
1470
|
const getLicenceAgeTitle = () => {
|
|
1355
|
-
if (isAlbertaProvince && isTheBig)
|
|
1471
|
+
if (isAlbertaProvince && isTheBig)
|
|
1356
1472
|
return 'At what age was Class 5 GDL or Class 5 obtained?';
|
|
1357
|
-
}
|
|
1358
|
-
|
|
1359
|
-
|
|
1473
|
+
return `What age was ${driverName} when first licenced?`;
|
|
1474
|
+
};
|
|
1475
|
+
if (useOntarioFlow) {
|
|
1476
|
+
// When isOnlyG (before Apr 1994), treat as G Full regardless of what licenceType is in the store
|
|
1477
|
+
const firstClass = isOnlyG ? mychoiceSdkComponents.DriverLicenceTypes.G : licenceType;
|
|
1478
|
+
// Q1 date lives in whichever slot the store wrote to (always ${licenceType}LicenceYear/Month).
|
|
1479
|
+
const q1SlotType = licenceType || mychoiceSdkComponents.DriverLicenceTypes.G1;
|
|
1480
|
+
const q1Year = getLicenceYear(q1SlotType);
|
|
1481
|
+
const q1Month = getLicenceMonth(q1SlotType);
|
|
1482
|
+
const q1Date = toDate(q1Year, q1Month);
|
|
1483
|
+
// ── path booleans ──
|
|
1484
|
+
const showG2Date = firstClass === mychoiceSdkComponents.DriverLicenceTypes.G1 && receivedG2 === true;
|
|
1485
|
+
// G question shows after G2 date entered (G1→G2 path) OR after No-G2 answer (G1→No G2 path)
|
|
1486
|
+
const showGQuestionAfterG1 = firstClass === mychoiceSdkComponents.DriverLicenceTypes.G1
|
|
1487
|
+
&& (receivedG2 === false || showG2Date);
|
|
1488
|
+
const showGDateAfterG1 = showGQuestionAfterG1 && receivedG === true;
|
|
1489
|
+
const showGDateAfterG2 = firstClass === mychoiceSdkComponents.DriverLicenceTypes.G2 && receivedG === true;
|
|
1490
|
+
const g2Date = toDate(g2LicenceYear, g2LicenceMonth);
|
|
1491
|
+
const gDate = toDate(gLicenceYear, gLicenceMonth);
|
|
1492
|
+
// G1 branch: DTC shows whenever G1 is selected and Q1 date is entered (no time gate per flowchart)
|
|
1493
|
+
const showDtcG1Only = firstClass === mychoiceSdkComponents.DriverLicenceTypes.G1 && !!q1Date;
|
|
1494
|
+
const showDtcG1G2 = firstClass === mychoiceSdkComponents.DriverLicenceTypes.G1
|
|
1495
|
+
&& showG2Date
|
|
1496
|
+
&& !!g2Date
|
|
1497
|
+
&& mychoiceSdkComponents.getDifferenceInYears('', g2Date) <= 3;
|
|
1498
|
+
// Branch B: DTC shown as soon as class=G2 and Q1 is within 3 years (before G question)
|
|
1499
|
+
const showDtcG2Only = firstClass === mychoiceSdkComponents.DriverLicenceTypes.G2
|
|
1500
|
+
&& !!q1Date
|
|
1501
|
+
&& mychoiceSdkComponents.getDifferenceInYears('', q1Date) <= 3;
|
|
1502
|
+
// Branch C G Full: within 3 years of Q1 (G date)
|
|
1503
|
+
const showDtcGFull = firstClass === mychoiceSdkComponents.DriverLicenceTypes.G
|
|
1504
|
+
&& !!q1Date
|
|
1505
|
+
&& mychoiceSdkComponents.getDifferenceInYears('', q1Date) <= 3;
|
|
1506
|
+
// ── Validation error messages ──
|
|
1507
|
+
const q1MinDate = getG1MinDate();
|
|
1508
|
+
const q1ChronoError = driverState.inValidation
|
|
1509
|
+
? validateLicenceDate(q1Year, q1Month, q1MinDate)
|
|
1510
|
+
: '';
|
|
1511
|
+
const q1FutureError = q1Date && mychoiceSdkComponents.compareDates(q1Date, today) > 0
|
|
1512
|
+
? 'License dates cannot be in the future' : '';
|
|
1513
|
+
const q1Error = q1FutureError || q1ChronoError || getDateErrorMessage(['01', q1Month, q1Year], driverState.inValidation);
|
|
1514
|
+
const g2ChronoError = driverState.inValidation
|
|
1515
|
+
? validateLicenceDate(g2LicenceYear, g2LicenceMonth, q1Date)
|
|
1516
|
+
: '';
|
|
1517
|
+
const g260MonthError = validate60Months(q1Year, q1Month, g2LicenceYear, g2LicenceMonth);
|
|
1518
|
+
const g2FutureError = g2Date && mychoiceSdkComponents.compareDates(g2Date, today) > 0 ? 'License dates cannot be in the future' : '';
|
|
1519
|
+
const g2Error = g2FutureError || g260MonthError || g2ChronoError || getDateErrorMessage(['01', g2LicenceMonth, g2LicenceYear], driverState.inValidation);
|
|
1520
|
+
// G preceding date: G2 date if on G1→G2→G path, else Q1 date
|
|
1521
|
+
const gPrecedingDate = showGDateAfterG1 && showG2Date ? g2Date : q1Date;
|
|
1522
|
+
const gChronoError = driverState.inValidation
|
|
1523
|
+
? validateLicenceDate(gLicenceYear, gLicenceMonth, gPrecedingDate)
|
|
1524
|
+
: '';
|
|
1525
|
+
const g60MonthError = validate60Months(q1Year, q1Month, gLicenceYear, gLicenceMonth);
|
|
1526
|
+
const gFutureError = gDate && mychoiceSdkComponents.compareDates(gDate, today) > 0 ? 'License dates cannot be in the future' : '';
|
|
1527
|
+
const gError = gFutureError || g60MonthError || gChronoError || getDateErrorMessage(['01', gLicenceMonth, gLicenceYear], driverState.inValidation);
|
|
1528
|
+
// ── Min dates (always capped to today so minDate never exceeds maxDate) ──
|
|
1529
|
+
const g2MinRaw = q1Date && mychoiceSdkComponents.compareDates(q1Date, gTwoMin) > 0 ? q1Date : gTwoMin;
|
|
1530
|
+
const g2MinDate = mychoiceSdkComponents.compareDates(g2MinRaw, today) > 0 ? today : g2MinRaw;
|
|
1531
|
+
const gMinRaw = gPrecedingDate && mychoiceSdkComponents.compareDates(gPrecedingDate, gMin) > 0 ? gPrecedingDate : gMin;
|
|
1532
|
+
const gMinDate = mychoiceSdkComponents.compareDates(gMinRaw, today) > 0 ? today : gMinRaw;
|
|
1533
|
+
const getMax60Date = (refDate) => {
|
|
1534
|
+
if (!refDate)
|
|
1535
|
+
return today;
|
|
1536
|
+
const max60 = mychoiceSdkComponents.addMonthsToDate(refDate, ON_MAX_MONTHS_BETWEEN_CLASSES);
|
|
1537
|
+
return mychoiceSdkComponents.compareDates(today, max60) > 0 ? max60 : today;
|
|
1538
|
+
};
|
|
1539
|
+
const g2MaxDate = getMax60Date(q1Date);
|
|
1540
|
+
const gMaxDate = getMax60Date(q1Date);
|
|
1541
|
+
return (jsxRuntime.jsxs("div", { className: `form-section ${mychoiceCls}`, children: [jsxRuntime.jsx(DateSelectFormBox, { name: "firstLicenceDate", dateNames: ['firstLicenceYear', 'firstLicenceMonth'], onDateChange: handleLicenceDateChange(q1SlotType), defaultValue: getDefaultLicenceDate(q1SlotType), title: `When did ${driverName} first receive their drivers license in Canada?`, description: "Select the year and month in which you received your first license to drive an automobile in Canada. This would include a beginners, intermediate or full license.", errorMessage: q1Error, error: driverState.inValidation, minDate: q1MinDate, maxDate: today, disabled: !birthDate }), q1Date && (jsxRuntime.jsx(SelectFormBox, { options: isOnlyG ? ontarioOnlyGOptions : ontarioFirstClassOptions, name: "firstLicenceClass", onChange: handleLicenceTypeChange, defaultValue: getSelectedOption(isOnlyG ? ontarioOnlyGOptions : ontarioFirstClassOptions, licenceType), title: "What class of license was it?", placeholder: "Select from the list", disabled: isOnlyG, description: "Drivers licensed in Ontario under the graduated licensing program would select G1 Beginner. If the driver was licensed outside Ontario or granted an exception for having driving experience from another jurisdiction then select the license class they first received. Select class G Full or equivalent if the driver was licensed in Ontario before 1994 or was licensed in another province. G equivalent classes in Canada are class 5.", autoSelectIfValueIsOutOfOptions: false })), firstClass === mychoiceSdkComponents.DriverLicenceTypes.G1 && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [showDtcG1Only && (jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleTrainingChange, name: "passedDriverTraining", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, passedDriverTraining), title: `Has ${driverName} completed a gov't approved drivers education course within the past 5 years?` })), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleReceivedG2Change, name: "receivedG2", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, receivedG2), title: `Did ${driverName} receive a G2 license?` }), showG2Date && (jsxRuntime.jsx(DateSelectFormBox, { name: "g2LicenceDate", dateNames: ['g2LicenceYear', 'g2LicenceMonth'], onDateChange: handleLicenceDateChange(mychoiceSdkComponents.DriverLicenceTypes.G2), defaultValue: getDefaultLicenceDate(mychoiceSdkComponents.DriverLicenceTypes.G2), title: `When did ${driverName} receive this G2 license?`, errorMessage: g2Error, error: driverState.inValidation, minDate: g2MinDate, maxDate: g2MaxDate })), showDtcG1G2 && (jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleTrainingChange, name: "passedDriverTraining", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, passedDriverTraining), title: `Has ${driverName} completed a gov't approved drivers education course within the past 3 years?` })), showGQuestionAfterG1 && (jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleReceivedGChange, name: "receivedG", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, receivedG), title: `Did ${driverName} receive a G license?` })), showGDateAfterG1 && (jsxRuntime.jsx(DateSelectFormBox, { name: "gLicenceDate", dateNames: ['gLicenceYear', 'gLicenceMonth'], onDateChange: handleLicenceDateChange(mychoiceSdkComponents.DriverLicenceTypes.G), defaultValue: getDefaultLicenceDate(mychoiceSdkComponents.DriverLicenceTypes.G), title: `When did ${driverName} receive this G license?`, errorMessage: gError, error: driverState.inValidation, minDate: gMinDate, maxDate: gMaxDate }))] })), firstClass === mychoiceSdkComponents.DriverLicenceTypes.G2 && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [showDtcG2Only && (jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleTrainingChange, name: "passedDriverTraining", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, passedDriverTraining), title: `Has ${driverName} completed a gov't approved drivers education course within the past 3 years?` })), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleReceivedGChange, name: "receivedG", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, receivedG), title: `Did ${driverName} receive a G license?` }), showGDateAfterG2 && (jsxRuntime.jsx(DateSelectFormBox, { name: "gLicenceDate", dateNames: ['gLicenceYear', 'gLicenceMonth'], onDateChange: handleLicenceDateChange(mychoiceSdkComponents.DriverLicenceTypes.G), defaultValue: getDefaultLicenceDate(mychoiceSdkComponents.DriverLicenceTypes.G), title: `When did ${driverName} receive this G license?`, errorMessage: gError, error: driverState.inValidation, minDate: gMinDate, maxDate: gMaxDate }))] })), firstClass === mychoiceSdkComponents.DriverLicenceTypes.G && !isOnlyG && showDtcGFull && (jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleTrainingChange, name: "passedDriverTraining", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, passedDriverTraining), title: `Has ${driverName} completed a gov't approved drivers education course within the past 3 years?` })), isOnlyG && showDtcGFull && (jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleTrainingChange, name: "passedDriverTraining", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, passedDriverTraining), title: `Has ${driverName} completed a gov't approved drivers education course within the past 3 years?` })), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handlePreviousLicenceChange, name: "previousLicence", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, previousLicence), title: `Has ${driverName} ever had a full license anywhere else in Canada or USA?`, description: "If you have driving experience outside Canada or the United States, it may lower your premium. Your insurer may require proof of insurance in these other locations or some proof of driving experience from the country you indicate (like a copy of a previous driver's licence)." })] }));
|
|
1542
|
+
}
|
|
1360
1543
|
return (jsxRuntime.jsxs("div", { className: `form-section ${mychoiceCls}`, children: [jsxRuntime.jsx(InputFormBox, { name: "firstLicenceAge", title: getLicenceAgeTitle(), onChange: handleLicenceAgeChange, type: mychoiceSdkComponents.InputTypes.Number, defaultValue: firstLicenceAge, description: configState.toolTip.licenceAge, hintMessage: birthDate
|
|
1361
|
-
? `${
|
|
1362
|
-
|
|
1363
|
-
: '', placeholder: "Select Licence Age", disabled: !birthDate, error: !firstLicenceAge && driverState.inValidation, errorMessage: getErrorMessage(firstLicenceAge, driverState.inValidation), minValue: minLicenceAge || 16, maxValue: maxLicenceAge }), jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.getLicenceTypeOptions(licenceTypeOptions, mychoiceSdkComponents.getDisabledLicenceTypes(gBlock, gTwoBlock, gOneBlock), true), name: "licenceType", onChange: handleLicenceTypeChange, defaultValue: getSelectedOption(licenceTypeOptions, licenceType), title: `Please choose the type of licence that ${firstName || driverNameDefault} currently holds`, placeholder: "Select from the list", disabled: !birthDate, description: configState.toolTip.licenceType, autoSelectIfValueIsOutOfOptions: false }), licenceType === mychoiceSdkComponents.DriverLicenceTypes.G && !isOnlyG && (jsxRuntime.jsx(DateSelectFormBox, { name: "g2LicenceDate", dateNames: ['g2LicenceYear', 'g2LicenceMonth'], onDateChange: handleLicenceDateChange(mychoiceSdkComponents.DriverLicenceTypes.G2), defaultValue: getDefaultLicenceDate(mychoiceSdkComponents.DriverLicenceTypes.G2), title: `${configState.licenceConfig.g2.title} licence date`, errorMessage: getDateErrorMessage(['01', g2LicenceMonth, g2LicenceYear], driverState.inValidation), hintMessage: getHintMessage(mychoiceSdkComponents.DriverLicenceTypes.G2), error: driverState.inValidation, minDate: getMinDate(mychoiceSdkComponents.DriverLicenceTypes.G2), maxDate: getMaxDate(mychoiceSdkComponents.DriverLicenceTypes.G2) })), licenceType && (jsxRuntime.jsx(DateSelectFormBox, { name: `${licenceType}LicenceDate`, dateNames: [`${licenceType}LicenceYear`, `${licenceType}LicenceMonth`], onDateChange: handleLicenceDateChange(), defaultValue: getDefaultLicenceDate(licenceType), title: `${configState.licenceConfig[licenceType].title} licence date`, errorMessage: getDateErrorMessage(['01', getLicenceMonth(licenceType), getLicenceYear(licenceType)], driverState.inValidation), hintMessage: getHintMessage(), error: driverState.inValidation, maxDate: getMaxDate(licenceType), minDate: getMinDate(licenceType) })), driverEducation && (jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleTrainingChange, name: "passedDriverTraining", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, passedDriverTraining), title: `Has ${firstName || driverNameDefault} completed a driver education course within the last 3 years?` })), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handlePreviousLicenceChange, name: "previousLicence", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, previousLicence), title: `Has ${firstName || driverNameDefault} ever had a full license anywhere else in Canada or USA?`, description: "If you have driving experience outside Canada or the United States, it may lower your premium. Your insurer may require proof of insurance in these other locations or some proof of driving experience from the country you indicate (like a copy of a previous driver\u2019s licence)." })] }));
|
|
1544
|
+
? `${driverName} was licenced in ${Number(birthYear) + Number(firstLicenceAge)} - ${Number(birthYear) + Number(firstLicenceAge) + 1}`
|
|
1545
|
+
: '', placeholder: "Select Licence Age", disabled: !birthDate, error: !firstLicenceAge && driverState.inValidation, errorMessage: getErrorMessage(firstLicenceAge, driverState.inValidation), minValue: minLicenceAge || 16, maxValue: maxLicenceAge }), jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.getLicenceTypeOptions(licenceTypeOptions, mychoiceSdkComponents.getDisabledLicenceTypes(gBlock, gTwoBlock, gOneBlock), true), name: "licenceType", onChange: handleLicenceTypeChange, defaultValue: getSelectedOption(licenceTypeOptions, licenceType), title: `Please choose the type of licence that ${driverName} currently holds`, placeholder: "Select from the list", disabled: !birthDate, description: configState.toolTip.licenceType, autoSelectIfValueIsOutOfOptions: false }), licenceType === mychoiceSdkComponents.DriverLicenceTypes.G && !isOnlyG && (jsxRuntime.jsx(DateSelectFormBox, { name: "g2LicenceDate", dateNames: ['g2LicenceYear', 'g2LicenceMonth'], onDateChange: handleLicenceDateChange(mychoiceSdkComponents.DriverLicenceTypes.G2), defaultValue: getDefaultLicenceDate(mychoiceSdkComponents.DriverLicenceTypes.G2), title: `${configState.licenceConfig.g2.title} licence date`, errorMessage: getDateErrorMessage(['01', g2LicenceMonth, g2LicenceYear], driverState.inValidation), hintMessage: getHintMessage(mychoiceSdkComponents.DriverLicenceTypes.G2), error: driverState.inValidation, minDate: getMinDate(mychoiceSdkComponents.DriverLicenceTypes.G2), maxDate: getMaxDate(mychoiceSdkComponents.DriverLicenceTypes.G2) })), licenceType && (jsxRuntime.jsx(DateSelectFormBox, { name: `${licenceType}LicenceDate`, dateNames: [`${licenceType}LicenceYear`, `${licenceType}LicenceMonth`], onDateChange: handleLicenceDateChange(), defaultValue: getDefaultLicenceDate(licenceType), title: `${configState.licenceConfig[licenceType].title} licence date`, errorMessage: getDateErrorMessage(['01', getLicenceMonth(licenceType), getLicenceYear(licenceType)], driverState.inValidation), hintMessage: getHintMessage(), error: driverState.inValidation, maxDate: getMaxDate(licenceType), minDate: getMinDate(licenceType) })), driverEducation && (jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleTrainingChange, name: "passedDriverTraining", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, passedDriverTraining), title: `Has ${driverName} completed a driver education course within the last 3 years?` })), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handlePreviousLicenceChange, name: "previousLicence", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, previousLicence), title: `Has ${driverName} ever had a full license anywhere else in Canada or USA?`, description: "If you have driving experience outside Canada or the United States, it may lower your premium. Your insurer may require proof of insurance in these other locations or some proof of driving experience from the country you indicate (like a copy of a previous driver's licence)." })] }));
|
|
1364
1546
|
};
|
|
1365
1547
|
|
|
1366
1548
|
const SectionDriverInsurancePolicy = () => {
|
|
@@ -1369,7 +1551,7 @@ const SectionDriverInsurancePolicy = () => {
|
|
|
1369
1551
|
const { driverState, dispatchDriverInsuranceState } = mychoiceSdkStore.useStoreFormCarDriverInsurance();
|
|
1370
1552
|
const { discountState, dispatchDiscountState } = mychoiceSdkStore.useStoreFormCarDiscount();
|
|
1371
1553
|
const { quoteState: { isRequested }, } = mychoiceSdkStore.useStoreFormCarQuote();
|
|
1372
|
-
const { listed, listedMonth = '', listedYear = '', insured, insuredDate = '', firstName, birthYear, birthMonth, birthDay, licenceInfo: { firstLicenceAge, licenceType, gLicenceYear, gLicenceMonth, g1LicenceYear, g1LicenceMonth }, } = driverState.items[driverState.activeIndex];
|
|
1554
|
+
const { listed, listedMonth = '', listedYear = '', insured, insuredDate = '', notCurrentlyInsured, lastPolicyEndYear = '', lastPolicyEndMonth = '', lastPolicyCancelReason = '', firstName, birthYear, birthMonth, birthDay, licenceInfo: { firstLicenceAge, licenceType, gLicenceYear, gLicenceMonth, g1LicenceYear, g1LicenceMonth }, } = driverState.items[driverState.activeIndex];
|
|
1373
1555
|
const { policyStartYear, policyStartMonth, policyStartDay } = discountState;
|
|
1374
1556
|
const driverNameDefault = `Driver ${driverState.activeIndex + 1}`;
|
|
1375
1557
|
const birthDate = birthYear && birthMonth && birthDay ? `${birthYear}-${birthMonth}-${birthDay}` : '';
|
|
@@ -1380,20 +1562,20 @@ const SectionDriverInsurancePolicy = () => {
|
|
|
1380
1562
|
const options = [{ value: '', name: 'Date Period', disabled: true }];
|
|
1381
1563
|
if (year && month) {
|
|
1382
1564
|
const todayDate = new Date();
|
|
1383
|
-
const
|
|
1384
|
-
const
|
|
1385
|
-
const yearsInPast = todayDate.getFullYear() - parseInt(year);
|
|
1386
|
-
|
|
1387
|
-
|
|
1565
|
+
const effectiveMonth = policyStartMonth || String(todayDate.getMonth() + 1).padStart(2, '0');
|
|
1566
|
+
const effectiveDay = policyStartDay || String(todayDate.getDate()).padStart(2, '0');
|
|
1567
|
+
const yearsInPast = Math.min(todayDate.getFullYear() - parseInt(year, 10), 10);
|
|
1568
|
+
options.push({
|
|
1569
|
+
value: mychoiceSdkComponents.subMonthsFromDate('', 6),
|
|
1570
|
+
name: 'Less than 1 year',
|
|
1571
|
+
});
|
|
1572
|
+
for (let i = 1; i <= yearsInPast; i += 1) {
|
|
1573
|
+
const pastDate = `${todayDate.getFullYear() - i}-${effectiveMonth}-${effectiveDay}`;
|
|
1388
1574
|
options.push({
|
|
1389
1575
|
value: pastDate,
|
|
1390
|
-
name: `${i} ${i === 1 ? 'Year' : 'Years'}`,
|
|
1576
|
+
name: i === 10 ? '10+ Years' : `${i} ${i === 1 ? 'Year' : 'Years'}`,
|
|
1391
1577
|
});
|
|
1392
1578
|
}
|
|
1393
|
-
options.push({
|
|
1394
|
-
value: `${todayDate.getFullYear() - 1}-${month}-${day}`,
|
|
1395
|
-
name: 'Less than 1 Year',
|
|
1396
|
-
});
|
|
1397
1579
|
}
|
|
1398
1580
|
return options;
|
|
1399
1581
|
};
|
|
@@ -1459,6 +1641,26 @@ you had insurance. If this is correct, please continue with the form.`);
|
|
|
1459
1641
|
payload: { insured: !value },
|
|
1460
1642
|
});
|
|
1461
1643
|
};
|
|
1644
|
+
const handleLastPolicyEndDateChange = (dateType) => ({ value }) => {
|
|
1645
|
+
if (dateType === mychoiceSdkComponents.DateTypes.Month) {
|
|
1646
|
+
dispatchDriverInsuranceState({
|
|
1647
|
+
type: mychoiceSdkStore.StoreFormCarDriverInsuranceActionTypes.FormCarDriverLastPolicyEndMonthSelect,
|
|
1648
|
+
payload: { lastPolicyEndMonth: value },
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
if (dateType === mychoiceSdkComponents.DateTypes.Year) {
|
|
1652
|
+
dispatchDriverInsuranceState({
|
|
1653
|
+
type: mychoiceSdkStore.StoreFormCarDriverInsuranceActionTypes.FormCarDriverLastPolicyEndYearSelect,
|
|
1654
|
+
payload: { lastPolicyEndYear: value },
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
};
|
|
1658
|
+
const handleLastPolicyCancelReasonChange = ({ value }) => {
|
|
1659
|
+
dispatchDriverInsuranceState({
|
|
1660
|
+
type: mychoiceSdkStore.StoreFormCarDriverInsuranceActionTypes.FormCarDriverLastPolicyCancelReasonSelect,
|
|
1661
|
+
payload: { lastPolicyCancelReason: value },
|
|
1662
|
+
});
|
|
1663
|
+
};
|
|
1462
1664
|
const handleListedChange = ({ value }) => {
|
|
1463
1665
|
dispatchDriverInsuranceState({
|
|
1464
1666
|
type: mychoiceSdkStore.StoreFormCarDriverInsuranceActionTypes.FormCarDriverListedSelect,
|
|
@@ -1505,20 +1707,26 @@ you had insurance. If this is correct, please continue with the form.`);
|
|
|
1505
1707
|
});
|
|
1506
1708
|
}
|
|
1507
1709
|
};
|
|
1508
|
-
return (jsxRuntime.jsxs("div", { className: `form-section ${mychoiceCls}`, children: [jsxRuntime.jsxs("div", { className: "box-container", children: [jsxRuntime.jsx(DateSelectFormBox, { name: "listedYear", dateNames: ['listedYear', 'listedMonth'], onDateChange: handleListedDateChange, defaultValue: defaultListedDate, disabled: !listed, title: `When was ${firstName || driverNameDefault} first listed as a driver on a Canadian or US insurance policy?`, description: "The selection indicates what year the
|
|
1710
|
+
return (jsxRuntime.jsxs("div", { className: `form-section ${mychoiceCls}`, children: [jsxRuntime.jsxs("div", { className: "box-container", children: [jsxRuntime.jsx(DateSelectFormBox, { name: "listedYear", dateNames: ['listedYear', 'listedMonth'], onDateChange: handleListedDateChange, defaultValue: defaultListedDate, disabled: !listed, title: `When was ${firstName || driverNameDefault} first listed as a driver on a Canadian or US insurance policy?`, description: "The selection indicates what month and year the driver was first listed on a Canadian or US insurance policy. If you do not remember this date, it is acceptable to provide a best estimate for the purposes of the policy or quote.", errorMessage: listed
|
|
1509
1711
|
? getDateErrorMessage(['01', listedMonth, listedYear], driverState.inValidation)
|
|
1510
|
-
: '', error: driverState.inValidation, hintMessage: hintMessage, minDate: mychoiceSdkComponents.getMinDate(birthDate, firstLicenceAge) }), jsxRuntime.jsx(mychoiceSdkComponents.CheckboxForm, { name: "listed", label: "Never listed on an insurance policy", onChange: handleListedChange, defaultValue: !listed })] }), listed && (jsxRuntime.jsxs("div", { className: "box-container", children: [jsxRuntime.jsx(SelectFormBox, { name: "insuredDate", onChange: handleInsuredPeriodChange, options: getPeriodOptions(listedYear, listedMonth), defaultValue: insuredDate, disabled: !insured, title: `How long has ${firstName || driverNameDefault} been with their current insurance provider?`, description: "It is common for insurers to provide loyalty rewards or discounts for valued customers. Loyalty is a positive trait in the industry, and most insurance companies will want to provide some incentive for continued customer relationships through tangible policy rewards.", errorMessage: insured ? getErrorMessage(insuredDate, driverState.inValidation) : '', error: !insuredDate && driverState.inValidation }), jsxRuntime.jsx(mychoiceSdkComponents.CheckboxForm, { name: "insured", label: "Not currently insured", onChange: handleInsuredChange, defaultValue: !insured })] })), !isTheBig && !mychoiceSdkComponents.isMyChoiceLike(appType) && (jsxRuntime.jsx(DateSelectFormBox, { name: "policyStart", dateNames: ['policyStartYear', 'policyStartMonth', 'policyStartDay'], onDateChange: handlePolicyStartDateChange, defaultValue: defaultPolicyStartDate, title: "What is the ideal start date for your new insurance policy?", description: "Select your preferred date for the beginning of your new insurance policy. For instance, you may set the start date for the day that your current insurance expires to ensure that you\u2019re continuously covered. Alternatively, select today's date for a quote or new policy.", errorMessage: getDateErrorMessage([policyStartDay || '', policyStartMonth || '', policyStartYear || ''], driverState.inValidation), error: driverState.inValidation, minDate: mychoiceSdkComponents.addDaysToDate('', 1), maxDate: mychoiceSdkComponents.addDaysToDate('', 60), isDay: true }))] }));
|
|
1712
|
+
: '', error: driverState.inValidation, hintMessage: hintMessage, minDate: mychoiceSdkComponents.getMinDate(birthDate, firstLicenceAge) }), jsxRuntime.jsx(mychoiceSdkComponents.CheckboxForm, { name: "listed", label: "Never listed on an insurance policy", onChange: handleListedChange, defaultValue: !listed })] }), listed && (jsxRuntime.jsxs("div", { className: "box-container", children: [jsxRuntime.jsx(SelectFormBox, { name: "insuredDate", onChange: handleInsuredPeriodChange, options: getPeriodOptions(listedYear, listedMonth), defaultValue: insuredDate, disabled: !insured, title: `How long has ${firstName || driverNameDefault} been with their current insurance provider?`, description: "It is common for insurers to provide loyalty rewards or discounts for valued customers. Loyalty is a positive trait in the industry, and most insurance companies will want to provide some incentive for continued customer relationships through tangible policy rewards.", errorMessage: insured ? getErrorMessage(insuredDate, driverState.inValidation) : '', error: !insuredDate && driverState.inValidation }), jsxRuntime.jsx(mychoiceSdkComponents.CheckboxForm, { name: "insured", label: "Not currently insured", onChange: handleInsuredChange, defaultValue: !insured })] })), listed && !insured && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(DateSelectFormBox, { name: "lastPolicyEnd", dateNames: ['lastPolicyEndYear', 'lastPolicyEndMonth'], onDateChange: handleLastPolicyEndDateChange, defaultValue: { year: lastPolicyEndYear, month: lastPolicyEndMonth, day: '01' }, title: `When did ${firstName || driverNameDefault}'s most recent policy end?`, errorMessage: getDateErrorMessage(['01', lastPolicyEndMonth, lastPolicyEndYear], driverState.inValidation), error: driverState.inValidation, maxDate: mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd') }), lastPolicyEndYear && lastPolicyEndMonth && (jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.insuranceCancellationReasonOptions, name: "lastPolicyCancelReason", onChange: handleLastPolicyCancelReasonChange, defaultValue: lastPolicyCancelReason, title: "Why was this last insurance policy cancelled?", placeholder: "Select from the list", autoSelectIfValueIsOutOfOptions: false, error: !lastPolicyCancelReason && driverState.inValidation, errorMessage: getErrorMessage(lastPolicyCancelReason, driverState.inValidation) }))] })), !isTheBig && !mychoiceSdkComponents.isMyChoiceLike(appType) && (jsxRuntime.jsx(DateSelectFormBox, { name: "policyStart", dateNames: ['policyStartYear', 'policyStartMonth', 'policyStartDay'], onDateChange: handlePolicyStartDateChange, defaultValue: defaultPolicyStartDate, title: "What is the ideal start date for your new insurance policy?", description: "Select your preferred date for the beginning of your new insurance policy. For instance, you may set the start date for the day that your current insurance expires to ensure that you\u2019re continuously covered. Alternatively, select today's date for a quote or new policy.", errorMessage: getDateErrorMessage([policyStartDay || '', policyStartMonth || '', policyStartYear || ''], driverState.inValidation), error: driverState.inValidation, minDate: mychoiceSdkComponents.addDaysToDate('', 1), maxDate: mychoiceSdkComponents.addDaysToDate('', 60), isDay: true }))] }));
|
|
1511
1713
|
};
|
|
1512
1714
|
|
|
1513
1715
|
const SectionDriverCancellation = () => {
|
|
1514
1716
|
const { driverState, dispatchDriverCancellationState } = mychoiceSdkStore.useStoreFormCarDriverCancellation();
|
|
1515
1717
|
const { dispatchDriverBaseState } = mychoiceSdkStore.useStoreFormCarDriverBase();
|
|
1718
|
+
const { discountState } = mychoiceSdkStore.useStoreFormCarDiscount();
|
|
1516
1719
|
const { insuranceCancellation, insuranceCancellationList = [] } = driverState.items[driverState.activeIndex];
|
|
1517
1720
|
const { appConfigState: { appType }, } = mychoiceSdkStore.useStoreAppConfig();
|
|
1518
1721
|
const isTheBig = appType === mychoiceSdkComponents.AppTypes.TheBig;
|
|
1519
1722
|
const mychoiceCls = mychoiceSdkComponents.isMyChoiceLike(appType) ? 'mychoice' : '';
|
|
1520
|
-
const { firstName, birthYear, birthMonth, birthDay, licenceInfo: { firstLicenceAge }, } = driverState.items[driverState.activeIndex];
|
|
1723
|
+
const { firstName, birthYear, birthMonth, birthDay, listedYear, listedMonth, licenceInfo: { firstLicenceAge }, } = driverState.items[driverState.activeIndex];
|
|
1521
1724
|
const birthDate = birthYear && birthMonth && birthDay ? `${birthYear}-${birthMonth}-${birthDay}` : '';
|
|
1725
|
+
const policyStart = discountState.policyStart || mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd');
|
|
1726
|
+
const firstInsuredDate = listedYear && listedMonth ? `${listedYear}-${listedMonth}-01` : '';
|
|
1727
|
+
const rawYearsSinceFirstInsured = firstInsuredDate ? mychoiceSdkComponents.getDifferenceInYears(policyStart, firstInsuredDate) : 0;
|
|
1728
|
+
const cancellationYearCap = Math.min(rawYearsSinceFirstInsured, 10);
|
|
1729
|
+
const cancellationYearLabel = cancellationYearCap <= 1 ? 'past year' : `past ${cancellationYearCap} years`;
|
|
1522
1730
|
const handleIconClick = (index) => () => {
|
|
1523
1731
|
dispatchDriverCancellationState({
|
|
1524
1732
|
type: mychoiceSdkStore.StoreFormCarDriverCancellationActionTypes.FormCarDriverInsuranceCancellationDelete,
|
|
@@ -1591,8 +1799,7 @@ const SectionDriverCancellation = () => {
|
|
|
1591
1799
|
});
|
|
1592
1800
|
}
|
|
1593
1801
|
};
|
|
1594
|
-
return (jsxRuntime.jsxs("div", { className: `form-section ${mychoiceCls}`, children: [jsxRuntime.jsx("h2", { className: isTheBig ? 'thebig-bold' : '', children: "Insurance Cancellation" }), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleCancellationChange, name: "insuranceCancellation", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, insuranceCancellation), title: `Has ${firstName} had an insurance company cancellation or
|
|
1595
|
-
a time without insurance coverage, within the past 3 years?`, description: "If an insurance company cancels your policy, it will increase your future insurance premiums. The most common reasons for cancellations include missed payments, excessive claims, false declarations, or criminal actions, for example. If you cancel the insurance policy, it is not relevant." }), insuranceCancellation && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [insuranceCancellationList?.map(({ cancellationReason, startYear, startMonth, endYear, endMonth }, index) => {
|
|
1802
|
+
return (jsxRuntime.jsxs("div", { className: `form-section ${mychoiceCls}`, children: [jsxRuntime.jsx("h2", { className: isTheBig ? 'thebig-bold' : '', children: "Insurance Cancellation" }), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleCancellationChange, name: "insuranceCancellation", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, insuranceCancellation), title: `Has ${firstName} had an insurance company cancellation or a time without insurance coverage, within the ${cancellationYearLabel}?`, description: "If an insurance company cancels your policy, it will increase your future insurance premiums. The most common reasons for cancellations include missed payments, excessive claims, false declarations, or criminal actions, for example. If you cancel the insurance policy, it is not relevant." }), insuranceCancellation && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [insuranceCancellationList?.map(({ cancellationReason, startYear, startMonth, endYear, endMonth }, index) => {
|
|
1596
1803
|
const defaultStartDate = {
|
|
1597
1804
|
year: startYear,
|
|
1598
1805
|
month: startMonth,
|
|
@@ -1604,7 +1811,7 @@ const SectionDriverCancellation = () => {
|
|
|
1604
1811
|
const now = mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd');
|
|
1605
1812
|
const days = birthDay ? +birthDay + 1 : 1;
|
|
1606
1813
|
const endDate = endYear && endMonth ? mychoiceSdkStore.addDayToDate(`${endYear}-${endMonth}`, days) : now;
|
|
1607
|
-
const currentMinDate = mychoiceSdkComponents.getMinDateByYears(mychoiceSdkComponents.getMinDate(birthDate, firstLicenceAge),
|
|
1814
|
+
const currentMinDate = mychoiceSdkComponents.getMinDateByYears(mychoiceSdkComponents.getMinDate(birthDate, firstLicenceAge), cancellationYearCap + 1);
|
|
1608
1815
|
const currentEndDate = mychoiceSdkComponents.compareDates(endDate, currentMinDate) < 0 ? currentMinDate : endDate;
|
|
1609
1816
|
return (jsxRuntime.jsxs("div", { className: "list-block", children: [jsxRuntime.jsx("hr", {}), jsxRuntime.jsxs("div", { className: "list-item", children: [jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.insuranceCancellationReasonOptions, name: `cancellationReason-${index}`, onChange: handleReasonChange(index), defaultValue: cancellationReason, title: "Reason", placeholder: "Select from the list", isRemovable: insuranceCancellationList.length > 1, onIconClick: handleIconClick(index), autoSelectIfValueIsOutOfOptions: false, error: !cancellationReason && driverState.inValidation, errorMessage: getErrorMessage(cancellationReason, driverState.inValidation) }), jsxRuntime.jsx(DateSelectFormBox, { name: `startDate-${index}`, dateNames: [`startYear-${index}`, `startMonth-${index}`], onDateChange: handleStartDateChange(index), defaultValue: defaultStartDate, title: "Start date", errorMessage: getDateErrorMessage(['01', startMonth, startYear], driverState.inValidation), error: driverState.inValidation, minDate: currentMinDate, maxDate: currentEndDate }), jsxRuntime.jsx(DateSelectFormBox, { name: `endDate-${index}`, dateNames: [`endYear-${index}`, `endMonth-${index}`], onDateChange: handleEndDateChange(index), defaultValue: defaultEndDate, title: "End Date", errorMessage: getDateErrorMessage(['01', endMonth, endYear], driverState.inValidation), error: driverState.inValidation, minDate: startMonth && startYear ? mychoiceSdkStore.addDayToDate(`${startYear}-${startMonth}`, days) : currentMinDate })] })] }, `insurance-cancellation-${index}`));
|
|
1610
1817
|
}), insuranceCancellationList?.length < 3 && (jsxRuntime.jsx(mychoiceSdkComponents.ButtonBase, { category: mychoiceSdkComponents.CategoryTypes.Filled, onClick: handleAddButtonClick, size: mychoiceSdkComponents.SizeTypes.Medium, color: mychoiceSdkComponents.ColorTypes.Primary, label: "Add another" }))] }))] }));
|
|
@@ -1614,10 +1821,15 @@ const BlockDriverSuspension = () => {
|
|
|
1614
1821
|
const { driverState, dispatchDriverSuspensionState } = mychoiceSdkStore.useStoreFormCarDriverSuspension();
|
|
1615
1822
|
const { licenceSuspension, licenceSuspensionList = [] } = driverState.items[driverState.activeIndex];
|
|
1616
1823
|
const { dispatchDriverBaseState } = mychoiceSdkStore.useStoreFormCarDriverBase();
|
|
1824
|
+
const { discountState } = mychoiceSdkStore.useStoreFormCarDiscount();
|
|
1617
1825
|
const { appConfigState: { appType } } = mychoiceSdkStore.useStoreAppConfig();
|
|
1618
1826
|
const isTheBig = appType === mychoiceSdkComponents.AppTypes.TheBig;
|
|
1619
1827
|
const { firstName, birthYear, birthMonth, birthDay, licenceInfo: { firstLicenceAge }, } = driverState.items[driverState.activeIndex];
|
|
1620
1828
|
const birthDate = birthYear && birthMonth && birthDay ? `${birthYear}-${birthMonth}-${birthDay}` : '';
|
|
1829
|
+
const earliestLicenceDate = birthDate && firstLicenceAge ? mychoiceSdkComponents.addYearsToDate(birthDate, +firstLicenceAge) : '';
|
|
1830
|
+
const policyStart = discountState.policyStart || mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd');
|
|
1831
|
+
const yearsElapsed = earliestLicenceDate ? Math.min(mychoiceSdkComponents.getDifferenceInYears(policyStart, earliestLicenceDate), 6) : 6;
|
|
1832
|
+
const suspensionYearLabel = yearsElapsed <= 1 ? 'past year' : `past ${yearsElapsed} years`;
|
|
1621
1833
|
const handleSuspensionChange = ({ value }) => {
|
|
1622
1834
|
dispatchDriverSuspensionState({
|
|
1623
1835
|
type: mychoiceSdkStore.StoreFormCarDriverSuspensionActionTypes.FormCarDriverLicenceSuspensionSelect,
|
|
@@ -1690,7 +1902,7 @@ const BlockDriverSuspension = () => {
|
|
|
1690
1902
|
});
|
|
1691
1903
|
}
|
|
1692
1904
|
};
|
|
1693
|
-
return (jsxRuntime.jsxs("div", { className: "form-block-container", children: [jsxRuntime.jsx("h2", { className: isTheBig ? 'thebig-bold' : '', children: "Licence Suspensions" }), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleSuspensionChange, name: "licenceSuspension", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, licenceSuspension), title: `Has ${firstName} had a licence suspension within the
|
|
1905
|
+
return (jsxRuntime.jsxs("div", { className: "form-block-container", children: [jsxRuntime.jsx("h2", { className: isTheBig ? 'thebig-bold' : '', children: "Licence Suspensions" }), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleSuspensionChange, name: "licenceSuspension", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, licenceSuspension), title: `Has ${firstName} had a licence suspension within the ${suspensionYearLabel}?`, description: "There are two main types of licence suspensions: 1. Non-administrated suspension for cause: A driver's licence is suspended or cancelled because of traffic and criminal code driving offences or collecting too many demerit points. 2. Administrative suspension/cancellation/lapse: A driver's licence is suspended, cancelled, or allowed to lapse for reasons other than driving offences or demerit points such as a roadside licence suspension, medical conditions or failure to comply with court\u2011ordered obligations." }), licenceSuspension && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [licenceSuspensionList?.map(({ suspensionReason, suspensionYear, suspensionMonth, reinstatementYear, reinstatementMonth, }, index) => {
|
|
1694
1906
|
const defaultSuspensionDate = {
|
|
1695
1907
|
year: suspensionYear,
|
|
1696
1908
|
month: suspensionMonth,
|
|
@@ -1702,7 +1914,7 @@ const BlockDriverSuspension = () => {
|
|
|
1702
1914
|
const now = mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd');
|
|
1703
1915
|
const days = birthDay ? (+birthDay + 1) : 1;
|
|
1704
1916
|
const endDate = reinstatementYear && reinstatementMonth ? mychoiceSdkStore.addDayToDate(`${reinstatementYear}-${reinstatementMonth}`, days) : now;
|
|
1705
|
-
const currentMinDate = mychoiceSdkComponents.getMinDateByYears(mychoiceSdkComponents.getMinDate(birthDate, firstLicenceAge),
|
|
1917
|
+
const currentMinDate = mychoiceSdkComponents.getMinDateByYears(mychoiceSdkComponents.getMinDate(birthDate, firstLicenceAge), 6);
|
|
1706
1918
|
const currentEndDate = mychoiceSdkComponents.compareDates(endDate, currentMinDate) < 0 ? currentMinDate : endDate;
|
|
1707
1919
|
return (jsxRuntime.jsxs("div", { className: "list-block", children: [jsxRuntime.jsx("hr", {}), jsxRuntime.jsxs("div", { className: "list-item", children: [jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.licenceSuspensionsReasonOptions, name: `suspensionReason-${index}`, onChange: handleReasonChange(index), defaultValue: suspensionReason, title: "Reason for licence suspension", placeholder: "Select from the list", isRemovable: licenceSuspensionList.length > 1, onIconClick: handleIconClick(index), autoSelectIfValueIsOutOfOptions: false, error: !suspensionReason && driverState.inValidation, errorMessage: getErrorMessage(suspensionReason, driverState.inValidation) }), jsxRuntime.jsx(DateSelectFormBox, { name: `suspensionDate-${index}`, dateNames: [`suspensionYear-${index}`, `suspensionMonth-${index}`], onDateChange: handleSuspensionDateChange(index), defaultValue: defaultSuspensionDate, title: "Start date", errorMessage: getDateErrorMessage(['01', suspensionMonth, suspensionYear], driverState.inValidation), error: driverState.inValidation, minDate: currentMinDate, maxDate: currentEndDate }), jsxRuntime.jsx(DateSelectFormBox, { name: `reinstatementDate-${index}`, dateNames: [`reinstatementYear-${index}`, `reinstatementMonth-${index}`], onDateChange: handleReinstatementDateChange(index), defaultValue: defaultReinstatementDate, title: "End Date", errorMessage: getDateErrorMessage(['01', reinstatementMonth, reinstatementYear], driverState.inValidation), error: driverState.inValidation, minDate: suspensionYear && suspensionMonth
|
|
1708
1920
|
? mychoiceSdkStore.addDayToDate(`${suspensionYear}-${suspensionMonth}`, days) : currentMinDate })] })] }, `suspension-${index}`));
|
|
@@ -1713,10 +1925,25 @@ const BlockDriverAccident = () => {
|
|
|
1713
1925
|
const { driverState, dispatchDriverAccidentState } = mychoiceSdkStore.useStoreFormCarDriverAccident();
|
|
1714
1926
|
const { dispatchDriverBaseState } = mychoiceSdkStore.useStoreFormCarDriverBase();
|
|
1715
1927
|
const { appConfigState: { appType } } = mychoiceSdkStore.useStoreAppConfig();
|
|
1928
|
+
const { discountState } = mychoiceSdkStore.useStoreFormCarDiscount();
|
|
1929
|
+
const { isAlbertaProvince, isNovaScotiaProvince, isNewfoundlandProvince, isOntarioProvince } = mychoiceSdkStore.useProvince();
|
|
1716
1930
|
const isTheBig = appType === mychoiceSdkComponents.AppTypes.TheBig;
|
|
1931
|
+
const accidentYearCap = isTheBig || isAlbertaProvince || isNovaScotiaProvince || isNewfoundlandProvince ? 10 : 25;
|
|
1717
1932
|
const { accident, accidentList = [] } = driverState.items[driverState.activeIndex];
|
|
1718
|
-
const { firstName, birthYear, birthMonth, birthDay, licenceInfo: { firstLicenceAge }, } = driverState.items[driverState.activeIndex];
|
|
1933
|
+
const { firstName, birthYear, birthMonth, birthDay, licenceInfo: { firstLicenceAge, licenceType, g1LicenceYear, g1LicenceMonth, g2LicenceYear, g2LicenceMonth, gLicenceYear, gLicenceMonth, }, } = driverState.items[driverState.activeIndex];
|
|
1719
1934
|
const birthDate = birthYear && birthMonth && birthDay ? `${birthYear}-${birthMonth}-${birthDay}` : '';
|
|
1935
|
+
const getOntarioQ1Date = () => {
|
|
1936
|
+
if (licenceType === mychoiceSdkComponents.DriverLicenceTypes.G2)
|
|
1937
|
+
return g2LicenceYear && g2LicenceMonth ? `${g2LicenceYear}-${g2LicenceMonth}-01` : '';
|
|
1938
|
+
if (licenceType === mychoiceSdkComponents.DriverLicenceTypes.G)
|
|
1939
|
+
return gLicenceYear && gLicenceMonth ? `${gLicenceYear}-${gLicenceMonth}-01` : '';
|
|
1940
|
+
return g1LicenceYear && g1LicenceMonth ? `${g1LicenceYear}-${g1LicenceMonth}-01` : '';
|
|
1941
|
+
};
|
|
1942
|
+
const ontarioQ1Date = isOntarioProvince && mychoiceSdkComponents.isMyChoiceLike(appType) ? getOntarioQ1Date() : '';
|
|
1943
|
+
const earliestLicenceDate = ontarioQ1Date || (birthDate && firstLicenceAge ? mychoiceSdkComponents.addYearsToDate(birthDate, +firstLicenceAge) : '');
|
|
1944
|
+
const policyStart = discountState.policyStart || mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd');
|
|
1945
|
+
const yearsElapsed = earliestLicenceDate ? Math.min(mychoiceSdkComponents.getDifferenceInYears(policyStart, earliestLicenceDate), accidentYearCap) : accidentYearCap;
|
|
1946
|
+
const accidentYearLabel = yearsElapsed <= 1 ? 'past year' : `past ${yearsElapsed} years`;
|
|
1720
1947
|
const handleAccidentChange = ({ value }) => {
|
|
1721
1948
|
dispatchDriverAccidentState({
|
|
1722
1949
|
type: mychoiceSdkStore.StoreFormCarDriverAccidentActionTypes.FormCarDriverAccidentSelect,
|
|
@@ -1760,13 +1987,13 @@ const BlockDriverAccident = () => {
|
|
|
1760
1987
|
});
|
|
1761
1988
|
}
|
|
1762
1989
|
};
|
|
1763
|
-
return (jsxRuntime.jsxs("div", { className: "form-block-container", children: [jsxRuntime.jsx("h2", { className: isTheBig ? 'thebig-bold' : '', children: "Accidents" }), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleAccidentChange, name: "accident", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, accident), title: `Has ${firstName}
|
|
1990
|
+
return (jsxRuntime.jsxs("div", { className: "form-block-container", children: [jsxRuntime.jsx("h2", { className: isTheBig ? 'thebig-bold' : '', children: "Accidents" }), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleAccidentChange, name: "accident", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, accident), title: `Has ${firstName} been at-fault for any accidents in the ${accidentYearLabel}?`, description: "An at-fault accident means you were responsible for the car accident according to provincially regulated Fault Determination Rules. Whether you did not obey traffic signals or hit the brakes too late, it can show up on your insurance record for up to 25 years. Insurers access at-fault information if one party reports it, so it is best to disclose previous incidents. A clean driving record mitigates additional hikes to your insurance premium." }), accident && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [accidentList?.map(({ accidentYear, accidentMonth, }, index) => {
|
|
1764
1991
|
const defaultSuspensionDate = {
|
|
1765
1992
|
year: accidentYear,
|
|
1766
1993
|
month: accidentMonth,
|
|
1767
1994
|
day: '01',
|
|
1768
1995
|
};
|
|
1769
|
-
return (jsxRuntime.jsxs("div", { className: "list-block", children: [jsxRuntime.jsx("hr", {}), jsxRuntime.jsx(DateSelectFormBox, { name: `accidentDate-${index}`, dateNames: [`accidentYear-${index}`, `accidentMonth-${index}`], onDateChange: handleAccidentDateChange(index), isRemovable: accidentList.length > 1, onIconClick: handleIconClick(index), defaultValue: defaultSuspensionDate, title: "Accident date", errorMessage: getDateErrorMessage(['01', accidentMonth, accidentYear], driverState.inValidation), error: driverState.inValidation, minDate: mychoiceSdkComponents.getMinDate(birthDate, firstLicenceAge) })] }, `accident-${index}`));
|
|
1996
|
+
return (jsxRuntime.jsxs("div", { className: "list-block", children: [jsxRuntime.jsx("hr", {}), jsxRuntime.jsx(DateSelectFormBox, { name: `accidentDate-${index}`, dateNames: [`accidentYear-${index}`, `accidentMonth-${index}`], onDateChange: handleAccidentDateChange(index), isRemovable: accidentList.length > 1, onIconClick: handleIconClick(index), defaultValue: defaultSuspensionDate, title: "Accident date", errorMessage: getDateErrorMessage(['01', accidentMonth, accidentYear], driverState.inValidation), error: driverState.inValidation, minDate: mychoiceSdkComponents.getMinDateByYears(ontarioQ1Date || mychoiceSdkComponents.getMinDate(birthDate, firstLicenceAge), accidentYearCap) })] }, `accident-${index}`));
|
|
1770
1997
|
}), accidentList?.length < 3 && (jsxRuntime.jsx(mychoiceSdkComponents.ButtonBase, { category: mychoiceSdkComponents.CategoryTypes.Filled, onClick: handleAddButtonClick, size: mychoiceSdkComponents.SizeTypes.Medium, color: mychoiceSdkComponents.ColorTypes.Primary, label: "Add another" }))] }))] }));
|
|
1771
1998
|
};
|
|
1772
1999
|
|
|
@@ -1793,11 +2020,39 @@ const BlockDriverTicket = () => {
|
|
|
1793
2020
|
const isTheBig = appType === mychoiceSdkComponents.AppTypes.TheBig;
|
|
1794
2021
|
const { firstName, minMaxDates, } = driverState.items[driverState.activeIndex];
|
|
1795
2022
|
const { gOneMin } = minMaxDates;
|
|
2023
|
+
const getSpeedingOptions = () => {
|
|
2024
|
+
if (isNovaScotiaProvince) {
|
|
2025
|
+
return [
|
|
2026
|
+
{ value: 'SP', name: 'Speeding 1 to 30 kph over limit' },
|
|
2027
|
+
{ value: 'SP', name: 'Speeding 31 to 50 kph over limit' },
|
|
2028
|
+
{ value: 'SP', name: 'Speeding 51 kph or more over limit' },
|
|
2029
|
+
];
|
|
2030
|
+
}
|
|
2031
|
+
if (isAlbertaProvince || isNewfoundlandProvince) {
|
|
2032
|
+
return [
|
|
2033
|
+
{ value: 'SP', name: 'Speeding 1 to 50 kph over limit' },
|
|
2034
|
+
{ value: 'SP', name: 'Speeding 51 kph or more over limit' },
|
|
2035
|
+
];
|
|
2036
|
+
}
|
|
2037
|
+
return [
|
|
2038
|
+
{ value: 'SP', name: 'Speeding 1 to 49 kph over limit' },
|
|
2039
|
+
{ value: 'SP', name: 'Speeding 50 kph or more over limit' },
|
|
2040
|
+
];
|
|
2041
|
+
};
|
|
1796
2042
|
const getTrafficTicketsGroupOptions = () => {
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
2043
|
+
const base = (isAlbertaProvince || isNewBrunswickProvince || isNovaScotiaProvince || isNewfoundlandProvince) && isTheBig
|
|
2044
|
+
? getTrafficTicketsGroupOptionsWithoutG1G2()
|
|
2045
|
+
: mychoiceSdkComponents.trafficTicketsGroupOptions;
|
|
2046
|
+
const speedingOptions = getSpeedingOptions();
|
|
2047
|
+
return base.map((group) => ({
|
|
2048
|
+
...group,
|
|
2049
|
+
options: group.options.flatMap((opt) => {
|
|
2050
|
+
if (opt.value === 'SP' && opt.name === 'Speeding') {
|
|
2051
|
+
return speedingOptions;
|
|
2052
|
+
}
|
|
2053
|
+
return [opt];
|
|
2054
|
+
}),
|
|
2055
|
+
}));
|
|
1801
2056
|
};
|
|
1802
2057
|
const handleTicketChange = ({ value }) => {
|
|
1803
2058
|
dispatchDriverTicketState({
|
|
@@ -1831,6 +2086,15 @@ const BlockDriverTicket = () => {
|
|
|
1831
2086
|
},
|
|
1832
2087
|
});
|
|
1833
2088
|
};
|
|
2089
|
+
const handleSpeedChange = (index) => ({ value }) => {
|
|
2090
|
+
dispatchDriverTicketState({
|
|
2091
|
+
type: mychoiceSdkStore.StoreFormCarDriverTicketActionTypes.FormCarDriverTrafficTicketSpeedSelect,
|
|
2092
|
+
payload: {
|
|
2093
|
+
speed: Number(value),
|
|
2094
|
+
index,
|
|
2095
|
+
},
|
|
2096
|
+
});
|
|
2097
|
+
};
|
|
1834
2098
|
const handleTicketDateChange = (index) => (dateType) => ({ value }) => {
|
|
1835
2099
|
if (dateType === mychoiceSdkComponents.DateTypes.Month) {
|
|
1836
2100
|
dispatchDriverTicketState({
|
|
@@ -1851,13 +2115,13 @@ const BlockDriverTicket = () => {
|
|
|
1851
2115
|
});
|
|
1852
2116
|
}
|
|
1853
2117
|
};
|
|
1854
|
-
return (jsxRuntime.jsxs("div", { className: "form-block-container", children: [jsxRuntime.jsx("h2", { className: isTheBig ? 'thebig-bold' : '', children: "Traffic Tickets" }), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleTicketChange, name: "ticket", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, ticket), title: `Except for parking, has ${firstName} had any driving related tickets within the past 3 years?`, description: "Insurers want to make sure drivers are safe, which means minimizing driving infractions and encouraging good behaviour on the roads. Some of the most common liabilities include speeding, failure to stop, running a red light, reckless driving, and seatbelt negligence. It affects your insurance premium for up to three years and may void your policy." }), ticket && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [ticketList?.map(({ ticketReason, ticketYear, ticketMonth, }, index) => {
|
|
2118
|
+
return (jsxRuntime.jsxs("div", { className: "form-block-container", children: [jsxRuntime.jsx("h2", { className: isTheBig ? 'thebig-bold' : '', children: "Traffic Tickets" }), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleTicketChange, name: "ticket", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, ticket), title: `Except for parking, has ${firstName} had any driving related tickets within the past 3 years?`, description: "Insurers want to make sure drivers are safe, which means minimizing driving infractions and encouraging good behaviour on the roads. Some of the most common liabilities include speeding, failure to stop, running a red light, reckless driving, and seatbelt negligence. It affects your insurance premium for up to three years and may void your policy." }), ticket && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [ticketList?.map(({ ticketReason, ticketYear, ticketMonth, speed, }, index) => {
|
|
1855
2119
|
const defaultTicketDate = {
|
|
1856
2120
|
year: ticketYear,
|
|
1857
2121
|
month: ticketMonth,
|
|
1858
2122
|
day: '01',
|
|
1859
2123
|
};
|
|
1860
|
-
return (jsxRuntime.jsxs("div", { className: "list-block", children: [jsxRuntime.jsx("hr", {}), jsxRuntime.jsxs("div", { className: "list-item", children: [jsxRuntime.jsx(SelectFormBox, { groupOptions: getTrafficTicketsGroupOptions(), name: `ticketReason-${index}`, onChange: handleReasonChange(index), defaultValue: ticketReason, title: "Reason for traffic ticket", placeholder: "Select from the list", isRemovable: ticketList.length > 1, onIconClick: handleIconClick(index), autoSelectIfValueIsOutOfOptions: false, error: !ticketReason && driverState.inValidation, errorMessage: getErrorMessage(ticketReason, driverState.inValidation) }), jsxRuntime.jsx(DateSelectFormBox, { name: `ticketDate-${index}`, dateNames: [`ticketYear-${index}`, `ticketMonth-${index}`], onDateChange: handleTicketDateChange(index), defaultValue: defaultTicketDate, title: "Ticket date", errorMessage: getDateErrorMessage(['01', ticketMonth, ticketYear], driverState.inValidation), error: driverState.inValidation, minDate: mychoiceSdkComponents.getMinDateByYears(gOneMin, 3) })] })] }, `ticket-${index}`));
|
|
2124
|
+
return (jsxRuntime.jsxs("div", { className: "list-block", children: [jsxRuntime.jsx("hr", {}), jsxRuntime.jsxs("div", { className: "list-item", children: [jsxRuntime.jsx(SelectFormBox, { groupOptions: getTrafficTicketsGroupOptions(), name: `ticketReason-${index}`, onChange: handleReasonChange(index), defaultValue: ticketReason, title: "Reason for traffic ticket", placeholder: "Select from the list", isRemovable: ticketList.length > 1, onIconClick: handleIconClick(index), autoSelectIfValueIsOutOfOptions: false, error: !ticketReason && driverState.inValidation, errorMessage: getErrorMessage(ticketReason, driverState.inValidation) }), ticketReason === 'SP' && (jsxRuntime.jsx(InputFormBox, { name: `ticketSpeed-${index}`, onChange: handleSpeedChange(index), defaultValue: speed !== undefined ? speed : '', title: "How fast were you going (km/h)?", type: mychoiceSdkComponents.InputTypes.Number, error: !speed && driverState.inValidation, errorMessage: getErrorMessage(speed, driverState.inValidation) })), jsxRuntime.jsx(DateSelectFormBox, { name: `ticketDate-${index}`, dateNames: [`ticketYear-${index}`, `ticketMonth-${index}`], onDateChange: handleTicketDateChange(index), defaultValue: defaultTicketDate, title: "Ticket date", errorMessage: getDateErrorMessage(['01', ticketMonth, ticketYear], driverState.inValidation), error: driverState.inValidation, minDate: mychoiceSdkComponents.getMinDateByYears(gOneMin, 3) })] })] }, `ticket-${index}`));
|
|
1861
2125
|
}), ticketList?.length < 3 && (jsxRuntime.jsx(mychoiceSdkComponents.ButtonBase, { className: "list-item-add", category: mychoiceSdkComponents.CategoryTypes.Filled, onClick: handleAddButtonClick, size: mychoiceSdkComponents.SizeTypes.Medium, color: mychoiceSdkComponents.ColorTypes.Primary, label: "Add another" }))] }))] }));
|
|
1862
2126
|
};
|
|
1863
2127
|
|
|
@@ -1951,6 +2215,7 @@ const getDynamicLicenceBoxProps = ({ isAlbertaProvince, isOntarioProvince, isNew
|
|
|
1951
2215
|
const SectionDiscountInfo$1 = () => {
|
|
1952
2216
|
const { appConfigState: { appType }, } = mychoiceSdkStore.useStoreAppConfig();
|
|
1953
2217
|
const allProvinces = mychoiceSdkStore.useProvince();
|
|
2218
|
+
const { isAlbertaProvince } = allProvinces;
|
|
1954
2219
|
const isTheBig = appType === mychoiceSdkComponents.AppTypes.TheBig;
|
|
1955
2220
|
const mychoiceCls = mychoiceSdkComponents.isMyChoiceLike(appType) ? 'mychoice' : '';
|
|
1956
2221
|
const { discountState, dispatchDiscountState } = mychoiceSdkStore.useStoreFormCarDiscount();
|
|
@@ -2008,7 +2273,7 @@ const SectionDiscountInfo$1 = () => {
|
|
|
2008
2273
|
payload: { caslConsent: value },
|
|
2009
2274
|
});
|
|
2010
2275
|
};
|
|
2011
|
-
return (jsxRuntime.jsxs("div", { className: `form-section ${mychoiceCls}`, children: [isTheBig ? (jsxRuntime.jsx(LabelFormBox, { title: "You are seconds away from receiving your car insurance quotes,\n please provide your email after completing the discount section so we\n can send you your personalized free car insurance quotes!" })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("h2", { className: "section-title", children: "A little extra info for discounts and connecting you with our partners." }), jsxRuntime.jsx("span", { className: "info-title-message", children: "You are seconds away from receiving your car insurance quotes, please provide your email after completing the discount section so we can send you your personalized free car insurance quotes!" })] })), jsxRuntime.jsx(BlockVehLinks, {}), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleMultiplePolicyChange, name: "multiplePoliciesDiscount", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, multiplePoliciesDiscount), title: "You could receive a 10-15% discount for bundling insurance with multiple policies with the same insurance company. Does that interest you?", description: "Bundling your home and auto insurance can save you significantly on insurance premiums as a whole package. Do you want to learn more about the benefits of multiple policies for home, tenant, condo, or car insurance? All you have to do is select yes.." }), !isTheBig && (jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleCaaMemberChange, name: "caaMemberDiscount", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, caaMemberDiscount), title: "Please indicate if you are a member of CAA, you could save up to an additional 20%." })), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleAppInstallChange, name: "appInstallDiscount", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, appInstallDiscount), title: "You could receive up to a 30% discount by using an app to track driving habits. Does that interest you?", description: "Get rewarded for safe driving with the click of a button. If you install the app, you may be eligible for a 30% discount on your insurance premiums. Typically, you receive 10% of the discount upfront and the balance after six months of good driving." }), isTheBig ? (jsxRuntime.jsxs("div", { className: "input-form-box-container", children: [jsxRuntime.jsx(LabelFormBox, { title: "Complete this form to see all your personalized\n quotes on the next page, you will also be able to:" }), jsxRuntime.jsxs("ol", { className: "ordered-block", children: [jsxRuntime.jsx("li", { children: "See what rates insurance carriers are offering" }), jsxRuntime.jsx("li", { children: "Get in touch with us and secure your rate" }), jsxRuntime.jsx("li", { children: "Potentially save more by speaking with a broker" })] })] })) : (jsxRuntime.jsx("h2", { children: "Complete the form below to see which companies are offering your quotes." })), jsxRuntime.jsx(InputFormBox, { name: "firstName", title: "First Name", onChange: handleFirstNameChange, defaultValue: firstName, placeholder: "Your First Name", error: !firstName && discountState.inValidation, errorMessage: getErrorMessage(firstName, discountState.inValidation) }), jsxRuntime.jsx(InputFormBox, { name: "lastname", title: "Last Name", onChange: handleLastNameChange, defaultValue: lastName, placeholder: "Your Last Name", error: !lastName && discountState.inValidation, errorMessage: getErrorMessage(lastName, discountState.inValidation) }), isTheBig && (jsxRuntime.jsx(InputFormLicenceBox, { ...getDynamicLicenceBoxProps({ ...allProvinces }), name: "driverLicense", title: "Driver Licence Number (Optional)", onChange: handleDriverLicenseChange, defaultValue: driverLicense, description: "Enter your drivers licence number in to receive a more accurate, prequalified quote from our broker partners. This will enable you to provide less details over the phone if you choose to have a broker contact you. This is an optional input." })), jsxRuntime.jsx(InputFormPhoneBox, { name: "phone", onChange: handlePhoneNumberChange, defaultValue: phone, title: "Phone Number", placeholder: "(855) 325-8444", error: !phone && discountState.inValidation, errorMessage: getErrorMessage(phone, discountState.inValidation) }), jsxRuntime.jsx(InputFormEmailBox, { validationStatus: emailStatus, errorMessage: emailStatus === mychoiceSdkComponents.ValidationStatusTypes.Declined
|
|
2276
|
+
return (jsxRuntime.jsxs("div", { className: `form-section ${mychoiceCls}`, children: [isTheBig ? (jsxRuntime.jsx(LabelFormBox, { title: "You are seconds away from receiving your car insurance quotes,\n please provide your email after completing the discount section so we\n can send you your personalized free car insurance quotes!" })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("h2", { className: "section-title", children: "A little extra info for discounts and connecting you with our partners." }), jsxRuntime.jsx("span", { className: "info-title-message", children: "You are seconds away from receiving your car insurance quotes, please provide your email after completing the discount section so we can send you your personalized free car insurance quotes!" })] })), jsxRuntime.jsx(BlockVehLinks, {}), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleMultiplePolicyChange, name: "multiplePoliciesDiscount", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, multiplePoliciesDiscount), title: "You could receive a 10-15% discount for bundling insurance with multiple policies with the same insurance company. Does that interest you?", description: "Bundling your home and auto insurance can save you significantly on insurance premiums as a whole package. Do you want to learn more about the benefits of multiple policies for home, tenant, condo, or car insurance? All you have to do is select yes.." }), !isTheBig && !isAlbertaProvince && (jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleCaaMemberChange, name: "caaMemberDiscount", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, caaMemberDiscount), title: "Please indicate if you are a member of CAA, you could save up to an additional 20%." })), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleAppInstallChange, name: "appInstallDiscount", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, appInstallDiscount), title: "You could receive up to a 30% discount by using an app to track driving habits. Does that interest you?", description: "Get rewarded for safe driving with the click of a button. If you install the app, you may be eligible for a 30% discount on your insurance premiums. Typically, you receive 10% of the discount upfront and the balance after six months of good driving." }), isTheBig ? (jsxRuntime.jsxs("div", { className: "input-form-box-container", children: [jsxRuntime.jsx(LabelFormBox, { title: "Complete this form to see all your personalized\n quotes on the next page, you will also be able to:" }), jsxRuntime.jsxs("ol", { className: "ordered-block", children: [jsxRuntime.jsx("li", { children: "See what rates insurance carriers are offering" }), jsxRuntime.jsx("li", { children: "Get in touch with us and secure your rate" }), jsxRuntime.jsx("li", { children: "Potentially save more by speaking with a broker" })] })] })) : (jsxRuntime.jsx("h2", { children: "Complete the form below to see which companies are offering your quotes." })), jsxRuntime.jsx(InputFormBox, { name: "firstName", title: "First Name", onChange: handleFirstNameChange, defaultValue: firstName, placeholder: "Your First Name", error: !firstName && discountState.inValidation, errorMessage: getErrorMessage(firstName, discountState.inValidation) }), jsxRuntime.jsx(InputFormBox, { name: "lastname", title: "Last Name", onChange: handleLastNameChange, defaultValue: lastName, placeholder: "Your Last Name", error: !lastName && discountState.inValidation, errorMessage: getErrorMessage(lastName, discountState.inValidation) }), isTheBig && (jsxRuntime.jsx(InputFormLicenceBox, { ...getDynamicLicenceBoxProps({ ...allProvinces }), name: "driverLicense", title: "Driver Licence Number (Optional)", onChange: handleDriverLicenseChange, defaultValue: driverLicense, description: "Enter your drivers licence number in to receive a more accurate, prequalified quote from our broker partners. This will enable you to provide less details over the phone if you choose to have a broker contact you. This is an optional input." })), jsxRuntime.jsx(InputFormPhoneBox, { name: "phone", onChange: handlePhoneNumberChange, defaultValue: phone, title: "Phone Number", placeholder: "(855) 325-8444", error: !phone && discountState.inValidation, errorMessage: getErrorMessage(phone, discountState.inValidation) }), jsxRuntime.jsx(InputFormEmailBox, { validationStatus: emailStatus, errorMessage: emailStatus === mychoiceSdkComponents.ValidationStatusTypes.Declined
|
|
2012
2277
|
? errorMessage
|
|
2013
2278
|
: getErrorMessage(email, discountState.inValidation), error: emailStatus === mychoiceSdkComponents.ValidationStatusTypes.Declined || (!email && discountState.inValidation), name: "email", title: "Please share your email address with us, we'll use it to send you a copy of your quotes.", description: "We will provide you with your insurance quotes immediately after this form completion. If you are not ready to apply today, don\u2019t worry as we will be emailing your quotes to you if you\u2019d like to complete at a later date with the help of one of our trusted broker partners.", onChange: handleEmailChange, defaultValue: email, placeholder: mychoiceSdkComponents.getPlaceholderEmail(appType) }), isTheBig && (jsxRuntime.jsx(mychoiceSdkComponents.CheckboxForm, { className: "casl-consent", name: "caslConsent", label: "Yes, I consent to receiving emails from the Billyard Insurance Group.\n I understand that I can unsubscribe at any time", onChange: handleCaslConsentChange, defaultValue: caslConsent })), jsxRuntime.jsx(BlockSubmit$2, { className: isTheBig ? 'thebig-bold' : 'mychoice' }), jsxRuntime.jsx(BlockNextPageInfo$2, {})] }));
|
|
2014
2279
|
};
|