Release 2.3.0: calendar categories, reservations, month view, dashboard
- 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>
This commit is contained in:
1 parent
4fb6f2d373
commit
2775b406bf
39 files changed
+9754
-701
No files matched your search
@@ -0,0 +1,87 @@
|
||||
"use client";
|
||||
|
||||
import { useState, useTransition } from "react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Badge, Button } from "@sakaniui/react";
|
||||
|
||||
import type { EventAccessState } from "@/modules/calendar/service";
|
||||
|
||||
import type { CalendarActionResult } from "./actions";
|
||||
|
||||
type Action = (state: CalendarActionResult, formData: FormData) => Promise<CalendarActionResult>;
|
||||
|
||||
export function EventAccessAction({
|
||||
eventId,
|
||||
access,
|
||||
albumId,
|
||||
reserveAction,
|
||||
unreserveAction,
|
||||
}: Readonly<{
|
||||
eventId: string;
|
||||
access: EventAccessState;
|
||||
albumId: string | null;
|
||||
reserveAction: Action;
|
||||
unreserveAction: Action;
|
||||
}>) {
|
||||
const router = useRouter();
|
||||
const [state, setState] = useState<CalendarActionResult>({ ok: true, message: "" });
|
||||
const [pending, startTransition] = useTransition();
|
||||
|
||||
const run = (action: Action) => {
|
||||
const formData = new FormData();
|
||||
formData.set("eventId", eventId);
|
||||
startTransition(async () => {
|
||||
const result = await action({ ok: true, message: "" }, formData);
|
||||
setState(result);
|
||||
if (result.ok) router.refresh();
|
||||
});
|
||||
};
|
||||
|
||||
let content: React.ReactNode;
|
||||
if ((access === "granted" || access === "auto_granted") && albumId) {
|
||||
content = (
|
||||
<>
|
||||
<Badge variant="success">{access === "auto_granted" ? "Automatisch freigegeben" : "Freigeschaltet"}</Badge>
|
||||
<Link
|
||||
className="inline-flex min-h-10 items-center justify-center rounded-md border border-[var(--color-border-default)] px-4 text-sm font-medium transition-colors hover:bg-[var(--color-bg-subtle)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--color-border-focus)]"
|
||||
href={`/redaktion/alben/${encodeURIComponent(albumId)}`}
|
||||
>
|
||||
Album öffnen
|
||||
</Link>
|
||||
</>
|
||||
);
|
||||
} else if (access === "auto_rule" || access === "auto_granted") {
|
||||
content = <Badge variant="info">Automatisch freigegeben (Auto-Regel)</Badge>;
|
||||
} else if (access === "reserved") {
|
||||
content = (
|
||||
<>
|
||||
<Badge variant="accent">Vorgemerkt</Badge>
|
||||
<Button disabled={pending} onClick={() => run(unreserveAction)} size="sm" type="button" variant="ghost">
|
||||
Vormerkung entfernen
|
||||
</Button>
|
||||
</>
|
||||
);
|
||||
} else {
|
||||
content = (
|
||||
<Button disabled={pending} onClick={() => run(reserveAction)} type="button" variant="primary">
|
||||
{pending ? "Wird hinzugefügt …" : "Zu meinen Alben hinzufügen"}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-start gap-1 sm:items-end">
|
||||
<div className="flex flex-wrap items-center gap-2">{content}</div>
|
||||
{state.message ? (
|
||||
<p
|
||||
aria-live="polite"
|
||||
className={`text-xs ${state.ok ? "text-[var(--color-fg-muted)]" : "text-[var(--color-danger-fg)]"}`}
|
||||
role={state.ok ? "status" : "alert"}
|
||||
>
|
||||
{state.message}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user