'use client'

import { Badge } from '@/components/ui/badge'
import { cn } from '@/lib/utils'
import { getStatusConfig, type OrderStatus } from '@/lib/constants/meal'

interface StatusBadgeProps {
  status: OrderStatus
  showIcon?: boolean
  className?: string
}

export function StatusBadge({ status, showIcon = true, className }: StatusBadgeProps) {
  const config = getStatusConfig(status)

  if (!config) {
    return <Badge variant="outline">{status}</Badge>
  }

  const Icon = config.icon

  return (
    <Badge
      variant="outline"
      className={cn(config.bgColor, config.textColor, config.borderColor, className)}
    >
      {showIcon && <Icon className="mr-1 h-3 w-3" />}
      {config.label}
    </Badge>
  )
}
