2
0
Files
bot/packages/scripts/getCoupon.ts
2024-01-08 13:47:23 +01:00

31 lines
633 B
TypeScript

import { PrismaClient } from '@typebot.io/prisma'
import { promptAndSetEnvironment } from './utils'
import * as p from '@clack/prompts'
const getCoupon = async () => {
await promptAndSetEnvironment('production')
const val = (await p.text({
message: 'Enter coupon code',
})) as string
const prisma = new PrismaClient({
log: [{ emit: 'event', level: 'query' }, 'info', 'warn', 'error'],
})
const coupon = await prisma.coupon.findFirst({
where: {
code: val,
},
})
if (!coupon) {
console.log('Coupon not found')
return
}
console.log(JSON.stringify(coupon, null, 2))
}
getCoupon()