fix promo codes

This commit is contained in:
Face 2025-05-31 16:45:34 +03:00
parent de0987a007
commit ccd4126953

View file

@ -65,8 +65,7 @@ export const POST: RequestHandler = async ({ request }) => {
const [{ totalUses }] = await tx
.select({ totalUses: count() })
.from(promoCodeRedemption)
.where(eq(promoCodeRedemption.promoCodeId, promoData.id))
.for('update');
.where(eq(promoCodeRedemption.promoCodeId, promoData.id));
if (totalUses >= promoData.maxUses) {
return json({ error: 'This promo code has reached its usage limit' }, { status: 400 });