Initial commit: Kalendartool (Next.js, Prisma, Docker)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
58
app/admin/calendars/page.tsx
Normal file
58
app/admin/calendars/page.tsx
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* Admin: Kalenderverwaltung (Cards-Ansicht).
|
||||
* Zeigt alle Kalender als Karten - eigene und die anderer Benutzer.
|
||||
* Verwaltung direkt im Bearbeiten-Modal oder auf der Detailseite
|
||||
* /admin/calendars/[id] (Invites, Mitglieder, Reservierungen).
|
||||
*/
|
||||
import { redirect } from 'next/navigation';
|
||||
import { prisma } from '@/lib/db/client';
|
||||
import { requireDbUser } from '@/lib/api/context';
|
||||
import { AppShell } from '@/components/layout/AppShell';
|
||||
import { CalendarManager } from '@/components/admin/CalendarManager';
|
||||
|
||||
export default async function ManageCalendarsPage() {
|
||||
const user = await requireDbUser().catch(() => null);
|
||||
if (!user || user.role !== 'ADMIN') {
|
||||
redirect('/dashboard');
|
||||
}
|
||||
|
||||
const calendars = await prisma.calendar.findMany({
|
||||
orderBy: { createdAt: 'desc' },
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
description: true,
|
||||
timezone: true,
|
||||
isActive: true,
|
||||
maxReservationMinutes: true,
|
||||
showTitleToMembers: true,
|
||||
showNotesToMembers: true,
|
||||
ownerId: true,
|
||||
owner: { select: { email: true, username: true } },
|
||||
_count: { select: { members: true, reservations: true } },
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<AppShell role={user.role} userEmail={user.email} username={user.username}>
|
||||
<CalendarManager
|
||||
currentUserId={user.id}
|
||||
isAdmin={user.role === 'ADMIN'}
|
||||
initialCalendars={calendars.map((calendar) => ({
|
||||
id: calendar.id,
|
||||
title: calendar.title,
|
||||
description: calendar.description,
|
||||
timezone: calendar.timezone,
|
||||
isActive: calendar.isActive,
|
||||
ownerEmail: calendar.owner.username ?? calendar.owner.email,
|
||||
isOwn: calendar.ownerId === user.id,
|
||||
memberCount: calendar._count.members,
|
||||
reservationCount: calendar._count.reservations,
|
||||
maxReservationMinutes: calendar.maxReservationMinutes,
|
||||
showTitleToMembers: calendar.showTitleToMembers,
|
||||
showNotesToMembers: calendar.showNotesToMembers,
|
||||
}))}
|
||||
/>
|
||||
</AppShell>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user