From 4d47eab07c06096513f4e45fb06ec987c597557e Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 6 Apr 2022 22:34:56 +0200 Subject: [PATCH] fix: Team view for root team --- src/routes/teams/[id]/index.json.ts | 4 ++-- src/routes/teams/index.json.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/routes/teams/[id]/index.json.ts b/src/routes/teams/[id]/index.json.ts index 59536fd03..7a06d4ab7 100644 --- a/src/routes/teams/[id]/index.json.ts +++ b/src/routes/teams/[id]/index.json.ts @@ -4,14 +4,14 @@ import { ErrorHandler } from '$lib/database'; import type { RequestHandler } from '@sveltejs/kit'; export const get: RequestHandler = async (event) => { - const { userId, status, body } = await getUserDetails(event, false); + const { teamId, userId, status, body } = await getUserDetails(event, false); if (status === 401) return { status, body }; const { id } = event.params; try { const user = await db.prisma.user.findFirst({ - where: { id: userId, teams: { some: { id } } }, + where: { id: userId, teams: teamId === '0' ? undefined : { some: { id } } }, include: { permission: true } }); if (!user) { diff --git a/src/routes/teams/index.json.ts b/src/routes/teams/index.json.ts index cf8ff2583..702e20887 100644 --- a/src/routes/teams/index.json.ts +++ b/src/routes/teams/index.json.ts @@ -4,14 +4,15 @@ import { ErrorHandler } from '$lib/database'; import type { RequestHandler } from '@sveltejs/kit'; export const get: RequestHandler = async (event) => { - const { userId, status, body } = await getUserDetails(event, false); + const { teamId, userId, status, body } = await getUserDetails(event, false); if (status === 401) return { status, body }; try { const teams = await db.prisma.permission.findMany({ - where: { userId }, + where: { userId: teamId === '0' ? undefined : teamId }, include: { team: { include: { _count: { select: { users: true } } } } } }); + const invitations = await db.prisma.teamInvitation.findMany({ where: { uid: userId } }); return { status: 200,