2
0

🪥 Consult submissions

This commit is contained in:
Baptiste Arnaud
2021-12-30 10:24:16 +01:00
parent f088f694b9
commit 1093453c07
25 changed files with 575 additions and 138 deletions

View File

@ -0,0 +1,25 @@
import { Answer } from 'db'
import prisma from 'libs/prisma'
import { NextApiRequest, NextApiResponse } from 'next'
import { methodNotAllowed } from 'utils'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (req.method === 'PUT') {
const answer = JSON.parse(req.body) as Answer
const result = await prisma.answer.upsert({
where: {
resultId_blockId_stepId: {
resultId: answer.resultId,
blockId: answer.blockId,
stepId: answer.stepId,
},
},
create: answer,
update: answer,
})
return res.send(result)
}
return methodNotAllowed(res)
}
export default handler