diff --git a/src/app/cart/page.tsx b/src/app/cart/page.tsx new file mode 100644 index 0000000..62f7444 --- /dev/null +++ b/src/app/cart/page.tsx @@ -0,0 +1,70 @@ +'use client' +import { useRouter } from 'next/navigation' +import Link from 'next/link' +import Image from 'next/image' +import { useVulaCart } from '@/hooks/useVulaCart' +import { ArrowRight, Minus, Plus, ShoppingBag, Trash2 } from 'lucide-react' + +function fmt(amount: number) { return `R${(amount / 100).toFixed(2)}` } + +export default function CartPage() { + const { items, subtotal, itemCount, updateQty, removeFromCart } = useVulaCart() + const router = useRouter() + + if (!itemCount) return ( + + + Your cart is empty + + Continue Shopping + + + ) + + return ( + + + Your Cart ({itemCount} item{itemCount !== 1 ? 's' : ''}) + + + {items.map(item => ( + + {item.thumbnail && ( + + + + )} + + {item.title} + {item.variant_title !== 'Default' && {item.variant_title}} + {fmt(item.unit_price)} + + + removeFromCart(item.variantId)} className="text-muted-foreground hover:text-destructive transition-colors"> + + + + updateQty(item.variantId, item.quantity - 1)} className="p-1.5 hover:bg-muted transition-colors"> + {item.quantity} + updateQty(item.variantId, item.quantity + 1)} className="p-1.5 hover:bg-muted transition-colors"> + + {fmt(item.unit_price * item.quantity)} + + + ))} + + + Order Summary + Subtotal{fmt(subtotal)} + DeliveryCalculated at checkout + Total{fmt(subtotal)} + router.push('/checkout')} className="w-full bg-primary text-primary-foreground py-3 rounded-lg font-medium hover:opacity-90 transition-opacity flex items-center justify-center gap-2"> + Proceed to Checkout + + Continue Shopping + + + + + ) +}
{item.title}
{item.variant_title}
{fmt(item.unit_price)}
{fmt(item.unit_price * item.quantity)}