@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.
package/dist/cjs/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var jsxRuntime = require('react/jsx-runtime');
6
+ var reactErrorBoundary = require('react-error-boundary');
6
7
  var mychoiceSdkComponents = require('@mychoice/mychoice-sdk-components');
7
8
  var mychoiceSdkStore = require('@mychoice/mychoice-sdk-store');
8
9
  var reactRouterDom = require('react-router-dom');
@@ -3983,7 +3984,7 @@ const AppRouteWrapper = (props) => {
3983
3984
  }
3984
3985
  }
3985
3986
  }, [carPostal, homePostal, lifePostal, isReady]);
3986
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: isReady && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(AppHeader, {}), jsxRuntime.jsx(AppModal, {}), insuranceType && (jsxRuntime.jsx(NavigationTop, { title: `${insuranceType.replace(/^./, insuranceType[0].toUpperCase())} Insurance Quote`, postalCode: postalCode, formSteps: steps, validationHooks: validationHooks, clearForm: clearFormData, propertyIsCompleted: isCompleted })), insuranceType && appType === mychoiceSdkComponents.AppTypes.MyChoice && (jsxRuntime.jsx("div", { className: "step-progress-bar", children: jsxRuntime.jsx("span", { style: { width: progressLength } }) })), jsxRuntime.jsx("div", { className: `${insuranceType ? 'form-page-content' : ''} ${insuranceType && appType === mychoiceSdkComponents.AppTypes.MyChoice ? 'mychoice' : ''}`, children: insuranceType && appType === mychoiceSdkComponents.AppTypes.MyChoice && isDesktop && progressLength ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { className: "mychoice-content", children: [jsxRuntime.jsx(StepsBox, { className: "step-box", formSteps: steps, validationHooks: validationHooks, propertyIsCompleted: isCompleted }), children, jsxRuntime.jsx("div", { className: "empty-steps-container" })] }) })) : children }), !appLoaderState.isOpen && jsxRuntime.jsx(ProviderImageFooter, {})] })) }));
3987
+ return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: isReady && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(AppHeader, {}), jsxRuntime.jsx(AppModal, {}), insuranceType && (jsxRuntime.jsx(NavigationTop, { title: `${insuranceType.replace(/^./, insuranceType[0].toUpperCase())} Insurance Quote`, postalCode: postalCode, formSteps: steps, validationHooks: validationHooks, clearForm: clearFormData, propertyIsCompleted: isCompleted })), insuranceType && appType === mychoiceSdkComponents.AppTypes.MyChoice && (jsxRuntime.jsx("div", { className: "step-progress-bar", children: jsxRuntime.jsx("span", { style: { width: progressLength } }) })), jsxRuntime.jsx("div", { className: `${insuranceType ? 'form-page-content' : ''} ${insuranceType && appType === mychoiceSdkComponents.AppTypes.MyChoice ? 'mychoice' : ''}`, children: insuranceType && appType === mychoiceSdkComponents.AppTypes.MyChoice && isDesktop && progressLength ? (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { className: "mychoice-content", children: [jsxRuntime.jsx(StepsBox, { className: "step-box", formSteps: steps, validationHooks: validationHooks, propertyIsCompleted: isCompleted }), children, jsxRuntime.jsx("div", { className: "empty-steps-container" })] }) })) : children }), !appLoaderState.isOpen && insuranceType === mychoiceSdkComponents.InsuranceTypes.Car && jsxRuntime.jsx(ProviderImageFooter, {})] })) }));
3987
3988
  };
3988
3989
  const NestedRoutes = () => {
3989
3990
  const insuranceType = mychoiceSdkComponents.getInsuranceType();
@@ -4290,6 +4291,15 @@ const AppConfig = (props) => {
4290
4291
  return null;
4291
4292
  };
4292
4293
 
4294
+ const AppErrorScreen = () => {
4295
+ const onClear = () => {
4296
+ localStorage.clear();
4297
+ // eslint-disable-next-line
4298
+ location.reload();
4299
+ };
4300
+ return (jsxRuntime.jsxs("div", { style: { textAlign: 'center', paddingTop: '100px' }, children: [jsxRuntime.jsx("h1", { children: "Something went wrong." }), jsxRuntime.jsxs("p", { style: { margin: '10px 0 10px 0' }, children: [jsxRuntime.jsx("a", { href: "#reset", onClick: onClear, style: { color: 'red', textDecoration: 'underline' }, children: "Click here" }), ' ', "to restart the application"] }), jsxRuntime.jsxs("p", { children: ["If that doesn't help, please reach out to us at", ' ', jsxRuntime.jsx("a", { href: "mailto:info@mychoice.ca", children: "info@mychoice.ca" })] })] }));
4301
+ };
4302
+
4293
4303
  const AppWrapperConfig = (props) => {
4294
4304
  mychoiceSdkStore.initHttpResponse();
4295
4305
  const { appType } = props;
@@ -4303,65 +4313,12 @@ const AppWrapperConfig = (props) => {
4303
4313
  return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(AppLoader, {}), jsxRuntime.jsx(AppConfig, { appType: appType }), drawWrapper && isReady
4304
4314
  && jsxRuntime.jsx(AppRoutes, { appType: appType })] }));
4305
4315
  };
4306
- const AppWrapper = ({ appType }) => (jsxRuntime.jsx(mychoiceSdkStore.StoreProvider, { children: jsxRuntime.jsx(AppWrapperConfig, { appType: appType }) }));
4316
+ const AppWrapper = ({ appType }) => (jsxRuntime.jsx(mychoiceSdkStore.StoreProvider, { children: jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary, { fallbackRender: AppErrorScreen, children: jsxRuntime.jsx(AppWrapperConfig, { appType: appType }) }) }));
4307
4317
  AppWrapper.defaultProps = {
4308
4318
  appType: mychoiceSdkComponents.AppTypes.MyChoice,
4309
4319
  insuranceType: mychoiceSdkComponents.InsuranceTypes.Car,
4310
4320
  };
4311
4321
 
4312
- const StoreConfig = () => {
4313
- const { dispatchAppConfigState } = mychoiceSdkStore.useStoreAppConfig();
4314
- const { dispatchDriverBaseState } = mychoiceSdkStore.useStoreFormCarDriverBase();
4315
- const { dispatchVehicleState } = mychoiceSdkStore.useStoreFormCarVehicle();
4316
- const { dispatchDeviceState } = mychoiceSdkStore.useStoreAppDevice();
4317
- const windowResize = () => {
4318
- dispatchDeviceState({
4319
- type: mychoiceSdkStore.StoreConfigAppDeviceActionTypes.AppDeviceSetSize,
4320
- payload: {
4321
- width: window.innerWidth,
4322
- height: window.innerHeight,
4323
- },
4324
- });
4325
- };
4326
- mychoiceSdkComponents.useEffectOnce(() => {
4327
- dispatchDriverBaseState({
4328
- type: mychoiceSdkStore.StoreFormCarDriverBaseActionTypes.FormCarDriverGetLocal,
4329
- });
4330
- dispatchVehicleState({
4331
- type: mychoiceSdkStore.StoreFormCarVehicleActionTypes.FormCarVehicleGetLocal,
4332
- });
4333
- dispatchAppConfigState({
4334
- type: mychoiceSdkStore.StoreConfigAppConfigActionTypes.AppConfigSetIsReady,
4335
- payload: true,
4336
- });
4337
- window.addEventListener('resize', windowResize);
4338
- windowResize();
4339
- });
4340
- return null;
4341
- };
4342
- const StoryAppWrapperConfig = (props) => {
4343
- const { children } = props;
4344
- const { appConfigState, dispatchAppConfigState } = mychoiceSdkStore.useStoreAppConfig();
4345
- mychoiceSdkComponents.useEffectOnce(() => {
4346
- dispatchAppConfigState({
4347
- type: mychoiceSdkStore.StoreConfigAppConfigActionTypes.AppConfigSetDrawWrapper,
4348
- payload: true,
4349
- });
4350
- });
4351
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(StoreConfig, {}), appConfigState.drawWrapper
4352
- && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(AppModal, {}), children] }))] }));
4353
- };
4354
- const StoryAppWrapper = (props) => {
4355
- const { appType, children } = props;
4356
- mychoiceSdkComponents.useEffectOnce(() => {
4357
- mychoiceSdkStore.initHttpResponse();
4358
- });
4359
- return (jsxRuntime.jsx(mychoiceSdkStore.StoreProvider, { children: jsxRuntime.jsx(reactRouterDom.BrowserRouter, { children: jsxRuntime.jsx(StoryAppWrapperConfig, { appType: appType, children: children }) }) }));
4360
- };
4361
- StoryAppWrapper.defaultProps = {
4362
- appType: mychoiceSdkComponents.AppTypes.MyChoice,
4363
- };
4364
-
4365
4322
  exports.AppWrapper = AppWrapper;
4366
4323
  exports.DateSelectFormBox = DateSelectFormBox;
4367
4324
  exports.HeaderMyChoice = HeaderMyChoice;
@@ -4400,7 +4357,6 @@ exports.PageProperty = PageProperty;
4400
4357
  exports.PageVehicle = PageVehicle;
4401
4358
  exports.ProviderImageFooter = ProviderImageFooter;
4402
4359
  exports.SelectFormBox = SelectFormBox;
4403
- exports.StoryAppWrapper = StoryAppWrapper;
4404
4360
  exports.SwitchButtonBox = SwitchButtonBox;
4405
4361
  exports.capitalize = capitalize;
4406
4362
  exports.formSteps = formSteps;