feat: v2.2 batch (calendar, self-service, sort, description, filename search, stats, collab, invoice) on pre-redesign base
This commit is contained in:
1 parent
453bece72c
commit
7204dd6b60
108 files changed
+10400
-105
No files matched your search
@@ -0,0 +1,47 @@
|
||||
"use client";
|
||||
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState, useTransition } from "react";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
import type { CalendarActionResult } from "./actions";
|
||||
|
||||
// Grants access to the event's linked album and jumps straight into it.
|
||||
export function SelfGrantButton({
|
||||
action,
|
||||
eventId,
|
||||
}: Readonly<{
|
||||
action: (state: CalendarActionResult, formData: FormData) => Promise<CalendarActionResult>;
|
||||
eventId: string;
|
||||
}>) {
|
||||
const router = useRouter();
|
||||
const [error, setError] = useState("");
|
||||
const [pending, startTransition] = useTransition();
|
||||
|
||||
const handleClick = () => {
|
||||
const formData = new FormData();
|
||||
formData.set("eventId", eventId);
|
||||
startTransition(async () => {
|
||||
const result = await action({ ok: true, message: "" }, formData);
|
||||
if (result.ok && result.albumId) {
|
||||
router.push(`/redaktion/alben/${encodeURIComponent(result.albumId)}`);
|
||||
} else {
|
||||
setError(result.message);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-1">
|
||||
<Button type="button" className="min-h-11" disabled={pending} onClick={handleClick}>
|
||||
{pending ? "Wird freigeschaltet…" : "Zugriff freischalten"}
|
||||
</Button>
|
||||
{error ? (
|
||||
<p role="alert" className="text-xs text-destructive">
|
||||
{error}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user