@mychoice/mychoice-sdk-modules 2.1.27 → 2.1.29

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, lifeProvinceOptions, lifeInsuranceTypeOptions, 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, 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';
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';
@@ -125,7 +125,6 @@ const SwitchButtonBox = (props) => {
125
125
  };
126
126
  const handleClick = useCallback((selectedItem) => () => {
127
127
  setActiveId(selectedItem.value);
128
- console.log(selectedItem.value, "value?");
129
128
  if (onChange) {
130
129
  onChange({
131
130
  name,
@@ -2942,7 +2941,8 @@ const SectionCoverage = () => {
2942
2941
  payload: { coverage: value },
2943
2942
  });
2944
2943
  };
2945
- 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: lifeInsuranceTypeOptions, 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) })] }));
2944
+ const newLifeOptions = lifeInsuranceTypeOptions.filter(option => option.name.includes("Year Level") && option.name !== "40 Year Level Term");
2945
+ 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
2946
  };
2947
2947
 
2948
2948
  const PageCoverage = () => {
@@ -3051,7 +3051,6 @@ const SectionApplicant = () => {
3051
3051
  const handleEmailChange = ({ value }) => {
3052
3052
  validateEmail(value);
3053
3053
  };
3054
- console.log(getSelectedOption(smokerOptions, smoker), "show me");
3055
3054
  return (jsxs("div", { className: "form-section", children: [jsx("h2", { className: "section-title", style: { textAlign: 'center' }, children: "Just the basics about you." }), 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: subYearsFromDate('', 14), isDay: true }), jsx(SelectFormBox, { options: genderOptions, name: "gender", onChange: handleGenderChange, defaultValue: getSelectedOption(genderOptions, gender), title: "Gender", placeholder: "Select", autoSelectIfValueIsOutOfOptions: false, error: !gender && inValidation, errorMessage: getErrorMessage(`${gender}`.toString(), inValidation) }), jsx(SwitchButtonBox, { items: smokerOptions, onChange: handleSmokerChange, name: "smoker", defaultValue: getSelectedOption(smokerOptions, smoker), title: "Smoker" }), isTheBig
3056
3055
  ? (jsxs("div", { className: "input-form-box-container", children: [jsx(LabelFormBox, { title: "Complete this form to see all your personalized\n quotes on the next page, you will also be able to:" }), jsxs("ol", { className: "ordered-block", children: [jsx("li", { children: "See what rates insurance carriers are offering" }), jsx("li", { children: "Get in touch with us and secure your rate" }), jsx("li", { children: "Potentially save more by speaking with a broker" })] })] }))
3057
3056
  : jsx("h2", { children: "Complete the form below to see which companies are offering your quotes." }), jsx(InputFormBox, { name: "firstName", title: "First Name", onChange: handleFirstNameChange, defaultValue: firstName, placeholder: "Your First Name", error: !firstName && inValidation, errorMessage: getErrorMessage(firstName, inValidation) }), jsx(InputFormBox, { name: "lastname", title: "Last Name", onChange: handleLastNameChange, defaultValue: lastName, placeholder: "Your Last Name", error: !lastName && inValidation, errorMessage: getErrorMessage(lastName, inValidation) }), jsx(InputFormPhoneBox, { name: "phone", onChange: handlePhoneNumberChange, defaultValue: phone, title: "Phone Number", placeholder: "(855) 325-8444", error: !phone && inValidation, errorMessage: getErrorMessage(phone, inValidation) }), 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: "johnsmith@mychoice.ca", errorMessage: emailStatus === ValidationStatusTypes.Declined
@@ -3077,8 +3076,6 @@ const SectionQuoteEdit = () => {
3077
3076
  const { applicantState } = useStoreFormLifeApplicant();
3078
3077
  const { coverageState } = useStoreFormLifeCoverage();
3079
3078
  const { smoker, quoterInfo } = applicantState;
3080
- console.log(applicantState, "applicantState");
3081
- console.log(smoker, "smoker app stat");
3082
3079
  const navigate = useNavigate();
3083
3080
  const coverageLabel = coverageOptions.find((item) => item.value.toString() === coverageState.coverage.toString())?.name || '';
3084
3081
  const coverageTypeLabel = lifeInsuranceTypeOptions.find((item) => item.value.toString() === coverageState.type.toString())?.name || '';
@@ -3126,20 +3123,29 @@ const PageLifeQuote = () => {
3126
3123
  behavior: 'smooth',
3127
3124
  });
3128
3125
  });
3126
+ const uniqueItems = items.reduce((acc, currentItem) => {
3127
+ // Check if the company is already added and if so, whether the current item has a lower priceMonthly.
3128
+ if (!acc[currentItem.company] || currentItem.priceMonthly < acc[currentItem.company].priceMonthly) {
3129
+ acc[currentItem.company] = currentItem; // Add or update the item for the company
3130
+ }
3131
+ return acc;
3132
+ }, {});
3133
+ const result = Object.values(uniqueItems);
3134
+ console.log(result, "ach");
3129
3135
  return (jsx("div", { className: "quote-page-content", children: !appLoaderState.isOpen
3130
- && (jsxs(Fragment, { children: [jsxs("div", { className: "form-section-container", children: [appDeviceType === DeviceTypes.Mobile && (jsx(Fragment, { children: !!items?.length && (jsx(Fragment, { children: !quoteState.showCallMessage
3131
- ? (jsx("div", { className: "offer-container", children: jsx(OfferSection, { isBestOffer: true, offerCompany: items[0]?.company, brokerCompany: items[0]?.brokerProfile, offerPrice: {
3132
- monthly: items[0]?.priceMonthly,
3133
- yearly: items[0]?.priceYearly,
3136
+ && (jsxs(Fragment, { children: [jsxs("div", { className: "form-section-container", children: [appDeviceType === DeviceTypes.Mobile && (jsx(Fragment, { children: !!result?.length && (jsx(Fragment, { children: !quoteState.showCallMessage
3137
+ ? (jsx("div", { className: "offer-container", children: jsx(OfferSection, { isBestOffer: true, offerCompany: result[0]?.company, brokerCompany: result[0]?.brokerProfile, offerPrice: {
3138
+ monthly: result[0]?.priceMonthly,
3139
+ yearly: result[0]?.priceYearly,
3134
3140
  }, operationHours: {
3135
- saturdayHours: items[0]?.brokerProfile.hoursSaturday,
3136
- sundayHours: items[0]?.brokerProfile.hoursSunday,
3137
- weekdayHours: items[0]?.brokerProfile.hoursWorkdays,
3141
+ saturdayHours: result[0]?.brokerProfile.hoursSaturday,
3142
+ sundayHours: result[0]?.brokerProfile.hoursSunday,
3143
+ weekdayHours: result[0]?.brokerProfile.hoursWorkdays,
3138
3144
  }, phoneNumber: formatPhoneObject(items[0]?.brokerProfile.phone), redirectUrl: items[0]?.brokerProfile.redirectUrl || '' }) }))
3139
3145
  : jsx(SplashScreen, {}) })) })), jsx(SectionQuoteEdit, {})] }), appDeviceType !== DeviceTypes.Mobile && quoteState.showCallMessage
3140
3146
  && jsx(SplashScreen, {}), !quoteState.showCallMessage
3141
- && (jsx("div", { className: "offer-container", children: !!items?.length
3142
- && items.map(({ company, brokerProfile, priceMonthly, priceYearly, }, index) => (jsx("div", { children: (appDeviceType !== DeviceTypes.Mobile || (appDeviceType === DeviceTypes.Mobile && index !== 0)) && (jsx(OfferSection, { isBestOffer: index === 0, offerCompany: company, brokerCompany: brokerProfile, offerPrice: {
3147
+ && (jsx("div", { className: "offer-container", children: !!result?.length
3148
+ && result.map(({ company, brokerProfile, priceMonthly, priceYearly, }, index) => (jsx("div", { children: (appDeviceType !== DeviceTypes.Mobile || (appDeviceType === DeviceTypes.Mobile && index !== 0)) && (jsx(OfferSection, { isBestOffer: index === 0, offerCompany: company, brokerCompany: brokerProfile, offerPrice: {
3143
3149
  monthly: priceMonthly,
3144
3150
  yearly: priceYearly,
3145
3151
  }, operationHours: {