Refactor Prisma call creating attendees and seat reference (#8014)

* Refactor prisma calls

* Reverted change to pass test
This commit is contained in:
Joe Au-Yeung
2023-03-29 23:13:35 +02:00
committed by GitHub
parent 6cbb9bf967
commit 715aea5733
5 changed files with 19 additions and 20 deletions
@@ -3,6 +3,7 @@
Don't modify this file manually.
**/
import dynamic from "next/dynamic";
export const InstallAppButtonMap = {
applecalendar: dynamic(() => import("./applecalendar/components/InstallAppButton")),
around: dynamic(() => import("./around/components/InstallAppButton")),
@@ -24,6 +24,7 @@ import { appKeysSchema as vital_zod_ts } from "./vital/zod";
import { appKeysSchema as wordpress_zod_ts } from "./wordpress/zod";
import { appKeysSchema as zapier_zod_ts } from "./zapier/zod";
import { appKeysSchema as zoomvideo_zod_ts } from "./zoomvideo/zod";
export const appKeysSchemas = {
dailyvideo: dailyvideo_zod_ts,
fathom: fathom_zod_ts,
@@ -58,6 +58,7 @@ import wordpress_config_json from "./wordpress/config.json";
import { metadata as zapier__metadata_ts } from "./zapier/_metadata";
import zohocrm_config_json from "./zohocrm/config.json";
import { metadata as zoomvideo__metadata_ts } from "./zoomvideo/_metadata";
export const appStoreMetadata = {
amie: amie_config_json,
applecalendar: applecalendar__metadata_ts,
@@ -24,6 +24,7 @@ import { appDataSchema as vital_zod_ts } from "./vital/zod";
import { appDataSchema as wordpress_zod_ts } from "./wordpress/zod";
import { appDataSchema as zapier_zod_ts } from "./zapier/zod";
import { appDataSchema as zoomvideo_zod_ts } from "./zoomvideo/zod";
export const appDataSchemas = {
dailyvideo: dailyvideo_zod_ts,
fathom: fathom_zod_ts,
@@ -1284,6 +1284,8 @@ async function handler(
};
}
const attendeeUniqueId = uuid();
const bookingUpdated = await prisma.booking.update({
where: {
uid: reqBody.bookingUid,
@@ -1298,32 +1300,25 @@ async function handler(
name: invitee[0].name,
timeZone: invitee[0].timeZone,
locale: invitee[0].language.locale,
bookingSeat: {
create: {
referenceUid: attendeeUniqueId,
data: {
description: additionalNotes,
},
booking: {
connect: {
id: booking.id,
},
},
},
},
},
},
...(booking.status === BookingStatus.CANCELLED && { status: BookingStatus.ACCEPTED }),
},
});
// Add entry to bookingSeat table
const attendeeUniqueId = uuid();
await prisma.bookingSeat.create({
data: {
data: {
description: additionalNotes,
},
booking: {
connect: {
id: booking.id,
},
},
referenceUid: attendeeUniqueId,
attendee: {
connect: {
id: bookingUpdated.attendees[bookingUpdated.attendees.length - 1].id,
},
},
},
});
evt.attendeeSeatId = attendeeUniqueId;
const newSeat = booking.attendees.length !== 0;