import type { ReactNode } from "react";

import { Badge } from "@/components/ui/badge";
import {
  adminStatusBadgeClassName,
  resolveAdminStatusTone,
  type AdminStatusTone,
} from "@/lib/admin-status-tone";
import { cn } from "@/lib/utils";

type AdminStatusBadgeProps = {
  children: ReactNode;
  /** 用于自动解析色调；也可仅用 `tone` 显式指定 */
  status?: string | number | boolean | null;
  tone?: AdminStatusTone;
  className?: string;
};

export function AdminStatusBadge({
  children,
  status,
  tone,
  className,
}: AdminStatusBadgeProps) {
  const resolvedTone = tone ?? resolveAdminStatusTone(status);

  return (
    <Badge
      variant="outline"
      className={cn(
        "font-medium whitespace-nowrap",
        adminStatusBadgeClassName(resolvedTone),
        className,
      )}
    >
      {children}
    </Badge>
  );
}
