Files
immich-redaktions-plugin/src/app/admin/kalender/CalendarEventForm.tsx
T
Leon TonhäuserandClaude Opus 5.5 71110208a9 Release 2.2.1: quarterly billing and Sakani form polish
- Billing is always quarterly: the billing page opens the current
  quarter, the month view is gone, old ?month= links land in their
  quarter and invalid quarters no longer throw.
- Calendar and release-note forms and the RSVP buttons use Sakani
  components (Card, Input, Textarea, FormSelect, Button, Alert).
- Sidebar logo stays visible in dark mode (Sakani's logo tile is light).
- Release notes for 2.2.1 seeded via custom migration 0004; popup
  version bumped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 22:38:32 +01:00

80 lines
2.6 KiB
TypeScript

"use client";
import { useId, useState, useTransition } from "react";
import { Alert, Input } from "@sakaniui/react";
import { Button } from "@/components/ui/button";
import { Card, FormSelect } from "@/components/ui/sakani";
import type { CalendarActionResult } from "./actions";
export function CalendarEventForm({
action,
defaultEventDate,
albums,
}: Readonly<{
action: (state: CalendarActionResult, formData: FormData) => Promise<CalendarActionResult>;
defaultEventDate: string;
albums: Array<{ id: string; albumName: string }>;
}>) {
const titleId = useId();
const dateId = useId();
const [state, setState] = useState<CalendarActionResult>({ ok: true, message: "" });
const [pending, startTransition] = useTransition();
const [title, setTitle] = useState("");
const handleSubmit = (formData: FormData) => {
startTransition(async () => {
const result = await action({ ok: true, message: "" }, formData);
setState(result);
if (result.ok) {
setTitle("");
}
});
};
return (
<Card title="Neuer Termin">
<form action={handleSubmit} className="flex flex-col gap-4">
<Input
description="Ohne direkte Album-Auswahl wird automatisch verknüpft, sobald ein Album exakt „{Titel}“ oder „{Titel} | TT.MM.JJJJ“ heißt (Datum dieses Termins)."
id={titleId}
label="Titel (Spielpaarung oder Event)"
maxLength={200}
name="title"
onChange={(event) => setTitle(event.target.value)}
placeholder="z. B. Hamburger SV - VfL Wolfsburg"
required
value={title}
/>
<div className="flex flex-col gap-4 sm:flex-row">
<div className="sm:w-48">
<Input defaultValue={defaultEventDate} id={dateId} label="Datum" name="eventDate" required type="date" />
</div>
<div className="flex-1">
<FormSelect
label="Album direkt verknüpfen (optional)"
name="immichAlbumId"
options={[
{ label: "Automatisch über den Namen", value: "" },
...albums.map((album) => ({ label: album.albumName, value: album.id })),
]}
/>
</div>
</div>
<div>
<Button type="submit" disabled={pending}>
{pending ? "Wird angelegt …" : "Termin anlegen"}
</Button>
</div>
{state.message ? (
<div aria-live="polite">
<Alert color={state.ok ? "success" : "danger"} description={state.message} />
</div>
) : null}
</form>
</Card>
);
}