@mychoice/mychoice-sdk-modules 2.2.24 → 2.2.25
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 +157 -79
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/insurances/car/pages/driver/helpers.d.ts +1 -1
- package/dist/cjs/shared/boxes/InputFormBox/InputFormPhoneBox.d.ts +2 -2
- package/dist/cjs/shared/boxes/InputFormBox/interface.d.ts +3 -0
- package/dist/esm/index.js +159 -81
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/insurances/car/pages/driver/helpers.d.ts +1 -1
- package/dist/esm/shared/boxes/InputFormBox/InputFormPhoneBox.d.ts +2 -2
- package/dist/esm/shared/boxes/InputFormBox/interface.d.ts +3 -0
- package/dist/index.d.ts +4 -1
- package/package.json +4 -4
package/dist/cjs/index.js
CHANGED
|
@@ -58,8 +58,8 @@ InputFormBox.defaultProps = {
|
|
|
58
58
|
};
|
|
59
59
|
|
|
60
60
|
const InputFormPhoneBox = (props) => {
|
|
61
|
-
const { className, defaultValue, placeholder, disabled, error, name, title, onChange, errorMessage, hintMessage, } = props;
|
|
62
|
-
return (jsxRuntime.jsx(Container, { name: name, className: ` ${className} ${error ? 'error' : ''}`, title: title, errorMessage: errorMessage, hintMessage: hintMessage, children: jsxRuntime.jsx(mychoiceSdkComponents.InputFormPhone, { className: "input-form", name: name, type: mychoiceSdkComponents.InputTypes.Text, defaultValue: defaultValue, onChange: onChange, placeholder: placeholder, disabled: disabled, error: error }) }));
|
|
61
|
+
const { className, defaultValue, placeholder, disabled, error, name, title, onChange, errorMessage, hintMessage, validationStatus, } = props;
|
|
62
|
+
return (jsxRuntime.jsx(Container, { name: name, className: ` ${className} ${error ? 'error' : ''}`, title: title, errorMessage: errorMessage, hintMessage: hintMessage, children: jsxRuntime.jsx(mychoiceSdkComponents.InputFormPhone, { className: "input-form", name: name, type: mychoiceSdkComponents.InputTypes.Text, defaultValue: defaultValue, onChange: onChange, placeholder: placeholder, disabled: disabled, error: error, validationStatus: validationStatus }) }));
|
|
63
63
|
};
|
|
64
64
|
InputFormPhoneBox.defaultProps = {
|
|
65
65
|
className: '',
|
|
@@ -709,14 +709,22 @@ const getRecommendedRange = (distanceDaily, distanceBusiness) => {
|
|
|
709
709
|
kmEachDay = +distanceBusiness;
|
|
710
710
|
}
|
|
711
711
|
switch (true) {
|
|
712
|
+
case kmEachDay === 0:
|
|
713
|
+
return 5000;
|
|
712
714
|
case kmEachDay === 1:
|
|
713
715
|
return 8000;
|
|
714
|
-
case ((kmEachDay >= 2) && (kmEachDay <=
|
|
716
|
+
case ((kmEachDay >= 2) && (kmEachDay <= 5)):
|
|
715
717
|
return 10000;
|
|
716
|
-
case ((kmEachDay >=
|
|
718
|
+
case ((kmEachDay >= 6) && (kmEachDay <= 12)):
|
|
719
|
+
return 10000;
|
|
720
|
+
case ((kmEachDay >= 13) && (kmEachDay <= 20)):
|
|
717
721
|
return 15000;
|
|
722
|
+
case ((kmEachDay >= 21) && (kmEachDay <= 29)):
|
|
723
|
+
return 20000;
|
|
718
724
|
case ((kmEachDay >= 30) && (kmEachDay <= 40)):
|
|
719
725
|
return 20000;
|
|
726
|
+
case ((kmEachDay >= 41) && (kmEachDay <= 49)):
|
|
727
|
+
return 30000;
|
|
720
728
|
case ((kmEachDay >= 50) && (kmEachDay <= 80)):
|
|
721
729
|
return 30000;
|
|
722
730
|
case ((kmEachDay >= 90) && (kmEachDay <= 100)):
|
|
@@ -885,9 +893,7 @@ const BlockCarConditionInfo = () => {
|
|
|
885
893
|
type: mychoiceSdkStore.StoreFormCarVehicleActionTypes.FormCarDailyDistanceSelect,
|
|
886
894
|
payload: { distanceDaily: value },
|
|
887
895
|
});
|
|
888
|
-
const yearlyDefault =
|
|
889
|
-
? '5000'
|
|
890
|
-
: `${getRecommendedRange(value, primaryUse === mychoiceSdkComponents.VehiclePrimaryUseTypes.Business ? distanceBusiness : 1)}`;
|
|
896
|
+
const yearlyDefault = `${getRecommendedRange(value, primaryUse === mychoiceSdkComponents.VehiclePrimaryUseTypes.Business ? distanceBusiness : 1)}`;
|
|
891
897
|
dispatchVehicleState({
|
|
892
898
|
type: mychoiceSdkStore.StoreFormCarVehicleActionTypes.FormCarYearlyDistanceSelect,
|
|
893
899
|
payload: { distanceYearly: yearlyDefault },
|
|
@@ -909,7 +915,7 @@ const BlockCarConditionInfo = () => {
|
|
|
909
915
|
purchaseDay || '',
|
|
910
916
|
purchaseMonth || '',
|
|
911
917
|
purchaseYear || '',
|
|
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
|
|
918
|
+
], 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 !== undefined ? `Based on your daily driven kilometers, we recommend
|
|
913
919
|
${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 }))] }));
|
|
914
920
|
};
|
|
915
921
|
|
|
@@ -1489,20 +1495,19 @@ const SectionDriverLicence = () => {
|
|
|
1489
1495
|
const showGDateAfterG2 = firstClass === mychoiceSdkComponents.DriverLicenceTypes.G2 && receivedG === true;
|
|
1490
1496
|
const g2Date = toDate(g2LicenceYear, g2LicenceMonth);
|
|
1491
1497
|
const gDate = toDate(gLicenceYear, gLicenceMonth);
|
|
1492
|
-
// G1 branch:
|
|
1493
|
-
const showDtcG1Only = firstClass === mychoiceSdkComponents.DriverLicenceTypes.G1
|
|
1494
|
-
|
|
1495
|
-
&&
|
|
1496
|
-
&&
|
|
1497
|
-
|
|
1498
|
-
// Branch B: DTC shown as soon as class=G2 and Q1 is within 3 years (before G question)
|
|
1498
|
+
// G1 branch: ask once, based on the first licence date. Show/hide uses 5-year gate; question text says "3 years".
|
|
1499
|
+
const showDtcG1Only = firstClass === mychoiceSdkComponents.DriverLicenceTypes.G1
|
|
1500
|
+
&& !!q1Date
|
|
1501
|
+
&& mychoiceSdkComponents.getDifferenceInYears('', q1Date) <= 5
|
|
1502
|
+
&& !showG2Date;
|
|
1503
|
+
// Branch B: DTC shown as soon as class=G2 and Q1 is within 5 years (before G question)
|
|
1499
1504
|
const showDtcG2Only = firstClass === mychoiceSdkComponents.DriverLicenceTypes.G2
|
|
1500
1505
|
&& !!q1Date
|
|
1501
|
-
&& mychoiceSdkComponents.getDifferenceInYears('', q1Date) <=
|
|
1502
|
-
// Branch C G Full: within
|
|
1506
|
+
&& mychoiceSdkComponents.getDifferenceInYears('', q1Date) <= 5;
|
|
1507
|
+
// Branch C G Full: within 5 years of Q1 (G date)
|
|
1503
1508
|
const showDtcGFull = firstClass === mychoiceSdkComponents.DriverLicenceTypes.G
|
|
1504
1509
|
&& !!q1Date
|
|
1505
|
-
&& mychoiceSdkComponents.getDifferenceInYears('', q1Date) <=
|
|
1510
|
+
&& mychoiceSdkComponents.getDifferenceInYears('', q1Date) <= 5;
|
|
1506
1511
|
// ── Validation error messages ──
|
|
1507
1512
|
const q1MinDate = getG1MinDate();
|
|
1508
1513
|
const q1ChronoError = driverState.inValidation
|
|
@@ -1538,7 +1543,7 @@ const SectionDriverLicence = () => {
|
|
|
1538
1543
|
};
|
|
1539
1544
|
const g2MaxDate = getMax60Date(q1Date);
|
|
1540
1545
|
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
|
|
1546
|
+
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 3 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 })), 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
1547
|
}
|
|
1543
1548
|
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
|
|
1544
1549
|
? `${driverName} was licenced in ${Number(birthYear) + Number(firstLicenceAge)} - ${Number(birthYear) + Number(firstLicenceAge) + 1}`
|
|
@@ -1551,7 +1556,7 @@ const SectionDriverInsurancePolicy = () => {
|
|
|
1551
1556
|
const { driverState, dispatchDriverInsuranceState } = mychoiceSdkStore.useStoreFormCarDriverInsurance();
|
|
1552
1557
|
const { discountState, dispatchDiscountState } = mychoiceSdkStore.useStoreFormCarDiscount();
|
|
1553
1558
|
const { quoteState: { isRequested }, } = mychoiceSdkStore.useStoreFormCarQuote();
|
|
1554
|
-
const { listed, listedMonth = '', listedYear = '', insured, insuredDate = '',
|
|
1559
|
+
const { listed, listedMonth = '', listedYear = '', insured, insuredDate = '', lastPolicyEndYear = '', lastPolicyEndMonth = '', lastPolicyCancelReason = '', firstName, birthYear, birthMonth, birthDay, licenceInfo: { firstLicenceAge, licenceType, gLicenceYear, gLicenceMonth, g1LicenceYear, g1LicenceMonth, g2LicenceYear, g2LicenceMonth, }, } = driverState.items[driverState.activeIndex];
|
|
1555
1560
|
const { policyStartYear, policyStartMonth, policyStartDay } = discountState;
|
|
1556
1561
|
const driverNameDefault = `Driver ${driverState.activeIndex + 1}`;
|
|
1557
1562
|
const birthDate = birthYear && birthMonth && birthDay ? `${birthYear}-${birthMonth}-${birthDay}` : '';
|
|
@@ -1589,17 +1594,49 @@ const SectionDriverInsurancePolicy = () => {
|
|
|
1589
1594
|
month: policyStartMonth,
|
|
1590
1595
|
day: policyStartDay,
|
|
1591
1596
|
};
|
|
1597
|
+
const prevListedRef = React.useRef({ year: listedYear, month: listedMonth });
|
|
1598
|
+
const getFirstLicenceDateKey = () => {
|
|
1599
|
+
if (licenceType === mychoiceSdkComponents.DriverLicenceTypes.G)
|
|
1600
|
+
return `${gLicenceYear || ''}-${gLicenceMonth || ''}`;
|
|
1601
|
+
if (licenceType === mychoiceSdkComponents.DriverLicenceTypes.G2)
|
|
1602
|
+
return `${g2LicenceYear || ''}-${g2LicenceMonth || ''}`;
|
|
1603
|
+
if (licenceType === mychoiceSdkComponents.DriverLicenceTypes.G1)
|
|
1604
|
+
return `${g1LicenceYear || ''}-${g1LicenceMonth || ''}`;
|
|
1605
|
+
return `${firstLicenceAge || ''}`;
|
|
1606
|
+
};
|
|
1607
|
+
const firstLicenceDateKey = getFirstLicenceDateKey();
|
|
1608
|
+
const prevFirstLicenceRef = React.useRef(firstLicenceDateKey);
|
|
1592
1609
|
React.useEffect(() => {
|
|
1593
1610
|
if (listedYear && listedMonth && !isRequested) {
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1611
|
+
const prev = prevListedRef.current;
|
|
1612
|
+
const hasChanged = prev.year !== listedYear || prev.month !== listedMonth;
|
|
1613
|
+
prevListedRef.current = { year: listedYear, month: listedMonth };
|
|
1614
|
+
if (!insuredDate || hasChanged) {
|
|
1615
|
+
const options = getPeriodOptions(listedYear, listedMonth);
|
|
1616
|
+
if (options.length > 1) {
|
|
1617
|
+
dispatchDriverInsuranceState({
|
|
1618
|
+
type: mychoiceSdkStore.StoreFormCarDriverInsuranceActionTypes.FormCarDriverInsuredDateSelect,
|
|
1619
|
+
payload: { insuredDate: options[1].value },
|
|
1620
|
+
});
|
|
1621
|
+
}
|
|
1600
1622
|
}
|
|
1601
1623
|
}
|
|
1602
1624
|
}, [listedYear, listedMonth]);
|
|
1625
|
+
React.useEffect(() => {
|
|
1626
|
+
if (!listedYear || !listedMonth || isRequested)
|
|
1627
|
+
return;
|
|
1628
|
+
const hasChanged = prevFirstLicenceRef.current !== firstLicenceDateKey;
|
|
1629
|
+
prevFirstLicenceRef.current = firstLicenceDateKey;
|
|
1630
|
+
if (!hasChanged)
|
|
1631
|
+
return;
|
|
1632
|
+
const options = getPeriodOptions(listedYear, listedMonth);
|
|
1633
|
+
if (options.length > 1) {
|
|
1634
|
+
dispatchDriverInsuranceState({
|
|
1635
|
+
type: mychoiceSdkStore.StoreFormCarDriverInsuranceActionTypes.FormCarDriverInsuredDateSelect,
|
|
1636
|
+
payload: { insuredDate: options[1].value },
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1639
|
+
}, [firstLicenceDateKey]);
|
|
1603
1640
|
React.useEffect(() => {
|
|
1604
1641
|
if (listedYear && listedMonth && listed) {
|
|
1605
1642
|
const listedDate = mychoiceSdkComponents.addDaysToDate(`${listedYear}-${listedMonth}-01`, birthDay ? +birthDay + 1 : 1);
|
|
@@ -1640,6 +1677,10 @@ you had insurance. If this is correct, please continue with the form.`);
|
|
|
1640
1677
|
type: mychoiceSdkStore.StoreFormCarDriverInsuranceActionTypes.FormCarDriverInsuredSelect,
|
|
1641
1678
|
payload: { insured: !value },
|
|
1642
1679
|
});
|
|
1680
|
+
dispatchDriverInsuranceState({
|
|
1681
|
+
type: mychoiceSdkStore.StoreFormCarDriverInsuranceActionTypes.FormCarDriverNotCurrentlyInsuredSelect,
|
|
1682
|
+
payload: { notCurrentlyInsured: value },
|
|
1683
|
+
});
|
|
1643
1684
|
};
|
|
1644
1685
|
const handleLastPolicyEndDateChange = (dateType) => ({ value }) => {
|
|
1645
1686
|
if (dateType === mychoiceSdkComponents.DateTypes.Month) {
|
|
@@ -1687,6 +1728,14 @@ you had insurance. If this is correct, please continue with the form.`);
|
|
|
1687
1728
|
});
|
|
1688
1729
|
}
|
|
1689
1730
|
};
|
|
1731
|
+
const firstInsuredMinDate = listedYear && listedMonth
|
|
1732
|
+
? mychoiceSdkComponents.addDaysToDate(`${listedYear}-${listedMonth}-01`, birthDay ? +birthDay + 1 : 1)
|
|
1733
|
+
: mychoiceSdkComponents.getMinDate(birthDate, firstLicenceAge);
|
|
1734
|
+
const twentyYearsAgo = mychoiceSdkComponents.getMinDateByYears(mychoiceSdkComponents.getFormattedDate('', 'yyyy-MM-dd'), 20);
|
|
1735
|
+
let lastPolicyEndMinDate = twentyYearsAgo;
|
|
1736
|
+
if (firstInsuredMinDate && mychoiceSdkComponents.compareDates(firstInsuredMinDate, twentyYearsAgo) > 0) {
|
|
1737
|
+
lastPolicyEndMinDate = firstInsuredMinDate;
|
|
1738
|
+
}
|
|
1690
1739
|
const handlePolicyStartDateChange = (dateType) => ({ value }) => {
|
|
1691
1740
|
if (dateType === mychoiceSdkComponents.DateTypes.Day) {
|
|
1692
1741
|
dispatchDiscountState({
|
|
@@ -1709,7 +1758,7 @@ you had insurance. If this is correct, please continue with the form.`);
|
|
|
1709
1758
|
};
|
|
1710
1759
|
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
|
|
1711
1760
|
? getDateErrorMessage(['01', listedMonth, listedYear], driverState.inValidation)
|
|
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 }))] }));
|
|
1761
|
+
: '', 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'), minDate: lastPolicyEndMinDate }), 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 }))] }));
|
|
1713
1762
|
};
|
|
1714
1763
|
|
|
1715
1764
|
const SectionDriverCancellation = () => {
|
|
@@ -1998,16 +2047,17 @@ const BlockDriverAccident = () => {
|
|
|
1998
2047
|
};
|
|
1999
2048
|
|
|
2000
2049
|
/**
|
|
2001
|
-
* Filter out G1/G2 options from "
|
|
2050
|
+
* Filter out G1/G2 options (ALC, RB) from the "Criminal" section for trafficTicketsGroupOptions
|
|
2002
2051
|
*/
|
|
2003
2052
|
const getTrafficTicketsGroupOptionsWithoutG1G2 = () => {
|
|
2004
2053
|
const excludeOptions = ['ALC', 'RB'];
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2054
|
+
return mychoiceSdkComponents.trafficTicketsGroupOptions.map((group) => {
|
|
2055
|
+
if (group.label !== 'Criminal')
|
|
2056
|
+
return group;
|
|
2057
|
+
return {
|
|
2058
|
+
...group,
|
|
2059
|
+
options: group.options.filter((option) => !excludeOptions.includes(option.value)),
|
|
2060
|
+
};
|
|
2011
2061
|
});
|
|
2012
2062
|
};
|
|
2013
2063
|
|
|
@@ -2020,23 +2070,25 @@ const BlockDriverTicket = () => {
|
|
|
2020
2070
|
const isTheBig = appType === mychoiceSdkComponents.AppTypes.TheBig;
|
|
2021
2071
|
const { firstName, minMaxDates, } = driverState.items[driverState.activeIndex];
|
|
2022
2072
|
const { gOneMin } = minMaxDates;
|
|
2073
|
+
// Each speeding tier is tagged with the picklist section it belongs to.
|
|
2074
|
+
// The tier itself determines the Fortus <Speed> and <Severity>, so no speed is asked of the user.
|
|
2023
2075
|
const getSpeedingOptions = () => {
|
|
2024
2076
|
if (isNovaScotiaProvince) {
|
|
2025
2077
|
return [
|
|
2026
|
-
{ value: '
|
|
2027
|
-
{ value: '
|
|
2028
|
-
{ value: '
|
|
2078
|
+
{ value: 'SP_NS_MINOR', name: 'Speeding 1 to 30 kph over limit', section: 'Minor' },
|
|
2079
|
+
{ value: 'SP_NS_MAJOR', name: 'Speeding 31 to 50 kph over limit', section: 'Major' },
|
|
2080
|
+
{ value: 'SP_NS_CRIMINAL', name: 'Speeding 51 kph or more over limit', section: 'Criminal' },
|
|
2029
2081
|
];
|
|
2030
2082
|
}
|
|
2031
2083
|
if (isAlbertaProvince || isNewfoundlandProvince) {
|
|
2032
2084
|
return [
|
|
2033
|
-
{ value: '
|
|
2034
|
-
{ value: '
|
|
2085
|
+
{ value: 'SP_MINOR', name: 'Speeding 1 to 50 kph over limit', section: 'Minor' },
|
|
2086
|
+
{ value: 'SP_51_CRIMINAL', name: 'Speeding 51 kph or more over limit', section: 'Criminal' },
|
|
2035
2087
|
];
|
|
2036
2088
|
}
|
|
2037
2089
|
return [
|
|
2038
|
-
{ value: '
|
|
2039
|
-
{ value: '
|
|
2090
|
+
{ value: 'SP_MINOR', name: 'Speeding 1 to 49 kph over limit', section: 'Minor' },
|
|
2091
|
+
{ value: 'SP_50_CRIMINAL', name: 'Speeding 50 kph or more over limit', section: 'Criminal' },
|
|
2040
2092
|
];
|
|
2041
2093
|
};
|
|
2042
2094
|
const getTrafficTicketsGroupOptions = () => {
|
|
@@ -2044,15 +2096,17 @@ const BlockDriverTicket = () => {
|
|
|
2044
2096
|
? getTrafficTicketsGroupOptionsWithoutG1G2()
|
|
2045
2097
|
: mychoiceSdkComponents.trafficTicketsGroupOptions;
|
|
2046
2098
|
const speedingOptions = getSpeedingOptions();
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2099
|
+
const toOption = ({ value, name }) => ({ value, name });
|
|
2100
|
+
return base.map((group) => {
|
|
2101
|
+
// Drop the generic "Speeding" entry; tiers are injected per section below.
|
|
2102
|
+
const options = group.options.filter((opt) => !(opt.value === 'SP' && opt.name === 'Speeding'));
|
|
2103
|
+
// Each tier appears in the Common section and in its matching severity section.
|
|
2104
|
+
const tiersForGroup = speedingOptions.filter((tier) => group.label === 'Common' || group.label === tier.section);
|
|
2105
|
+
return {
|
|
2106
|
+
...group,
|
|
2107
|
+
options: [...options, ...tiersForGroup.map(toOption)],
|
|
2108
|
+
};
|
|
2109
|
+
});
|
|
2056
2110
|
};
|
|
2057
2111
|
const handleTicketChange = ({ value }) => {
|
|
2058
2112
|
dispatchDriverTicketState({
|
|
@@ -2086,15 +2140,6 @@ const BlockDriverTicket = () => {
|
|
|
2086
2140
|
},
|
|
2087
2141
|
});
|
|
2088
2142
|
};
|
|
2089
|
-
const handleSpeedChange = (index) => ({ value }) => {
|
|
2090
|
-
dispatchDriverTicketState({
|
|
2091
|
-
type: mychoiceSdkStore.StoreFormCarDriverTicketActionTypes.FormCarDriverTrafficTicketSpeedSelect,
|
|
2092
|
-
payload: {
|
|
2093
|
-
speed: Number(value),
|
|
2094
|
-
index,
|
|
2095
|
-
},
|
|
2096
|
-
});
|
|
2097
|
-
};
|
|
2098
2143
|
const handleTicketDateChange = (index) => (dateType) => ({ value }) => {
|
|
2099
2144
|
if (dateType === mychoiceSdkComponents.DateTypes.Month) {
|
|
2100
2145
|
dispatchDriverTicketState({
|
|
@@ -2115,13 +2160,13 @@ const BlockDriverTicket = () => {
|
|
|
2115
2160
|
});
|
|
2116
2161
|
}
|
|
2117
2162
|
};
|
|
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,
|
|
2163
|
+
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) => {
|
|
2119
2164
|
const defaultTicketDate = {
|
|
2120
2165
|
year: ticketYear,
|
|
2121
2166
|
month: ticketMonth,
|
|
2122
2167
|
day: '01',
|
|
2123
2168
|
};
|
|
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) }),
|
|
2169
|
+
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}`));
|
|
2125
2170
|
}), 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" }))] }))] }));
|
|
2126
2171
|
};
|
|
2127
2172
|
|
|
@@ -2220,8 +2265,9 @@ const SectionDiscountInfo$1 = () => {
|
|
|
2220
2265
|
const mychoiceCls = mychoiceSdkComponents.isMyChoiceLike(appType) ? 'mychoice' : '';
|
|
2221
2266
|
const { discountState, dispatchDiscountState } = mychoiceSdkStore.useStoreFormCarDiscount();
|
|
2222
2267
|
const { validateEmail, errorMessage } = mychoiceSdkStore.useHandlerCarQuoterEmail();
|
|
2268
|
+
const { validatePhone, errorMessage: phoneErrorMessage } = mychoiceSdkStore.useHandlerCarQuoterPhone();
|
|
2223
2269
|
const { multiplePoliciesDiscount, appInstallDiscount, caaMemberDiscount, quoterInfo, emailTo: { email, emailStatus }, } = discountState;
|
|
2224
|
-
const { firstName, lastName, phone, driverLicense = '', caslConsent } = quoterInfo;
|
|
2270
|
+
const { firstName, lastName, phone, phoneStatus, driverLicense = '', caslConsent } = quoterInfo;
|
|
2225
2271
|
const handleMultiplePolicyChange = ({ value }) => {
|
|
2226
2272
|
dispatchDiscountState({
|
|
2227
2273
|
type: mychoiceSdkStore.StoreFormCarDiscountActionTypes.FormCarDiscountMultiplePoliciesSelect,
|
|
@@ -2259,10 +2305,16 @@ const SectionDiscountInfo$1 = () => {
|
|
|
2259
2305
|
});
|
|
2260
2306
|
};
|
|
2261
2307
|
const handlePhoneNumberChange = ({ value }) => {
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
}
|
|
2308
|
+
const digits = value.replace(/\D/g, '');
|
|
2309
|
+
if (digits.length === 10) {
|
|
2310
|
+
validatePhone(value);
|
|
2311
|
+
}
|
|
2312
|
+
else {
|
|
2313
|
+
dispatchDiscountState({
|
|
2314
|
+
type: mychoiceSdkStore.StoreFormCarDiscountActionTypes.FormCarDiscountQuoterPhoneStatusSet,
|
|
2315
|
+
payload: { phone: value, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Initial },
|
|
2316
|
+
});
|
|
2317
|
+
}
|
|
2266
2318
|
};
|
|
2267
2319
|
const handleEmailChange = ({ value }) => {
|
|
2268
2320
|
validateEmail(value);
|
|
@@ -2273,7 +2325,11 @@ const SectionDiscountInfo$1 = () => {
|
|
|
2273
2325
|
payload: { caslConsent: value },
|
|
2274
2326
|
});
|
|
2275
2327
|
};
|
|
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",
|
|
2328
|
+
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", validationStatus: phoneStatus, error: phoneStatus === mychoiceSdkComponents.ValidationStatusTypes.Declined
|
|
2329
|
+
|| (phoneStatus === mychoiceSdkComponents.ValidationStatusTypes.Initial && discountState.inValidation)
|
|
2330
|
+
|| (!phone && discountState.inValidation), errorMessage: phoneStatus === mychoiceSdkComponents.ValidationStatusTypes.Declined
|
|
2331
|
+
? phoneErrorMessage
|
|
2332
|
+
: getErrorMessage(phone, discountState.inValidation) || (discountState.inValidation ? 'Enter a valid phone number.' : '') }), jsxRuntime.jsx(InputFormEmailBox, { validationStatus: emailStatus, errorMessage: emailStatus === mychoiceSdkComponents.ValidationStatusTypes.Declined
|
|
2277
2333
|
? errorMessage
|
|
2278
2334
|
: 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, {})] }));
|
|
2279
2335
|
};
|
|
@@ -3458,8 +3514,9 @@ const SectionDiscountInfo = () => {
|
|
|
3458
3514
|
const { discountState, dispatchDiscountState } = mychoiceSdkStore.useStoreFormHomeDiscount();
|
|
3459
3515
|
// const { applicantState, dispatchApplicantInfoState } = useStoreFormHomeApplicantInfo();
|
|
3460
3516
|
const { validateEmail, errorMessage } = mychoiceSdkStore.useHandlerHomeQuoterEmail();
|
|
3517
|
+
const { validatePhone, errorMessage: phoneErrorMessage } = mychoiceSdkStore.useHandlerHomeQuoterPhone();
|
|
3461
3518
|
const { multiplePoliciesDiscount, emailTo: { email, emailStatus }, quoterInfo = {}, } = discountState;
|
|
3462
|
-
const { firstName = '', lastName = '', phone = '', caslConsent } = quoterInfo;
|
|
3519
|
+
const { firstName = '', lastName = '', phone = '', phoneStatus, caslConsent } = quoterInfo;
|
|
3463
3520
|
const handleMultiplePolicyChange = ({ value }) => {
|
|
3464
3521
|
dispatchDiscountState({
|
|
3465
3522
|
type: mychoiceSdkStore.StoreFormHomeDiscountActionTypes.FormHomeDiscountMultiplePoliciesSelect,
|
|
@@ -3479,10 +3536,16 @@ const SectionDiscountInfo = () => {
|
|
|
3479
3536
|
});
|
|
3480
3537
|
};
|
|
3481
3538
|
const handlePhoneNumberChange = ({ value }) => {
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
}
|
|
3539
|
+
const digits = value.replace(/\D/g, '');
|
|
3540
|
+
if (digits.length === 10) {
|
|
3541
|
+
validatePhone(value);
|
|
3542
|
+
}
|
|
3543
|
+
else {
|
|
3544
|
+
dispatchDiscountState({
|
|
3545
|
+
type: mychoiceSdkStore.StoreFormHomeDiscountActionTypes.FormHomeQuoterPhoneStatusSet,
|
|
3546
|
+
payload: { phone: value, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Initial },
|
|
3547
|
+
});
|
|
3548
|
+
}
|
|
3486
3549
|
};
|
|
3487
3550
|
const handleEmailChange = ({ value }) => {
|
|
3488
3551
|
validateEmail(value);
|
|
@@ -3495,7 +3558,11 @@ const SectionDiscountInfo = () => {
|
|
|
3495
3558
|
};
|
|
3496
3559
|
return (jsxRuntime.jsxs("div", { className: `form-section ${mychoiceCls}`, children: [jsxRuntime.jsx("h2", { className: "section-title", children: "A little extra info for discounts and connecting you with our partners." }), isTheBig ? (jsxRuntime.jsx(LabelFormBox, { title: `You are seconds away from receiving your ${insuranceType} insurance quotes, please provide your email after completing the discount section so we can send you your personalized free ${insuranceType} insurance quotes!` })) : (jsxRuntime.jsx("span", { className: "info-title-message", children: `You are seconds away from receiving your ${insuranceType} insurance quotes,
|
|
3497
3560
|
please provide your email after completing the discount section so we
|
|
3498
|
-
can send you your personalized free ${insuranceType} insurance quotes!` })), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleMultiplePolicyChange, name: "multiplePoliciesDiscount", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, multiplePoliciesDiscount), title: "You could potentially save up to 18% more. Would you consider consolidating multiple policies (like auto insurance) with the same provider?", description: "Most insurers offer discounts to consumers who purchase multiple policies. Select \u2018yes\u2019 if you\u2019d like to bundle your home and auto insurance policies." }), jsxRuntime.jsx(BlockDwellingInfo, {}), 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) }), jsxRuntime.jsx(InputFormPhoneBox, { name: "phone", onChange: handlePhoneNumberChange, defaultValue: phone, title: "Phone Number", placeholder: "(855) 325-8444",
|
|
3561
|
+
can send you your personalized free ${insuranceType} insurance quotes!` })), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.yesNoOptions, onChange: handleMultiplePolicyChange, name: "multiplePoliciesDiscount", defaultValue: getSelectedOption(mychoiceSdkComponents.yesNoOptions, multiplePoliciesDiscount), title: "You could potentially save up to 18% more. Would you consider consolidating multiple policies (like auto insurance) with the same provider?", description: "Most insurers offer discounts to consumers who purchase multiple policies. Select \u2018yes\u2019 if you\u2019d like to bundle your home and auto insurance policies." }), jsxRuntime.jsx(BlockDwellingInfo, {}), 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) }), jsxRuntime.jsx(InputFormPhoneBox, { name: "phone", onChange: handlePhoneNumberChange, defaultValue: phone, title: "Phone Number", placeholder: "(855) 325-8444", validationStatus: phoneStatus, error: phoneStatus === mychoiceSdkComponents.ValidationStatusTypes.Declined
|
|
3562
|
+
|| (phoneStatus === mychoiceSdkComponents.ValidationStatusTypes.Initial && discountState.inValidation)
|
|
3563
|
+
|| (!phone && discountState.inValidation), errorMessage: phoneStatus === mychoiceSdkComponents.ValidationStatusTypes.Declined
|
|
3564
|
+
? phoneErrorMessage
|
|
3565
|
+
: getErrorMessage(phone, discountState.inValidation) || (discountState.inValidation ? 'Enter a valid phone number.' : '') }), jsxRuntime.jsx(InputFormEmailBox, { validationStatus: emailStatus, 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), errorMessage: emailStatus === mychoiceSdkComponents.ValidationStatusTypes.Declined
|
|
3499
3566
|
? errorMessage
|
|
3500
3567
|
: getErrorMessage(email, discountState.inValidation), error: emailStatus === mychoiceSdkComponents.ValidationStatusTypes.Declined || (!email && discountState.inValidation) }), 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$1, { className: isTheBig ? 'thebig-bold' : 'mychoice' }), jsxRuntime.jsx(BlockNextPageInfo$1, {})] }));
|
|
3501
3568
|
};
|
|
@@ -3817,8 +3884,9 @@ const SectionApplicant = () => {
|
|
|
3817
3884
|
const isTheBig = appType === mychoiceSdkComponents.AppTypes.TheBig;
|
|
3818
3885
|
const { applicantState, dispatchApplicantState } = mychoiceSdkStore.useStoreFormLifeApplicant();
|
|
3819
3886
|
const { validateEmail, errorMessage } = mychoiceSdkStore.useHandlerLifeQuoterEmail();
|
|
3887
|
+
const { validatePhone, errorMessage: phoneErrorMessage } = mychoiceSdkStore.useHandlerLifeQuoterPhone();
|
|
3820
3888
|
const { birthYear, birthMonth, birthDay, gender, smoker, quoterInfo, emailTo: { email, emailStatus }, inValidation, } = applicantState;
|
|
3821
|
-
const { firstName, lastName, phone } = quoterInfo || {};
|
|
3889
|
+
const { firstName, lastName, phone, phoneStatus } = quoterInfo || {};
|
|
3822
3890
|
const defaultDateOfBirth = {
|
|
3823
3891
|
day: birthDay,
|
|
3824
3892
|
month: birthMonth,
|
|
@@ -3869,10 +3937,16 @@ const SectionApplicant = () => {
|
|
|
3869
3937
|
});
|
|
3870
3938
|
};
|
|
3871
3939
|
const handlePhoneNumberChange = ({ value }) => {
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
}
|
|
3940
|
+
const digits = value.replace(/\D/g, '');
|
|
3941
|
+
if (digits.length === 10) {
|
|
3942
|
+
validatePhone(value);
|
|
3943
|
+
}
|
|
3944
|
+
else {
|
|
3945
|
+
dispatchApplicantState({
|
|
3946
|
+
type: mychoiceSdkStore.StoreFormLifeApplicantActionTypes.FormLifeQuoterPhoneStatusSet,
|
|
3947
|
+
payload: { phone: value, phoneStatus: mychoiceSdkComponents.ValidationStatusTypes.Initial },
|
|
3948
|
+
});
|
|
3949
|
+
}
|
|
3876
3950
|
};
|
|
3877
3951
|
const handleEmailChange = ({ value }) => {
|
|
3878
3952
|
validateEmail(value);
|
|
@@ -3892,7 +3966,11 @@ const SectionApplicant = () => {
|
|
|
3892
3966
|
textAlign: 'center',
|
|
3893
3967
|
fontSize: '1.15rem',
|
|
3894
3968
|
marginTop: '10px',
|
|
3895
|
-
}, children: `Canadians have compared rates in the last 24 hours and saved ${savedPercentage}% on average` })] }), jsxRuntime.jsx("h2", { className: "section-title", style: { textAlign: 'center' }, children: `${lockEmoji} Complete the form below to see which companies are offering your quotes.` }), jsxRuntime.jsx("span", { className: "info-title-message", children: "You are seconds away from receiving your life insurance quotes, please provide your email after completing the final steps so we can send you your personalized free life insurance quotes!" }), jsxRuntime.jsx(DateSelectFormBox, { name: "dateOfBirth", dateNames: ['birthYear', 'birthMonth', 'birthDay'], onDateChange: handleDateOfBirthChange, defaultValue: defaultDateOfBirth, title: "Date of birth", error: inValidation, errorMessage: getDateErrorMessage([birthDay || '', birthMonth || '', birthYear || ''], inValidation), maxDate: mychoiceSdkComponents.subYearsFromDate('', 14), isDay: true }), jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.genderOptions, name: "gender", onChange: handleGenderChange, defaultValue: getSelectedOption(mychoiceSdkComponents.genderOptions, gender), title: "Gender", placeholder: "Select", autoSelectIfValueIsOutOfOptions: false, error: !gender && inValidation, errorMessage: getErrorMessage(`${gender}`.toString(), inValidation) }), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.smokerOptions, onChange: handleSmokerChange, name: "smoker", defaultValue: getSelectedOption(mychoiceSdkComponents.smokerOptions, smoker), title: "Smoker" }), 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(InputFormBox, { name: "firstName", title: "First Name", onChange: handleFirstNameChange, defaultValue: firstName, placeholder: "Your First Name", error: !firstName && inValidation, errorMessage: getErrorMessage(firstName, inValidation) }), jsxRuntime.jsx(InputFormBox, { name: "lastname", title: "Last Name", onChange: handleLastNameChange, defaultValue: lastName, placeholder: "Your Last Name", error: !lastName && inValidation, errorMessage: getErrorMessage(lastName, inValidation) }), jsxRuntime.jsx(InputFormPhoneBox, { name: "phone", onChange: handlePhoneNumberChange, defaultValue: phone, title: "Phone Number", placeholder: "(855) 325-8444",
|
|
3969
|
+
}, children: `Canadians have compared rates in the last 24 hours and saved ${savedPercentage}% on average` })] }), jsxRuntime.jsx("h2", { className: "section-title", style: { textAlign: 'center' }, children: `${lockEmoji} Complete the form below to see which companies are offering your quotes.` }), jsxRuntime.jsx("span", { className: "info-title-message", children: "You are seconds away from receiving your life insurance quotes, please provide your email after completing the final steps so we can send you your personalized free life insurance quotes!" }), jsxRuntime.jsx(DateSelectFormBox, { name: "dateOfBirth", dateNames: ['birthYear', 'birthMonth', 'birthDay'], onDateChange: handleDateOfBirthChange, defaultValue: defaultDateOfBirth, title: "Date of birth", error: inValidation, errorMessage: getDateErrorMessage([birthDay || '', birthMonth || '', birthYear || ''], inValidation), maxDate: mychoiceSdkComponents.subYearsFromDate('', 14), isDay: true }), jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.genderOptions, name: "gender", onChange: handleGenderChange, defaultValue: getSelectedOption(mychoiceSdkComponents.genderOptions, gender), title: "Gender", placeholder: "Select", autoSelectIfValueIsOutOfOptions: false, error: !gender && inValidation, errorMessage: getErrorMessage(`${gender}`.toString(), inValidation) }), jsxRuntime.jsx(SwitchButtonBox, { items: mychoiceSdkComponents.smokerOptions, onChange: handleSmokerChange, name: "smoker", defaultValue: getSelectedOption(mychoiceSdkComponents.smokerOptions, smoker), title: "Smoker" }), 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(InputFormBox, { name: "firstName", title: "First Name", onChange: handleFirstNameChange, defaultValue: firstName, placeholder: "Your First Name", error: !firstName && inValidation, errorMessage: getErrorMessage(firstName, inValidation) }), jsxRuntime.jsx(InputFormBox, { name: "lastname", title: "Last Name", onChange: handleLastNameChange, defaultValue: lastName, placeholder: "Your Last Name", error: !lastName && inValidation, errorMessage: getErrorMessage(lastName, inValidation) }), jsxRuntime.jsx(InputFormPhoneBox, { name: "phone", onChange: handlePhoneNumberChange, defaultValue: phone, title: "Phone Number", placeholder: "(855) 325-8444", validationStatus: phoneStatus, error: phoneStatus === mychoiceSdkComponents.ValidationStatusTypes.Declined
|
|
3970
|
+
|| (phoneStatus === mychoiceSdkComponents.ValidationStatusTypes.Initial && inValidation)
|
|
3971
|
+
|| (!phone && inValidation), errorMessage: phoneStatus === mychoiceSdkComponents.ValidationStatusTypes.Declined
|
|
3972
|
+
? phoneErrorMessage
|
|
3973
|
+
: getErrorMessage(phone, inValidation) || (inValidation ? 'Enter a valid phone number.' : '') }), jsxRuntime.jsx(InputFormEmailBox, { validationStatus: emailStatus, name: "email", title: "Please provide your email address so we can send you a copy of your quotes", onChange: handleEmailChange, defaultValue: email, placeholder: mychoiceSdkComponents.getPlaceholderEmail(appType), errorMessage: emailStatus === mychoiceSdkComponents.ValidationStatusTypes.Declined
|
|
3896
3974
|
? errorMessage
|
|
3897
3975
|
: getErrorMessage(email, inValidation), error: emailStatus === mychoiceSdkComponents.ValidationStatusTypes.Declined || (!email && inValidation) }), jsxRuntime.jsx(BlockSubmit, { className: isTheBig ? 'thebig-bold' : '' }), jsxRuntime.jsx(BlockNextPageInfo, {})] }));
|
|
3898
3976
|
};
|