"use client"; import { useCartStore } from "@/store/cart-store"; import { X, Minus, Plus, Trash2, ArrowRight } from "lucide-react"; import { useEffect, useState } from "react"; import Image from "next/image"; import { getProductImageUrl } from "@/lib/supabase"; import { cn } from "@/lib/utils"; export default function CartDrawer() { const { items, isOpen, closeCart, removeItem, updateQuantity, getTotalPrice } = useCartStore(); const [mounted, setMounted] = useState(false); // Evitar problemas de hidratación (SSR vs Client) useEffect(() => { setMounted(true); }, []); if (!mounted) return null; return ( <> {/* Overlay Oscuro (Backdrop) */}
{/* Panel Deslizante */}
{/* Header */}

Tu Pedido ({items.length})

{/* Lista de Items */}
{items.length === 0 ? (
🥑

Tu cesta está vacía.

) : (
{items.map((item) => (
{/* Imagen Miniatura */}
{item.name}
{/* Info */}

{item.name}

{item.category}

{/* Control Cantidad Mini */}
{item.quantity}
{new Intl.NumberFormat('es-ES', { style: 'currency', currency: 'EUR' }).format(item.price * item.quantity)}
))}
)}
{/* Footer / Checkout */} {items.length > 0 && (
Subtotal {new Intl.NumberFormat('es-ES', { style: 'currency', currency: 'EUR' }).format(getTotalPrice())}

Envío calculado en el siguiente paso

)}
); }