import React, { createContext, useState } from 'react'; export const CartContext = createContext(); export const CartProvider = ({ children }) => { const [cart, setCart] = useState([]); const addToCart = (product) => { setCart([...cart, product]); }; const updateQuantity = (productId, quantity) => { setCart(cart.map(item => item.id === productId ? { ...item, quantity } : item)); }; return ( {children} ); };