2025-01-30 12:55:51 +03:00
|
|
|
|
import { useNavigate, useRouteError } from 'react-router';
|
2024-06-07 20:17:03 +03:00
|
|
|
|
|
2025-02-10 01:32:16 +03:00
|
|
|
|
import { Button } from '@/components/Control';
|
|
|
|
|
import { InfoError } from '@/components/InfoError';
|
2024-06-07 20:17:03 +03:00
|
|
|
|
|
2025-02-10 01:32:16 +03:00
|
|
|
|
export function ErrorFallback() {
|
2025-01-30 12:55:51 +03:00
|
|
|
|
const error = useRouteError();
|
|
|
|
|
const router = useNavigate();
|
|
|
|
|
|
|
|
|
|
function resetErrorBoundary() {
|
2025-02-20 14:45:12 +03:00
|
|
|
|
Promise.resolve(router('/')).catch(console.error);
|
2025-01-30 12:55:51 +03:00
|
|
|
|
}
|
2024-06-07 20:17:03 +03:00
|
|
|
|
return (
|
2025-01-29 14:51:34 +03:00
|
|
|
|
<div className='flex flex-col gap-3 my-3 items-center antialiased' role='alert'>
|
|
|
|
|
<h1 className='my-2'>Что-то пошло не так!</h1>
|
2025-01-30 12:55:51 +03:00
|
|
|
|
<Button onClick={resetErrorBoundary} text='Вернуться на главную' />
|
2024-06-07 20:17:03 +03:00
|
|
|
|
<InfoError error={error as Error} />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|