ADD TO CART
import React , { useEffect , useState } from 'react' ; import { useNavigate } from 'react-router-dom' ; const Cart = () => { const navigate = useNavigate (); const [ cartItems , setCartItems ] = useState ([]); useEffect (() => { getProducts (); }, []); function getProducts () { fetch ( 'http://localhost/Petshop/showcart.php' ) . then (( res ) => res . json ()) . then (( data ) => { // Ensure quantity is parsed as number const itemsWithId = data . map (( item , index ) => ({ ... item , id : index + 1 , quantity : parseInt ( item . quantity ) })); console . log ( itemsWithId ); setCartItems ( itemsWithId ); }) . catch (( error ) => { console . error ( 'Error fetching products:' , error ); }); } const increaseQuantity = ( id ) => { setCartItems ( prevCartItems => { return prevCartItems . map ( item =...