first commit

This commit is contained in:
mega 2026-03-19 11:32:17 +00:00
commit 4b98219bf7
144 changed files with 31561 additions and 0 deletions

View file

@ -0,0 +1,47 @@
"use client";
import React from "react";
import { ErrorCard } from "@/components/ui/error-card";
interface Props {
children: React.ReactNode;
fallback?: React.ReactNode;
}
interface State {
hasError: boolean;
message: string;
}
export class ErrorBoundary extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = { hasError: false, message: "" };
}
static getDerivedStateFromError(error: Error): State {
return { hasError: true, message: error.message };
}
componentDidCatch(error: Error, info: React.ErrorInfo) {
console.error("[ErrorBoundary]", error, info);
}
handleRetry = () => {
this.setState({ hasError: false, message: "" });
};
render() {
if (this.state.hasError) {
return (
this.props.fallback ?? (
<ErrorCard
message={this.state.message || "An unexpected error occurred."}
onRetry={this.handleRetry}
/>
)
);
}
return this.props.children;
}
}