From 95a56d88283b14c5689672b51bb18bf25a9d44be Mon Sep 17 00:00:00 2001 From: alma Date: Thu, 15 Jan 2026 14:48:52 +0100 Subject: [PATCH] Agenda refactor --- app/agenda/page.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/agenda/page.tsx b/app/agenda/page.tsx index f48885c..0109432 100644 --- a/app/agenda/page.tsx +++ b/app/agenda/page.tsx @@ -51,20 +51,20 @@ export default async function CalendarPage() { // Exclude "Privée" and "Default" calendars that are not synced (they should only exist if synced from courrier) // Get personal calendars + // First, get all calendars, then filter in code for "Privée"/"Default" with sync let personalCalendars = await prisma.calendar.findMany({ where: { userId: session?.user?.id || '', OR: [ // Keep calendars that are not "Privée" or "Default" { name: { notIn: ["Privée", "Default"] } }, - // Or keep "Privée"/"Default" calendars that have active sync config + // Or keep "Privée"/"Default" calendars that have sync config (we'll filter syncEnabled in code) { AND: [ { name: { in: ["Privée", "Default"] } }, { syncConfig: { - isNot: null, - syncEnabled: true // Also check that sync is enabled + isNot: null } } ] @@ -96,6 +96,16 @@ export default async function CalendarPage() { } }); + // Filter out "Privée"/"Default" calendars that don't have syncEnabled=true + personalCalendars = personalCalendars.filter(cal => { + // Keep all non-"Privée"/"Default" calendars + if (cal.name !== "Privée" && cal.name !== "Default") { + return true; + } + // For "Privée"/"Default", only keep if syncConfig exists and is enabled + return cal.syncConfig && cal.syncConfig.syncEnabled === true; + }); + // Get mission calendars where user is associated via MissionUser const missionUserRelations = await prisma.missionUser.findMany({ where: {