import { AI_PRIORITY_LABEL, type AiPriority } from "@/lib/constants";
import { cn } from "@/lib/utils";

const TONE: Record<string, string> = {
  pursue: "bg-success/15 text-success",
  watch: "bg-warning/15 text-warning",
  skip: "bg-muted text-muted-foreground",
};

export function PriorityBadge({
  priority,
  importance,
}: {
  priority?: string | null;
  importance?: number | null;
}) {
  if (!priority) {
    return <span className="text-xs text-muted-foreground">Unscored</span>;
  }
  return (
    <span
      className={cn(
        "inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium uppercase tracking-wide",
        TONE[priority] ?? TONE.skip,
      )}
    >
      {AI_PRIORITY_LABEL[priority as AiPriority] ?? priority}
      {importance != null ? <span className="tabular font-normal">{importance}</span> : null}
    </span>
  );
}
