diff --git a/src/app/cart/page.tsx b/src/app/cart/page.tsx new file mode 100644 index 0000000..97a316d --- /dev/null +++ b/src/app/cart/page.tsx @@ -0,0 +1,237 @@ +"use client"; + +import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider"; +import NavbarStyleCentered from '@/components/navbar/NavbarStyleCentered/NavbarStyleCentered'; +import FooterBaseCard from '@/components/sections/footer/FooterBaseCard'; +import { Mail, Trash2, Plus, Minus } from "lucide-react"; +import Link from "next/link"; +import { useState } from "react"; + +interface CartItem { + id: string; + name: string; + price: number; + quantity: number; + image: string; +} + +export default function CartPage() { + const [cartItems, setCartItems] = useState([ + { + id: "1", name: "Radiant Hydration Moisturizer", price: 58, + quantity: 1, + image: "http://img.b2bpic.net/free-vector/cosmetics-products-realistic-composition-poster_1284-18210.jpg" + }, + { + id: "2", name: "Luminous Glow Serum", price: 72, + quantity: 2, + image: "http://img.b2bpic.net/free-photo/front-view-argan-product-composition_23-2148955787.jpg" + } + ]); + + const updateQuantity = (id: string, newQuantity: number) => { + if (newQuantity <= 0) { + removeItem(id); + } else { + 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 shipping = subtotal > 100 ? 0 : 10; + const total = subtotal + tax + shipping; + + return ( + + + +
+
+
+

Shopping Cart

+

{cartItems.length} items in your cart

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

Your cart is empty

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

{item.name}

+

${item.price.toFixed(2)}

+
+ + updateQuantity(item.id, parseInt(e.target.value) || 1)} + className="w-12 text-center border border-background-accent rounded px-2 py-1" + min="1" + /> + +
+
+
+

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

+ +
+
+ ))} +
+
+ +
+
+

Order Summary

+
+
+ Subtotal + ${subtotal.toFixed(2)} +
+
+ Tax (10%) + ${tax.toFixed(2)} +
+
+ Shipping + {shipping === 0 ? "FREE" : `$${shipping.toFixed(2)}`} +
+
+
+ Total + ${total.toFixed(2)} +
+ + + Continue Shopping + + {shipping === 0 && subtotal > 0 && ( +

✓ Free shipping on orders over $100

+ )} +
+
+
+ )} +
+
+ + +
+ ); +} \ No newline at end of file