Files
calendar/apps/web/lib/getBooking.tsx
T
9e3e1418c2 Fix disabled locations when rescheduling (#5046)
* fix phone number input when attendee phone number is default checked

* add selected location for rescheduling and remove default checked

* don't show locations when rescheduling on availability page

* fix type error

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
2022-10-17 15:47:11 +02:00

35 lines
830 B
TypeScript

import { Prisma, PrismaClient } from "@prisma/client";
async function getBooking(prisma: PrismaClient, uid: string) {
const booking = await prisma.booking.findFirst({
where: {
uid,
},
select: {
startTime: true,
description: true,
customInputs: true,
smsReminderNumber: true,
location: true,
attendees: {
select: {
email: true,
name: true,
},
},
},
});
if (booking) {
// @NOTE: had to do this because Server side cant return [Object objects]
// probably fixable with json.stringify -> json.parse
booking["startTime"] = (booking?.startTime as Date)?.toISOString() as unknown as Date;
}
return booking;
}
export type GetBookingType = Prisma.PromiseReturnType<typeof getBooking>;
export default getBooking;