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