Files
calendar/packages/trpc/server/routers/viewer/attributes/list.handler.ts
T
08e1b0a9c8 feat: attributes (#15964)
Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com>
Co-authored-by: Omar López <zomars@me.com>
2024-08-15 14:49:05 -07:00

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;