fix: omit metadata/locations and rewrite as json

pull/9078/head
Agusti Fernandez Pardo 2022-05-18 20:22:43 +02:00
parent e7a7c89071
commit 37069e2d7b
4 changed files with 14 additions and 12 deletions

View File

@ -124,17 +124,17 @@ export type EventTypeCustomInputResponse = BaseResponse & {
export type EventTypeCustomInputsResponse = BaseResponse & {
event_type_custom_inputs?: Partial<EventTypeCustomInput>[];
};
export type EventTypeWithMetadataLocations = EventType & {
locations?: object;
metadata?: object;
recurringEvent?: object;
};
export interface EventTypeMeta extends Omit<EventType, "locations" | "metadata" | "recurringEvent"> {
locations?: JSON;
metadata?: JSON;
recurringEvent: JSON;
}
// EventType
export type EventTypeResponse = BaseResponse & {
event_type?: Partial<EventTypeWithMetadataLocations>;
event_type?: Partial<EventTypeMeta>;
};
export type EventTypesResponse = BaseResponse & {
event_types?: Partial<EventTypeWithMetadataLocations>[];
event_types?: Partial<EventTypeMeta>[];
};
// Payment

View File

@ -38,8 +38,8 @@ const schemaEventTypeCreateParams = z
slug: z.string(),
description: z.string().optional().nullable(),
length: z.number().int(),
// locations: jsonSchema.optional().nullable().or(z.null()),
// metadata: z.any().optional().nullable().or(z.null()),
locations: jsonSchema.optional().nullable().or(z.null()),
metadata: z.any().optional().nullable().or(z.null()),
recurringEvent: jsonSchema.optional().nullable().or(z.null()),
})
.strict();
@ -85,4 +85,6 @@ export const schemaEventTypeReadPublic = EventType.pick({
slotInterval: true,
successRedirectUrl: true,
description: true,
locations: true,
metadata: true,
});

View File

@ -55,7 +55,7 @@ export async function eventTypeById(
case "GET":
await prisma.eventType
.findUnique({ where: { id: safeQuery.data.id } })
// .then((data) => schemaEventTypeReadPublic.parse(data))
.then((data) => schemaEventTypeReadPublic.parse(data))
.then((event_type) => res.status(200).json({ event_type }))
.catch((error: Error) =>
res.status(404).json({

View File

@ -30,8 +30,8 @@ async function createOrlistAllEventTypes(
* description: No event types were found
*/
const data = await prisma.eventType.findMany({ where: { userId } });
// const event_types = data.map((eventType) => schemaEventTypeReadPublic.parse(eventType));
if (data) res.status(200).json({ event_types: data });
const event_types = data.map((eventType) => schemaEventTypeReadPublic.parse(eventType));
if (event_types) res.status(200).json({ event_types });
else
(error: Error) =>
res.status(404).json({