Files
calendar/packages/trpc/server/routers/viewer/teams/hasTeamPlan.handler.ts
T
7f23ae156b fix: improved team upgrade screen to also show unpublished teams (#12492)
* improved team upgrade screen to also show unpublished teams

* Update TeamsListing.tsx

* bunch of stuff

---------

Co-authored-by: Omar López <zomars@me.com>
2023-11-29 14:48:26 -07:00

28 lines
570 B
TypeScript

import { prisma } from "@calcom/prisma";
import type { TrpcSessionUser } from "@calcom/trpc/server/trpc";
type HasTeamPlanOptions = {
ctx: {
user: NonNullable<TrpcSessionUser>;
};
};
export const hasTeamPlanHandler = async ({ ctx }: HasTeamPlanOptions) => {
const userId = ctx.user.id;
const hasTeamPlan = await prisma.membership.findFirst({
where: {
accepted: true,
userId,
team: {
slug: {
not: null,
},
},
},
});
return { hasTeamPlan: !!hasTeamPlan };
};
export default hasTeamPlanHandler;