Files
OllaHub/components/chat/error-display.tsx
T

65 lines
1.9 KiB
TypeScript

'use client';
import { AlertCircle, RefreshCw, X } from 'lucide-react';
import { cn } from '@/lib/utils';
import { Button } from '@/components/ui/button';
interface ErrorDisplayProps {
error: string | Error;
onRetry?: () => void;
onDismiss?: () => void;
className?: string;
}
export function ErrorDisplay({ error, onRetry, onDismiss, className }: ErrorDisplayProps) {
const errorMessage = error instanceof Error ? error.message : String(error);
return (
<div
className={cn(
"mx-4 mb-3 px-4 py-3 rounded-lg border border-destructive/40 bg-destructive/10",
className
)}
>
<div className="flex items-start gap-3">
<AlertCircle className="w-5 h-5 text-destructive flex-shrink-0" />
<div className="flex-1 min-w-0">
<div className="text-sm font-medium text-destructive mb-1">
Erro ao processar
</div>
<p className="text-sm text-foreground break-words">
{errorMessage}
</p>
{(onRetry || onDismiss) && (
<div className="flex items-center gap-2 mt-3">
{onRetry && (
<Button
size="sm"
variant="outline"
onClick={onRetry}
className="h-8 text-xs"
>
<RefreshCw className="w-3 h-3" />
Tentar novamente
</Button>
)}
{onDismiss && (
<Button
size="sm"
variant="ghost"
onClick={onDismiss}
className="h-8 text-xs text-muted-foreground hover:text-foreground"
>
<X className="w-3 h-3" />
Fechar
</Button>
)}
</div>
)}
</div>
</div>
</div>
);
}