import { AddToCartButton } from "@/components/cart/add-to-cart-button";
import { Badge } from "@/components/ui/badge";
import { ButtonLink } from "@/components/ui/button-link";

type Props = {
  productId: string;
  isOwned: boolean;
  hasActivePlan: boolean;
};

export function PlanCardActions({ productId, isOwned, hasActivePlan }: Props) {
  if (isOwned) {
    return (
      <div className="flex flex-wrap items-center gap-3">
        <Badge className="rounded-full bg-emerald-500/15 px-4 py-1.5 text-sm font-medium text-emerald-600 dark:text-emerald-400">
          Current plan
        </Badge>
        <ButtonLink href="/dashboard/plans" variant="outline" className="rounded-full px-6">
          Manage plan
        </ButtonLink>
      </div>
    );
  }

  if (hasActivePlan) {
    return <AddToCartButton productId={productId} label="Upgrade plan" />;
  }

  return <AddToCartButton productId={productId} />;
}
