2022-02-15 08:43:11 +01:00
|
|
|
import { withSentry } from '@sentry/nextjs'
|
2021-12-29 10:22:26 +01:00
|
|
|
import prisma from 'libs/prisma'
|
|
|
|
import { NextApiRequest, NextApiResponse } from 'next'
|
|
|
|
import { methodNotAllowed } from 'utils'
|
|
|
|
|
|
|
|
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
|
|
|
if (req.method === 'POST') {
|
2022-01-25 18:19:37 +01:00
|
|
|
const { typebotId } = JSON.parse(req.body) as { typebotId: string }
|
2021-12-29 10:22:26 +01:00
|
|
|
const result = await prisma.result.create({
|
2022-01-25 18:19:37 +01:00
|
|
|
data: { typebotId, isCompleted: false },
|
2021-12-29 10:22:26 +01:00
|
|
|
})
|
|
|
|
return res.send(result)
|
|
|
|
}
|
|
|
|
return methodNotAllowed(res)
|
|
|
|
}
|
|
|
|
|
2022-02-15 08:43:11 +01:00
|
|
|
export default withSentry(handler)
|