'use client'

import * as React from 'react'

export interface StageBadgeConfig {
  label: string
  className: string
}

export interface StageBadgeProps {
  stage: string
  configMap: Record<string, StageBadgeConfig>
  className?: string
}

const DEFAULT_CONFIG: StageBadgeConfig = {
  label: '',
  className: 'bg-gray-100 text-gray-700 border-gray-200',
}

export function StageBadge({ stage, configMap, className = '' }: StageBadgeProps) {
  const config = configMap[stage] ?? { ...DEFAULT_CONFIG, label: stage }

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