Files
calendar/packages/features/bookings/lib/handleNewBooking/findBookingQuery.ts
T
5f8d090d3c refactor: handleNewBooking #3 (#15612)
* refactor: handleNewBooking #3

* fix: type error

* fix: type err

* fix: type err

* refactor: create booking factor

* chore: refactor availusers

* chore: type err

---------

Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2024-07-08 18:18:36 +00:00

49 lines
1.1 KiB
TypeScript

import prisma from "@calcom/prisma";
export const findBookingQuery = async (bookingId: number) => {
const foundBooking = await prisma.booking.findUnique({
where: {
id: bookingId,
},
select: {
uid: true,
location: true,
startTime: true,
endTime: true,
title: true,
description: true,
status: true,
responses: true,
metadata: true,
user: {
select: {
name: true,
email: true,
timeZone: true,
username: true,
},
},
eventType: {
select: {
title: true,
description: true,
currency: true,
length: true,
lockTimeZoneToggleOnBookingPage: true,
requiresConfirmation: true,
requiresBookerEmailVerification: true,
price: true,
},
},
},
});
// This should never happen but it's just typescript safe
if (!foundBooking) {
throw new Error("Internal Error. Couldn't find booking");
}
// Don't leak any sensitive data
return foundBooking;
};