{product.name}
${product.price}
import { useState } from 'react'; import { ShoppingCart, X, Plus, Minus } from 'lucide-react'; export default function DropshippingStore() { const [cartOpen, setCartOpen] = useState(false); const [cart, setCart] = useState([]); const products = [ { id: 1, name: "Premium Wireless Earbuds", price: 79.99, image: "https://placehold.co/300x300/e2e8f0/475569?text=Wireless+Earbuds" }, { id: 2, name: "Smart Watch Pro", price: 129.99, image: "https://placehold.co/300x300/e2e8f0/475569?text=Smart+Watch" }, { id: 3, name: "Phone Stand & Charger", price: 39.99, image: "https://placehold.co/300x300/e2e8f0/475569?text=Phone+Stand" }, { id: 4, name: "Portable Power Bank", price: 49.99, image: "https://placehold.co/300x300/e2e8f0/475569?text=Power+Bank" } ]; const addToCart = (product) => { const existingItem = cart.find(item => item.id === product.id); if (existingItem) { setCart(cart.map(item => item.id === product.id ? { ...item, quantity: item.quantity + 1 } : item )); } else { setCart([...cart, { ...product, quantity: 1 }]); } }; const removeFromCart = (productId) => { setCart(cart.filter(item => item.id !== productId)); }; const updateQuantity = (productId, change) => { setCart(cart.map(item => { if (item.id === productId) { const newQuantity = item.quantity + change; return newQuantity > 0 ? { ...item, quantity: newQuantity } : item; } return item; })); }; const total = cart.reduce((sum, item) => sum + (item.price * item.quantity), 0); return (
${product.price}
Your cart is empty
) : ( cart.map(item => (${item.price}