2
0

refactor(♻️ Add defaults everywhere (+ settings page)):

This commit is contained in:
Baptiste Arnaud
2022-01-25 18:19:37 +01:00
parent 21448bcc8a
commit c5aaa323d1
115 changed files with 1436 additions and 720 deletions

View File

@ -4,9 +4,9 @@ import { methodNotAllowed } from 'utils'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (req.method === 'POST') {
const { typebotId } = JSON.parse(req.body)
const { typebotId } = JSON.parse(req.body) as { typebotId: string }
const result = await prisma.result.create({
data: { typebotId },
data: { typebotId, isCompleted: false },
})
return res.send(result)
}

View File

@ -1,10 +1,11 @@
import prisma from 'libs/prisma'
import { Result } from 'models'
import { NextApiRequest, NextApiResponse } from 'next'
import { methodNotAllowed } from 'utils'
const handler = async (req: NextApiRequest, res: NextApiResponse) => {
if (req.method === 'PATCH') {
const data = JSON.parse(req.body)
const data = JSON.parse(req.body) as Result
const id = req.query.id.toString()
const result = await prisma.result.update({
where: { id },