@mychoice/mychoice-sdk-modules 2.1.1 → 2.1.3

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.
@@ -0,0 +1 @@
1
+ export declare const AppErrorScreen: () => import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1 @@
1
1
  export { AppWrapper } from './AppWrapper';
2
- export { StoryAppWrapper } from './StoryAppWrapper';
package/dist/esm/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
+ import { ErrorBoundary } from 'react-error-boundary';
2
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, IconLoaderPrimary, getInsuranceType, RequestStatusTypes, formatPostalCode, IconLoaderSecondary, postalCodeFormat, defaultBrokerPhone, useEffectOnce, yearMessage, carCondition, carStatus, carWinterTiresCheck, carKeepPlace, carUsagePurpose, firstDriveDistanceList, dailyDriveBusinessDistanceList, yearlyDriveDistanceList, numberWithCommas, VehiclePrimaryUseTypes, comprehensiveCoverage, collisionCoverage, DeviceTypes, 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
4
  import { useStoreAppConfig, CarQuoteDataHandler, useStorePartner, useStoreAppLoader, useStoreAppModal, StoreConfigAppModalActionTypes, useHandlerPostal, useHandlerCarMake, useHandlerCarModel, useStoreFormCarVehicle, StoreFormCarVehicleActionTypes, useProvince, useStoreFormCarDiscount, useStoreDeviceType, 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';
4
5
  import { useNavigate, useLocation, BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
@@ -3973,7 +3974,7 @@ const AppRouteWrapper = (props) => {
3973
3974
  }
3974
3975
  }
3975
3976
  }, [carPostal, homePostal, lifePostal, isReady]);
3976
- return (jsx(Fragment, { children: isReady && (jsxs(Fragment, { children: [jsx(AppHeader, {}), jsx(AppModal, {}), insuranceType && (jsx(NavigationTop, { title: `${insuranceType.replace(/^./, insuranceType[0].toUpperCase())} Insurance Quote`, postalCode: postalCode, formSteps: steps, validationHooks: validationHooks, clearForm: clearFormData, propertyIsCompleted: isCompleted })), insuranceType && appType === AppTypes.MyChoice && (jsx("div", { className: "step-progress-bar", children: jsx("span", { style: { width: progressLength } }) })), jsx("div", { className: `${insuranceType ? 'form-page-content' : ''} ${insuranceType && appType === AppTypes.MyChoice ? 'mychoice' : ''}`, children: insuranceType && appType === AppTypes.MyChoice && isDesktop && progressLength ? (jsx(Fragment, { children: jsxs("div", { className: "mychoice-content", children: [jsx(StepsBox, { className: "step-box", formSteps: steps, validationHooks: validationHooks, propertyIsCompleted: isCompleted }), children, jsx("div", { className: "empty-steps-container" })] }) })) : children }), !appLoaderState.isOpen && jsx(ProviderImageFooter, {})] })) }));
3977
+ return (jsx(Fragment, { children: isReady && (jsxs(Fragment, { children: [jsx(AppHeader, {}), jsx(AppModal, {}), insuranceType && (jsx(NavigationTop, { title: `${insuranceType.replace(/^./, insuranceType[0].toUpperCase())} Insurance Quote`, postalCode: postalCode, formSteps: steps, validationHooks: validationHooks, clearForm: clearFormData, propertyIsCompleted: isCompleted })), insuranceType && appType === AppTypes.MyChoice && (jsx("div", { className: "step-progress-bar", children: jsx("span", { style: { width: progressLength } }) })), jsx("div", { className: `${insuranceType ? 'form-page-content' : ''} ${insuranceType && appType === AppTypes.MyChoice ? 'mychoice' : ''}`, children: insuranceType && appType === AppTypes.MyChoice && isDesktop && progressLength ? (jsx(Fragment, { children: jsxs("div", { className: "mychoice-content", children: [jsx(StepsBox, { className: "step-box", formSteps: steps, validationHooks: validationHooks, propertyIsCompleted: isCompleted }), children, jsx("div", { className: "empty-steps-container" })] }) })) : children }), !appLoaderState.isOpen && insuranceType === InsuranceTypes.Car && jsx(ProviderImageFooter, {})] })) }));
3977
3978
  };
3978
3979
  const NestedRoutes = () => {
3979
3980
  const insuranceType = getInsuranceType();
@@ -4280,6 +4281,15 @@ const AppConfig = (props) => {
4280
4281
  return null;
4281
4282
  };
4282
4283
 
4284
+ const AppErrorScreen = () => {
4285
+ const onClear = () => {
4286
+ localStorage.clear();
4287
+ // eslint-disable-next-line
4288
+ location.reload();
4289
+ };
4290
+ return (jsxs("div", { style: { textAlign: 'center', paddingTop: '100px' }, children: [jsx("h1", { children: "Something went wrong." }), jsxs("p", { style: { margin: '10px 0 10px 0' }, children: [jsx("a", { href: "#reset", onClick: onClear, style: { color: 'red', textDecoration: 'underline' }, children: "Click here" }), ' ', "to restart the application"] }), jsxs("p", { children: ["If that doesn't help, please reach out to us at", ' ', jsx("a", { href: "mailto:info@mychoice.ca", children: "info@mychoice.ca" })] })] }));
4291
+ };
4292
+
4283
4293
  const AppWrapperConfig = (props) => {
4284
4294
  initHttpResponse();
4285
4295
  const { appType } = props;
@@ -4293,64 +4303,11 @@ const AppWrapperConfig = (props) => {
4293
4303
  return (jsxs(Fragment, { children: [jsx(AppLoader, {}), jsx(AppConfig, { appType: appType }), drawWrapper && isReady
4294
4304
  && jsx(AppRoutes, { appType: appType })] }));
4295
4305
  };
4296
- const AppWrapper = ({ appType }) => (jsx(StoreProvider, { children: jsx(AppWrapperConfig, { appType: appType }) }));
4306
+ const AppWrapper = ({ appType }) => (jsx(StoreProvider, { children: jsx(ErrorBoundary, { fallbackRender: AppErrorScreen, children: jsx(AppWrapperConfig, { appType: appType }) }) }));
4297
4307
  AppWrapper.defaultProps = {
4298
4308
  appType: AppTypes.MyChoice,
4299
4309
  insuranceType: InsuranceTypes.Car,
4300
4310
  };
4301
4311
 
4302
- const StoreConfig = () => {
4303
- const { dispatchAppConfigState } = useStoreAppConfig();
4304
- const { dispatchDriverBaseState } = useStoreFormCarDriverBase();
4305
- const { dispatchVehicleState } = useStoreFormCarVehicle();
4306
- const { dispatchDeviceState } = useStoreAppDevice();
4307
- const windowResize = () => {
4308
- dispatchDeviceState({
4309
- type: StoreConfigAppDeviceActionTypes.AppDeviceSetSize,
4310
- payload: {
4311
- width: window.innerWidth,
4312
- height: window.innerHeight,
4313
- },
4314
- });
4315
- };
4316
- useEffectOnce(() => {
4317
- dispatchDriverBaseState({
4318
- type: StoreFormCarDriverBaseActionTypes.FormCarDriverGetLocal,
4319
- });
4320
- dispatchVehicleState({
4321
- type: StoreFormCarVehicleActionTypes.FormCarVehicleGetLocal,
4322
- });
4323
- dispatchAppConfigState({
4324
- type: StoreConfigAppConfigActionTypes.AppConfigSetIsReady,
4325
- payload: true,
4326
- });
4327
- window.addEventListener('resize', windowResize);
4328
- windowResize();
4329
- });
4330
- return null;
4331
- };
4332
- const StoryAppWrapperConfig = (props) => {
4333
- const { children } = props;
4334
- const { appConfigState, dispatchAppConfigState } = useStoreAppConfig();
4335
- useEffectOnce(() => {
4336
- dispatchAppConfigState({
4337
- type: StoreConfigAppConfigActionTypes.AppConfigSetDrawWrapper,
4338
- payload: true,
4339
- });
4340
- });
4341
- return (jsxs(Fragment, { children: [jsx(StoreConfig, {}), appConfigState.drawWrapper
4342
- && (jsxs(Fragment, { children: [jsx(AppModal, {}), children] }))] }));
4343
- };
4344
- const StoryAppWrapper = (props) => {
4345
- const { appType, children } = props;
4346
- useEffectOnce(() => {
4347
- initHttpResponse();
4348
- });
4349
- return (jsx(StoreProvider, { children: jsx(BrowserRouter, { children: jsx(StoryAppWrapperConfig, { appType: appType, children: children }) }) }));
4350
- };
4351
- StoryAppWrapper.defaultProps = {
4352
- appType: AppTypes.MyChoice,
4353
- };
4354
-
4355
- export { AppWrapper, DateSelectFormBox, HeaderMyChoice, HeaderMyChoiceMobile, HeaderPartner, HeaderTheBig, InputFormBox, InputFormEmailBox, InputFormLicenceBox, InputFormPhoneBox, LabelFormBox, LoaderPrimary, ModalAddress, ModalConfirm, ModalFinale, ModalMessage, ModalPostal, ModalQuoteRequest, NavigationBottom, NavigationBottomTheBig, NavigationTab, NavigationTabMobile, NavigationTop, OfferSection, PageAddress, PageApplicant, PageCarDiscount, PageCarQuote, PageCoverage, PageDriver, PageHomeDiscount, PageHomeQuote, PageLifeApplicant, PageLifeQuote, PageProperty, PageVehicle, ProviderImageFooter, SelectFormBox, StoryAppWrapper, SwitchButtonBox, capitalize, formSteps, formatPhoneObject, formatTitleToCapital, getDateErrorMessage, getErrorMessage, getSelectedOption, usePathGroups };
4312
+ export { AppWrapper, DateSelectFormBox, HeaderMyChoice, HeaderMyChoiceMobile, HeaderPartner, HeaderTheBig, InputFormBox, InputFormEmailBox, InputFormLicenceBox, InputFormPhoneBox, LabelFormBox, LoaderPrimary, ModalAddress, ModalConfirm, ModalFinale, ModalMessage, ModalPostal, ModalQuoteRequest, NavigationBottom, NavigationBottomTheBig, NavigationTab, NavigationTabMobile, NavigationTop, OfferSection, PageAddress, PageApplicant, PageCarDiscount, PageCarQuote, PageCoverage, PageDriver, PageHomeDiscount, PageHomeQuote, PageLifeApplicant, PageLifeQuote, PageProperty, PageVehicle, ProviderImageFooter, SelectFormBox, SwitchButtonBox, capitalize, formSteps, formatPhoneObject, formatTitleToCapital, getDateErrorMessage, getErrorMessage, getSelectedOption, usePathGroups };
4356
4313
  //# sourceMappingURL=index.js.map