"use client"; import { useState, MouseEvent } from "react"; import Link from "next/link"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { Heart, HeartOff, Minus, Plus } from "lucide-react"; import Image, { StaticImageData } from "next/image"; type ProductCardProps = { id: number; name: string; price: number | null; struct_price_text: string; discount?: number | null; discount_text?: string | null; images: (StaticImageData | string)[]; is_favorite: boolean; labels?: { text: string; bg_color: string }[]; price_color?: string; height?: number; width?: number; button?: boolean; }; export default function ProductCard({ id, name, price, struct_price_text, discount, discount_text, images, is_favorite, labels = [], price_color = "#005bff", height = 360, width = 280, button = true, }: ProductCardProps) { const [favorite, setFavorite] = useState(is_favorite); const [cart, setCart] = useState(false); const [count, setCount] = useState(1); const handleFavorite = (e: MouseEvent) => { e.preventDefault(); e.stopPropagation(); setFavorite((prev) => !prev); }; const handleAddToCart = (e: MouseEvent) => { e.preventDefault(); e.stopPropagation(); setCart(true); }; const handleIncrement = (e: MouseEvent) => { e.preventDefault(); e.stopPropagation(); setCount((c) => c + 1); }; const handleDecrement = (e: MouseEvent) => { e.preventDefault(); e.stopPropagation(); setCount((c) => (c > 1 ? c - 1 : c)); }; return ( {/* Image Section */}
{images?.[0] && ( {name} )} {/* Favorite Button */} {/* Labels */} {labels?.length > 0 && (
{labels.map((label) => ( {label.text} ))}
)}
{/* Content */}

{struct_price_text}

{name}

{/* Buttons */} {/* {button && (
{!cart ? ( ) : (
{count}
)}
)} */}
); }