diff --git a/app/agenda/page.tsx b/app/agenda/page.tsx index 061fcb4..97820c2 100644 --- a/app/agenda/page.tsx +++ b/app/agenda/page.tsx @@ -45,18 +45,23 @@ export default async function CalendarPage() { const userId = session.user.username || session.user.email || ''; // Get all calendars for the user with mission relation and sync configuration - // Exclude "Privée" calendars that are not synced (they should only exist if synced from courrier) + // Exclude "Privée" and "Default" calendars that are not synced (they should only exist if synced from courrier) let calendars = 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 sync config + // Or keep "Privée"/"Default" calendars that have active sync config { AND: [ { name: { in: ["Privée", "Default"] } }, - { syncConfig: { isNot: null } } + { + syncConfig: { + isNot: null, + syncEnabled: true + } + } ] } ] @@ -181,18 +186,23 @@ export default async function CalendarPage() { } // Refresh calendars after auto-setup - // Exclude "Privée" calendars that are not synced + // Exclude "Privée" and "Default" calendars that are not synced calendars = 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 sync config + // Or keep "Privée"/"Default" calendars that have active sync config { AND: [ { name: { in: ["Privée", "Default"] } }, - { syncConfig: { isNot: null } } + { + syncConfig: { + isNot: null, + syncEnabled: true + } + } ] } ] diff --git a/components/calendar/calendar-client.tsx b/components/calendar/calendar-client.tsx index 6ed9ef4..2df5abe 100644 --- a/components/calendar/calendar-client.tsx +++ b/components/calendar/calendar-client.tsx @@ -688,16 +688,17 @@ function EventPreview({ event, calendar }: { event: Event; calendar: Calendar }) } export function CalendarClient({ initialCalendars, userId, userProfile }: CalendarClientProps) { - // Filter out "Privée" calendars that are not synced + // Filter out "Privée" and "Default" calendars that are not synced const filterCalendars = (cals: typeof initialCalendars) => { return cals.filter(cal => { // Keep calendars that are synced, groups, missions, or have a different name const isSynced = cal.syncConfig?.syncEnabled && cal.syncConfig?.mailCredential; const isGroup = cal.name?.startsWith("Groupe:"); const isMission = cal.name?.startsWith("Mission:"); - const isPrivateNotSynced = (cal.name === "Privée" || cal.name === "Default") && !isSynced; + const isPrivateOrDefault = cal.name === "Privée" || cal.name === "Default"; + const isPrivateNotSynced = isPrivateOrDefault && !isSynced; - // Exclude "Privée" calendars that are not synced + // Exclude "Privée" and "Default" calendars that are not synced return !isPrivateNotSynced; }); };