diff --git a/components/calendar/calendar-client.tsx b/components/calendar/calendar-client.tsx index 2358ebb..ca28304 100644 --- a/components/calendar/calendar-client.tsx +++ b/components/calendar/calendar-client.tsx @@ -175,9 +175,8 @@ function CalendarDialog({ open, onClose, onSave, onDelete, onSyncSetup, initialD if (response.ok) { const data = await response.json(); if (data.success && data.accounts) { - // Filter Infomaniak and Microsoft accounts + // Filter Microsoft accounts only const syncableAccounts = data.accounts.filter((acc: any) => - (acc.host && acc.host.includes('infomaniak')) || (acc.host && acc.host.includes('outlook.office365.com') && acc.use_oauth) ); setAvailableAccounts(syncableAccounts.map((acc: any) => ({ @@ -198,13 +197,8 @@ function CalendarDialog({ open, onClose, onSave, onDelete, onSyncSetup, initialD setIsDiscovering(true); try { - // Determine which endpoint to use based on account type - const selectedAccount = availableAccounts.find(acc => acc.id === selectedAccountId); - const isMicrosoft = selectedAccount?.host?.includes('outlook.office365.com'); - - const endpoint = isMicrosoft - ? "/api/calendars/sync/discover-microsoft" - : "/api/calendars/sync/discover"; + // Use Microsoft endpoint only + const endpoint = "/api/calendars/sync/discover-microsoft"; const response = await fetch(endpoint, { method: "POST", @@ -214,11 +208,11 @@ function CalendarDialog({ open, onClose, onSave, onDelete, onSyncSetup, initialD if (response.ok) { const data = await response.json(); - // Normalize calendar format (Infomaniak uses 'url', Microsoft uses 'id' and 'webLink') + // Normalize calendar format (Microsoft uses 'id' and 'webLink') const normalizedCalendars = (data.calendars || []).map((cal: any) => ({ id: cal.id, name: cal.name, - url: cal.url || cal.webLink || cal.id, // Use url, webLink, or id as fallback + url: cal.webLink || cal.id, // Use webLink or id as fallback })); setAvailableCalendars(normalizedCalendars); } else { @@ -238,15 +232,12 @@ function CalendarDialog({ open, onClose, onSave, onDelete, onSyncSetup, initialD setIsSettingUpSync(true); try { - // Determine provider based on selected account + // All accounts are Microsoft const selectedAccount = availableAccounts.find(acc => acc.id === selectedAccountId); - const isMicrosoft = selectedAccount?.host?.includes('outlook.office365.com'); - const provider = isMicrosoft ? 'microsoft' : 'infomaniak'; + const provider = 'microsoft'; // For Microsoft, use calendar ID instead of URL - const externalCalendarId = isMicrosoft - ? availableCalendars.find(cal => cal.url === selectedCalendarUrl)?.id || selectedCalendarUrl - : null; + const externalCalendarId = availableCalendars.find(cal => cal.url === selectedCalendarUrl)?.id || selectedCalendarUrl; await onSyncSetup(initialData.id, selectedAccountId, selectedCalendarUrl, externalCalendarId, provider); setShowSyncSection(false); @@ -450,7 +441,7 @@ function CalendarDialog({ open, onClose, onSave, onDelete, onSyncSetup, initialD {showSyncSection && (
- +