Skip to content

Commit

Permalink
馃 Add redeemCoupon script
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 8, 2024
1 parent 396ca5b commit 5d38b44
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"inspectTypebot": "tsx inspectTypebot.ts",
"inspectWorkspace": "tsx inspectWorkspace.ts",
"getCoupon": "tsx getCoupon.ts",
"redeemCoupon": "tsx redeemCoupon.ts",
"exportResults": "tsx exportResults.ts",
"updateUserEmail": "tsx updateUserEmail.ts",
"inspectChatSession": "tsx inspectChatSession.ts"
Expand Down
28 changes: 28 additions & 0 deletions packages/scripts/redeemCoupon.ts
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 5d38b44

Please sign in to comment.