- ZIP download from the Merkzettel: every photo is a new usage by default; only already downloaded photos offer "Neu / Bereits genutzt" (SegmentedControl), with thumbnails and a cost summary. "Bild auslassen" is gone. - Toasts (Sakani Toaster) for admin saves, deletes and errors; billing errors are readable and use router.refresh instead of reloads. Errors inside modal dialogs stay inline (a toast would sit behind the backdrop). - Album overview in blog-listing style, Sakani Pagination for albums, search and usage history, skeleton loading states. - Registration stepper; verification mail lands on step 3. - Editorials as a searchable, filterable table; audit log with event picker, German labels and collapsible details. - Release notes 2.4.0 seeded (migration 0009). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
2.5 KiB
TypeScript
80 lines
2.5 KiB
TypeScript
"use client";
|
|
|
|
import { useTransition } from "react";
|
|
import Link from "next/link";
|
|
import { useRouter } from "next/navigation";
|
|
import { Badge, Button, toast } 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 [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);
|
|
if (result.ok) {
|
|
toast.success(result.message);
|
|
router.refresh();
|
|
} else {
|
|
toast.error(result.message);
|
|
}
|
|
});
|
|
};
|
|
|
|
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-wrap items-center gap-2">{content}</div>
|
|
);
|
|
}
|