diff --git a/src/app/cart/page.tsx b/src/app/cart/page.tsx new file mode 100644 index 0000000..63d1da7 --- /dev/null +++ b/src/app/cart/page.tsx @@ -0,0 +1,162 @@ +'use client'; + +import { useState } from 'react'; +import { ThemeProvider } from '@/components/theme-provider'; +import NavbarStyleFullscreen from '@/components/navbar/NavbarStyleFullscreen/NavbarStyleFullscreen'; +import ButtonHoverBubble from '@/components/button/ButtonHoverBubble'; +import { Trash2, Plus, Minus } from 'lucide-react'; + +const navItems = [ + { name: 'Home', id: '/' }, + { name: 'Shop', id: '/shop' }, + { name: 'Cart', id: '/cart' }, + { name: 'Checkout', id: '/checkout' }, +]; + +interface CartItem { + id: string; + name: string; + price: number; + quantity: number; + image: string; +} + +export default function CartPage() { + const [cartItems, setCartItems] = useState([ + { id: '1', name: 'Premium Headphones', price: 199.99, quantity: 1, image: '/product1.jpg' }, + { id: '2', name: 'Wireless Mouse', price: 49.99, quantity: 2, image: '/product2.jpg' }, + ]); + + const updateQuantity = (id: string, newQuantity: number) => { + if (newQuantity <= 0) { + removeItem(id); + return; + } + setCartItems(cartItems.map(item => + item.id === id ? { ...item, quantity: newQuantity } : item + )); + }; + + const removeItem = (id: string) => { + setCartItems(cartItems.filter(item => item.id !== id)); + }; + + const subtotal = cartItems.reduce((sum, item) => sum + item.price * item.quantity, 0); + const tax = subtotal * 0.1; + const total = subtotal + tax; + + return ( + + +
+
+

Shopping Cart

+ +
+ {/* Cart Items */} +
+ {cartItems.length === 0 ? ( +
+

Your cart is empty

+ +
+ ) : ( +
+ {cartItems.map(item => ( +
+ {/* Product Image */} +
+ + {/* Product Details */} +
+

{item.name}

+

${item.price.toFixed(2)}

+ + {/* Quantity Controls */} +
+ + updateQuantity(item.id, parseInt(e.target.value))} + className="w-12 text-center border rounded px-2 py-1" + min="1" + /> + +
+
+ + {/* Price and Remove */} +
+

${(item.price * item.quantity).toFixed(2)}

+ +
+
+ ))} +
+ )} +
+ + {/* Order Summary */} + {cartItems.length > 0 && ( +
+
+

Order Summary

+
+
+ Subtotal + ${subtotal.toFixed(2)} +
+
+ Tax (10%) + ${tax.toFixed(2)} +
+
+ Total + ${total.toFixed(2)} +
+
+ +
+
+ )} +
+
+
+
+ ); +}