"use client";

import { Button } from "@/components/ui/button";
import { toast } from "sonner";
import { useCartStore } from "@/store/cart-store";

export function AddToCartButton({
  productId,
  label = "Add to cart",
}: {
  productId: string;
  label?: string;
}) {
  const addItem = useCartStore((s) => s.addItem);

  return (
    <Button
      type="button"
      className="rounded-full px-8"
      onClick={() => {
        addItem(productId);
        toast.success("Added to cart");
      }}
    >
      {label}
    </Button>
  );
}
