Add logout to error fallback

This commit is contained in:
jeffvli
2022-11-20 17:01:52 -08:00
parent b0f031bedc
commit de1e6c16c0
@@ -1,14 +1,18 @@
import { Box, Center, Group, Stack } from '@mantine/core'; import { Box, Center, Group, Stack } from '@mantine/core';
import { FallbackProps } from 'react-error-boundary'; import { FallbackProps } from 'react-error-boundary';
import { RiErrorWarningLine } from 'react-icons/ri'; import { RiErrorWarningLine } from 'react-icons/ri';
import { Link } from 'react-router-dom';
import styled from 'styled-components'; import styled from 'styled-components';
import { Button, Text } from '@/renderer/components'; import { Button, Text } from '@/renderer/components';
import { useAuthStore } from '@/renderer/store';
const Container = styled(Box)` const Container = styled(Box)`
background: var(--main-bg); background: var(--main-bg);
`; `;
export const ErrorFallback = ({ error, resetErrorBoundary }: FallbackProps) => { export const ErrorFallback = ({ error, resetErrorBoundary }: FallbackProps) => {
const logout = useAuthStore((state) => state.logout);
return ( return (
<Container> <Container>
<Center sx={{ height: '100vh' }}> <Center sx={{ height: '100vh' }}>
@@ -21,6 +25,17 @@ export const ErrorFallback = ({ error, resetErrorBoundary }: FallbackProps) => {
<Button variant="filled" onClick={resetErrorBoundary}> <Button variant="filled" onClick={resetErrorBoundary}>
Reload Reload
</Button> </Button>
<Button
component={Link}
to="/"
variant="filled"
onClick={() => {
logout();
}}
>
Log out
</Button>
</Stack> </Stack>
</Center> </Center>
</Container> </Container>