Files
calendar/packages/trpc/server/routers/viewer/availability/schedule/get.handler.ts
T

24 lines
780 B
TypeScript

import { ScheduleRepository } from "@calcom/features/schedules/repositories/ScheduleRepository";
import { prisma } from "@calcom/prisma";
import type { TrpcSessionUser } from "../../../../types";
import type { TGetInputSchema } from "./get.schema";
type GetOptions = {
ctx: {
user: Pick<NonNullable<TrpcSessionUser>, "id" | "timeZone" | "defaultScheduleId">;
};
input: TGetInputSchema;
};
export const getHandler = async ({ ctx, input }: GetOptions) => {
const scheduleRepo = new ScheduleRepository(prisma);
return await scheduleRepo.findDetailedScheduleById({
scheduleId: input.scheduleId,
isManagedEventType: input.isManagedEventType,
userId: ctx.user.id,
timeZone: ctx.user.timeZone,
defaultScheduleId: ctx.user.defaultScheduleId,
});
};