'use client'; import { XMarkIcon } from '@heroicons/react/24/outline'; import { CartItem } from 'lib/woocomerce/models/cart'; import { useCart } from './cart-context'; export function DeleteItemButton({ item }: { item: CartItem }) { const { setNewCart } = useCart(); return (
{ try { const cart = await ( await fetch('/api/cart', { method: 'DELETE', body: JSON.stringify({ key: item.key }) }) ).json(); setNewCart(cart); } catch (error) { console.error(error); } }} >
); }