From 110edd7dcce0ae07554857c7a3c18395f3440b5a Mon Sep 17 00:00:00 2001 From: Syed Ali Shahbaz Date: Sat, 11 Jun 2022 16:54:30 +0530 Subject: [PATCH 1/4] removed 18next rel --- pages/api/bookings/index.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/pages/api/bookings/index.ts b/pages/api/bookings/index.ts index 90f9cf7f22..6f8f2ceadc 100644 --- a/pages/api/bookings/index.ts +++ b/pages/api/bookings/index.ts @@ -1,7 +1,6 @@ import { WebhookTriggerEvents } from "@prisma/client"; import type { NextApiRequest, NextApiResponse } from "next"; -import { getTranslation } from "@calcom/lib/server/i18n"; import prisma from "@calcom/prisma"; import { withMiddleware } from "@lib/helpers/withMiddleware"; @@ -98,7 +97,6 @@ async function createOrlistAllBookings( error, }) ); - const fallbackTfunction = await getTranslation("en", "common"); const evt = { type: eventType?.title || booking.title, title: booking.title, @@ -112,7 +110,6 @@ async function createOrlistAllBookings( email: "", timeZone: "", language: { - translate: fallbackTfunction, locale: "en", }, }, From 61e742ed5ef42d9d2584a92d06c9ec59e2785e5b Mon Sep 17 00:00:00 2001 From: Syed Ali Shahbaz Date: Sat, 11 Jun 2022 16:57:35 +0530 Subject: [PATCH 2/4] uuid automate in booking API --- lib/validations/booking.ts | 1 - pages/api/bookings/index.ts | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/validations/booking.ts b/lib/validations/booking.ts index 67b4f1b35a..b61d6913fd 100644 --- a/lib/validations/booking.ts +++ b/lib/validations/booking.ts @@ -13,7 +13,6 @@ const schemaBookingBaseBodyParams = Booking.pick({ const schemaBookingCreateParams = z .object({ - uid: z.string(), eventTypeId: z.number(), title: z.string(), startTime: z.date().or(z.string()), diff --git a/pages/api/bookings/index.ts b/pages/api/bookings/index.ts index 6f8f2ceadc..37fbd94262 100644 --- a/pages/api/bookings/index.ts +++ b/pages/api/bookings/index.ts @@ -1,5 +1,6 @@ import { WebhookTriggerEvents } from "@prisma/client"; import type { NextApiRequest, NextApiResponse } from "next"; +import { v4 as uuidv4 } from "uuid"; import prisma from "@calcom/prisma"; @@ -82,7 +83,7 @@ async function createOrlistAllBookings( return; } safe.data.userId = userId; - const data = await prisma.booking.create({ data: { ...safe.data } }); + const data = await prisma.booking.create({ data: { id: uuidv4(), ...safe.data } }); const booking = schemaBookingReadPublic.parse(data); if (booking) { From 3c98c5cefc4db970d674e54b14846504a2c1bf3f Mon Sep 17 00:00:00 2001 From: Syed Ali Shahbaz Date: Sat, 11 Jun 2022 16:58:21 +0530 Subject: [PATCH 3/4] fixing id to uid in create body --- pages/api/bookings/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/api/bookings/index.ts b/pages/api/bookings/index.ts index 37fbd94262..6bd220aaf5 100644 --- a/pages/api/bookings/index.ts +++ b/pages/api/bookings/index.ts @@ -83,7 +83,7 @@ async function createOrlistAllBookings( return; } safe.data.userId = userId; - const data = await prisma.booking.create({ data: { id: uuidv4(), ...safe.data } }); + const data = await prisma.booking.create({ data: { uid: uuidv4(), ...safe.data } }); const booking = schemaBookingReadPublic.parse(data); if (booking) { From 719e21497b58e4a57b6914a6c4000e9443fa5188 Mon Sep 17 00:00:00 2001 From: Syed Ali Shahbaz Date: Sat, 11 Jun 2022 17:03:11 +0530 Subject: [PATCH 4/4] removed invalid response --- pages/api/bookings/index.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pages/api/bookings/index.ts b/pages/api/bookings/index.ts index 6bd220aaf5..af20e851fe 100644 --- a/pages/api/bookings/index.ts +++ b/pages/api/bookings/index.ts @@ -92,12 +92,9 @@ async function createOrlistAllBookings( const eventType = await prisma.eventType .findUnique({ where: { id: booking.eventTypeId as number } }) .then((data) => schemaEventTypeReadPublic.parse(data)) - .catch((error: Error) => - res.status(404).json({ - message: `EventType with id: ${booking.eventTypeId} not found`, - error, - }) - ); + .catch((e: Error) => { + console.error(`Event type with ID: ${booking.eventTypeId} not found`, e); + }); const evt = { type: eventType?.title || booking.title, title: booking.title,