Files
calendar/packages/trpc/server/routers/viewer/attributes/list.handler.ts
T
3c1297aa72 fix: calcom trpc sessio circle dep (#19893)
* 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>
2025-03-19 05:50:22 -03:00

34 lines
636 B
TypeScript

import prisma from "@calcom/prisma";
import { TRPCError } from "@trpc/server";
import type { TrpcSessionUser } from "../../../types";
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;