import { type ComponentProps } from 'react'
import { Tag } from '../../components'

type Variant =
  | 'Stable'
  | 'Internal'
  | 'In Development'
  | 'Legacy'
  | 'Deprecated'

export type LifecycleTagProps = {
  variant: Variant
}

const variantConfig: Record<
  Variant,
  { variant: ComponentProps<typeof Tag>['variant']; text: string }
> = {
  Stable: { variant: 'success', text: 'Stable' },
  Internal: { variant: 'default', text: 'Internal' },
  'In Development': { variant: 'progress', text: 'In Development' },
  Legacy: { variant: 'muted', text: 'Legacy' },
  Deprecated: { variant: 'urgent', text: 'Deprecated' },
}

export const LifecycleTag = ({ variant }: LifecycleTagProps) => {
  const config = variantConfig[variant]

  if (!config) {
    return null
  }

  return (
    <Tag variant={config.variant} hideIcon>
      {config.text}
    </Tag>
  )
}
