🐛 Remove delete result cascade
This commit is contained in:
committed by
Baptiste Arnaud
parent
30dff2d5d7
commit
3c803b1345
@ -38,6 +38,10 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const typebots = await prisma.typebot.deleteMany({
|
||||
where: canWriteTypebot(typebotId, user),
|
||||
})
|
||||
await prisma.result.updateMany({
|
||||
where: { typebot: canWriteTypebot(typebotId, user) },
|
||||
data: { isArchived: true },
|
||||
})
|
||||
return res.send({ typebots })
|
||||
}
|
||||
if (req.method === 'PUT') {
|
||||
|
@ -30,6 +30,17 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
members: { some: { userId: user.id, role: WorkspaceRole.ADMIN } },
|
||||
},
|
||||
})
|
||||
await prisma.result.updateMany({
|
||||
where: {
|
||||
typebot: {
|
||||
workspace: {
|
||||
id,
|
||||
members: { some: { userId: user.id, role: WorkspaceRole.ADMIN } },
|
||||
},
|
||||
},
|
||||
},
|
||||
data: { isArchived: true },
|
||||
})
|
||||
return res.status(200).json({
|
||||
message: 'success',
|
||||
})
|
||||
|
Reference in New Issue
Block a user