import { PrismaClient } from '@prisma/client'; const prisma = new PrismaClient(); async function checkEmailSync() { console.log('🔍 Prüfe E-Mail-Sync Status...\n'); const luebeck = await prisma.location.findUnique({ where: { slug: 'luebeck' }, select: { name: true, emailSyncEnabled: true, lastEmailSync: true, imapHost: true, imapUser: true, }, }); if (!luebeck) { console.log('❌ Lübeck Location nicht gefunden!'); return; } console.log('📍 Lübeck:'); console.log(` E-Mail-Sync: ${luebeck.emailSyncEnabled ? '✅ Aktiviert' : '❌ Deaktiviert'}`); console.log(` IMAP konfiguriert: ${luebeck.imapHost ? '✅ Ja' : '❌ Nein'}`); console.log(` Letzter Sync: ${luebeck.lastEmailSync ? new Date(luebeck.lastEmailSync).toLocaleString('de-DE') : 'Noch nie'}`); if (!luebeck.emailSyncEnabled) { console.log('\n⚠️ E-Mail-Sync ist deaktiviert!'); console.log(' Buchungen werden NICHT automatisch erfasst.'); console.log(' → Entweder manuell im Dashboard anlegen'); console.log(' → Oder E-Mail-Sync aktivieren\n'); } else { console.log('\n✅ E-Mail-Sync ist aktiviert!'); console.log(' → E-Mails werden automatisch abgerufen (Cron-Job oder manuell)'); console.log(' → Buchungen erscheinen im Dashboard\n'); } // Prüfe ob es neue Buchungen gibt const recentBookings = await prisma.booking.findMany({ where: { locationId: luebeck ? undefined : undefined, }, orderBy: { createdAt: 'desc', }, take: 5, select: { id: true, bookingNumber: true, customerName: true, createdAt: true, location: { select: { name: true }, }, }, }); if (recentBookings.length > 0) { console.log('📊 Letzte 5 Buchungen:'); recentBookings.forEach((booking, idx) => { console.log(` ${idx + 1}. ${booking.bookingNumber} - ${booking.customerName} (${booking.location.name})`); console.log(` Erstellt: ${new Date(booking.createdAt).toLocaleString('de-DE')}`); }); } else { console.log('📊 Keine Buchungen gefunden.'); } await prisma.$disconnect(); } checkEmailSync();