import Image from "next/image";
import Link from "next/link";

interface PackagingProductCardProps {
  img: string;
  title: string;
  weights: number[];
  href: string;
}

export function PackagingProductCard({
  img,
  title,
  weights,
  href,
}: PackagingProductCardProps) {
  return (
    <div className="w-full">
      <div className="rounded-t-xl overflow-hidden">
        <Image
          src={img}
          alt={title}
          width={300}
          height={400}
          className="w-full h-auto object-cover"
        />
      </div>
      <div className="flex flex-col shadow-sm items-center pt-8 pb-6 gap-6 bg-white border border-t-0 border-gray-100 rounded-b-xl">
        <div className="flex justify-center">
          {weights.map((weight, index) => (
            <span className="flex items-center" key={index}>
              <p className="font-bold text-lg inline text-gray-800">
                {weight + "kg"}
              </p>
              {index < weights.length - 1 && (
                <span className="mx-0.5 font-bold text-lg"> | </span>
              )}
            </span>
          ))}
        </div>
        <Link
          href={href}
          className="text-sm block w-fit px-8 py-3 font-semibold rounded-md bg-primary text-white cursor-pointer transition duration-300 hover:bg-accent"
        >
          {title}
        </Link>
      </div>
    </div>
  );
}
