@mychoice/mychoice-sdk-modules 2.1.36 → 2.1.38
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 +42 -33
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +43 -34
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -958,36 +958,35 @@ const SectionDriverInsurancePolicy = () => {
|
|
|
958
958
|
const { configState } = mychoiceSdkStore.useStoreFormCarConfig();
|
|
959
959
|
const { driverState, dispatchDriverInsuranceState } = mychoiceSdkStore.useStoreFormCarDriverInsurance();
|
|
960
960
|
const { discountState, dispatchDiscountState } = mychoiceSdkStore.useStoreFormCarDiscount();
|
|
961
|
-
const { quoteState: { isRequested } } = mychoiceSdkStore.useStoreFormCarQuote();
|
|
961
|
+
const { quoteState: { isRequested }, } = mychoiceSdkStore.useStoreFormCarQuote();
|
|
962
962
|
const { listed, listedMonth = '', listedYear = '', insured, insuredDate = '', firstName, birthYear, birthMonth, birthDay, licenceInfo: { firstLicenceAge, licenceType, gLicenceYear, gLicenceMonth, g1LicenceYear, g1LicenceMonth, }, } = driverState.items[driverState.activeIndex];
|
|
963
963
|
const { policyStartYear, policyStartMonth, policyStartDay } = discountState;
|
|
964
964
|
const driverNameDefault = `Driver ${driverState.activeIndex + 1}`;
|
|
965
|
-
const birthDate = birthYear && birthMonth && birthDay
|
|
966
|
-
|
|
965
|
+
const birthDate = birthYear && birthMonth && birthDay
|
|
966
|
+
? `${birthYear}-${birthMonth}-${birthDay}`
|
|
967
|
+
: '';
|
|
968
|
+
const { appConfigState: { appType }, } = mychoiceSdkStore.useStoreAppConfig();
|
|
967
969
|
const mychoiceCls = appType === mychoiceSdkComponents.AppTypes.MyChoice ? 'mychoice' : '';
|
|
968
970
|
const getPeriodOptions = (year, month) => {
|
|
969
|
-
const options = [
|
|
971
|
+
const options = [
|
|
972
|
+
{ value: '', name: 'Date Period', disabled: true },
|
|
973
|
+
];
|
|
970
974
|
if (year && month) {
|
|
971
|
-
const
|
|
972
|
-
const
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
case y === 1:
|
|
982
|
-
options.push({ value: mychoiceSdkComponents.addYearsToDate(listedDate, y), name: '1 Year' });
|
|
983
|
-
break;
|
|
984
|
-
default:
|
|
985
|
-
options.push({
|
|
986
|
-
value: mychoiceSdkComponents.addYearsToDate(listedDate, y),
|
|
987
|
-
name: `${y} Years`,
|
|
988
|
-
});
|
|
989
|
-
}
|
|
975
|
+
const todayDate = new Date();
|
|
976
|
+
const month = String(todayDate.getMonth() + 1).padStart(2, '0');
|
|
977
|
+
const day = String(todayDate.getDate()).padStart(2, '0');
|
|
978
|
+
const yearsInPast = todayDate.getFullYear() - parseInt(year);
|
|
979
|
+
for (let i = yearsInPast; i > 0; i--) {
|
|
980
|
+
const pastDate = `${todayDate.getFullYear() - i}-${month}-${day}`;
|
|
981
|
+
options.push({
|
|
982
|
+
value: pastDate,
|
|
983
|
+
name: `${i} ${i === 1 ? 'Year' : 'Years'}`,
|
|
984
|
+
});
|
|
990
985
|
}
|
|
986
|
+
options.push({
|
|
987
|
+
value: `${todayDate.getFullYear() - 1}-${month}-${day}`,
|
|
988
|
+
name: 'Less than 1 Year',
|
|
989
|
+
});
|
|
991
990
|
}
|
|
992
991
|
return options;
|
|
993
992
|
};
|
|
@@ -1027,7 +1026,9 @@ you had insurance. If this is correct, please continue with the form.`);
|
|
|
1027
1026
|
}
|
|
1028
1027
|
};
|
|
1029
1028
|
if (birthDate) {
|
|
1030
|
-
const defaultMinDate = birthDate && firstLicenceAge
|
|
1029
|
+
const defaultMinDate = birthDate && firstLicenceAge
|
|
1030
|
+
? mychoiceSdkComponents.addYearsToDate(birthDate, +firstLicenceAge)
|
|
1031
|
+
: '';
|
|
1031
1032
|
const isOnlyG = mychoiceSdkComponents.checkDateIsSpecial(defaultMinDate, configState.minDates.g.specialDate);
|
|
1032
1033
|
if (isOnlyG) {
|
|
1033
1034
|
setMessage(gLicenceYear, gLicenceMonth);
|
|
@@ -1046,7 +1047,16 @@ you had insurance. If this is correct, please continue with the form.`);
|
|
|
1046
1047
|
else {
|
|
1047
1048
|
setHintMessage('');
|
|
1048
1049
|
}
|
|
1049
|
-
}, [
|
|
1050
|
+
}, [
|
|
1051
|
+
listedYear,
|
|
1052
|
+
listedMonth,
|
|
1053
|
+
g1LicenceYear,
|
|
1054
|
+
g1LicenceMonth,
|
|
1055
|
+
firstLicenceAge,
|
|
1056
|
+
birthDate,
|
|
1057
|
+
gLicenceYear,
|
|
1058
|
+
gLicenceMonth,
|
|
1059
|
+
]);
|
|
1050
1060
|
const handleInsuredChange = ({ value }) => {
|
|
1051
1061
|
dispatchDriverInsuranceState({
|
|
1052
1062
|
type: mychoiceSdkStore.StoreFormCarDriverInsuranceActionTypes.FormCarDriverInsuredSelect,
|
|
@@ -1099,12 +1109,11 @@ you had insurance. If this is correct, please continue with the form.`);
|
|
|
1099
1109
|
});
|
|
1100
1110
|
}
|
|
1101
1111
|
};
|
|
1102
|
-
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 main driver was first listed on a Canadian or US insurance policy. If you do not remember your age, it is acceptable to provide a best estimate for the purposes of the policy or quote.", errorMessage: listed
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
], driverState.inValidation), error: driverState.inValidation, minDate: mychoiceSdkComponents.addDaysToDate('', 1), maxDate: mychoiceSdkComponents.addDaysToDate('', 60), isDay: true })] }));
|
|
1112
|
+
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 main driver was first listed on a Canadian or US insurance policy. If you do not remember your age, it is acceptable to provide a best estimate for the purposes of the policy or quote.", errorMessage: listed
|
|
1113
|
+
? getDateErrorMessage(['01', listedMonth, listedYear], driverState.inValidation)
|
|
1114
|
+
: '', 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
|
|
1115
|
+
? getErrorMessage(insuredDate, driverState.inValidation)
|
|
1116
|
+
: '', error: !insuredDate && driverState.inValidation }), jsxRuntime.jsx(mychoiceSdkComponents.CheckboxForm, { name: "insured", label: "Not currently insured", onChange: handleInsuredChange, defaultValue: !insured })] })), 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 })] }));
|
|
1108
1117
|
};
|
|
1109
1118
|
|
|
1110
1119
|
const SectionDriverCancellation = () => {
|
|
@@ -2932,7 +2941,7 @@ const PageHomeQuote = () => {
|
|
|
2932
2941
|
|
|
2933
2942
|
const Description = () => (jsxRuntime.jsxs("div", { children: [jsxRuntime.jsx("span", { children: jsxRuntime.jsx("p", { children: "There are two primary categories of life insurance policies: term life insurance and permanent life insurance." }) }), jsxRuntime.jsx("h4", { children: "Term Life Insurance Options" }), jsxRuntime.jsx("h5", { children: "Options include 10, 15, 20, 30-year plans" }), jsxRuntime.jsx("p", { children: "These policies provide coverage for a specific term of either 10, 15, 20, or 30 years. The premiums are consistent throughout the term. At the end of the term, policyholders have the choice to renew or convert their policy." }), jsxRuntime.jsx("h5", { children: "Coverage Until Ages 65, 70, 75" }), jsxRuntime.jsx("p", { children: "These are term life policies that extend coverage until the policyholder reaches the age of 65, 70, or 75. Premiums are consistent for the entirety of the policy's duration. However, renewal options are not available after reaching the specified age." }), jsxRuntime.jsx("h5", { children: "Coverage Until Age 100" }), jsxRuntime.jsx("p", { children: "Although it's sometimes categorized as a permanent life insurance plan, the Term to 100 plan is, in fact, a term life policy. This plan offers coverage until the policyholder reaches the age of 100 and cannot be renewed." }), jsxRuntime.jsx("h4", { children: "Permanent Life Insurance Options" }), jsxRuntime.jsx("h5", { children: "Universal Life Insurance" }), jsxRuntime.jsx("p", { children: "This policy is valid for the entirety of the policyholder's life and includes a cash value component. The premium can be modified by reducing the death benefit or utilizing the cash value within the plan. The premiums for this type of plan are typically higher than those for term life insurance." }), jsxRuntime.jsx("h5", { children: "Whole Life Insurance" }), jsxRuntime.jsx("p", { children: "This is a lifetime policy where the premiums are fixed and never increase (without exception). The policy also has a cash value feature, which the policyholder can borrow against in a tax-free manner. Similar to universal life insurance, the premiums for whole life insurance are generally higher than those for term life insurance." })] }));
|
|
2934
2943
|
const SectionCoverage = () => {
|
|
2935
|
-
const { coverageState: { type, coverage, province, inValidation
|
|
2944
|
+
const { coverageState: { type, coverage, province, inValidation }, dispatchCoverageState, } = mychoiceSdkStore.useStoreFormLifeCoverage();
|
|
2936
2945
|
const handleProvinceChange = ({ value }) => {
|
|
2937
2946
|
dispatchCoverageState({
|
|
2938
2947
|
type: mychoiceSdkStore.StoreFormLifeCoverageActionTypes.FormLifeProvinceSelect,
|
|
@@ -2951,7 +2960,7 @@ const SectionCoverage = () => {
|
|
|
2951
2960
|
payload: { coverage: value },
|
|
2952
2961
|
});
|
|
2953
2962
|
};
|
|
2954
|
-
const newLifeOptions = mychoiceSdkComponents.lifeInsuranceTypeOptions.filter(option => option.name.includes(
|
|
2963
|
+
const newLifeOptions = mychoiceSdkComponents.lifeInsuranceTypeOptions.filter((option) => option.name.includes('Year Level'));
|
|
2955
2964
|
return (jsxRuntime.jsxs("div", { className: "form-section", children: [jsxRuntime.jsx("h2", { className: "section-title", style: { textAlign: 'center' }, children: "Let us meet your needs." }), jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.lifeProvinceOptions, name: "province", onChange: handleProvinceChange, defaultValue: province, title: "Province", placeholder: "Select", autoSelectIfValueIsOutOfOptions: false, error: !province && inValidation, errorMessage: getErrorMessage(type, inValidation) }), jsxRuntime.jsx(SelectFormBox, { options: newLifeOptions, name: "type", onChange: handleLifeInsuranceTypeChange, defaultValue: type, title: "Type of Insurance", description: jsxRuntime.jsx(Description, {}), placeholder: "Select", autoSelectIfValueIsOutOfOptions: false, error: !type && inValidation, errorMessage: getErrorMessage(type, inValidation) }), jsxRuntime.jsx(SelectFormBox, { options: mychoiceSdkComponents.lifeCoverageOptions, name: "coverage", onChange: handleCoverageChange, defaultValue: coverage, title: "Required coverage", description: "The extent of coverage you need is determined by several factors,\n including your expenditure patterns, anticipated future expenses, yearly earnings,\n and so forth. Generally, individuals opt for a coverage amount that equals five\n times their current annual income before taxes. On an average,\n it is observed that Canadians choose a coverage amount of around $500,000.", placeholder: "Select", autoSelectIfValueIsOutOfOptions: false, error: !coverage && inValidation, errorMessage: getErrorMessage(coverage, inValidation) })] }));
|
|
2956
2965
|
};
|
|
2957
2966
|
|