diff --git a/lib/validations/event-type.ts b/lib/validations/event-type.ts index e3a6d83228..bd2ba68728 100644 --- a/lib/validations/event-type.ts +++ b/lib/validations/event-type.ts @@ -93,16 +93,16 @@ export const schemaEventTypeReadPublic = EventType.pick({ metadata: true, }).merge( z.object({ - // { dtstart?: Date | undefined; interval?: number | undefined; count?: number | undefined; freq?: Frequency | undefined; until?: Date | undefined; tzid?: string | undefined; } | undefined' - // recurringEvent: jsonSchema.nullable(), - recurringEvent: z.object({ - dtstart: z.date().optional(), - interval: z.number().int().optional(), - count: z.number().int().optional(), - freq: z.nativeEnum(Frequency).optional(), - until: z.date().optional(), - tzid: timeZone, - }), + recurringEvent: z + .object({ + dtstart: z.date().optional(), + interval: z.number().int().optional(), + count: z.number().int().optional(), + freq: z.nativeEnum(Frequency).optional(), + until: z.date().optional(), + tzid: timeZone.optional(), + }) + .optional(), locations: z.array( z.object({ link: z.string().optional(), diff --git a/pages/api/event-types/[id].ts b/pages/api/event-types/[id].ts index 6319b48b9e..12cee4433c 100644 --- a/pages/api/event-types/[id].ts +++ b/pages/api/event-types/[id].ts @@ -19,8 +19,12 @@ export async function eventTypeById( res.status(400).json({ message: "Your query was invalid" }); return; } - const data = await prisma.eventType.findMany({ where: { userId } }); - const userEventTypes = data.map((eventType) => eventType.id); + const data = await await prisma.user.findUnique({ + where: { id: userId }, + rejectOnNotFound: true, + select: { eventTypes: true }, + }); + const userEventTypes = data.eventTypes.map((eventType) => eventType.id); if (!userEventTypes.includes(safeQuery.data.id)) res.status(401).json({ message: "Unauthorized" }); else { switch (method) {