From d9ec897006f243f7ba629ea12087014ce2ff987c Mon Sep 17 00:00:00 2001 From: development Date: Mon, 29 Dec 2025 09:23:04 +0000 Subject: [PATCH] Update src/app/page.tsx --- src/app/page.tsx | 101 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 96 insertions(+), 5 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index fa89f58..33d194c 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,6 +1,7 @@ -"use client" +"use client"; import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider"; +import { useState } from "react"; import NavbarStyleCentered from '@/components/navbar/NavbarStyleCentered/NavbarStyleCentered'; import HeroBillboardGallery from '@/components/sections/hero/HeroBillboardGallery'; import ProductCardOne from '@/components/sections/product/ProductCardOne'; @@ -11,9 +12,51 @@ import TeamCardSix from '@/components/sections/team/TeamCardSix'; import TestimonialCardFive from '@/components/sections/testimonial/TestimonialCardFive'; import ContactCenterForm from '@/components/sections/contact/ContactCenterForm'; import FooterBaseCard from '@/components/sections/footer/FooterBaseCard'; -import { Sparkles, Star, Users } from "lucide-react"; +import { Sparkles, Star, Users, ShoppingCart, X } from "lucide-react"; + +interface CartItem { + id: string; + name: string; + price: string; + imageSrc: string; + imageAlt: string; + quantity: number; +} export default function LandingPage() { + const [cartItems, setCartItems] = useState([]); + const [showCart, setShowCart] = useState(false); + + const handleAddToCart = (productId: string, productName: string, productPrice: string, productImage: string, productAlt: string) => { + setCartItems(prevItems => { + const existingItem = prevItems.find(item => item.id === productId); + if (existingItem) { + return prevItems.map(item => + item.id === productId ? { ...item, quantity: item.quantity + 1 } : item + ); + } + return [...prevItems, { id: productId, name: productName, price: productPrice, imageSrc: productImage, imageAlt: productAlt, quantity: 1 }]; + }); + }; + + const handleRemoveFromCart = (productId: string) => { + setCartItems(prevItems => prevItems.filter(item => item.id !== productId)); + }; + + const handleUpdateQuantity = (productId: string, quantity: number) => { + if (quantity <= 0) { + handleRemoveFromCart(productId); + } else { + setCartItems(prevItems => + prevItems.map(item => + item.id === productId ? { ...item, quantity } : item + ) + ); + } + }; + + const totalItems = cartItems.reduce((sum, item) => sum + item.quantity, 0); + return ( + {/* Shopping Cart Modal */} + {showCart && ( +
+
+
+

Shopping Cart ({totalItems})

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

Your cart is empty

+ ) : ( +
+ {cartItems.map(item => ( +
+ {item.imageAlt} +
+

{item.name}

+

{item.price}

+
+ + {item.quantity} + + +
+
+
+ ))} +
+ )} +
+
+ +
+
+
+ )} + -- 2.49.1