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)
|
// Exclude "Privée" and "Default" calendars that are not synced (they should only exist if synced from courrier)
|
||||||
|
|
||||||
// Get personal calendars
|
// Get personal calendars
|
||||||
|
// First, get all calendars, then filter in code for "Privée"/"Default" with sync
|
||||||
let personalCalendars = await prisma.calendar.findMany({
|
let personalCalendars = await prisma.calendar.findMany({
|
||||||
where: {
|
where: {
|
||||||
userId: session?.user?.id || '',
|
userId: session?.user?.id || '',
|
||||||
OR: [
|
OR: [
|
||||||
// Keep calendars that are not "Privée" or "Default"
|
// Keep calendars that are not "Privée" or "Default"
|
||||||
{ name: { notIn: ["Privée", "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: [
|
AND: [
|
||||||
{ name: { in: ["Privée", "Default"] } },
|
{ name: { in: ["Privée", "Default"] } },
|
||||||
{
|
{
|
||||||
syncConfig: {
|
syncConfig: {
|
||||||
isNot: null,
|
isNot: null
|
||||||
syncEnabled: true // Also check that sync is enabled
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -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
|
// Get mission calendars where user is associated via MissionUser
|
||||||
const missionUserRelations = await prisma.missionUser.findMany({
|
const missionUserRelations = await prisma.missionUser.findMany({
|
||||||
where: {
|
where: {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user