From 075808ce404529dea681344d9f84d8892cbc2e29 Mon Sep 17 00:00:00 2001 From: Agusti Fernandez Pardo Date: Wed, 18 May 2022 13:55:05 +0200 Subject: [PATCH] fix event types --- lib/validations/event-type.ts | 4 +++- pages/api/event-types/index.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/validations/event-type.ts b/lib/validations/event-type.ts index d341a49f5e..34ca8e0a14 100644 --- a/lib/validations/event-type.ts +++ b/lib/validations/event-type.ts @@ -39,6 +39,7 @@ const schemaEventTypeBaseParams = z description: z.string().optional().nullable(), length: z.number().int(), locations: jsonSchema.optional().nullable().or(z.null()), + metadata: jsonSchema.optional().nullable().or(z.null()), recurringEvent: jsonSchema.optional().nullable().or(z.null()), }) .strict(); @@ -79,8 +80,9 @@ export const schemaEventTypeReadPublic = EventType.pick({ beforeEventBuffer: true, afterEventBuffer: true, schedulingType: true, + metadata: true, price: true, currency: true, slotInterval: true, successRedirectUrl: true, -}).partial(); +}).merge(schemaEventTypeBaseParams); diff --git a/pages/api/event-types/index.ts b/pages/api/event-types/index.ts index cd5e97fc92..163fa501fb 100644 --- a/pages/api/event-types/index.ts +++ b/pages/api/event-types/index.ts @@ -30,7 +30,7 @@ async function createOrlistAllEventTypes( * description: No event types were found */ const data = await prisma.eventType.findMany({ where: { userId } }); - const event_types = data.map((eventType) => (eventType.metadata = {})); + const event_types = data.map((eventType) => schemaEventTypeReadPublic.parse(eventType)); if (event_types) res.status(200).json({ event_types }); else (error: Error) =>