import { withSentry } from '@sentry/nextjs' import prisma from 'libs/prisma' import { NextApiRequest, NextApiResponse } from 'next' import { methodNotAllowed } from 'utils' const handler = async (req: NextApiRequest, res: NextApiResponse) => { if (req.method === 'PATCH') { const data = ( typeof req.body === 'string' ? JSON.parse(req.body) : req.body ) as { isCompleted: true } const id = req.query.id.toString() const result = await prisma.result.update({ where: { id }, data, }) return res.send(result) } return methodNotAllowed(res) } export default withSentry(handler)