2
0

🧐 Add redeemCoupon script

This commit is contained in:
Baptiste Arnaud
2024-02-08 10:27:22 +01:00
parent 396ca5bbdc
commit 5d38b4451a
2 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,28 @@
import { PrismaClient } from '@typebot.io/prisma'
import { promptAndSetEnvironment } from './utils'
import * as p from '@clack/prompts'
const redeemCoupon = async () => {
await promptAndSetEnvironment('production')
const prisma = new PrismaClient()
const code = await p.text({
message: 'Coupon code?',
})
if (!code || p.isCancel(code)) process.exit()
const coupon = await prisma.coupon.update({
where: {
code,
},
data: {
dateRedeemed: new Date(),
},
})
console.log(coupon)
}
redeemCoupon()