fix promo codes
This commit is contained in:
parent
de0987a007
commit
ccd4126953
1 changed files with 1 additions and 2 deletions
|
|
@ -65,8 +65,7 @@ export const POST: RequestHandler = async ({ request }) => {
|
||||||
const [{ totalUses }] = await tx
|
const [{ totalUses }] = await tx
|
||||||
.select({ totalUses: count() })
|
.select({ totalUses: count() })
|
||||||
.from(promoCodeRedemption)
|
.from(promoCodeRedemption)
|
||||||
.where(eq(promoCodeRedemption.promoCodeId, promoData.id))
|
.where(eq(promoCodeRedemption.promoCodeId, promoData.id));
|
||||||
.for('update');
|
|
||||||
|
|
||||||
if (totalUses >= promoData.maxUses) {
|
if (totalUses >= promoData.maxUses) {
|
||||||
return json({ error: 'This promo code has reached its usage limit' }, { status: 400 });
|
return json({ error: 'This promo code has reached its usage limit' }, { status: 400 });
|
||||||
|
|
|
||||||
Reference in a new issue