'use client'; import { useState } from 'react'; import { useSession } from 'next-auth/react'; import DashboardSidebar from '@/components/DashboardSidebar'; import { FiCheck, FiX, FiRefreshCw, FiCloud } from 'react-icons/fi'; export default function SettingsPage() { const { data: session } = useSession(); const [testResult, setTestResult] = useState(null); const [syncResult, setSyncResult] = useState(null); const [loading, setLoading] = useState(false); const testConnection = async () => { setLoading(true); setTestResult(null); try { const response = await fetch('/api/calendar/sync', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action: 'test-connection' }), }); const data = await response.json(); setTestResult(data); } catch (error) { setTestResult({ success: false, error: 'Connection failed' }); } finally { setLoading(false); } }; const syncAllBookings = async () => { setLoading(true); setSyncResult(null); try { const response = await fetch('/api/calendar/sync', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action: 'sync-all' }), }); const data = await response.json(); setSyncResult(data); } catch (error) { setSyncResult({ success: false, error: 'Sync failed' }); } finally { setLoading(false); } }; return (

Einstellungen

Nextcloud Kalender-Synchronisation

{testResult && (
{testResult.success ? ( <> Verbindung erfolgreich! ) : ( <> Verbindung fehlgeschlagen )}
{testResult.success && testResult.calendars && (

Gefundene Kalender:

    {testResult.calendars.map((cal: any, idx: number) => (
  • • {cal.displayName} {cal.description && `(${cal.description})`}
  • ))}
)} {!testResult.success && (

Fehler: {testResult.error || 'Unbekannter Fehler'}

)}
)} {syncResult && (
{syncResult.success ? ( <> Synchronisation abgeschlossen! ) : ( <> Synchronisation fehlgeschlagen )}
{syncResult.success && (

✅ Erfolgreich synchronisiert: {syncResult.synced}

{syncResult.failed > 0 && (

❌ Fehlgeschlagen: {syncResult.failed}

)}

📊 Gesamt: {syncResult.total}

)} {!syncResult.success && (

Fehler: {syncResult.error || 'Unbekannter Fehler'}

)}
)}

ℹ️ Hinweise:

  • • Stelle sicher, dass die Nextcloud-Zugangsdaten in der .env-Datei korrekt hinterlegt sind
  • • Die Synchronisation erstellt/aktualisiert Events für alle RESERVED, CONFIRMED und TOUR_CREATED Buchungen
  • • Bei Änderungen an Buchungen werden die Kalender-Events automatisch aktualisiert
); }