Agenda refactor
This commit is contained in:
parent
f9e8409ab8
commit
95a56d8828
@ -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: {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user