This commit is contained in:
David Nguyen
2025-01-31 18:57:45 +11:00
parent d7d0fca501
commit aec44b78d0
34 changed files with 2252 additions and 422 deletions

View File

@ -9,6 +9,8 @@ import {
} from '@documenso/prisma/generated/zod';
import { TeamMemberSchema } from '@documenso/prisma/generated/zod';
import { AppError, AppErrorCode } from '../../errors/app-error';
export type GetTeamByIdOptions = {
userId?: number;
teamId: number;
@ -74,6 +76,8 @@ export type GetTeamByUrlOptions = {
teamUrl: string;
};
export type TGetTeamByUrlResponse = Awaited<ReturnType<typeof getTeamByUrl>>;
/**
* Get a team given a team URL.
*/
@ -90,7 +94,7 @@ export const getTeamByUrl = async ({ userId, teamUrl }: GetTeamByUrlOptions) =>
};
}
const result = await prisma.team.findUniqueOrThrow({
const result = await prisma.team.findFirst({
where: whereFilter,
include: {
teamEmail: true,
@ -121,6 +125,10 @@ export const getTeamByUrl = async ({ userId, teamUrl }: GetTeamByUrlOptions) =>
},
});
if (!result) {
throw new AppError(AppErrorCode.NOT_FOUND);
}
const { members, ...team } = result;
return {