@mychoice/mychoice-sdk-modules 2.2.6 → 2.2.9
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 +24 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +25 -3
- package/dist/esm/index.js.map +1 -1
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
3
3
|
import { AppTypes, isMyChoiceLike, TitleForm, TooltipForm, IconDelete, ColorVariablesTypes, InputTypes, InputForm, InputFormPhone, InputFormEmail, InputFormLicence, SelectForm, getFormattedDate, DateTypes, getDateOptions, ButtonForm, defaultBrokerPhone, DriverPriorityTypes, SizeTypes, ButtonBase, CategoryTypes, ColorTypes, defaultLocalIndex, liabilityOptions, coverageOptions, lossOfUseOptions, liabilityForDamageOptions, limitedWaiverOfDepreciationOptions, OfferDetail, CompanyRoleTypes, OperationHoursInfo, OfferHeader, OfferPrice, ButtonTypes, ButtonVariantTypes, IconDropdownArrow, InsuranceTypes, HeaderNavGroup, ButtonMenu, DeviceTypes, IconLoaderPrimary, getInsuranceType, RequestStatusTypes, formatPostalCode, IconLoaderSecondary, postalCodeFormat, useEffectOnce, carCondition, carStatus, carWinterTiresCheck, carKeepPlace, carUsagePurpose, firstDriveDistanceList, dailyDriveBusinessDistanceList, yearlyDriveDistanceList, numberWithCommas, VehiclePrimaryUseTypes, comprehensiveCoverage, collisionCoverage, maritalStatusOptions, subYearsFromDate, occupationOptions, genderOptions, applicantRelationshipOptions, addYearsToDate, checkDateIsSpecial, DriverLicenceTypes, getDifferenceInYears, getLicenceTypeOptions, getDisabledLicenceTypes, yesNoOptions, addDaysToDate, getMinDate, CheckboxForm, getMinDateByYears, compareDates, insuranceCancellationReasonOptions, DriverListTypes, licenceSuspensionsReasonOptions, trafficTicketsGroupOptions, ValidationStatusTypes, getPlaceholderEmail, QuoteEdit, homeOwnerTypeOptions, tenantBuildingStructureOptions, condoBuildingStructureOptions, homeBuildingStructureOptions, residentsOptions, insuredYearsOptions, getInsuranceYearsOptions, ApplicantListTypes, claimTypeOptions, exteriorFinishOptions, constructionTypeOptions, garageTypeOptions, getNumericOptions, fireHallDistanceOptions, fireHydrantDistanceOptions, primaryHeatingTypeOptions, auxHeatingTypeOptions, InfoMessage, ppOptions, homeCoverageOptions, homeLiabilityOptions, lifeInsuranceTypeOptions, lifeInsuranceOntarioTypeOptions, lifeCoverageOptions, smokerOptions, MychoiceStep, Step, IconClock, ButtonArrow, DirectionTypes, ButtonTabArrow, ButtonTab, ButtonTabMobile, NavigationCar, NavigationPerson, NavigationDiscount, NavigationQuotes, NavigationAddress, NavigationProperty, ModalTypes } from '@mychoice/mychoice-sdk-components';
|
|
4
|
-
import { useStoreAppConfig, useStoreFormCarVehicle, useStoreFormCarDriverBase, useStoreFormCarDiscount, StoreFormCarDiscountActionTypes, useStoreFormCarQuote, CarQuoteDataHandler, useValidationCarDiscount, StoreFormCarVehicleActionTypes, useStorePartner, useStoreDeviceType, useStoreAppLoader, useStoreAppModal, StoreConfigAppModalActionTypes, useHandlerPostal, useHandlerCarMake, useHandlerCarModel, useProvince, useValidationVehicle, StoreFormCarDriverBaseActionTypes, useStoreFormCarConfig, useStoreFormCarDriverInfo, StoreFormCarDriverInfoActionTypes, useStoreFormCarDriverLicence, addDayToDate, StoreFormCarDriverLicenceActionTypes, useStoreFormCarDriverInsurance, StoreFormCarDriverInsuranceActionTypes, useStoreFormCarDriverCancellation, StoreFormCarDriverCancellationActionTypes, useStoreFormCarDriverSuspension, StoreFormCarDriverSuspensionActionTypes, useStoreFormCarDriverAccident, StoreFormCarDriverAccidentActionTypes, useStoreFormCarDriverTicket, StoreFormCarDriverTicketActionTypes, useValidationDriver, useHandlerCarQuoterEmail, useStoreFormHomeDwelling, useStoreFormHomePostal, useStoreFormHomeApplicantBase, StoreFormHomePostalActionTypes, StoreFormHomeDwellingActionTypes, StoreConfigAppConfigActionTypes, StoreFormHomeApplicantBaseActionTypes, useValidationAddress, useStoreFormHomeApplicantInfo,
|
|
4
|
+
import { useStoreAppConfig, useStoreFormCarVehicle, useStoreFormCarDriverBase, useStoreFormCarDiscount, StoreFormCarDiscountActionTypes, useStoreFormCarQuote, CarQuoteDataHandler, useValidationCarDiscount, StoreFormCarVehicleActionTypes, useStoreFormHomeDiscount, useStorePartner, useStoreDeviceType, useStoreAppLoader, useStoreAppModal, StoreConfigAppModalActionTypes, useHandlerPostal, useHandlerCarMake, useHandlerCarModel, useProvince, useValidationVehicle, StoreFormCarDriverBaseActionTypes, useStoreFormCarConfig, useStoreFormCarDriverInfo, StoreFormCarDriverInfoActionTypes, useStoreFormCarDriverLicence, addDayToDate, StoreFormCarDriverLicenceActionTypes, useStoreFormCarDriverInsurance, StoreFormCarDriverInsuranceActionTypes, useStoreFormCarDriverCancellation, StoreFormCarDriverCancellationActionTypes, useStoreFormCarDriverSuspension, StoreFormCarDriverSuspensionActionTypes, useStoreFormCarDriverAccident, StoreFormCarDriverAccidentActionTypes, useStoreFormCarDriverTicket, StoreFormCarDriverTicketActionTypes, useValidationDriver, useHandlerCarQuoterEmail, useStoreFormHomeDwelling, useStoreFormHomePostal, useStoreFormHomeApplicantBase, StoreFormHomePostalActionTypes, StoreFormHomeDwellingActionTypes, StoreConfigAppConfigActionTypes, StoreFormHomeApplicantBaseActionTypes, useValidationAddress, useStoreFormHomeApplicantInfo, 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, useMemo } from 'react';
|
|
7
7
|
import { random } from 'lodash';
|
|
@@ -378,12 +378,33 @@ const VehicleOfferCoverages = ({ coverages, nonStandardCoverages, }) => {
|
|
|
378
378
|
};
|
|
379
379
|
|
|
380
380
|
const OfferSection = ({ offerCompany, brokerCompany, offerPrice, phoneNumber, isBestOffer, isFirstOffer = true, operationHours = {}, redirectUrl, fulfillmentUrl, coverages, nonStandardCoverages, brokerIntegration, }) => {
|
|
381
|
-
const { appConfigState: { appType }, } = useStoreAppConfig();
|
|
381
|
+
const { appConfigState: { appType, insuranceType }, } = useStoreAppConfig();
|
|
382
|
+
// Get discount states for broker phone
|
|
383
|
+
const { discountState: carDiscountState } = useStoreFormCarDiscount();
|
|
384
|
+
const { discountState: homeDiscountState } = useStoreFormHomeDiscount();
|
|
382
385
|
const { postRequestQuoteOnliaUrl } = CarQuoteDataHandler();
|
|
383
386
|
const isTheBig = appType === AppTypes.TheBig;
|
|
384
387
|
const isMyChoice = isMyChoiceLike(appType);
|
|
385
388
|
const isBeginInsurance = appType === AppTypes.BeginInsurance;
|
|
386
389
|
const mychoiceCls = isMyChoiceLike(appType) ? 'mychoice' : '';
|
|
390
|
+
// Get broker phone from discount state
|
|
391
|
+
const getBrokerPhoneFromState = () => {
|
|
392
|
+
if (!isTheBig)
|
|
393
|
+
return undefined;
|
|
394
|
+
let discountState;
|
|
395
|
+
if (insuranceType === 'car') {
|
|
396
|
+
discountState = carDiscountState;
|
|
397
|
+
}
|
|
398
|
+
else if (insuranceType === 'home') {
|
|
399
|
+
discountState = homeDiscountState;
|
|
400
|
+
}
|
|
401
|
+
else if (insuranceType === 'life') {
|
|
402
|
+
discountState = carDiscountState;
|
|
403
|
+
}
|
|
404
|
+
return discountState?.quoterInfo?.brokerInfo?.phone;
|
|
405
|
+
};
|
|
406
|
+
const brokerPhoneFromState = getBrokerPhoneFromState();
|
|
407
|
+
const effectivePhoneNumber = brokerPhoneFromState ? formatPhoneObject(brokerPhoneFromState) : phoneNumber;
|
|
387
408
|
const { weekdayHours, saturdayHours, sundayHours } = operationHours;
|
|
388
409
|
const [detailsIsOpen, setDetailsIsOpenIsOpen] = useState(isBestOffer ?? false);
|
|
389
410
|
const handleDropdownClick = () => {
|
|
@@ -400,6 +421,7 @@ const OfferSection = ({ offerCompany, brokerCompany, offerPrice, phoneNumber, is
|
|
|
400
421
|
postRequestQuoteOnliaUrl(true, redirectUrl);
|
|
401
422
|
};
|
|
402
423
|
const isHubIntegration = brokerIntegration?.type === 'hub';
|
|
424
|
+
const isDCWIntegration = brokerIntegration?.type === 'dcw';
|
|
403
425
|
return (jsxs("div", { className: `offer-section ${mychoiceCls}`, children: [shouldShowBrokerInfo && isMyChoice && (isTheBig || !offsiteUrl) && (jsxs(Fragment, { children: [jsx(OfferDetail, { className: isTheBig ? 'thebig-bold' : '', logo: brokerCompany?.logo, name: brokerCompany?.title, companyType: CompanyRoleTypes.Broker, description: brokerCompany?.description, isBestOffer: isBestOffer, isMyChoice: isMyChoice }), jsx("hr", { style: {
|
|
404
426
|
margin: '0',
|
|
405
427
|
padding: '0',
|
|
@@ -412,7 +434,7 @@ const OfferSection = ({ offerCompany, brokerCompany, offerPrice, phoneNumber, is
|
|
|
412
434
|
width: '100%',
|
|
413
435
|
height: '1px',
|
|
414
436
|
backgroundColor: '$color-background-header-primary',
|
|
415
|
-
} })] })), !isHubIntegration && (jsx(OfferHeader, { className: isTheBig ? 'thebig-bold' : '', companyName: offerCompany?.name, isBestOffer: isBestOffer, isMyChoice: isMyChoice })), !isHubIntegration && (jsx(OfferPrice, { className: isTheBig ? 'thebig' : '', companyLogo: offerCompany?.logo, price: offerPrice })), isHubIntegration && (jsx("div", { className: "offer-phone
|
|
437
|
+
} })] })), !isHubIntegration && !isDCWIntegration && (jsx(OfferHeader, { className: isTheBig ? 'thebig-bold' : '', companyName: offerCompany?.name, isBestOffer: isBestOffer, isMyChoice: isMyChoice })), !isHubIntegration && !isDCWIntegration && (jsx(OfferPrice, { className: isTheBig ? 'thebig' : '', companyLogo: offerCompany?.logo, price: offerPrice })), (isHubIntegration || isDCWIntegration) && (jsx("div", { className: "offer-phone noprice-integration", children: jsx("div", { className: "noprice-message-container", children: jsxs("p", { className: "noprice-description", children: [jsx("span", { children: brokerIntegration?.data?.label }), jsx("br", {}), brokerIntegration?.data?.description] }) }) })), brokerIntegration?.type === 'youset' && brokerIntegration?.data?.url && (jsxs("div", { className: "offer-phone", children: [jsx("h3", { children: brokerIntegration?.data?.description || 'Click below to view your YouSet offer' }), jsx(ButtonBase, { className: `offer-phone-number ${mychoiceCls}`, label: brokerIntegration?.data?.label || 'View Offer', type: ButtonTypes.Button, category: CategoryTypes.Filled, color: ColorTypes.Primary, variant: ButtonVariantTypes.Rectangle, size: SizeTypes.Medium, onClick: () => window.open(brokerIntegration.data.url, '_blank') })] })), !brokerIntegration && !isTheBig && offsiteUrl && (jsxs("div", { className: "offer-phone", children: [jsx("h3", { children: "Click below to get this rate" }), jsx(ButtonBase, { className: `offer-phone-number ${mychoiceCls}`, label: "Buy Online", type: ButtonTypes.Button, category: CategoryTypes.Filled, color: ColorTypes.Primary, variant: ButtonVariantTypes.Rectangle, size: SizeTypes.Medium, onClick: handleCTAClick })] })), !brokerIntegration && (isTheBig || !offsiteUrl) && (jsxs("div", { className: "offer-phone", children: [jsx("h3", { className: isTheBig ? 'thebig-bold' : '', children: "Call now to get this rate" }), jsx("a", { target: "_blank", rel: "noreferrer noopener", href: `tel:${effectivePhoneNumber?.number}`, children: jsx(ButtonBase, { className: `${isTheBig ? 'thebig-bold' : 'mychoice'} offer-phone-number`, label: effectivePhoneNumber?.title, type: ButtonTypes.Button, category: CategoryTypes.Filled, color: ColorTypes.Primary, variant: ButtonVariantTypes.Rectangle, size: SizeTypes.Medium }) })] })), jsxs("button", { className: "dropdown", onClick: handleDropdownClick, children: [jsx("span", { children: detailsIsOpen ? 'Less Info' : 'More Info' }), jsx(IconDropdownArrow, { color: "grey", className: detailsIsOpen ? 'rotated' : '' })] }), detailsIsOpen && (jsxs("div", { className: "offer-details", children: [!isHubIntegration && (jsxs(Fragment, { children: [jsx(OfferDetail, { className: isTheBig ? 'thebig-bold' : '', name: offerCompany?.name, companyType: CompanyRoleTypes.Offering, description: offerCompany?.description, isBestOffer: !isMyChoice ? isBestOffer : false, isMyChoice: isMyChoice }), !isMyChoice && jsx("hr", {})] })), !isMyChoice && (isTheBig || !offsiteUrl) && (jsxs(Fragment, { children: [jsx(OfferDetail, { className: isTheBig ? 'thebig-bold' : '', logo: brokerCompany?.logo, name: brokerCompany?.title, companyType: CompanyRoleTypes.Broker, description: brokerCompany?.description, isMyChoice: isMyChoice }), jsx("hr", {})] })), !isMyChoice && (jsx(OfferDetail, { className: isTheBig ? 'thebig-bold' : '', name: "Hours of Operation", isMyChoice: isMyChoice, children: jsx(OperationHoursInfo, { weekdayHours: weekdayHours, saturdayHours: saturdayHours, sundayHours: sundayHours }) })), isMyChoice && coverages && (jsxs(Fragment, { children: [jsx("hr", {}), jsx(VehicleOfferCoverages, { coverages: coverages, nonStandardCoverages: nonStandardCoverages })] }))] }))] }));
|
|
416
438
|
};
|
|
417
439
|
OfferSection.defaultProps = {
|
|
418
440
|
offerPrice: { monthly: 0, yearly: 0 },
|