* fix trpc session circle dep * fixes trpc session cirlce dep * fix relative imports * fix more imports to use types and not trpc * fix exports * Fixed types --------- Co-authored-by: Keith Williams <keithwillcode@gmail.com>
36 lines
795 B
TypeScript
36 lines
795 B
TypeScript
import { prisma } from "@calcom/prisma";
|
|
|
|
import type { TrpcSessionUser } from "../../../types";
|
|
import type { TCheckIfMembershipExistsInputSchema } from "./checkIfMembershipExists.schema";
|
|
|
|
type CheckIfMembershipExistsOptions = {
|
|
ctx: {
|
|
user: NonNullable<TrpcSessionUser>;
|
|
};
|
|
input: TCheckIfMembershipExistsInputSchema;
|
|
};
|
|
|
|
const checkIfMembershipExistsHandler = async ({ ctx, input }: CheckIfMembershipExistsOptions) => {
|
|
const { teamId, value } = input;
|
|
|
|
const membership = await prisma.membership.findFirst({
|
|
where: {
|
|
teamId,
|
|
user: {
|
|
OR: [
|
|
{
|
|
email: value,
|
|
},
|
|
{
|
|
username: value,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
});
|
|
|
|
return !!membership;
|
|
};
|
|
|
|
export default checkIfMembershipExistsHandler;
|