Agenda refactor
This commit is contained in:
parent
39fd43f995
commit
5d90bc6989
@ -459,13 +459,15 @@ export default async function CalendarPage() {
|
|||||||
|
|
||||||
// Refresh calendars after auto-setup and cleanup
|
// Refresh calendars after auto-setup and cleanup
|
||||||
// Exclude "Privée" and "Default" calendars that are not synced
|
// Exclude "Privée" and "Default" calendars that are not synced
|
||||||
|
// IMPORTANT: Include all "Privée"/"Default" calendars that have ANY syncConfig (enabled or disabled)
|
||||||
|
// We'll filter by syncEnabled later
|
||||||
calendars = await prisma.calendar.findMany({
|
calendars = 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 ANY sync config (we'll filter by enabled later)
|
||||||
{
|
{
|
||||||
AND: [
|
AND: [
|
||||||
{ name: { in: ["Privée", "Default"] } },
|
{ name: { in: ["Privée", "Default"] } },
|
||||||
@ -505,6 +507,14 @@ export default async function CalendarPage() {
|
|||||||
|
|
||||||
// No default calendar creation - only synced calendars from courrier
|
// No default calendar creation - only synced calendars from courrier
|
||||||
|
|
||||||
|
// Debug: Log calendars before filtering
|
||||||
|
console.log(`[AGENDA] Calendars before filtering: ${calendars.length}`);
|
||||||
|
const infomaniakBeforeFilter = calendars.filter(cal => cal.syncConfig?.provider === 'infomaniak');
|
||||||
|
console.log(`[AGENDA] Infomaniak calendars before filtering: ${infomaniakBeforeFilter.length}`);
|
||||||
|
infomaniakBeforeFilter.forEach(cal => {
|
||||||
|
console.log(`[AGENDA] Before filter - Calendar: ${cal.name}, id: ${cal.id}, syncEnabled: ${cal.syncConfig?.syncEnabled}, hasMailCredential: ${!!cal.syncConfig?.mailCredential}`);
|
||||||
|
});
|
||||||
|
|
||||||
// Filter out "Privée" and "Default" calendars that don't have active sync
|
// Filter out "Privée" and "Default" calendars that don't have active sync
|
||||||
calendars = calendars.filter(cal => {
|
calendars = calendars.filter(cal => {
|
||||||
const isPrivateOrDefault = cal.name === "Privée" || cal.name === "Default";
|
const isPrivateOrDefault = cal.name === "Privée" || cal.name === "Default";
|
||||||
@ -529,6 +539,13 @@ export default async function CalendarPage() {
|
|||||||
// Log final count of Infomaniak calendars
|
// Log final count of Infomaniak calendars
|
||||||
const infomaniakCalendars = calendars.filter(cal => cal.syncConfig?.provider === 'infomaniak');
|
const infomaniakCalendars = calendars.filter(cal => cal.syncConfig?.provider === 'infomaniak');
|
||||||
console.log(`[AGENDA] Final Infomaniak calendars count: ${infomaniakCalendars.length}`);
|
console.log(`[AGENDA] Final Infomaniak calendars count: ${infomaniakCalendars.length}`);
|
||||||
|
|
||||||
|
// Debug: Log all calendars with syncConfig to see what we have
|
||||||
|
const calendarsWithSync = calendars.filter(cal => cal.syncConfig);
|
||||||
|
console.log(`[AGENDA] Total calendars with syncConfig: ${calendarsWithSync.length}`);
|
||||||
|
calendarsWithSync.forEach(cal => {
|
||||||
|
console.log(`[AGENDA] Calendar: ${cal.name}, provider: ${cal.syncConfig?.provider}, syncEnabled: ${cal.syncConfig?.syncEnabled}, hasMailCredential: ${!!cal.syncConfig?.mailCredential}`);
|
||||||
|
});
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const nextWeek = add(now, { days: 7 });
|
const nextWeek = add(now, { days: 7 });
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user