2
0
Files
cal/calcom/packages/trpc/server/routers/viewer/bookings/getInstantBookingLocation.handler.ts
2024-08-09 00:39:27 +02:00

40 lines
851 B
TypeScript

import type { PrismaClient } from "@calcom/prisma";
import { BookingStatus } from "@calcom/prisma/enums";
import type { TInstantBookingInputSchema } from "./getInstantBookingLocation.schema";
type GetOptions = {
ctx: {
prisma: PrismaClient;
};
input: TInstantBookingInputSchema;
};
export const getHandler = async ({ ctx, input }: GetOptions) => {
const { prisma } = ctx;
const { bookingId } = input;
const booking = await prisma.booking.findUnique({
where: {
id: bookingId,
status: BookingStatus.ACCEPTED,
},
select: {
id: true,
uid: true,
location: true,
metadata: true,
startTime: true,
status: true,
endTime: true,
description: true,
eventTypeId: true,
},
});
// Don't leak anything private from the booking
return {
booking,
};
};