add conditional (#20057)
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user