feat: v2.2 batch (calendar, self-service, sort, description, filename search, stats, collab, invoice) on pre-redesign base

This commit is contained in:
Leon Tonhäuser committed 2026-11-30 21:20:13 +01:00
1 parent 453bece72c
commit 7204dd6b60
108 files changed
+10400 -105

No files matched your search

@@ -0,0 +1,71 @@
"use client";
import { useState, useTransition } from "react";
import type { EventResponseStatus } from "@/modules/calendar/service";
import type { CalendarActionResult } from "./actions";
export function EventRsvpButtons({
action,
eventId,
initialResponse,
}: Readonly<{
action: (state: CalendarActionResult, formData: FormData) => Promise<CalendarActionResult>;
eventId: string;
initialResponse: EventResponseStatus | null;
}>) {
const [response, setResponse] = useState<EventResponseStatus | null>(initialResponse);
const [error, setError] = useState("");
const [pending, startTransition] = useTransition();
const respond = (status: EventResponseStatus) => {
const formData = new FormData();
formData.set("eventId", eventId);
formData.set("status", status);
startTransition(async () => {
const result = await action({ ok: true, message: "" }, formData);
if (result.ok) {
setResponse(status);
setError("");
} else {
setError(result.message);
}
});
};
const base =
"min-h-11 rounded-md border px-4 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 disabled:cursor-not-allowed disabled:opacity-50";
const active = "border-primary-600 bg-primary-600 text-white";
const inactive = "border-border bg-background hover:bg-accent";
return (
<div className="flex flex-col gap-1">
<div className="flex flex-wrap gap-2" role="group" aria-label="Rückmeldung zu diesem Termin">
<button
type="button"
className={`${base} ${response === "attending" ? active : inactive}`}
aria-pressed={response === "attending"}
disabled={pending}
onClick={() => respond("attending")}
>
Bin da
</button>
<button
type="button"
className={`${base} ${response === "not_attending" ? active : inactive}`}
aria-pressed={response === "not_attending"}
disabled={pending}
onClick={() => respond("not_attending")}
>
Bin nicht da
</button>
</div>
{error ? (
<p role="alert" className="text-xs text-destructive">
{error}
</p>
) : null}
</div>
);
}