'use client'

import { cn } from '@/lib/utils'
import type { HTTPMethod } from '@/lib/api-docs/types'

interface MethodBadgeProps {
  method: HTTPMethod
  size?: 'sm' | 'md' | 'lg'
  className?: string
}

const methodColors: Record<HTTPMethod, string> = {
  GET: 'bg-emerald-500/90 text-white',
  POST: 'bg-blue-500/90 text-white',
  PUT: 'bg-amber-500/90 text-white',
  DELETE: 'bg-red-500/90 text-white',
  PATCH: 'bg-violet-500/90 text-white',
  HEAD: 'bg-slate-500/90 text-white',
  OPTIONS: 'bg-slate-500/90 text-white',
}

const sizeClasses = {
  sm: 'px-1.5 py-0.5 text-[10px]',
  md: 'px-2 py-0.5 text-xs',
  lg: 'px-2.5 py-1 text-sm',
}

export function MethodBadge({ method, size = 'md', className = '' }: MethodBadgeProps) {
  return (
    <span
      className={cn(
        'font-semibold rounded uppercase tracking-wide',
        methodColors[method],
        sizeClasses[size],
        className
      )}
    >
      {method}
    </span>
  )
}
