From 6f82250c15d26b8bfaaff07cda9f6b05c53ef2c4 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sun, 16 Aug 2020 00:24:09 +0300 Subject: feat: add error boundary --- src/assets/error.svg | 1 + src/components/EmptyState/EmptyState.tsx | 7 ++++++- src/containers/Page/Page.tsx | 36 +++++++++++++++++++------------- 3 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 src/assets/error.svg (limited to 'src') diff --git a/src/assets/error.svg b/src/assets/error.svg new file mode 100644 index 0000000..5adc7a3 --- /dev/null +++ b/src/assets/error.svg @@ -0,0 +1 @@ +Taken \ No newline at end of file diff --git a/src/components/EmptyState/EmptyState.tsx b/src/components/EmptyState/EmptyState.tsx index 1a8eec5..7167ba2 100644 --- a/src/components/EmptyState/EmptyState.tsx +++ b/src/components/EmptyState/EmptyState.tsx @@ -6,10 +6,11 @@ import Message from '../Message/Message'; import noContentIcon from '../../assets/noContent.svg'; import constructionIcon from '../../assets/construction.svg'; import serverIcon from '../../assets/server.svg'; +import errorIcon from '../../assets/error.svg'; interface PropTypes { - variant?: 'default' | 'construction' | 'waiting'; + variant?: 'default' | 'construction' | 'waiting' | 'error'; message?: string; smart?: boolean; } @@ -32,6 +33,10 @@ const CONTEXT = { waiting: { icon: serverIcon, tagline: 'Waiting for server' + }, + error: { + icon: errorIcon, + tagline: 'Something went wrong' } }; diff --git a/src/containers/Page/Page.tsx b/src/containers/Page/Page.tsx index 475f76d..a1d6456 100644 --- a/src/containers/Page/Page.tsx +++ b/src/containers/Page/Page.tsx @@ -2,11 +2,13 @@ import React, { Suspense, useEffect } from 'react'; import { makeStyles, useTheme } from '@material-ui/core/styles'; import { useMediaQuery } from '@material-ui/core'; import { SnackbarProvider } from 'notistack'; +import { ErrorBoundary } from 'react-error-boundary'; import { useHistory } from 'react-router-dom'; import Router from './Router'; import DynoWaiter from './DynoWaiter'; import Loading from '../../components/Loading/Loading'; +import EmptyState from '../../components/EmptyState/EmptyState'; const useStyles = makeStyles(theme => ({ @@ -33,22 +35,26 @@ const Page: React.FC = () => { }, [history]); return ( - } > -
- }> - - - - -
-
+ +
+ }> + + + + +
+
+ ); }; -- cgit v1.2.3