import { Badge } from '@/components/base/badges/badges';
import type { LeadSource } from '@/types/entities';

type SourceColor = 'blue' | 'pink' | 'success' | 'blue-light' | 'gray' | 'purple' | 'orange' | 'warning';

const sourceColorMap: Record<LeadSource, SourceColor> = {
    FACEBOOK_AD: 'blue',
    INSTAGRAM: 'pink',
    GOOGLE_AD: 'success',
    GOOGLE_MY_BUSINESS: 'blue-light',
    WHATSAPP: 'success',
    WEBSITE: 'gray',
    REFERRAL: 'purple',
    WALK_IN: 'orange',
    PHONE: 'warning',
    OTHER: 'gray',
};

const sourceLabelMap: Record<LeadSource, string> = {
    FACEBOOK_AD: 'Facebook',
    INSTAGRAM: 'Instagram',
    GOOGLE_AD: 'Google',
    GOOGLE_MY_BUSINESS: 'GMB',
    WHATSAPP: 'WhatsApp',
    WEBSITE: 'Website',
    REFERRAL: 'Referral',
    WALK_IN: 'Walk-in',
    PHONE: 'Phone',
    OTHER: 'Other',
};

interface SourceTagProps {
    source: LeadSource;
    size?: 'sm' | 'md';
}

export const SourceTag = ({ source, size = 'sm' }: SourceTagProps) => {
    const color = sourceColorMap[source];
    const label = sourceLabelMap[source];
    return (
        <Badge size={size} type="pill-color" color={color}>
            {label}
        </Badge>
    );
};
