@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/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import { ErrorBoundary } from 'react-error-boundary';
3
- import { AppTypes, TitleForm, TooltipForm, IconDelete, ColorVariablesTypes, InputTypes, InputForm, InputFormPhone, InputFormEmail, InputFormLicence, SelectForm, getFormattedDate, DateTypes, getDateOptions, ButtonForm, OfferHeader, OfferPrice, ButtonBase, ButtonTypes, CategoryTypes, ColorTypes, ButtonVariantTypes, SizeTypes, IconDropdownArrow, OfferDetail, CompanyRoleTypes, OperationHoursInfo, InsuranceTypes, HeaderNavGroup, ButtonMenu, DeviceTypes, IconLoaderPrimary, getInsuranceType, RequestStatusTypes, formatPostalCode, IconLoaderSecondary, postalCodeFormat, defaultBrokerPhone, useEffectOnce, carCondition, carStatus, carWinterTiresCheck, carKeepPlace, carUsagePurpose, firstDriveDistanceList, dailyDriveBusinessDistanceList, yearlyDriveDistanceList, numberWithCommas, VehiclePrimaryUseTypes, comprehensiveCoverage, collisionCoverage, defaultLocalIndex, maritalStatusOptions, subYearsFromDate, occupationOptions, genderOptions, applicantRelationshipOptions, addYearsToDate, checkDateIsSpecial, DriverLicenceTypes, getDifferenceInYears, getLicenceTypeOptions, getDisabledLicenceTypes, yesNoOptions, addDaysToDate, getMinDate, CheckboxForm, subMonthsFromDate, getMinDateByYears, compareDates, insuranceCancellationReasonOptions, DriverListTypes, licenceSuspensionsReasonOptions, trafficTicketsGroupOptions, DriverPriorityTypes, ValidationStatusTypes, QuoteEdit, coverageOptions, liabilityOptions, homeOwnerTypeOptions, tenantBuildingStructureOptions, condoBuildingStructureOptions, homeBuildingStructureOptions, residentsOptions, insuredYearsOptions, getInsuranceYearsOptions, ApplicantListTypes, claimTypeOptions, exteriorFinishOptions, constructionTypeOptions, garageTypeOptions, getNumericOptions, fireHallDistanceOptions, fireHydrantDistanceOptions, primaryHeatingTypeOptions, auxHeatingTypeOptions, InfoMessage, ppOptions, homeCoverageOptions, homeLiabilityOptions, lifeInsuranceTypeOptions, lifeProvinceOptions, lifeCoverageOptions, smokerOptions, MychoiceStep, Step, IconClock, ButtonArrow, DirectionTypes, ButtonTabArrow, ButtonTab, ButtonTabMobile, NavigationCar, NavigationPerson, NavigationDiscount, NavigationQuotes, NavigationAddress, NavigationProperty, ModalTypes } from '@mychoice/mychoice-sdk-components';
3
+ import { AppTypes, TitleForm, TooltipForm, IconDelete, ColorVariablesTypes, InputTypes, InputForm, InputFormPhone, InputFormEmail, InputFormLicence, SelectForm, getFormattedDate, DateTypes, getDateOptions, ButtonForm, OfferHeader, OfferPrice, ButtonBase, ButtonTypes, CategoryTypes, ColorTypes, ButtonVariantTypes, SizeTypes, IconDropdownArrow, OfferDetail, CompanyRoleTypes, OperationHoursInfo, InsuranceTypes, HeaderNavGroup, ButtonMenu, DeviceTypes, IconLoaderPrimary, getInsuranceType, RequestStatusTypes, formatPostalCode, IconLoaderSecondary, postalCodeFormat, defaultBrokerPhone, useEffectOnce, carCondition, carStatus, carWinterTiresCheck, carKeepPlace, carUsagePurpose, firstDriveDistanceList, dailyDriveBusinessDistanceList, yearlyDriveDistanceList, numberWithCommas, VehiclePrimaryUseTypes, comprehensiveCoverage, collisionCoverage, defaultLocalIndex, maritalStatusOptions, subYearsFromDate, occupationOptions, genderOptions, applicantRelationshipOptions, addYearsToDate, checkDateIsSpecial, DriverLicenceTypes, getDifferenceInYears, getLicenceTypeOptions, getDisabledLicenceTypes, yesNoOptions, addDaysToDate, getMinDate, CheckboxForm, getMinDateByYears, compareDates, insuranceCancellationReasonOptions, DriverListTypes, licenceSuspensionsReasonOptions, trafficTicketsGroupOptions, DriverPriorityTypes, ValidationStatusTypes, QuoteEdit, coverageOptions, liabilityOptions, homeOwnerTypeOptions, tenantBuildingStructureOptions, condoBuildingStructureOptions, homeBuildingStructureOptions, residentsOptions, insuredYearsOptions, getInsuranceYearsOptions, ApplicantListTypes, claimTypeOptions, exteriorFinishOptions, constructionTypeOptions, garageTypeOptions, getNumericOptions, fireHallDistanceOptions, fireHydrantDistanceOptions, primaryHeatingTypeOptions, auxHeatingTypeOptions, InfoMessage, ppOptions, homeCoverageOptions, homeLiabilityOptions, lifeInsuranceTypeOptions, lifeProvinceOptions, lifeCoverageOptions, smokerOptions, MychoiceStep, Step, IconClock, ButtonArrow, DirectionTypes, ButtonTabArrow, ButtonTab, ButtonTabMobile, NavigationCar, NavigationPerson, NavigationDiscount, NavigationQuotes, NavigationAddress, NavigationProperty, ModalTypes } from '@mychoice/mychoice-sdk-components';
4
4
  import { useStoreAppConfig, CarQuoteDataHandler, useStorePartner, useStoreDeviceType, useStoreAppLoader, useStoreAppModal, StoreConfigAppModalActionTypes, useHandlerPostal, useHandlerCarMake, useHandlerCarModel, useStoreFormCarVehicle, StoreFormCarVehicleActionTypes, useProvince, useStoreFormCarDiscount, StoreFormCarDiscountActionTypes, useValidationVehicle, useStoreFormCarDriverBase, StoreFormCarDriverBaseActionTypes, useStoreFormCarConfig, useStoreFormCarDriverInfo, StoreFormCarDriverInfoActionTypes, useStoreFormCarDriverLicence, addDayToDate, StoreFormCarDriverLicenceActionTypes, useStoreFormCarDriverInsurance, useStoreFormCarQuote, StoreFormCarDriverInsuranceActionTypes, useStoreFormCarDriverCancellation, StoreFormCarDriverCancellationActionTypes, useStoreFormCarDriverSuspension, StoreFormCarDriverSuspensionActionTypes, useStoreFormCarDriverAccident, StoreFormCarDriverAccidentActionTypes, useStoreFormCarDriverTicket, StoreFormCarDriverTicketActionTypes, useValidationDriver, useValidationCarDiscount, useHandlerCarQuoterEmail, useStoreFormHomeDwelling, useStoreFormHomePostal, useStoreFormHomeApplicantBase, StoreFormHomePostalActionTypes, StoreFormHomeDwellingActionTypes, StoreConfigAppConfigActionTypes, StoreFormHomeApplicantBaseActionTypes, useValidationAddress, useStoreFormHomeApplicantInfo, useStoreFormHomeDiscount, StoreFormHomeDiscountActionTypes, StoreFormHomeApplicantInfoActionTypes, useStoreFormHomeApplicantInsurance, StoreFormHomeApplicantInsuranceActionTypes, useStoreFormHomeApplicantCancellation, StoreFormHomeApplicantCancellationActionTypes, useStoreFormHomeApplicantClaim, StoreFormHomeApplicantClaimActionTypes, useValidationApplicant, useValidationDwelling, useStoreFormHomeQuote, HomeQuoteDataHandler, useValidationHomeDiscount, useHandlerHomeQuoterEmail, useStoreFormLifeCoverage, StoreFormLifeCoverageActionTypes, useValidationCoverage, useStoreFormLifeQuote, useStoreFormLifeApplicant, LifeQuoteDataHandler, useValidationLifeApplicant, useHandlerLifeQuoterEmail, StoreFormLifeApplicantActionTypes, useStoreFormCarPostal, useStoreFormLifePostal, ClearFormDataHandler, useStoreAppDevice, useStoreClient, useHandlerAuth, useHandlerPartner, StoreConfigAppLoaderActionTypes, StoreFormCarConfigActionTypes, StoreFormCarPostalActionTypes, StoreFormCarQuoteActionTypes, StoreFormHomeQuoteActionTypes, StoreFormLifePostalActionTypes, StoreFormLifeQuoteActionTypes, StoreClientActionTypes, StoreConfigAppDeviceActionTypes, StoreProvider, initHttpResponse } from '@mychoice/mychoice-sdk-store';
5
5
  import { useNavigate, useLocation, BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
6
6
  import React, { useState, useCallback, useEffect, useRef } from 'react';
@@ -948,36 +948,35 @@ const SectionDriverInsurancePolicy = () => {
948
948
  const { configState } = useStoreFormCarConfig();
949
949
  const { driverState, dispatchDriverInsuranceState } = useStoreFormCarDriverInsurance();
950
950
  const { discountState, dispatchDiscountState } = useStoreFormCarDiscount();
951
- const { quoteState: { isRequested } } = useStoreFormCarQuote();
951
+ const { quoteState: { isRequested }, } = useStoreFormCarQuote();
952
952
  const { listed, listedMonth = '', listedYear = '', insured, insuredDate = '', firstName, birthYear, birthMonth, birthDay, licenceInfo: { firstLicenceAge, licenceType, gLicenceYear, gLicenceMonth, g1LicenceYear, g1LicenceMonth, }, } = driverState.items[driverState.activeIndex];
953
953
  const { policyStartYear, policyStartMonth, policyStartDay } = discountState;
954
954
  const driverNameDefault = `Driver ${driverState.activeIndex + 1}`;
955
- const birthDate = birthYear && birthMonth && birthDay ? `${birthYear}-${birthMonth}-${birthDay}` : '';
956
- const { appConfigState: { appType } } = useStoreAppConfig();
955
+ const birthDate = birthYear && birthMonth && birthDay
956
+ ? `${birthYear}-${birthMonth}-${birthDay}`
957
+ : '';
958
+ const { appConfigState: { appType }, } = useStoreAppConfig();
957
959
  const mychoiceCls = appType === AppTypes.MyChoice ? 'mychoice' : '';
958
960
  const getPeriodOptions = (year, month) => {
959
- const options = [{ value: '', name: 'Date Period', disabled: true }];
961
+ const options = [
962
+ { value: '', name: 'Date Period', disabled: true },
963
+ ];
960
964
  if (year && month) {
961
- const listedDate = addDaysToDate(`${year}-${month}-01`, birthDay ? +birthDay + 1 : 1);
962
- const yearPeriod = getDifferenceInYears('', listedDate) || 0;
963
- for (let y = yearPeriod; y >= 0; y -= 1) {
964
- switch (true) {
965
- case y === 0:
966
- options.push({
967
- value: subMonthsFromDate('', 10),
968
- name: 'Less than 1 Year',
969
- });
970
- break;
971
- case y === 1:
972
- options.push({ value: addYearsToDate(listedDate, y), name: '1 Year' });
973
- break;
974
- default:
975
- options.push({
976
- value: addYearsToDate(listedDate, y),
977
- name: `${y} Years`,
978
- });
979
- }
965
+ const todayDate = new Date();
966
+ const month = String(todayDate.getMonth() + 1).padStart(2, '0');
967
+ const day = String(todayDate.getDate()).padStart(2, '0');
968
+ const yearsInPast = todayDate.getFullYear() - parseInt(year);
969
+ for (let i = yearsInPast; i > 0; i--) {
970
+ const pastDate = `${todayDate.getFullYear() - i}-${month}-${day}`;
971
+ options.push({
972
+ value: pastDate,
973
+ name: `${i} ${i === 1 ? 'Year' : 'Years'}`,
974
+ });
980
975
  }
976
+ options.push({
977
+ value: `${todayDate.getFullYear() - 1}-${month}-${day}`,
978
+ name: 'Less than 1 Year',
979
+ });
981
980
  }
982
981
  return options;
983
982
  };
@@ -1017,7 +1016,9 @@ you had insurance. If this is correct, please continue with the form.`);
1017
1016
  }
1018
1017
  };
1019
1018
  if (birthDate) {
1020
- const defaultMinDate = birthDate && firstLicenceAge ? addYearsToDate(birthDate, +firstLicenceAge) : '';
1019
+ const defaultMinDate = birthDate && firstLicenceAge
1020
+ ? addYearsToDate(birthDate, +firstLicenceAge)
1021
+ : '';
1021
1022
  const isOnlyG = checkDateIsSpecial(defaultMinDate, configState.minDates.g.specialDate);
1022
1023
  if (isOnlyG) {
1023
1024
  setMessage(gLicenceYear, gLicenceMonth);
@@ -1036,7 +1037,16 @@ you had insurance. If this is correct, please continue with the form.`);
1036
1037
  else {
1037
1038
  setHintMessage('');
1038
1039
  }
1039
- }, [listedYear, listedMonth, g1LicenceYear, g1LicenceMonth, firstLicenceAge, birthDate, gLicenceYear, gLicenceMonth]);
1040
+ }, [
1041
+ listedYear,
1042
+ listedMonth,
1043
+ g1LicenceYear,
1044
+ g1LicenceMonth,
1045
+ firstLicenceAge,
1046
+ birthDate,
1047
+ gLicenceYear,
1048
+ gLicenceMonth,
1049
+ ]);
1040
1050
  const handleInsuredChange = ({ value }) => {
1041
1051
  dispatchDriverInsuranceState({
1042
1052
  type: StoreFormCarDriverInsuranceActionTypes.FormCarDriverInsuredSelect,
@@ -1089,12 +1099,11 @@ you had insurance. If this is correct, please continue with the form.`);
1089
1099
  });
1090
1100
  }
1091
1101
  };
1092
- return (jsxs("div", { className: `form-section ${mychoiceCls}`, children: [jsxs("div", { className: "box-container", children: [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 ? getDateErrorMessage(['01', listedMonth, listedYear], driverState.inValidation) : '', error: driverState.inValidation, hintMessage: hintMessage, minDate: getMinDate(birthDate, firstLicenceAge) }), jsx(CheckboxForm, { name: "listed", label: "Never listed on an insurance policy", onChange: handleListedChange, defaultValue: !listed })] }), listed
1093
- && (jsxs("div", { className: "box-container", children: [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 }), jsx(CheckboxForm, { name: "insured", label: "Not currently insured", onChange: handleInsuredChange, defaultValue: !insured })] })), 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([
1094
- policyStartDay || '',
1095
- policyStartMonth || '',
1096
- policyStartYear || '',
1097
- ], driverState.inValidation), error: driverState.inValidation, minDate: addDaysToDate('', 1), maxDate: addDaysToDate('', 60), isDay: true })] }));
1102
+ return (jsxs("div", { className: `form-section ${mychoiceCls}`, children: [jsxs("div", { className: "box-container", children: [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
+ ? getDateErrorMessage(['01', listedMonth, listedYear], driverState.inValidation)
1104
+ : '', error: driverState.inValidation, hintMessage: hintMessage, minDate: getMinDate(birthDate, firstLicenceAge) }), jsx(CheckboxForm, { name: "listed", label: "Never listed on an insurance policy", onChange: handleListedChange, defaultValue: !listed })] }), listed && (jsxs("div", { className: "box-container", children: [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
1105
+ ? getErrorMessage(insuredDate, driverState.inValidation)
1106
+ : '', error: !insuredDate && driverState.inValidation }), jsx(CheckboxForm, { name: "insured", label: "Not currently insured", onChange: handleInsuredChange, defaultValue: !insured })] })), 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: addDaysToDate('', 1), maxDate: addDaysToDate('', 60), isDay: true })] }));
1098
1107
  };
1099
1108
 
1100
1109
  const SectionDriverCancellation = () => {
@@ -2922,7 +2931,7 @@ const PageHomeQuote = () => {
2922
2931
 
2923
2932
  const Description = () => (jsxs("div", { children: [jsx("span", { children: jsx("p", { children: "There are two primary categories of life insurance policies: term life insurance and permanent life insurance." }) }), jsx("h4", { children: "Term Life Insurance Options" }), jsx("h5", { children: "Options include 10, 15, 20, 30-year plans" }), 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." }), jsx("h5", { children: "Coverage Until Ages 65, 70, 75" }), 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." }), jsx("h5", { children: "Coverage Until Age 100" }), 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." }), jsx("h4", { children: "Permanent Life Insurance Options" }), jsx("h5", { children: "Universal Life Insurance" }), 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." }), jsx("h5", { children: "Whole Life Insurance" }), 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." })] }));
2924
2933
  const SectionCoverage = () => {
2925
- const { coverageState: { type, coverage, province, inValidation, }, dispatchCoverageState, } = useStoreFormLifeCoverage();
2934
+ const { coverageState: { type, coverage, province, inValidation }, dispatchCoverageState, } = useStoreFormLifeCoverage();
2926
2935
  const handleProvinceChange = ({ value }) => {
2927
2936
  dispatchCoverageState({
2928
2937
  type: StoreFormLifeCoverageActionTypes.FormLifeProvinceSelect,
@@ -2941,7 +2950,7 @@ const SectionCoverage = () => {
2941
2950
  payload: { coverage: value },
2942
2951
  });
2943
2952
  };
2944
- const newLifeOptions = lifeInsuranceTypeOptions.filter(option => option.name.includes("Year Level") && option.name !== "40 Year Level Term");
2953
+ const newLifeOptions = lifeInsuranceTypeOptions.filter((option) => option.name.includes('Year Level'));
2945
2954
  return (jsxs("div", { className: "form-section", children: [jsx("h2", { className: "section-title", style: { textAlign: 'center' }, children: "Let us meet your needs." }), jsx(SelectFormBox, { options: lifeProvinceOptions, name: "province", onChange: handleProvinceChange, defaultValue: province, title: "Province", placeholder: "Select", autoSelectIfValueIsOutOfOptions: false, error: !province && inValidation, errorMessage: getErrorMessage(type, inValidation) }), jsx(SelectFormBox, { options: newLifeOptions, name: "type", onChange: handleLifeInsuranceTypeChange, defaultValue: type, title: "Type of Insurance", description: jsx(Description, {}), placeholder: "Select", autoSelectIfValueIsOutOfOptions: false, error: !type && inValidation, errorMessage: getErrorMessage(type, inValidation) }), jsx(SelectFormBox, { options: 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) })] }));
2946
2955
  };
2947
2956