import type { ContractPhase } from "../../lib/api";

interface PhaseBadgeProps {
  phase: ContractPhase;
  size?: "sm" | "md";
}

const phaseConfig: Record<
  ContractPhase,
  { label: string; color: string; bgColor: string }
> = {
  research: {
    label: "Research",
    color: "text-purple-400",
    bgColor: "bg-purple-400/10 border-purple-400/30",
  },
  specify: {
    label: "Specify",
    color: "text-blue-400",
    bgColor: "bg-blue-400/10 border-blue-400/30",
  },
  plan: {
    label: "Plan",
    color: "text-cyan-400",
    bgColor: "bg-cyan-400/10 border-cyan-400/30",
  },
  execute: {
    label: "Execute",
    color: "text-yellow-400",
    bgColor: "bg-yellow-400/10 border-yellow-400/30",
  },
  review: {
    label: "Review",
    color: "text-green-400",
    bgColor: "bg-green-400/10 border-green-400/30",
  },
};

export function PhaseBadge({ phase, size = "sm" }: PhaseBadgeProps) {
  const config = phaseConfig[phase];
  const sizeClasses = size === "sm" ? "px-2 py-0.5 text-[10px]" : "px-3 py-1 text-xs";

  return (
    <span
      className={`${sizeClasses} ${config.color} ${config.bgColor} border font-mono uppercase tracking-wider`}
    >
      {config.label}
    </span>
  );
}

export function getPhaseLabel(phase: ContractPhase): string {
  return phaseConfig[phase].label;
}
