import React from 'react' import Link from 'next/link' import * as Icon from 'react-feather' import { useSelector, useDispatch } from 'react-redux' import { useToasts } from 'react-toast-notifications' import { useRouter } from 'next/router' import QtyForm from './QtyForm' const CartContent = () => { const router = useRouter() const { addToast } = useToasts() const dispatch = useDispatch() const cart = useSelector((state) => state.cart) const total = useSelector((state) => state.total) // console.log(cart) const removeItem = (pId) => { dispatch({ type: 'REMOVE_ITEM', id: pId }) addToast('Cart Removed Successfully', { appearance: 'error' }) } const reset = () => { dispatch({ type: 'RESET' }) addToast('Thanks for your order.', { appearance: 'success' }) router.push('/') } return ( <>
{cart.length ? cart.map(crt => ( )) : ( )}
Product Name Unit Price Quantity Total
item {crt.name} ${crt.price} ${(crt.quantity * crt.price).toFixed(2)} {removeItem(crt.id)}}>
Empty
Continue Shopping
Update Cart

Cart Totals

{ e.preventDefault(); reset() }} className="btn btn-primary">Proceed to Checkout
) } export default CartContent