fix: event types id endpoints
parent
8627b28a8e
commit
be4ca8835e
|
@ -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({
|
||||
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,
|
||||
}),
|
||||
tzid: timeZone.optional(),
|
||||
})
|
||||
.optional(),
|
||||
locations: z.array(
|
||||
z.object({
|
||||
link: z.string().optional(),
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue