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>
This commit is contained in:
Leon TonhäuserandClaude Opus 5.5 committed 2026-11-30 22:38:32 +01:00
1 parent c0c2425dda
commit 71110208a9
16 files changed
+2653 -274

No files matched your search

@@ -70,10 +70,8 @@ const defaultProps = {
editorialId: "e1",
repeatDownloads: [] as RepeatDownloadPosition[],
year: 2026,
month: 8 as number | null,
quarter: null as number | null,
isQuarter: false,
periodLabel: "August 2026",
quarter: 3,
periodLabel: "Q3 2026",
reports: [] as FinalizedReportSummary[],
};
@@ -110,7 +108,7 @@ test("disables the checkbox for billed positions and shows report reference", ()
expect(screen.getByText(/RE-2026-042/)).toBeTruthy();
});
test("selects all open positions via Alle offenen im Monat", () => {
test("selects all open positions via Alle offenen im Quartal", () => {
render(
<BillingSelection
{...defaultProps}
@@ -118,7 +116,7 @@ test("selects all open positions via Alle offenen im Monat", () => {
/>,
);
fireEvent.click(screen.getByRole("button", { name: /Alle offenen im Monat/i }));
fireEvent.click(screen.getByRole("button", { name: /Alle offenen im Quartal/i }));
expect(getCheckbox("jubel.jpg").checked).toBe(true);
expect(getCheckbox("redaktion.jpg").checked).toBe(true);
@@ -149,7 +147,7 @@ test("displays selected count and cents-derived EUR total", () => {
/>,
);
fireEvent.click(screen.getByRole("button", { name: /Alle offenen im Monat/i }));
fireEvent.click(screen.getByRole("button", { name: /Alle offenen im Quartal/i }));
const summary = container.querySelector(".billing-summary");
expect(summary?.textContent ?? "").toMatch(/2 Nutzungen ausgewählt/);
@@ -180,30 +178,11 @@ test("shows empty state when no billable positions exist", () => {
expect(screen.getByText(/Keine abrechenbaren Nutzungen/)).toBeTruthy();
});
test("links to quarter view from month view", () => {
render(
<BillingSelection
{...defaultProps}
positions={[openPosition]}
/>,
);
test("offers only quarterly periods", () => {
render(<BillingSelection {...defaultProps} positions={[openPosition]} />);
const quarterLink = screen.getByRole("link", { name: /Ganzes Quartal/i });
expect(quarterLink.getAttribute("href") ?? "").toContain("quarter=3");
expect(screen.queryByRole("link", { name: /Monatsansicht/i })).toBeNull();
expect(screen.queryByText("Monat")).toBeNull();
expect(screen.getByText("Quartal")).toBeTruthy();
expect(screen.getByText(/Zeitraum: Q3 2026/)).toBeTruthy();
});
test("links to month view from quarter view", () => {
render(
<BillingSelection
{...defaultProps}
positions={[openPosition]}
month={null}
quarter={3}
isQuarter={true}
periodLabel="Q3 2026"
/>,
);
const monthLink = screen.getByRole("link", { name: /Monatsansicht/i });
expect(monthLink.getAttribute("href") ?? "").toContain("month=");
});
@@ -1,7 +1,6 @@
"use client";
import { useMemo, useState } from "react";
import Link from "next/link";
import { Alert, Badge, Checkbox, EmptyState, Table, Textarea } from "@sakaniui/react";
import { IconDownload, IconFileText } from "@sakaniui/react/icons";
@@ -17,28 +16,11 @@ type BillingSelectionProps = {
positions: BillingPosition[];
repeatDownloads: RepeatDownloadPosition[];
year: number;
month: number | null;
quarter: number | null;
isQuarter: boolean;
quarter: number;
periodLabel: string;
reports: FinalizedReportSummary[];
};
const MONTHS = [
"Januar",
"Februar",
"März",
"April",
"Mai",
"Juni",
"Juli",
"August",
"September",
"Oktober",
"November",
"Dezember",
];
const STATUS_LABELS: Record<BillingPosition["status"], string> = {
open: "Offen",
billed: "Abgerechnet",
@@ -62,9 +44,7 @@ export function BillingSelection({
positions,
repeatDownloads,
year,
month,
quarter,
isQuarter,
periodLabel,
reports,
}: BillingSelectionProps) {
@@ -107,7 +87,7 @@ export function BillingSelection({
setSelectedIds(new Set());
}
const periodPayload = { year, ...(isQuarter ? { quarter: quarter ?? 1 } : { month: month ?? 1 }) };
const periodPayload = { year, quarter };
async function handlePreview() {
if (selectedIds.size === 0) return;
@@ -195,22 +175,14 @@ export function BillingSelection({
}
}
const quarterParam = isQuarter ? null : Math.ceil((month ?? 1) / 3);
const quarterHref = quarter
? `/admin/abrechnungen/${editorialId}?year=${year}&quarter=${quarter}`
: `/admin/abrechnungen/${editorialId}?year=${year}&quarter=${quarterParam}`;
const monthHref = `/admin/abrechnungen/${editorialId}?year=${year}&month=${month ?? (quarter ? (quarter - 1) * 3 + 1 : new Date().getUTCMonth() + 1)}`;
return (
<>
<PeriodSelector year={year} month={month} quarter={quarter} isQuarter={isQuarter} />
<PeriodSelector year={year} quarter={quarter} />
<div className="flex flex-wrap items-center gap-3">
<Button type="button" variant="secondary" onClick={selectAllOpen} disabled={selectablePositions.length === 0}>
{isQuarter ? "Alle offenen im Quartal" : "Alle offenen im Monat"}
</Button>
<Button asChild variant="outline">
{isQuarter ? <Link href={monthHref}>Monatsansicht</Link> : <Link href={quarterHref}>Ganzes Quartal</Link>}
Alle offenen im Quartal
</Button>
<Button type="button" variant="ghost" onClick={clearSelection} disabled={selectedCount === 0}>
Auswahl aufheben
@@ -223,7 +195,7 @@ export function BillingSelection({
<section className="flex flex-col gap-3" aria-labelledby="positions-title">
<h2 id="positions-title" className="text-lg font-semibold">Abrechenbare Nutzungen</h2>
{positions.length === 0 ? (
<EmptyState title="Keine abrechenbaren Nutzungen in diesem Zeitraum." description="Wählen Sie oben einen anderen Monat oder ein Quartal." />
<EmptyState title="Keine abrechenbaren Nutzungen in diesem Zeitraum." description="Wählen Sie oben ein anderes Quartal." />
) : (
<Table<BillingPosition>
rowKey={(position) => position.id}
@@ -426,12 +398,10 @@ export function BillingSelection({
type PeriodSelectorProps = {
year: number;
month: number | null;
quarter: number | null;
isQuarter: boolean;
quarter: number;
};
function PeriodSelector({ year, month, quarter, isQuarter }: PeriodSelectorProps) {
function PeriodSelector({ year, quarter }: PeriodSelectorProps) {
const years = [2025, 2026, 2027];
return (
@@ -440,25 +410,14 @@ function PeriodSelector({ year, month, quarter, isQuarter }: PeriodSelectorProps
<div className="w-32">
<FormSelect name="year" label="Jahr" defaultValue={String(year)} options={years.map((y) => ({ label: String(y), value: String(y) }))} />
</div>
{isQuarter ? (
<div className="w-32">
<FormSelect
name="quarter"
label="Quartal"
defaultValue={String(quarter ?? 1)}
options={[1, 2, 3, 4].map((q) => ({ label: `Q${q}`, value: String(q) }))}
/>
</div>
) : (
<div className="w-40">
<FormSelect
name="month"
label="Monat"
defaultValue={String(month ?? 8)}
options={MONTHS.map((name, index) => ({ label: name, value: String(index + 1) }))}
/>
</div>
)}
<div className="w-32">
<FormSelect
name="quarter"
label="Quartal"
defaultValue={String(quarter)}
options={[1, 2, 3, 4].map((q) => ({ label: `Q${q}`, value: String(q) }))}
/>
</div>
<Button type="submit" variant="secondary">Zeitraum laden</Button>
</form>
</Card>
@@ -0,0 +1,13 @@
import { expect, test } from "vitest";
import { resolvePeriod } from "./page-content";
test("resolvePeriod is always quarterly", () => {
expect(resolvePeriod({ year: "2026", quarter: "4" })).toMatchObject({ year: 2026, quarter: 4, periodLabel: "Q4 2026" });
// Old month links land in their quarter.
expect(resolvePeriod({ year: "2026", month: "8" })).toMatchObject({ quarter: 3, periodLabel: "Q3 2026" });
// Invalid quarters fall back to the current one instead of throwing.
const current = Math.floor(new Date().getUTCMonth() / 3) + 1;
expect(resolvePeriod({ year: "2026", quarter: "7" }).quarter).toBe(current);
expect(resolvePeriod({}).quarter).toBe(current);
});
@@ -5,7 +5,7 @@ import { desc, eq } from "drizzle-orm";
import { db } from "@/db/client";
import { billingReports, editorialAccounts } from "@/db/schema";
import { queries } from "@/modules/billing/queries";
import { monthPeriod, quarterPeriod, type BillingPeriod } from "@/modules/billing/period";
import { quarterPeriod, type BillingPeriod } from "@/modules/billing/period";
import type { BillingPosition, RepeatDownloadPosition } from "@/modules/billing/queries";
export type FinalizedReportSummary = {
@@ -25,10 +25,8 @@ export type BillingSelectionData = {
editorial: { id: string; name: string };
period: BillingPeriod;
periodLabel: string;
isQuarter: boolean;
year: number;
month: number | null;
quarter: number | null;
quarter: number;
positions: BillingPosition[];
repeatDownloads: RepeatDownloadPosition[];
reports: FinalizedReportSummary[];
@@ -45,7 +43,7 @@ export async function loadBillingSelection(
.limit(1);
if (!editorial) return null;
const { period, isQuarter, year, month, quarter, periodLabel } = resolvePeriod(searchParams);
const { period, year, quarter, periodLabel } = resolvePeriod(searchParams);
const [positions, repeatDownloads, reportRows] = await Promise.all([
queries.listBillablePositions(editorialId, period),
@@ -72,9 +70,7 @@ export async function loadBillingSelection(
editorial,
period,
periodLabel,
isQuarter,
year,
month,
quarter,
positions,
repeatDownloads,
@@ -93,60 +89,26 @@ export async function loadBillingSelection(
};
}
/**
* Billing is always quarterly. An old `?month=` link resolves to its quarter;
* invalid values fall back to the current quarter.
*/
export function resolvePeriod(searchParams: Record<string, string | string[] | undefined>): {
period: BillingPeriod;
isQuarter: boolean;
year: number;
month: number | null;
quarter: number | null;
quarter: number;
periodLabel: string;
} {
const now = new Date();
const defaultYear = now.getUTCFullYear();
const defaultMonth = now.getUTCMonth() + 1;
const year = parseNumberParam(searchParams.year, defaultYear);
const quarterParam = firstParam(searchParams.quarter);
if (quarterParam !== undefined) {
const quarter = parseNumberParam(searchParams.quarter, Math.floor((defaultMonth - 1) / 3) + 1);
return {
period: quarterPeriod(year, quarter),
isQuarter: true,
year,
month: null,
quarter,
periodLabel: `Q${quarter} ${year}`,
};
}
const month = parseNumberParam(searchParams.month, defaultMonth);
return {
period: monthPeriod(year, month),
isQuarter: false,
year,
month,
quarter: null,
periodLabel: monthLabel(year, month),
};
}
function monthLabel(year: number, month: number): string {
const names = [
"Januar",
"Februar",
"März",
"April",
"Mai",
"Juni",
"Juli",
"August",
"September",
"Oktober",
"November",
"Dezember",
];
return `${names[month - 1]} ${year}`;
const currentQuarter = Math.floor(now.getUTCMonth() / 3) + 1;
const year = parseNumberParam(searchParams.year, now.getUTCFullYear());
const month = parseNumberParam(searchParams.month, 0);
const requested = parseNumberParam(
searchParams.quarter,
month >= 1 && month <= 12 ? Math.floor((month - 1) / 3) + 1 : currentQuarter,
);
const quarter = requested >= 1 && requested <= 4 ? requested : currentQuarter;
return { period: quarterPeriod(year, quarter), year, quarter, periodLabel: `Q${quarter} ${year}` };
}
function parseNumberParam(
@@ -32,9 +32,7 @@ export default async function BillingSelectionPage({
positions={data.positions}
repeatDownloads={data.repeatDownloads}
year={data.year}
month={data.month}
quarter={data.quarter}
isQuarter={data.isQuarter}
periodLabel={data.periodLabel}
reports={data.reports}
/>
+1 -1
View File
@@ -27,7 +27,7 @@ export default async function BillingOverviewPage() {
kicker="Abrechnungen"
title="Redaktionen"
titleId="billing-title"
description="Wählen Sie eine Redaktion, um deren abrechenbare Nutzungen für einen Monat oder ein Quartal auszuwählen."
description="Wählen Sie eine Redaktion, um deren abrechenbare Nutzungen für ein Quartal auszuwählen."
/>
{editorials.length === 0 ? (
<EmptyState title="Noch keine Redaktionen registriert." description="Registrierte Redaktionen erscheinen hier zur Abrechnung." />
+36 -56
View File
@@ -2,8 +2,10 @@
import { useId, useState, useTransition } from "react";
import { Alert, Input } from "@sakaniui/react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Card, FormSelect } from "@/components/ui/sakani";
import type { CalendarActionResult } from "./actions";
@@ -18,7 +20,6 @@ export function CalendarEventForm({
}>) {
const titleId = useId();
const dateId = useId();
const albumId = useId();
const [state, setState] = useState<CalendarActionResult>({ ok: true, message: "" });
const [pending, startTransition] = useTransition();
const [title, setTitle] = useState("");
@@ -34,66 +35,45 @@ export function CalendarEventForm({
};
return (
<form
action={handleSubmit}
className="bg-card p-4 rounded-xl border border-border shadow-sm space-y-4"
>
<div className="space-y-2">
<label htmlFor={titleId} className="text-sm font-medium">
Titel (Spielpaarung oder Event)
</label>
<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}
name="title"
value={title}
onChange={(event) => setTitle(event.target.value)}
label="Titel (Spielpaarung oder Event)"
maxLength={200}
required
name="title"
onChange={(event) => setTitle(event.target.value)}
placeholder="z. B. Hamburger SV - VfL Wolfsburg"
required
value={title}
/>
<p className="text-xs text-muted-foreground">
Ohne direkte Album-Auswahl wird automatisch verknüpft, sobald ein Album exakt
{" „{Titel}“ "}oder{" „{Titel} | TT.MM.JJJJ“ "}heißt (Datum dieses Termins).
</p>
</div>
<div className="flex flex-col sm:flex-row gap-4">
<div className="space-y-2">
<label htmlFor={dateId} className="text-sm font-medium">
Datum
</label>
<Input id={dateId} type="date" name="eventDate" defaultValue={defaultEventDate} required className="sm:w-48" />
<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 className="space-y-2 flex-1">
<label htmlFor={albumId} className="text-sm font-medium">
Album direkt verknüpfen (optional)
</label>
<select
id={albumId}
name="immichAlbumId"
defaultValue=""
className="flex h-10 w-full rounded-md border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary-500"
>
<option value="">Automatisch über den Namen</option>
{albums.map((album) => (
<option key={album.id} value={album.id}>
{album.albumName}
</option>
))}
</select>
<div>
<Button type="submit" disabled={pending}>
{pending ? "Wird angelegt …" : "Termin anlegen"}
</Button>
</div>
</div>
<Button type="submit" disabled={pending}>
{pending ? "Wird angelegt…" : "Termin anlegen"}
</Button>
{state.message ? (
<p
role="status"
aria-live="polite"
className={state.ok ? "text-sm text-green-600 dark:text-green-400" : "text-sm text-destructive"}
>
{state.message}
</p>
) : null}
</form>
{state.message ? (
<div aria-live="polite">
<Alert color={state.ok ? "success" : "danger"} description={state.message} />
</div>
) : null}
</form>
</Card>
);
}
+40 -53
View File
@@ -2,8 +2,10 @@
import { useId, useState, useTransition } from "react";
import { Alert, Input, Textarea } from "@sakaniui/react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Card, FormSelect } from "@/components/ui/sakani";
import type { ReleaseNoteActionResult } from "./actions";
@@ -13,7 +15,6 @@ export function ReleaseNoteForm({
action: (state: ReleaseNoteActionResult, formData: FormData) => Promise<ReleaseNoteActionResult>;
}>) {
const versionId = useId();
const audienceId = useId();
const bodyId = useId();
const [state, setState] = useState<ReleaseNoteActionResult>({ ok: true, message: "" });
const [pending, startTransition] = useTransition();
@@ -30,62 +31,48 @@ export function ReleaseNoteForm({
};
return (
<form
action={handleSubmit}
className="bg-card p-4 rounded-xl border border-border shadow-sm space-y-4"
>
<div className="flex flex-col sm:flex-row gap-4">
<div className="space-y-2">
<label htmlFor={versionId} className="text-sm font-medium">
Version
</label>
<Input id={versionId} name="version" placeholder="z. B. 2.1.1" required className="sm:w-36" />
<Card title="Neuer Versionshinweis">
<form action={handleSubmit} className="flex flex-col gap-4">
<div className="flex flex-col gap-4 sm:flex-row">
<div className="sm:w-36">
<Input id={versionId} label="Version" name="version" placeholder="z. B. 2.1.1" required />
</div>
<div className="sm:w-48">
<FormSelect
defaultValue="editorial"
label="Zielgruppe"
name="audience"
options={[
{ label: "Redaktionen", value: "editorial" },
{ label: "Admins", value: "admin" },
{ label: "Beide", value: "both" },
]}
/>
</div>
</div>
<div className="space-y-2">
<label htmlFor={audienceId} className="text-sm font-medium">
Zielgruppe
</label>
<select
id={audienceId}
name="audience"
defaultValue="editorial"
className="flex h-10 w-full sm:w-48 rounded-md border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary-500"
>
<option value="editorial">Redaktionen</option>
<option value="admin">Admins</option>
<option value="both">Beide</option>
</select>
</div>
</div>
<div className="space-y-2">
<label htmlFor={bodyId} className="text-sm font-medium">
Hinweis
</label>
<textarea
<Textarea
description={`${body.length}/2000 Zeichen`}
id={bodyId}
name="body"
rows={4}
label="Hinweis"
maxLength={2000}
required
value={body}
name="body"
onChange={(event) => setBody(event.target.value)}
placeholder="Was ist neu in dieser Version?"
className="flex w-full rounded-md border border-border bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
required
rows={4}
value={body}
/>
<p className="text-xs text-muted-foreground">{body.length}/2000 Zeichen</p>
</div>
<Button type="submit" disabled={pending}>
{pending ? "Wird veröffentlicht…" : "Hinweis veröffentlichen"}
</Button>
{state.message ? (
<p
role="status"
aria-live="polite"
className={state.ok ? "text-sm text-green-600 dark:text-green-400" : "text-sm text-destructive"}
>
{state.message}
</p>
) : null}
</form>
<div>
<Button type="submit" disabled={pending}>
{pending ? "Wird veröffentlicht …" : "Hinweis veröffentlichen"}
</Button>
</div>
{state.message ? (
<div aria-live="polite">
<Alert color={state.ok ? "success" : "danger"} description={state.message} />
</div>
) : null}
</form>
</Card>
);
}