import React from "react";
import { cn } from "~/lib/utils";
import { AlertCircle, X, RefreshCw } from "lucide-react";
import { Button } from "./button";
interface ErrorAlertProps {
title?: string;
message: string;
variant?: "error" | "warning" | "info";
dismissible?: boolean;
onDismiss?: () => void;
onRetry?: () => void;
retryLabel?: string;
className?: string;
icon?: React.ReactNode;
actions?: React.ReactNode;
}
export function ErrorAlert({
title,
message,
variant = "error",
dismissible = false,
onDismiss,
onRetry,
retryLabel = "تلاش مجدد",
className,
icon,
actions,
}: ErrorAlertProps) {
const variants = {
error: {
container:
"bg-red-50 border-red-200 dark:bg-red-950/20 dark:border-red-800/30",
icon: "text-red-500 dark:text-red-400",
title: "text-red-800 dark:text-red-200",
message: "text-red-700 dark:text-red-300",
button:
"text-red-700 hover:text-red-800 dark:text-red-300 dark:hover:text-red-200",
},
warning: {
container:
"bg-yellow-50 border-yellow-200 dark:bg-yellow-950/20 dark:border-yellow-800/30",
icon: "text-yellow-500 dark:text-yellow-400",
title: "text-yellow-800 dark:text-yellow-200",
message: "text-yellow-700 dark:text-yellow-300",
button:
"text-yellow-700 hover:text-yellow-800 dark:text-yellow-300 dark:hover:text-yellow-200",
},
info: {
container:
"bg-blue-50 border-blue-200 dark:bg-blue-950/20 dark:border-blue-800/30",
icon: "text-blue-500 dark:text-blue-400",
title: "text-blue-800 dark:text-blue-200",
message: "text-blue-700 dark:text-blue-300",
button:
"text-blue-700 hover:text-blue-800 dark:text-blue-300 dark:hover:text-blue-200",
},
};
const variantStyles = variants[variant];
const defaultIcon =