тут нихуя не работает, ебаный рот этого казино

This commit is contained in:
User
2025-01-08 15:14:15 +03:00
parent 847102e843
commit 8c4c3f2e38
56 changed files with 1448 additions and 267 deletions

View File

@@ -1,25 +1,49 @@
"use client"
import { useCart } from "@/contexts/cart-context"
import { useAuth } from "@/contexts/auth-context"
import { Button } from "./ui/button"
import { useRouter } from "next/navigation"
export function CartSummary() {
const { items, getTotalItems } = useCart()
const { isLoggedIn } = useAuth()
const router = useRouter()
const totalPrice = items.reduce((sum, item) => sum + item.price * item.quantity, 0)
const handleCheckout = () => {
if (!isLoggedIn) {
router.push('/login')
} else {
router.push('/checkout')
}
}
if (getTotalItems() === 0) {
return (
<div className="bg-white p-4 rounded-lg">
<h2 className="text-lg font-semibold mb-4">Ваша корзина</h2>
<p className="text-gray-500">В вашей корзине пока нет товаров</p>
</div>
)
}
return (
<div className="bg-white p-4 rounded-lg">
<h2 className="text-lg font-semibold mb-4">Ваша корзина</h2>
<div className="space-y-2 mb-4">
<div className="flex justify-between">
<span>Товары (2)</span>
<span>10 236 </span>
</div>
<div className="flex justify-between text-green-600">
<span>Скидка</span>
<span>- 4 387 </span>
<span>Товары ({getTotalItems()})</span>
<span>{totalPrice} </span>
</div>
</div>
<div className="flex justify-between text-lg font-bold mb-4">
<span>С Ozon Картой</span>
<span>5 467 </span>
<span>Итого</span>
<span>{totalPrice} </span>
</div>
<Button className="w-full" size="lg">
Перейти к оформлению
<Button className="w-full" size="lg" onClick={handleCheckout}>
{isLoggedIn ? "Перейти к оформлению" : "Войти для оформления"}
</Button>
</div>
)