2
0

🐛 Fix focus after selecting mark in text editor

This commit is contained in:
Baptiste Arnaud
2023-03-21 18:26:39 +01:00
parent a41c65f528
commit 02d25d0fc7
6 changed files with 456 additions and 270 deletions

View File

@@ -1,7 +1,11 @@
import { CollaborationType, WorkspaceRole } from '@typebot.io/prisma'
import prisma from '@/lib/prisma'
import { NextApiRequest, NextApiResponse } from 'next'
import { canReadTypebots, canWriteTypebots } from '@/helpers/databaseRules'
import {
canReadTypebots,
canWriteTypebots,
isUniqueConstraintError,
} from '@/helpers/databaseRules'
import {
badRequest,
forbidden,
@@ -41,13 +45,23 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
select: { id: true },
})
if (existingUser) {
await prisma.collaboratorsOnTypebots.create({
data: {
type,
typebotId,
userId: existingUser.id,
},
})
try {
await prisma.collaboratorsOnTypebots.create({
data: {
type,
typebotId,
userId: existingUser.id,
},
})
} catch (error) {
if (isUniqueConstraintError(error)) {
return res.status(400).send({
message: 'User already has access to this typebot.',
})
}
throw error
}
await prisma.memberInWorkspace.upsert({
where: {
userId_workspaceId: {