diff --git a/apps/web/pages/api/eventtype/mentor.ts b/apps/web/pages/api/eventtype/mentor.ts index ace409db3d417a..32dec05003a36d 100644 --- a/apps/web/pages/api/eventtype/mentor.ts +++ b/apps/web/pages/api/eventtype/mentor.ts @@ -4,7 +4,7 @@ import { z } from "zod"; import prisma from "@calcom/prisma"; export const getEventTypeQuerySchema = z.object({ - userEmail: z.string().optional(), + email: z.string().optional(), page: z .preprocess((val) => Number(val), z.number().int().positive()) .optional() @@ -15,13 +15,13 @@ export const getEventTypeQuerySchema = z.object({ .default(10), }); -export default async function handler(req: NextApiRequest, res: NextApiResponse) { +async function GET(req: NextApiRequest, res: NextApiResponse) { try { - const { userEmail, page, take } = getEventTypeQuerySchema.parse(req.query); + const { email, page, take } = getEventTypeQuerySchema.parse(req.query); const eventTypes = await prisma.user.findMany({ where: { - email: userEmail, + email: email, }, take: take, skip: (page - 1) * take, @@ -34,7 +34,16 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) return { userId: item.id, userEmail: item.email, - eventTypes: item.eventTypes, + eventTypes: item.eventTypes.map((eventType) => { + return { + id: eventType.id, + title: eventType.title, + description: eventType.description, + length: eventType.length, + slug: eventType.slug, + eventName: eventType.eventName, + }; + }), page: page, take: take, }; @@ -44,3 +53,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) return error; } } + +export default async function handler(req: NextApiRequest, res: NextApiResponse) { + if (req.method === "GET") { + const result = await GET(req, res); + return res.status(200).json(result); + } else { + return res.status(405).end(); + } +}