* fix: sticky action bar and align checkbox * feat: make teams filterable and clickable, total members * fix: update members count --------- Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
32 lines
639 B
TypeScript
32 lines
639 B
TypeScript
import { prisma } from "@calcom/prisma";
|
|
|
|
import { TRPCError } from "@trpc/server";
|
|
|
|
import type { TrpcSessionUser } from "../../../trpc";
|
|
|
|
type GetTeamsHandler = {
|
|
ctx: {
|
|
user: NonNullable<TrpcSessionUser>;
|
|
};
|
|
};
|
|
|
|
export async function getTeamsHandler({ ctx }: GetTeamsHandler) {
|
|
const currentUser = ctx.user;
|
|
|
|
if (!currentUser.organizationId) throw new TRPCError({ code: "UNAUTHORIZED" });
|
|
|
|
const allOrgTeams = await prisma.team.findMany({
|
|
where: {
|
|
parentId: currentUser.organizationId,
|
|
},
|
|
select: {
|
|
id: true,
|
|
name: true,
|
|
},
|
|
});
|
|
|
|
return allOrgTeams;
|
|
}
|
|
|
|
export default getTeamsHandler;
|