// app/(app)/dashboard/page.tsx import Alerts from '@/components/ui/Alerts'; import { prisma } from '@/lib/prisma'; const dtf = new Intl.DateTimeFormat('de-DE', { dateStyle: 'short', }); export default async function DashboardPage() { const now = new Date(); // Start / Ende des heutigen Tages (ohne Uhrzeit) const startOfToday = new Date( now.getFullYear(), now.getMonth(), now.getDate(), ); const startOfTomorrow = new Date( now.getFullYear(), now.getMonth(), now.getDate() + 1, ); // 🔴 Überfällige Geräte: loanedUntil < heute const overdueDevices = await prisma.device.findMany({ where: { loanedTo: { not: null }, loanedUntil: { lt: startOfToday }, }, orderBy: { loanedUntil: 'asc' }, select: { inventoryNumber: true, name: true, loanedTo: true, loanedUntil: true, }, }); // 🟡 Heute fällige Geräte: loanedUntil am heutigen Tag const dueTodayDevices = await prisma.device.findMany({ where: { loanedTo: { not: null }, loanedUntil: { gte: startOfToday, lt: startOfTomorrow, }, }, orderBy: { loanedUntil: 'asc' }, select: { inventoryNumber: true, name: true, loanedTo: true, loanedUntil: true, }, }); const hasOverdue = overdueDevices.length > 0; const hasDueToday = dueTodayDevices.length > 0; return ( <> {/* 🔴 Überfällige Geräte (rot) */} {hasOverdue && (

Diese Geräte haben das Rückgabedatum bereits überschritten:

} rightContent={ Zur Geräteliste } /> )} {/* 🟡 Heute fällige Geräte (gelb) */} {hasDueToday && (

Diese Geräte sollten heute zurückgegeben werden:

} rightContent={ Zur Geräteliste } /> )} ); }