"use client";

import { cn } from "@/lib/utils";
import {
  type QuarantineReason,
  reasonLabels,
  reasonColors,
  DEFAULT_REASON_COLOR,
} from "./constants";

interface ReasonBadgeProps {
  reason: string;
  className?: string;
}

export function ReasonBadge({ reason, className }: ReasonBadgeProps) {
  const normalizedReason = reason.toLowerCase().replace(/-/g, "_") as QuarantineReason;
  const label = reasonLabels[normalizedReason] ?? reason;
  const color = reasonColors[normalizedReason] ?? DEFAULT_REASON_COLOR;

  return (
    <span
      className={cn(
        "inline-flex items-center px-2 py-0.5 rounded text-xs font-medium uppercase tracking-wide",
        color,
        className
      )}
    >
      {label}
    </span>
  );
}
