mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-17 06:00:20 +02:00
Add logout to error fallback
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user