'use client'

import { LicenseType, LICENSE_TYPE_LABELS } from '@/lib/sdk/types'

export default function LicenseBadge({
  licenseId,
  small = false,
}: {
  licenseId: LicenseType | null
  small?: boolean
}) {
  if (!licenseId) return null
  const colors: Partial<Record<LicenseType, string>> = {
    public_domain: 'bg-green-100 text-green-700 border-green-200',
    cc0: 'bg-green-100 text-green-700 border-green-200',
    unlicense: 'bg-green-100 text-green-700 border-green-200',
    mit: 'bg-blue-100 text-blue-700 border-blue-200',
    cc_by_4: 'bg-purple-100 text-purple-700 border-purple-200',
    reuse_notice: 'bg-orange-100 text-orange-700 border-orange-200',
  }
  return (
    <span className={`${small ? 'px-1.5 py-0.5 text-[10px]' : 'px-2 py-1 text-xs'} rounded border ${colors[licenseId] || 'bg-gray-100 text-gray-600 border-gray-200'}`}>
      {LICENSE_TYPE_LABELS[licenseId] || licenseId}
    </span>
  )
}
