2025-06-24 00:04:36 -07:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-01-07 23:09:58 -08:00
|
|
|
import { useNavigate, useRouteError } from 'react-router';
|
2025-05-18 14:03:18 -07:00
|
|
|
|
2023-04-30 22:05:06 -07:00
|
|
|
import { AppMenu } from '/@/renderer/features/titlebar/components/app-menu';
|
2023-01-07 23:09:58 -08:00
|
|
|
import { AppRoute } from '/@/renderer/router/routes';
|
2025-06-24 00:04:36 -07:00
|
|
|
import { ActionIcon } from '/@/shared/components/action-icon/action-icon';
|
|
|
|
|
import { Button } from '/@/shared/components/button/button';
|
|
|
|
|
import { Center } from '/@/shared/components/center/center';
|
|
|
|
|
import { Divider } from '/@/shared/components/divider/divider';
|
|
|
|
|
import { DropdownMenu } from '/@/shared/components/dropdown-menu/dropdown-menu';
|
|
|
|
|
import { Group } from '/@/shared/components/group/group';
|
|
|
|
|
import { Icon } from '/@/shared/components/icon/icon';
|
|
|
|
|
import { Stack } from '/@/shared/components/stack/stack';
|
|
|
|
|
import { Text } from '/@/shared/components/text/text';
|
2023-01-07 23:09:58 -08:00
|
|
|
|
|
|
|
|
const RouteErrorBoundary = () => {
|
2025-06-24 00:04:36 -07:00
|
|
|
const { t } = useTranslation();
|
2023-07-01 19:10:05 -07:00
|
|
|
const navigate = useNavigate();
|
|
|
|
|
const error = useRouteError() as any;
|
2025-06-26 21:17:59 -07:00
|
|
|
console.error('error', error);
|
2023-01-07 23:09:58 -08:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
const handleReload = () => {
|
|
|
|
|
navigate(0);
|
|
|
|
|
};
|
2023-01-07 23:09:58 -08:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
const handleReturn = () => {
|
|
|
|
|
navigate(-1);
|
|
|
|
|
};
|
2023-01-07 23:09:58 -08:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
const handleHome = () => {
|
|
|
|
|
navigate(AppRoute.HOME);
|
|
|
|
|
};
|
2023-01-07 23:09:58 -08:00
|
|
|
|
2023-07-01 19:10:05 -07:00
|
|
|
return (
|
2025-06-24 00:04:36 -07:00
|
|
|
<div style={{ backgroundColor: 'var(--theme-colors-background)' }}>
|
|
|
|
|
<Center style={{ height: '100vh' }}>
|
|
|
|
|
<Stack style={{ maxWidth: '50%' }}>
|
2023-07-01 19:10:05 -07:00
|
|
|
<Group>
|
2025-06-24 00:04:36 -07:00
|
|
|
<ActionIcon
|
|
|
|
|
icon="arrowLeftS"
|
2025-05-18 14:03:18 -07:00
|
|
|
onClick={handleReturn}
|
2023-07-01 19:10:05 -07:00
|
|
|
px={10}
|
|
|
|
|
variant="subtle"
|
|
|
|
|
/>
|
2025-07-12 11:17:54 -07:00
|
|
|
<Icon fill="error" icon="error" size="lg" />
|
2025-06-24 00:04:36 -07:00
|
|
|
<Text size="lg">{t('error.genericError')}</Text>
|
2023-07-01 19:10:05 -07:00
|
|
|
</Group>
|
|
|
|
|
<Divider my={5} />
|
|
|
|
|
<Text size="sm">{error?.message}</Text>
|
2025-07-12 11:17:54 -07:00
|
|
|
<Group gap="sm" grow>
|
2023-07-01 19:10:05 -07:00
|
|
|
<Button
|
2025-06-24 00:04:36 -07:00
|
|
|
leftSection={<Icon icon="home" />}
|
2025-05-18 14:03:18 -07:00
|
|
|
onClick={handleHome}
|
2023-07-01 19:10:05 -07:00
|
|
|
size="md"
|
2025-06-24 00:04:36 -07:00
|
|
|
style={{ flex: 0.5 }}
|
2023-07-01 19:10:05 -07:00
|
|
|
variant="default"
|
|
|
|
|
>
|
2025-06-24 00:04:36 -07:00
|
|
|
{t('page.home.title')}
|
2023-07-01 19:10:05 -07:00
|
|
|
</Button>
|
|
|
|
|
<DropdownMenu position="bottom-start">
|
|
|
|
|
<DropdownMenu.Target>
|
|
|
|
|
<Button
|
2025-06-24 00:04:36 -07:00
|
|
|
leftSection={<Icon icon="menu" />}
|
2023-07-01 19:10:05 -07:00
|
|
|
size="md"
|
2025-06-24 00:04:36 -07:00
|
|
|
style={{ flex: 0.5 }}
|
2023-07-01 19:10:05 -07:00
|
|
|
variant="default"
|
|
|
|
|
>
|
2025-06-24 00:04:36 -07:00
|
|
|
{t('common.menu')}
|
2023-07-01 19:10:05 -07:00
|
|
|
</Button>
|
|
|
|
|
</DropdownMenu.Target>
|
|
|
|
|
<DropdownMenu.Dropdown>
|
|
|
|
|
<AppMenu />
|
|
|
|
|
</DropdownMenu.Dropdown>
|
|
|
|
|
</DropdownMenu>
|
|
|
|
|
</Group>
|
|
|
|
|
<Group grow>
|
2025-07-12 11:17:54 -07:00
|
|
|
<Button onClick={handleReload} size="md" variant="filled">
|
2025-06-24 00:04:36 -07:00
|
|
|
{t('common.reload')}
|
2023-07-01 19:10:05 -07:00
|
|
|
</Button>
|
|
|
|
|
</Group>
|
|
|
|
|
</Stack>
|
|
|
|
|
</Center>
|
2025-06-24 00:04:36 -07:00
|
|
|
</div>
|
2023-07-01 19:10:05 -07:00
|
|
|
);
|
2023-01-07 23:09:58 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default RouteErrorBoundary;
|