diff --git a/frontend/src/atoms/settings.ts b/frontend/src/atoms/settings.ts index abdcc22..c46c8d1 100644 --- a/frontend/src/atoms/settings.ts +++ b/frontend/src/atoms/settings.ts @@ -42,7 +42,7 @@ export interface SettingsState { export const languageState = atom({ key: 'languageState', - default: localStorage.getItem('language') as Language ?? 'english', + default: localStorage.getItem('language') as Language || 'english', effects: [ ({ onSet }) => onSet(l => localStorage.setItem('language', l.toString())) @@ -51,7 +51,7 @@ export const languageState = atom({ export const themeState = atom({ key: 'themeStateState', - default: localStorage.getItem('theme') as Theme ?? 'system', + default: localStorage.getItem('theme') as Theme || 'light', effects: [ ({ onSet }) => onSet(l => localStorage.setItem('theme', l.toString())) @@ -60,7 +60,7 @@ export const themeState = atom({ export const serverAddressState = atom({ key: 'serverAddressState', - default: localStorage.getItem('server-addr') ?? window.location.hostname, + default: localStorage.getItem('server-addr') || window.location.hostname, effects: [ ({ onSet }) => onSet(a => localStorage.setItem('server-addr', a.toString())) @@ -69,7 +69,7 @@ export const serverAddressState = atom({ export const serverPortState = atom({ key: 'serverPortState', - default: Number(localStorage.getItem('server-port')) ?? + default: Number(localStorage.getItem('server-port')) || Number(window.location.port), effects: [ ({ onSet }) => @@ -79,7 +79,7 @@ export const serverPortState = atom({ export const latestCliArgumentsState = atom({ key: 'latestCliArgumentsState', - default: localStorage.getItem('cli-args') ?? '', + default: localStorage.getItem('cli-args') || '', effects: [ ({ onSet }) => onSet(a => localStorage.setItem('cli-args', a.toString())) diff --git a/frontend/src/components/ErrorBoundary.tsx b/frontend/src/components/ErrorBoundary.tsx new file mode 100644 index 0000000..1e91879 --- /dev/null +++ b/frontend/src/components/ErrorBoundary.tsx @@ -0,0 +1,46 @@ +import { Button, Container, SvgIcon, Typography, styled } from '@mui/material' +import { useI18n } from '../hooks/useI18n' +import ErrorIcon from '@mui/icons-material/Error' +import { Link } from 'react-router-dom' + +const FlexContainer = styled(Container)({ + display: 'flex', + minWidth: '100%', + minHeight: '80vh', + alignItems: 'center', + justifyContent: 'center', + flexDirection: 'column' +}) + +const Title = styled(Typography)({ + display: 'flex', + width: '100%', + alignItems: 'center', + justifyContent: 'center', + paddingBottom: '0.5rem' +}) + +const ErrorBoundary: React.FC = () => { + return ( + + + <SvgIcon sx={{ fontSize: '200px' }}> + <ErrorIcon /> + </SvgIcon> + + + An error occurred :\ + + + Check your settings! + + + + + + ) +} + +export default ErrorBoundary \ No newline at end of file diff --git a/frontend/src/router.tsx b/frontend/src/router.tsx index 17f9cd1..a7bed11 100644 --- a/frontend/src/router.tsx +++ b/frontend/src/router.tsx @@ -8,6 +8,8 @@ const Login = lazy(() => import('./views/Login')) const Archive = lazy(() => import('./views/Archive')) const Settings = lazy(() => import('./views/Settings')) +const ErrorBoundary = lazy(() => import('./components/ErrorBoundary')) + export const router = createBrowserRouter([ { path: '/', @@ -19,6 +21,11 @@ export const router = createBrowserRouter([ }> + ), + errorElement: ( + }> + + ) }, { @@ -35,6 +42,11 @@ export const router = createBrowserRouter([ }> + ), + errorElement: ( + }> + + ) }, {