add conditional (#20057)

This commit is contained in:
sean-brydon
2025-03-13 15:58:19 +00:00
committed by GitHub
parent 0e5a0bfa7b
commit a6b6898697
@@ -85,6 +85,19 @@ export const chargeCardHandler = async ({ ctx, input }: ChargeCardHandlerOptions
? { teamId: booking.eventType.teamId }
: { userId: ctx.user.id };
if (booking.eventType?.teamId) {
const userIsInTeam = await prisma.membership.findFirst({
where: {
userId: ctx.user.id,
teamId: booking.eventType?.teamId,
},
});
if (!userIsInTeam) {
throw new TRPCError({ code: "UNAUTHORIZED", message: "User is not in team" });
}
}
const paymentCredential = await prisma.credential.findFirst({
where: {
...idToSearchObject,