Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com> Co-authored-by: Omar López <zomars@me.com>
34 lines
635 B
TypeScript
34 lines
635 B
TypeScript
import prisma from "@calcom/prisma";
|
|
|
|
import { TRPCError } from "@trpc/server";
|
|
|
|
import type { TrpcSessionUser } from "../../../trpc";
|
|
|
|
type GetOptions = {
|
|
ctx: {
|
|
user: NonNullable<TrpcSessionUser>;
|
|
};
|
|
};
|
|
|
|
const listHandler = async (opts: GetOptions) => {
|
|
const org = opts.ctx.user.organization;
|
|
|
|
if (!org.id) {
|
|
throw new TRPCError({
|
|
code: "UNAUTHORIZED",
|
|
message: "You need to be apart of an organization to use this feature",
|
|
});
|
|
}
|
|
|
|
return await prisma.attribute.findMany({
|
|
where: {
|
|
teamId: org.id,
|
|
},
|
|
include: {
|
|
options: true,
|
|
},
|
|
});
|
|
};
|
|
|
|
export default listHandler;
|