Download src/components/ui/error-fallback.tsx from felix-fx/fx-1: direct link, hf CLI and curl.
- Browser
- Download file 3.25 kB
-
https://huggingface.co/felix-fx/fx-1/resolve/main/src/components/ui/error-fallback.tsx
- Command line
-
hf download hf://felix-fx/fx-1/src/components/ui/error-fallback.tsx
-
curl -L -o error-fallback.tsx https://huggingface.co/felix-fx/fx-1/resolve/main/src/components/ui/error-fallback.tsx
3.25 kB
| import { Button } from "./button"; | |
| import { Card, CardContent, CardHeader, CardTitle } from "./card"; | |
| import { Badge } from "./badge"; | |
| import { AlertTriangle, RefreshCw, Home, Bug } from "lucide-react"; | |
| interface ErrorFallbackProps { | |
| error?: Error; | |
| resetErrorBoundary?: () => void; | |
| title?: string; | |
| description?: string; | |
| } | |
| export const ErrorFallback = ({ | |
| error, | |
| resetErrorBoundary, | |
| title = "حدث خطأ غير متوقع", | |
| description = "نعتذر عن هذا الخطأ. يرجى المحاولة مرة أخرى." | |
| }: ErrorFallbackProps) => { | |
| const handleReload = () => { | |
| window.location.reload(); | |
| }; | |
| const handleGoHome = () => { | |
| window.location.href = '/'; | |
| }; | |
| return ( | |
| <div className="min-h-screen flex items-center justify-center p-4"> | |
| <Card className="max-w-md w-full card-elegant border-destructive/20"> | |
| <CardHeader className="text-center pb-4"> | |
| <div className="flex justify-center mb-4"> | |
| <div className="p-4 bg-destructive/10 rounded-full"> | |
| <AlertTriangle className="w-12 h-12 text-destructive animate-pulse" /> | |
| </div> | |
| </div> | |
| <Badge variant="destructive" className="mx-auto mb-3"> | |
| <Bug className="w-3 h-3 mr-1" /> | |
| خطأ في النظام | |
| </Badge> | |
| <CardTitle className="text-xl text-foreground">{title}</CardTitle> | |
| </CardHeader> | |
| <CardContent className="text-center space-y-4"> | |
| <p className="text-muted-foreground leading-relaxed"> | |
| {description} | |
| </p> | |
| {error && ( | |
| <details className="text-left"> | |
| <summary className="cursor-pointer text-xs text-muted-foreground hover:text-foreground"> | |
| تفاصيل الخطأ التقنية | |
| </summary> | |
| <pre className="text-xs mt-2 p-2 bg-secondary/20 rounded text-destructive overflow-auto max-h-32"> | |
| {error.message} | |
| </pre> | |
| </details> | |
| )} | |
| <div className="flex flex-col gap-3 pt-4"> | |
| {resetErrorBoundary && ( | |
| <Button | |
| onClick={resetErrorBoundary} | |
| variant="default" | |
| className="w-full" | |
| > | |
| <RefreshCw className="w-4 h-4 mr-2" /> | |
| المحاولة مرة أخرى | |
| </Button> | |
| )} | |
| <Button | |
| onClick={handleReload} | |
| variant="outline" | |
| className="w-full" | |
| > | |
| <RefreshCw className="w-4 h-4 mr-2" /> | |
| إعادة تحميل الصفحة | |
| </Button> | |
| <Button | |
| onClick={handleGoHome} | |
| variant="ghost" | |
| className="w-full" | |
| > | |
| <Home className="w-4 h-4 mr-2" /> | |
| العودة للرئيسية | |
| </Button> | |
| </div> | |
| <p className="text-xs text-muted-foreground pt-2"> | |
| إذا استمر الخطأ، يرجى التواصل مع الدعم الفني | |
| </p> | |
| </CardContent> | |
| </Card> | |
| </div> | |
| ); | |
| }; |