diff --git a/apps/builder/pages/api/typebots/[typebotId].ts b/apps/builder/pages/api/typebots/[typebotId].ts index b4aceb2af8d..d4b227785c8 100644 --- a/apps/builder/pages/api/typebots/[typebotId].ts +++ b/apps/builder/pages/api/typebots/[typebotId].ts @@ -42,6 +42,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { } if (req.method === 'PUT') { const data = typeof req.body === 'string' ? JSON.parse(req.body) : req.body + const existingTypebot = await prisma.typebot.findFirst({ + where: canReadTypebot(typebotId, user), + }) + if ( + existingTypebot && + existingTypebot?.updatedAt > new Date(data.updatedAt) + ) + return res.send({ message: 'Found newer version of typebot in database' }) const typebots = await prisma.typebot.updateMany({ where: canWriteTypebot(typebotId, user), data: {