fix: Team view for root team
This commit is contained in:
parent
f2061c5c25
commit
4d47eab07c
@ -4,14 +4,14 @@ import { ErrorHandler } from '$lib/database';
|
|||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
|
||||||
export const get: RequestHandler = async (event) => {
|
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 };
|
if (status === 401) return { status, body };
|
||||||
|
|
||||||
const { id } = event.params;
|
const { id } = event.params;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const user = await db.prisma.user.findFirst({
|
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 }
|
include: { permission: true }
|
||||||
});
|
});
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
@ -4,14 +4,15 @@ import { ErrorHandler } from '$lib/database';
|
|||||||
import type { RequestHandler } from '@sveltejs/kit';
|
import type { RequestHandler } from '@sveltejs/kit';
|
||||||
|
|
||||||
export const get: RequestHandler = async (event) => {
|
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 };
|
if (status === 401) return { status, body };
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const teams = await db.prisma.permission.findMany({
|
const teams = await db.prisma.permission.findMany({
|
||||||
where: { userId },
|
where: { userId: teamId === '0' ? undefined : teamId },
|
||||||
include: { team: { include: { _count: { select: { users: true } } } } }
|
include: { team: { include: { _count: { select: { users: true } } } } }
|
||||||
});
|
});
|
||||||
|
|
||||||
const invitations = await db.prisma.teamInvitation.findMany({ where: { uid: userId } });
|
const invitations = await db.prisma.teamInvitation.findMany({ where: { uid: userId } });
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 200,
|
||||||
|
Loading…
Reference in New Issue
Block a user