diff --git a/src/components/InactiveSettingsCard.tsx b/src/components/InactiveSettingsCard.tsx index 55c708b8..1bf0779a 100644 --- a/src/components/InactiveSettingsCard.tsx +++ b/src/components/InactiveSettingsCard.tsx @@ -11,6 +11,7 @@ import { Loader, } from 'semantic-ui-react' import { useSettingsApi } from '../api/Settings' +import ErrorView from '../views/ErrorView' import InactiveSettingsModalForm from './InactiveSettingsModalForm' import useAuth from './useAuth' @@ -34,8 +35,7 @@ const InactiveSettingsCard: FC = () => { } if (error || data === undefined) { - //TODO: Generic Error View - return Error occured + return Unable to fetch inactive settings from server. } const setting = data.data.setting diff --git a/src/components/RefreshIntervalCard.tsx b/src/components/RefreshIntervalCard.tsx index b41ad9c8..9cc08867 100644 --- a/src/components/RefreshIntervalCard.tsx +++ b/src/components/RefreshIntervalCard.tsx @@ -2,6 +2,7 @@ import React, { FC } from 'react' import { useQuery } from 'react-query' import { Button, Card, Dimmer, Icon, List, Loader } from 'semantic-ui-react' import { useSettingsApi } from '../api/Settings' +import ErrorView from '../views/ErrorView' import RefreshIntervalModalForm from './RefreshIntervalModalForm' import useAuth from './useAuth' @@ -25,8 +26,11 @@ const RefreshIntervalCard: FC = () => { } if (error || data === undefined) { - //TODO: Generic Error View - return Error occured + return ( + + Unable to fetch refresh interval setting from server. + + ) } const setting = data.data.setting diff --git a/src/components/UserList.tsx b/src/components/UserList.tsx index ed361938..a1631791 100644 --- a/src/components/UserList.tsx +++ b/src/components/UserList.tsx @@ -5,6 +5,7 @@ import UserListItems from './UserListItems' import UserModalForm from './UserModalForm' import useAuth from './useAuth' import { useUserApi } from '../api/User' +import ErrorView from '../views/ErrorView' const UserList: FC = () => { const { token } = useAuth() @@ -22,8 +23,7 @@ const UserList: FC = () => { } if (error || data === undefined) { - //TODO: Generic Error View - return Error occured + return Unable to fetch users from server. } const users = data.data.users diff --git a/src/views/ErrorView.tsx b/src/views/ErrorView.tsx new file mode 100644 index 00000000..ac15341b --- /dev/null +++ b/src/views/ErrorView.tsx @@ -0,0 +1,23 @@ +import React, { FC } from 'react' +import { Icon, Message } from 'semantic-ui-react' + +interface Props { + children: React.ReactNode +} + +const ErrorView: FC = ({ children }) => { + return ( + + + + Oh no! An error occured + {children} + + Please try again later or contact your administrator. + + + + ) +} + +export default ErrorView diff --git a/src/views/HomeView.tsx b/src/views/HomeView.tsx index b39cd381..4904f6dd 100644 --- a/src/views/HomeView.tsx +++ b/src/views/HomeView.tsx @@ -14,6 +14,7 @@ import { useQuery } from 'react-query' import Ticker from '../components/Ticker' import TickerModalForm from '../components/TickerModalForm' import Layout from './Layout' +import ErrorView from './ErrorView' const HomeView: FC = () => { const { token, user } = useAuth() @@ -31,8 +32,11 @@ const HomeView: FC = () => { } if (error || data === undefined) { - //TODO: Generic Error View - return Error occured + return ( + + Unable to fetch tickers from server. + + ) } const tickers = data.data.tickers diff --git a/src/views/TickerView.tsx b/src/views/TickerView.tsx index 761ff5f4..f477f527 100644 --- a/src/views/TickerView.tsx +++ b/src/views/TickerView.tsx @@ -6,6 +6,7 @@ import { useParams } from 'react-router-dom' import useAuth from '../components/useAuth' import Ticker from '../components/Ticker' import Layout from './Layout' +import ErrorView from './ErrorView' interface TickerViewParams { tickerId: string @@ -28,8 +29,7 @@ const TickerView: FC = () => { } if (error || data === undefined) { - //TODO: Generic Error View - return Error occured + return Unable to fetch the ticker from server. } const ticker = data.data.ticker
{children}
+ Please try again later or contact your administrator. +