import { useState } from "react"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; import { ShoppingCart, CheckCircle, Menu } from "lucide-react"; import { products, formatPrice } from "@shared/products"; import { useLocation } from "wouter"; export default function Shop() { const [, navigate] = useLocation(); const [showMobileMenu, setShowMobileMenu] = useState(false); const handleAddToCart = (productId: string) => { // Store cart in both localStorage (persistent) and sessionStorage (immediate) let cartItems = []; // Try localStorage first (persistent across sessions) const storedCart = localStorage.getItem("cart"); if (storedCart) { try { cartItems = JSON.parse(storedCart); } catch (e) { console.error('Failed to parse localStorage cart:', e); } } const existing = cartItems.find((item: any) => item.productId === productId); if (existing) { existing.quantity += 1; } else { cartItems.push({ productId, quantity: 1 }); } // Save to both storages for redundancy localStorage.setItem("cart", JSON.stringify(cartItems)); sessionStorage.setItem("pendingCartItems", JSON.stringify(cartItems)); // Navigate to checkout navigate("/checkout"); }; return (
Kies het perfecte pakket voor jouw bedrijf
{product.description}