* init members page for platform * add missing icon * add members tab to sidebar * use data from useMe query instead of useSession * return user profiles since platform users are stored there * small refactor * fixup * remove unused logs from console * fixup * resolve merge conflicts * add missing tabs for members and billing * update schema * fixup * memoise selection options for org and platform * update onSubmit handler * resolve merge conflicts * add members tab * improve team billing view when user not subscribed * update members tab * add function to find if user is admin of team * update invite members handler to handle platform user as well --------- Co-authored-by: Morgan <33722304+ThyMinimalDev@users.noreply.github.com>
33 lines
713 B
TypeScript
33 lines
713 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;
|
|
const currentUserOrgId = ctx.user.organizationId ?? currentUser.profiles[0].organizationId;
|
|
|
|
if (!currentUserOrgId) throw new TRPCError({ code: "UNAUTHORIZED" });
|
|
|
|
const allOrgTeams = await prisma.team.findMany({
|
|
where: {
|
|
parentId: currentUserOrgId,
|
|
},
|
|
select: {
|
|
id: true,
|
|
name: true,
|
|
},
|
|
});
|
|
|
|
return allOrgTeams;
|
|
}
|
|
|
|
export default getTeamsHandler;
|