2025-01-30 12:56:06 +03:00
|
|
|
|
import { useNavigate, useRouteError } from 'react-router';
|
2023-07-25 20:27:29 +03:00
|
|
|
|
|
2025-03-12 11:55:43 +03:00
|
|
|
|
import { Button } from '@/components/control1';
|
|
|
|
|
import { InfoError } from '@/components/info-error';
|
2023-07-15 17:46:19 +03:00
|
|
|
|
|
2025-02-10 01:32:55 +03:00
|
|
|
|
export function ErrorFallback() {
|
2025-01-30 12:56:06 +03:00
|
|
|
|
const error = useRouteError();
|
|
|
|
|
const router = useNavigate();
|
|
|
|
|
|
|
|
|
|
function resetErrorBoundary() {
|
2025-02-20 14:45:52 +03:00
|
|
|
|
Promise.resolve(router('/')).catch(console.error);
|
2025-01-30 12:56:06 +03:00
|
|
|
|
}
|
2023-07-15 17:46:19 +03:00
|
|
|
|
return (
|
2025-01-29 14:52:07 +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:56:06 +03:00
|
|
|
|
<Button onClick={resetErrorBoundary} text='Вернуться на главную' />
|
2023-12-28 14:04:44 +03:00
|
|
|
|
<InfoError error={error as Error} />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2023-07-15 17:46:19 +03:00
|
|
|
|
}
|