@mychoice/mychoice-sdk-modules 2.1.36 → 2.1.37

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 = () => {