import { Badge } from '@/components/ui/badge';

type StatusBadgeConfig = Record<string, { label: string; className: string }>;

type StatusBadgeProps = {
    status: string;
    config: StatusBadgeConfig;
    fallbackKey?: string;
};

export function StatusBadge({
    status,
    config,
    fallbackKey = 'pending',
}: StatusBadgeProps) {
    const resolved = config[status] ?? config[fallbackKey];

    if (!resolved) {
        return null;
    }

    return (
        <Badge variant="secondary" className={resolved.className}>
            {resolved.label}
        </Badge>
    );
}
