import { Badge } from "@/components/ui/kit";
import type { SubscriptionStatus } from "@/lib/types";

const MAP: Record<SubscriptionStatus, { label: string; tone: "teal" | "amber" | "brick" | "neutral" }> = {
  trialing: { label: "Trial", tone: "amber" },
  active: { label: "Active", tone: "teal" },
  past_due: { label: "Payment due", tone: "amber" },
  suspended: { label: "Suspended", tone: "brick" },
  cancelled: { label: "Ended", tone: "neutral" },
};

export function SubscriptionBadge({ status }: { status: SubscriptionStatus }) {
  const m = MAP[status];
  return <Badge tone={m.tone}>{m.label}</Badge>;
}

export const PAYMENT_STATUS: Record<string, { label: string; tone: "teal" | "amber" | "brick" | "neutral" }> = {
  paid: { label: "Paid", tone: "teal" },
  failed: { label: "Failed", tone: "brick" },
  refunded: { label: "Refunded", tone: "neutral" },
  partially_refunded: { label: "Part refunded", tone: "amber" },
  created: { label: "Started", tone: "neutral" },
};

export const limitText = (v: number | null | undefined) => (v === null || v === undefined ? "Unlimited" : v.toLocaleString("en-IN"));
