@mychoice/mychoice-sdk-modules 2.1.27 → 2.1.28
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 +22 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +23 -8
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
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,
|
|
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,9 @@ const SectionCoverage = () => {
|
|
|
2942
2941
|
payload: { coverage: value },
|
|
2943
2942
|
});
|
|
2944
2943
|
};
|
|
2945
|
-
|
|
2944
|
+
console.log(lifeInsuranceTypeOptions, "opts");
|
|
2945
|
+
const newLifeOptions = lifeInsuranceTypeOptions.filter(option => option.name.includes("Year Level") && option.name !== "40 Year Level Term");
|
|
2946
|
+
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
2947
|
};
|
|
2947
2948
|
|
|
2948
2949
|
const PageCoverage = () => {
|
|
@@ -3051,7 +3052,6 @@ const SectionApplicant = () => {
|
|
|
3051
3052
|
const handleEmailChange = ({ value }) => {
|
|
3052
3053
|
validateEmail(value);
|
|
3053
3054
|
};
|
|
3054
|
-
console.log(getSelectedOption(smokerOptions, smoker), "show me");
|
|
3055
3055
|
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
3056
|
? (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
3057
|
: 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 +3077,6 @@ const SectionQuoteEdit = () => {
|
|
|
3077
3077
|
const { applicantState } = useStoreFormLifeApplicant();
|
|
3078
3078
|
const { coverageState } = useStoreFormLifeCoverage();
|
|
3079
3079
|
const { smoker, quoterInfo } = applicantState;
|
|
3080
|
-
console.log(applicantState, "applicantState");
|
|
3081
|
-
console.log(smoker, "smoker app stat");
|
|
3082
3080
|
const navigate = useNavigate();
|
|
3083
3081
|
const coverageLabel = coverageOptions.find((item) => item.value.toString() === coverageState.coverage.toString())?.name || '';
|
|
3084
3082
|
const coverageTypeLabel = lifeInsuranceTypeOptions.find((item) => item.value.toString() === coverageState.type.toString())?.name || '';
|
|
@@ -3126,6 +3124,23 @@ const PageLifeQuote = () => {
|
|
|
3126
3124
|
behavior: 'smooth',
|
|
3127
3125
|
});
|
|
3128
3126
|
});
|
|
3127
|
+
const uniqueItems = items.reduce((acc, currentItem) => {
|
|
3128
|
+
// Check if the company is already added.
|
|
3129
|
+
const existingItem = acc.find((item) => item.company === currentItem.company);
|
|
3130
|
+
if (existingItem) {
|
|
3131
|
+
// If exists, keep the one with the lower priceMonthly.
|
|
3132
|
+
if (currentItem.priceMonthly < existingItem.priceMonthly) {
|
|
3133
|
+
// Replace the existing item with the current item.
|
|
3134
|
+
const index = acc.indexOf(existingItem);
|
|
3135
|
+
acc[index] = currentItem;
|
|
3136
|
+
}
|
|
3137
|
+
}
|
|
3138
|
+
else {
|
|
3139
|
+
// If !exists, add the current item.
|
|
3140
|
+
acc.push(currentItem);
|
|
3141
|
+
}
|
|
3142
|
+
return acc;
|
|
3143
|
+
}, []);
|
|
3129
3144
|
return (jsx("div", { className: "quote-page-content", children: !appLoaderState.isOpen
|
|
3130
3145
|
&& (jsxs(Fragment, { children: [jsxs("div", { className: "form-section-container", children: [appDeviceType === DeviceTypes.Mobile && (jsx(Fragment, { children: !!items?.length && (jsx(Fragment, { children: !quoteState.showCallMessage
|
|
3131
3146
|
? (jsx("div", { className: "offer-container", children: jsx(OfferSection, { isBestOffer: true, offerCompany: items[0]?.company, brokerCompany: items[0]?.brokerProfile, offerPrice: {
|
|
@@ -3138,8 +3153,8 @@ const PageLifeQuote = () => {
|
|
|
3138
3153
|
}, phoneNumber: formatPhoneObject(items[0]?.brokerProfile.phone), redirectUrl: items[0]?.brokerProfile.redirectUrl || '' }) }))
|
|
3139
3154
|
: jsx(SplashScreen, {}) })) })), jsx(SectionQuoteEdit, {})] }), appDeviceType !== DeviceTypes.Mobile && quoteState.showCallMessage
|
|
3140
3155
|
&& jsx(SplashScreen, {}), !quoteState.showCallMessage
|
|
3141
|
-
&& (jsx("div", { className: "offer-container", children: !!
|
|
3142
|
-
&&
|
|
3156
|
+
&& (jsx("div", { className: "offer-container", children: !!uniqueItems?.length
|
|
3157
|
+
&& uniqueItems.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
3158
|
monthly: priceMonthly,
|
|
3144
3159
|
yearly: priceYearly,
|
|
3145
3160
|
}, operationHours: {
|