diff --git a/src/app/cart/page.tsx b/src/app/cart/page.tsx new file mode 100644 index 0000000..22d4ff5 --- /dev/null +++ b/src/app/cart/page.tsx @@ -0,0 +1,146 @@ +"use client"; + +import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider"; +import NavbarLayoutFloatingOverlay from "@/components/navbar/NavbarLayoutFloatingOverlay/NavbarLayoutFloatingOverlay"; +import { useState } from "react"; +import { ShoppingCart, Trash2, Minus, Plus } from "lucide-react"; +import Link from "next/link"; + +interface CartItem { + id: string; + name: string; + price: string; + quantity: number; + imageSrc: string; +} + +export default function CartPage() { + const [cartItems, setCartItems] = useState([ + { + id: "1", name: "Classic Rainbow Lollipops", price: "$12.99", quantity: 2, + imageSrc: "http://img.b2bpic.net/free-photo/valentines-day-postcard-with-red-lollipops-white-background_1268-31406.jpg"}, + ]); + + const handleQuantityChange = (id: string, newQuantity: number) => { + if (newQuantity < 1) return; + setCartItems(cartItems.map(item => + item.id === id ? { ...item, quantity: newQuantity } : item + )); + }; + + const handleRemove = (id: string) => { + setCartItems(cartItems.filter(item => item.id !== id)); + }; + + const calculateTotal = () => { + return cartItems.reduce((total, item) => { + const price = parseFloat(item.price.replace("$", "")); + return total + (price * item.quantity); + }, 0).toFixed(2); + }; + + return ( + + + +
+
+
+ +

Shopping Cart

+
+ + {cartItems.length === 0 ? ( +
+

Your cart is empty

+ + Continue Shopping + +
+ ) : ( + <> +
+ {cartItems.map((item) => ( +
+ {item.name} +
+

{item.name}

+

{item.price}

+
+ + {item.quantity} + +
+
+ +
+ ))} +
+ +
+
+ Total: + ${calculateTotal()} +
+ +
+ + )} +
+
+
+ ); +}