test commit

This commit is contained in:
Kirill
2026-05-21 12:02:29 +05:00
parent ae6f86041a
commit 1837b36b14
10 changed files with 113 additions and 45 deletions
+2 -2
View File
@@ -29,7 +29,7 @@ export async function registerUserCartRoutes(fastify) {
const product = await prisma.product.findFirst({ where: { id: productId, published: true } })
if (!product) return reply.code(404).send({ error: 'Товар не найден' })
const available = product.inStock ? product.quantity : 1
const available = product.quantity
const existing = await prisma.cartItem.findUnique({ where: { userId_productId: { userId, productId } } })
const nextQty = (existing?.qty ?? 0) + Math.floor(qty)
if (nextQty > available) return reply.code(409).send({ error: `Доступно: ${available} шт.` })
@@ -57,7 +57,7 @@ export async function registerUserCartRoutes(fastify) {
return reply.code(204).send()
}
const available = existing.product.inStock ? existing.product.quantity : 1
const available = existing.product.quantity
const nextQty = Math.floor(qty)
if (nextQty > available) return reply.code(409).send({ error: `Доступно: ${available} шт.` })