- Admin-managed event categories (name + one of Sakani's 8 calendar colors) at /admin/kalender/kategorien; events pick a category. - Calendar as Sakani MonthCalendar with a German header and a color legend, for editorials and admins. - "Zu meinen Alben hinzufügen" replaces RSVP: grants the event album at once when it exists, otherwise reserves it; the auto-rule scheduler grants pending reservations once the album appears. Editorials see when an auto rule already covers the event. event_responses is dropped. - New admin dashboard: to-dos, next events, 30-day figures, activity. - Photo grid reads left to right in uniform 3:2 tiles. - Release notes 2.3.0 seeded (migration 0008). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
128 lines
5.9 KiB
TypeScript
128 lines
5.9 KiB
TypeScript
import Link from "next/link";
|
|
|
|
import { CategoryDot, CategoryLegend } from "@/components/calendar/category-legend";
|
|
import { EventMonth } from "@/components/calendar/event-month";
|
|
import { Button } from "@/components/ui/button";
|
|
import { PageHeader } from "@/components/ui/page-header";
|
|
import { Alert, Badge, Card, EmptyState } from "@/components/ui/sakani";
|
|
import { formatIsoDateGerman, isoDateInBerlin } from "@/modules/announcements/service";
|
|
import { categoryService } from "@/modules/calendar/categories";
|
|
import { calendarService } from "@/modules/calendar/service";
|
|
import { immichClient } from "@/modules/immich/client";
|
|
|
|
import { requireAdminPage } from "../access";
|
|
import { CalendarEventForm } from "./CalendarEventForm";
|
|
import { DeleteCalendarEventButton } from "./DeleteCalendarEventButton";
|
|
import { createCalendarEventAction, deleteCalendarEventAction } from "./actions";
|
|
|
|
export default async function AdminCalendarPage() {
|
|
await requireAdminPage();
|
|
const [{ events, immichUnavailable }, albums, categories] = await Promise.all([
|
|
calendarService.listAdminEvents(),
|
|
immichClient.listAlbums().catch(() => []),
|
|
categoryService.listCategories(),
|
|
]);
|
|
const today = isoDateInBerlin(new Date());
|
|
|
|
return (
|
|
<section className="flex flex-col gap-6">
|
|
<PageHeader
|
|
kicker="Planung"
|
|
title="Kalender"
|
|
description="Termine für Redaktionen, z. B. kommende Spiele. Redaktionen merken Termine vor und bekommen das verknüpfte Album automatisch, sobald es da ist. Alben ohne Termin bleiben unsichtbar; automatische Zuweisungsregeln gelten unabhängig davon."
|
|
>
|
|
<Button asChild variant="outline">
|
|
<Link href="/admin/kalender/kategorien">Kategorien verwalten</Link>
|
|
</Button>
|
|
</PageHeader>
|
|
|
|
<CalendarEventForm
|
|
action={createCalendarEventAction}
|
|
albums={albums.map((album) => ({ id: album.id, albumName: album.albumName }))}
|
|
categories={categories.map((category) => ({ id: category.id, name: category.name }))}
|
|
defaultEventDate={today}
|
|
/>
|
|
|
|
{immichUnavailable ? (
|
|
<Alert
|
|
color="warning"
|
|
description="Immich ist gerade nicht erreichbar. Verknüpfte Alben werden angezeigt, sobald die Verbindung wieder steht."
|
|
/>
|
|
) : null}
|
|
|
|
<Card title="Monatsübersicht">
|
|
<EventMonth
|
|
events={events.map((event) => ({
|
|
id: event.id,
|
|
title: event.title,
|
|
eventDate: event.eventDate,
|
|
color: event.category?.color ?? null,
|
|
}))}
|
|
/>
|
|
<CategoryLegend categories={categories} showUncategorized={events.some((event) => !event.category)} />
|
|
</Card>
|
|
|
|
<section aria-labelledby="calendar-list-title" className="flex flex-col gap-4">
|
|
<div className="flex items-baseline justify-between">
|
|
<h2 className="text-xl font-semibold" id="calendar-list-title">
|
|
Alle Termine
|
|
</h2>
|
|
<p className="text-sm text-[var(--color-fg-muted)]">{events.length} insgesamt</p>
|
|
</div>
|
|
|
|
{events.length === 0 ? (
|
|
<EmptyState title="Noch keine Termine" description="Legen Sie oben den ersten Termin an." />
|
|
) : (
|
|
<ul className="flex flex-col gap-3">
|
|
{events.map((event) => {
|
|
const granted = event.reservations.filter((row) => row.grantedAt).length;
|
|
return (
|
|
<li
|
|
className="flex flex-col justify-between gap-4 rounded-xl border border-[var(--color-border-subtle)] bg-[var(--color-bg-surface)] p-4 outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-border-focus)] sm:flex-row sm:items-start"
|
|
id={`termin-${event.id}`}
|
|
key={event.id}
|
|
tabIndex={-1}
|
|
>
|
|
<div className="flex min-w-0 flex-col gap-2">
|
|
<p className="flex flex-wrap items-center gap-2 font-semibold">
|
|
{event.title}
|
|
{event.eventDate < today ? <Badge>vorbei</Badge> : null}
|
|
</p>
|
|
<p className="flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-[var(--color-fg-muted)]">
|
|
<span>{formatIsoDateGerman(event.eventDate)}</span>
|
|
{event.category ? (
|
|
<span className="flex items-center gap-1.5">
|
|
· <CategoryDot color={event.category.color} /> {event.category.name}
|
|
</span>
|
|
) : null}
|
|
<span>· {event.album ? `Album: ${event.album.albumName}` : "Noch kein Album verknüpft"}</span>
|
|
</p>
|
|
{event.reservations.length > 0 ? (
|
|
<div className="flex flex-col gap-1.5">
|
|
<p className="text-xs text-[var(--color-fg-muted)]">
|
|
{event.reservations.length === 1 ? "1 Vormerkung" : `${event.reservations.length} Vormerkungen`}
|
|
{granted > 0 ? `, ${granted} freigeschaltet` : ""}
|
|
</p>
|
|
<div className="flex flex-wrap gap-1.5">
|
|
{event.reservations.map((row) => (
|
|
<Badge key={row.editorialId} variant={row.grantedAt ? "success" : "neutral"}>
|
|
{row.editorialName}: {row.grantedAt ? "freigeschaltet" : "vorgemerkt"}
|
|
</Badge>
|
|
))}
|
|
</div>
|
|
</div>
|
|
) : (
|
|
<p className="text-xs text-[var(--color-fg-muted)]">Noch keine Vormerkungen.</p>
|
|
)}
|
|
</div>
|
|
<DeleteCalendarEventButton action={deleteCalendarEventAction} eventId={event.id} />
|
|
</li>
|
|
);
|
|
})}
|
|
</ul>
|
|
)}
|
|
</section>
|
|
</section>
|
|
);
|
|
}
|