fix: omit metadata/locations and rewrite as json
parent
e7a7c89071
commit
37069e2d7b
14
lib/types.ts
14
lib/types.ts
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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({
|
||||
|
|
Loading…
Reference in New Issue