'use client';

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

export function QuotationStatusBadge({ code, label }: { code?: string | null; label: string }) {
  const normalized = code?.toLowerCase() ?? '';
  const variant =
    normalized === 'approved' || normalized === 'accepted' || normalized === 'won'
      ? 'default'
      : normalized === 'draft' || normalized === 'new'
        ? 'secondary'
        : normalized === 'rejected' || normalized === 'lost'
          ? 'destructive'
          : 'outline';
  const Icon =
    normalized === 'approved' || normalized === 'accepted' || normalized === 'won'
      ? Icons.circleCheck
      : normalized === 'rejected' || normalized === 'lost'
        ? Icons.warning
        : Icons.circle;

  return (
    <Badge variant={variant} className='capitalize'>
      <Icon className='h-3 w-3' />
      {label}
    </Badge>
  );
}
