import React from 'react' import Link from 'next/link' import useCart from '~/hooks/useCart' import styles from './style.module.css' import axios from 'axios' export default function Card({item}) { const [cart, setCart] = useCart() const numInCart = cart?.items?.find(i => i.item.uuid === item.uuid)?.count || 0 let featuredImage = item.images.find(i=>i.featured) || item.images[0] const addToCart = async ev => { if(ev) ev.preventDefault() const {data: newCart} = await axios.post(`/api/cart/add/${item.uuid}`, {count: 1}) setCart(newCart) } return (
) }