Bamboe pen
€ 4,20
Beschrijving
Schrijf op een duurzame en stijlvolle manier met onze bamboe balpen! Deze pen combineert het natuurlijke gevoel van bamboe met elegante zilveren accenten voor een verfijnde uitstraling. Ideaal voor op kantoor, thuis of als een milieuvriendelijk geschenk. De bamboe constructie zorgt niet alleen voor een unieke textuur maar draagt ook bij aan de vermindering van plastic gebruik. Geef je schrijfervaring een natuurlijke touch met deze prachtige balpen.
import { useState } from "react";
import { Card, CardContent } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
export default function Cart() {
const [cartItems, setCartItems] = useState([
{ id: 1, name: "Produkt A", price: 100, quantity: 1 },
{ id: 2, name: "Produkt B", price: 200, quantity: 1 },
]);
const discountThresholds = [
{ minQuantity: 5, discount: 0.1 }, // 10% rabatu powyżej 5 sztuk
{ minQuantity: 10, discount: 0.2 }, // 20% rabatu powyżej 10 sztuk
];
const totalQuantity = cartItems.reduce((sum, item) => sum + item.quantity, 0);
const applicableDiscount = discountThresholds
.filter((t) => totalQuantity >= t.minQuantity)
.reduce((max, curr) => (curr.discount > max ? curr.discount : max), 0);
const subtotal = cartItems.reduce((sum, item) => sum + item.price * item.quantity, 0);
const discountAmount = subtotal * applicableDiscount;
const total = subtotal - discountAmount;
const updateQuantity = (id, delta) => {
setCartItems((prevItems) =>
prevItems.map((item) =>
item.id === id ? { ...item, quantity: Math.max(1, item.quantity + delta) } : item
)
);
};
return (
{cartItems.map((item) => (
);
}
Koszyk
{item.name}
))}
{item.quantity}
{(item.price * item.quantity).toFixed(2)} zł
Łączna ilość: {totalQuantity}
Rabat: {applicableDiscount * 100}%
Kwota rabatu: {discountAmount.toFixed(2)} zł
Razem: {total.toFixed(2)} zł