🧐 Add redeemCoupon script
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
"inspectTypebot": "tsx inspectTypebot.ts",
|
"inspectTypebot": "tsx inspectTypebot.ts",
|
||||||
"inspectWorkspace": "tsx inspectWorkspace.ts",
|
"inspectWorkspace": "tsx inspectWorkspace.ts",
|
||||||
"getCoupon": "tsx getCoupon.ts",
|
"getCoupon": "tsx getCoupon.ts",
|
||||||
|
"redeemCoupon": "tsx redeemCoupon.ts",
|
||||||
"exportResults": "tsx exportResults.ts",
|
"exportResults": "tsx exportResults.ts",
|
||||||
"updateUserEmail": "tsx updateUserEmail.ts",
|
"updateUserEmail": "tsx updateUserEmail.ts",
|
||||||
"inspectChatSession": "tsx inspectChatSession.ts"
|
"inspectChatSession": "tsx inspectChatSession.ts"
|
||||||
|
|||||||
28
packages/scripts/redeemCoupon.ts
Normal file
28
packages/scripts/redeemCoupon.ts
Normal 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()
|
||||||
Reference in New Issue
Block a user