fix event types

pull/9078/head
Agusti Fernandez Pardo 2022-05-18 13:55:05 +02:00
parent 47ce92714b
commit 075808ce40
2 changed files with 4 additions and 2 deletions

View File

@ -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);

View File

@ -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) =>