import React from "react";
import { LucideIcon, AlertCircle } from "lucide-react";
export interface MetricCardProps {
title: string;
value: number | string;
icon: LucideIcon;
iconColor: string;
iconBgColor: string;
description: string;
loading?: boolean;
error?: boolean;
emptyAction?: {
label: string;
onClick: () => void;
};
ariaLabel?: string;
}
const MetricCardSkeleton: React.FC = () => (
);
const MetricCardError: React.FC<{ title: string; onRetry?: () => void }> = ({
title,
onRetry,
}) => (
{title}
Erro ao carregar
{onRetry && (
)}
);
const MetricCardEmpty: React.FC<{
title: string;
icon: LucideIcon;
iconColor: string;
iconBgColor: string;
emptyAction: { label: string; onClick: () => void };
}> = ({ title, icon: Icon, iconColor, iconBgColor, emptyAction }) => (
{title}
0
);
export const MetricCard: React.FC = ({
title,
value,
icon: Icon,
iconColor,
iconBgColor,
description,
loading = false,
error = false,
emptyAction,
ariaLabel,
}) => {
if (loading) {
return ;
}
if (error) {
return ;
}
const numericValue =
typeof value === "number" ? value : parseInt(String(value), 10) || 0;
if (numericValue === 0 && emptyAction) {
return (
);
}
return (
);
};
export default MetricCard;