interface StatusBadgeProps {
  status: string
  type?: 'order' | 'metal' | 'money' | 'order_type'
  className?: string
}

export const StatusBadge = ({ status, type = 'order', className = '' }: StatusBadgeProps) => {
  const getBadgeConfig = () => {
    if (type === 'order') {
      switch (status) {
        case 'DRAFT':
          return {
            label: 'پیش‌نویس',
            bgColor: 'bg-slate-100',
            textColor: 'text-slate-700',
            borderColor: 'border-slate-300',
          }
        case 'CONFIRMED':
          return {
            label: 'تایید شده',
            bgColor: 'bg-blue-50',
            textColor: 'text-blue-700',
            borderColor: 'border-blue-300',
          }
        case 'LOCKED':
          return {
            label: 'قفل شده',
            bgColor: 'bg-emerald-50',
            textColor: 'text-emerald-700',
            borderColor: 'border-emerald-300',
          }
        default:
          return {
            label: status,
            bgColor: 'bg-gray-100',
            textColor: 'text-gray-700',
            borderColor: 'border-gray-300',
          }
      }
    }

    if (type === 'metal') {
      switch (status) {
        case 'BALANCED':
          return {
            label: 'متوازن',
            bgColor: 'bg-green-50',
            textColor: 'text-green-700',
            borderColor: 'border-green-300',
          }
        case 'UNBALANCED':
          return {
            label: 'نامتوازن',
            bgColor: 'bg-orange-50',
            textColor: 'text-orange-700',
            borderColor: 'border-orange-300',
          }
        default:
          return {
            label: status,
            bgColor: 'bg-gray-100',
            textColor: 'text-gray-700',
            borderColor: 'border-gray-300',
          }
      }
    }

    if (type === 'money') {
      switch (status) {
        case 'SETTLED':
          return {
            label: 'تسویه شده',
            bgColor: 'bg-green-50',
            textColor: 'text-green-700',
            borderColor: 'border-green-300',
          }
        case 'PARTIALLY_SETTLED':
          return {
            label: 'نیمه تسویه',
            bgColor: 'bg-yellow-50',
            textColor: 'text-yellow-700',
            borderColor: 'border-yellow-300',
          }
        case 'UNSETTLED':
          return {
            label: 'تسویه نشده',
            bgColor: 'bg-red-50',
            textColor: 'text-red-700',
            borderColor: 'border-red-300',
          }
        default:
          return {
            label: status,
            bgColor: 'bg-gray-100',
            textColor: 'text-gray-700',
            borderColor: 'border-gray-300',
          }
      }
    }

    if (type === 'order_type') {
      switch (status) {
        case 'BUY':
          return {
            label: 'خرید نقره از مشتری',
            bgColor: 'bg-blue-50',
            textColor: 'text-blue-700',
            borderColor: 'border-blue-300',
          }
        case 'SELL':
          return {
            label: 'فروش نقره به مشتری',
            bgColor: 'bg-purple-50',
            textColor: 'text-purple-700',
            borderColor: 'border-purple-300',
          }
        default:
          return {
            label: status,
            bgColor: 'bg-gray-100',
            textColor: 'text-gray-700',
            borderColor: 'border-gray-300',
          }
      }
    }

    return {
      label: status,
      bgColor: 'bg-gray-100',
      textColor: 'text-gray-700',
      borderColor: 'border-gray-300',
    }
  }

  const config = getBadgeConfig()

  return (
    <span
      className={`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium border ${config.bgColor} ${config.textColor} ${config.borderColor} ${className}`}
    >
      {config.label}
    </span>
  )
}

