* fix: simplify workflow page and improve load time * chore: use new endpoint * chore: save progress * refactor: code * refactor: remove not requried code * chore: remove schema * chore: fix typ * chore: improve * chore: change name * chore: remove unused * chore: remove page * refactor: teams page * feat: add auto scroll * chore: create validate unique invite * fix: auth check * fix: optimistic update * chore * fix: add loading * fix: improvements * chore: remove * chore * chore: fix teams page * fix: team profile page * fix: appearance page * fix: sso view * fix: type err * feat: defer loading connected Apps * fix: type err * fix: type error * fix: type err * fix: connectedApps type * chore: move * chore: missing export * feat: add search by name * fix: display role change * fix: use setInfiniteData * chore: save progress * test: add unit tests for loading members * fix: test * chore: update name * fix: bugs and improvements * chore: change variable name * test: add tests for checkCanAccessMembers * refactor: performance --------- Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
36 lines
794 B
TypeScript
36 lines
794 B
TypeScript
import { prisma } from "@calcom/prisma";
|
|
|
|
import type { TrpcSessionUser } from "../../../trpc";
|
|
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;
|