Moved categories to the same scope as calendar events

This commit is contained in:
Alexis
2025-04-16 10:49:11 +02:00
parent f1abae1cce
commit 6abf89e8db
6 changed files with 22 additions and 19 deletions

View File

@@ -4,6 +4,7 @@ import type { Category } from "~/models/Category";
const querySchema = z.object({
id: z.number({ coerce: true }).positive().int().optional(),
calendarId: z.number({ coerce: true }).positive().int()
})
export default defineEventHandler(async (event) => {
@@ -24,5 +25,9 @@ export default defineEventHandler(async (event) => {
return output.eq("id", query.id).limit(1).single<Category>()
}
if (query.calendarId) {
output.eq("calendar_id", query.calendarId)
}
return output.overrideTypes<Category[]>()
})

View File

@@ -52,6 +52,11 @@ export default defineEventHandler(async (event) => {
category:calendar_event_categories!calendar_events_category_fkey (*),
secondaryCategories:calendar_event_categories!calendar_event_categories_links (*)
),
categories:calendar_event_categories (
id,
name,
color
),
eventNb:calendar_events(count),
world:worlds (
id,