feat(mui): migrate ErrorBoundary off admin-* CSS

Class component lifecycle (getDerivedStateFromError, componentDidCatch,
console.error, state shape) preserved verbatim. Only the fallback render
is re-skinned: Box+Typography for layout/text, kit Button for the reload
action. Czech strings unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-06-07 08:37:19 +02:00
parent 85d7ffaa14
commit 67f98c1f66

View File

@@ -1,4 +1,7 @@
import { Component, type ReactNode, type ErrorInfo } from "react";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import { Button } from "../ui";
interface Props {
children: ReactNode;
@@ -22,19 +25,25 @@ export default class ErrorBoundary extends Component<Props, State> {
render() {
if (this.state.hasError) {
return (
<div
className="admin-empty-state"
style={{ minHeight: "60vh", justifyContent: "center" }}
<Box
sx={{
minHeight: "60vh",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
gap: 2,
textAlign: "center",
}}
>
<h2>Něco se pokazilo</h2>
<p>{this.state.error?.message}</p>
<button
className="admin-btn admin-btn-primary"
onClick={() => window.location.reload()}
>
<Typography variant="h5">Něco se pokazilo</Typography>
<Typography variant="body2" color="text.secondary">
{this.state.error?.message}
</Typography>
<Button onClick={() => window.location.reload()}>
Obnovit stránku
</button>
</div>
</Button>
</Box>
);
}
return this.props.children;