import { useState } from "react";
import { FaSmile, FaLaugh, FaStar, FaCog } from "react-icons/fa";
export default function StickerStore() {
const [cart, setCart] = useState([]);
const [email, setEmail] = useState("");
const [user, setUser] = useState(null);
const products = [
{ id: 1, name: "Sticker 1", price: 3.99, colorClass: "bg-orange-200" },
{ id: 2, name: "Sticker 2", price: 4.99, colorClass: "bg-blue-200" },
{ id: 3, name: "Sticker 3", price: 2.99, colorClass: "bg-green-200" },
{ id: 4, name: "Sticker 4", price: 5.49, colorClass: "bg-purple-200" }
];
const categories = [
{ name: "Cute", icon: },
{ name: "Funny", icon: },
{ name: "Holographic", icon: },
{ name: "Custom", icon: }
];
function addToCart(product) {
setCart((prev) => {
const idx = prev.findIndex((p) => p.id === product.id);
if (idx === -1) return [...prev, { ...product, qty: 1 }];
const copy = [...prev];
copy[idx] = { ...copy[idx], qty: copy[idx].qty + 1 };
return copy;
});
}
function removeFromCart(index) {
setCart((prev) => prev.filter((_, i) => i !== index));
}
function updateQty(index, qty) {
setCart((prev) => {
const copy = [...prev];
if (qty <= 0) {
copy.splice(index, 1);
} else {
copy[index] = { ...copy[index], qty };
}
return copy;
});
}
function cartItemCount() {
return cart.reduce((s, p) => s + (p.qty || 0), 0);
}
function cartTotal() {
return cart.reduce((s, p) => s + (p.qty || 0) * p.price, 0).toFixed(2);
}
function handleSubscribe() {
if (!email) return;
alert(`Subscribed with ${email}`);
setEmail("");
}
function handleLogin() {
setUser({ name: "Guest User" });
}
function handleLogout() {
setUser(null);
}
function handleCheckout() {
if (cart.length === 0) return alert("Your cart is empty");
alert(`Checking out ${cartItemCount()} item(s). Total: $${cartTotal()}`);
setCart([]);
}
return (
New Season, Fresh Stickers β¨
Discover our latest collection of fun and creative designs.
Shop by Category
{categories.map((cat) => (
))}
Best Sellers
{products.map((product, idx) => (
{product.name}
${product.price.toFixed(2)}
))}
{cart.length > 0 && (
Your Cart
{cart.map((item, idx) => (
-
{item.name}
${item.price.toFixed(2)} each
))}
Total: ${cartTotal()}
)}
Create Your Own Sticker
Upload your design, pick a size and finish, and make it yours.
What Our Customers Say
{[1, 2, 3].map((t) => (
βAbsolutely love these stickers! Great quality and super cute designs.β
β
β
β
β
β
- Happy Customer
))}
);
}