From 3ab047a48753783d173fa384543ffbbbbc84aa2a Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Mon, 12 Dec 2022 09:06:54 +0100 Subject: [PATCH] :zap: (dashboard) Improve folders and typebots get queries --- apps/builder/src/pages/api/folders.ts | 27 ++++++-------------------- apps/builder/src/pages/api/typebots.ts | 3 +-- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/apps/builder/src/pages/api/folders.ts b/apps/builder/src/pages/api/folders.ts index 1140ee17bf..2ac1f1039a 100644 --- a/apps/builder/src/pages/api/folders.ts +++ b/apps/builder/src/pages/api/folders.ts @@ -24,29 +24,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { workspaceId: workspaceId, }, { - OR: [ - { - workspace: { - members: { - some: { - userId: user.id, - role: { not: WorkspaceRole.GUEST }, - }, - }, + workspace: { + members: { + some: { + userId: user.id, + role: { not: WorkspaceRole.GUEST }, }, }, - { - typebots: { - some: { - collaborators: { - some: { - userId: user.id, - }, - }, - }, - }, - }, - ], + }, }, ], }, diff --git a/apps/builder/src/pages/api/typebots.ts b/apps/builder/src/pages/api/typebots.ts index 26faf9cad6..f3b593630a 100644 --- a/apps/builder/src/pages/api/typebots.ts +++ b/apps/builder/src/pages/api/typebots.ts @@ -1,5 +1,5 @@ import { withSentry } from '@sentry/nextjs' -import { Plan, Prisma, WorkspaceRole } from 'db' +import { Plan, WorkspaceRole } from 'db' import prisma from '@/lib/prisma' import { NextApiRequest, NextApiResponse } from 'next' import { @@ -73,7 +73,6 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => { some: { userId: user.id, role: WorkspaceRole.GUEST }, }, }, - collaborators: { some: { userId: user.id } }, }, ], },