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

+2 -2
View File
@@ -6,12 +6,12 @@ export function BrandLogo() {
<img
alt="Leon Tonhäuser Sportfotografie"
className="brand-logo brand-logo-light"
src="/brand/logo-black.png"
src="/brand/logo-black-header.png"
/>
<img
alt="Leon Tonhäuser Sportfotografie"
className="brand-logo brand-logo-dark"
src="/brand/logo-white.png"
src="/brand/logo-white-header.png"
/>
</>
);
@@ -107,6 +107,58 @@ test("reuses one idempotency key when the same failed submission is retried", as
}
});
test("collab checkbox only appears for enabled editorials and sends collab with price 0", async () => {
vi.spyOn(globalThis.crypto, "randomUUID").mockReturnValue(idempotencyKey);
const fetch = vi.fn().mockResolvedValue(
Response.json({
downloadId: "66666666-6666-4666-8666-666666666666",
fileUrl: "/api/downloads/66666666-6666-4666-8666-666666666666/file",
priceCents: 0,
billable: true,
}),
);
vi.stubGlobal("fetch", fetch);
vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(() => {});
const { unmount } = render(
<UsageDialog
albumId="33333333-3333-4333-8333-333333333333"
assetId="22222222-2222-4222-8222-222222222222"
filename="tor-des-monats.jpg"
newUsagePriceCents={1_500}
priorUsages={[]}
/>,
);
fireEvent.click(screen.getByRole("button", { name: /original laden/i }));
expect(screen.queryByRole("checkbox", { name: /collab/i })).toBeNull();
unmount();
render(
<UsageDialog
albumId="33333333-3333-4333-8333-333333333333"
assetId="22222222-2222-4222-8222-222222222222"
filename="tor-des-monats.jpg"
newUsagePriceCents={1_500}
priorUsages={[]}
collabEnabled
/>,
);
fireEvent.click(screen.getByRole("button", { name: /original laden/i }));
const checkbox = screen.getByRole("checkbox", { name: /collab-nutzung \(kostenfrei\)/i });
fireEvent.click(checkbox);
expect(screen.getByText("0,00 €")).not.toBeNull();
fireEvent.change(screen.getByRole("textbox", { name: /^verwendungszweck$/i }), {
target: { value: "Collab Strecke" },
});
fireEvent.click(screen.getByRole("button", { name: /download anfordern/i }));
await waitFor(() => expect(fetch).toHaveBeenCalledOnce());
expect(JSON.parse(String(fetch.mock.calls[0][1]?.body))).toMatchObject({
kind: "new_usage",
collab: true,
});
});
test("suppresses double-click submission while one request is pending", async () => {
vi.spyOn(globalThis.crypto, "randomUUID").mockReturnValue(idempotencyKey);
let resolveRequest: ((response: Response) => void) | undefined;
+26 -1
View File
@@ -11,6 +11,7 @@ type UsageDialogProps = Readonly<{
filename: string;
newUsagePriceCents: number;
priorUsages: DownloadDialogUsage[];
collabEnabled?: boolean;
}>;
type IntentResponse = {
@@ -31,18 +32,21 @@ export function UsageDialog({
filename,
newUsagePriceCents,
priorUsages,
collabEnabled = false,
}: UsageDialogProps) {
const dialogRef = useRef<HTMLDialogElement>(null);
const firstChoiceRef = useRef<HTMLInputElement>(null);
const idempotencyKeyRef = useRef<string | null>(null);
const initialChoice = priorUsages[0] ? `repeat:${priorUsages[0].id}` : "new_usage";
const [choice, setChoice] = useState(initialChoice);
const [collab, setCollab] = useState(false);
const [purpose, setPurpose] = useState("");
const [pending, setPending] = useState(false);
const [error, setError] = useState<string | null>(null);
function openDialog() {
setChoice(initialChoice);
setCollab(false);
setPurpose("");
setPending(false);
setError(null);
@@ -79,6 +83,7 @@ export function UsageDialog({
albumId,
purpose,
idempotencyKey: idempotencyKeyRef.current,
...(collab ? { collab: true } : {}),
};
try {
@@ -175,10 +180,28 @@ export function UsageDialog({
<strong>Neue Nutzung</strong>
<small>Neue Veröffentlichung oder neuer Verwendungszweck</small>
</span>
<b>{priceFormatter.format(newUsagePriceCents / 100)}</b>
<b>{priceFormatter.format((collab ? 0 : newUsagePriceCents) / 100)}</b>
</label>
</fieldset>
{collabEnabled && isNewUsage ? (
<label className="usage-collab-option">
<input
checked={collab}
disabled={pending}
onChange={(event) => {
setCollab(event.target.checked);
resetSubmission();
}}
type="checkbox"
/>
<span>
<strong>Collab-Nutzung (kostenfrei)</strong>
<small>Diese Nutzung wird mit 0,00 € in der Abrechnung geführt.</small>
</span>
</label>
) : null}
<label className="usage-purpose" htmlFor={`usage-purpose-${assetId}`}>
Verwendungszweck
<textarea
@@ -242,6 +265,8 @@ function downloadErrorMessage(code: string | null, status: number): string {
switch (code) {
case "FORBIDDEN":
return "Ihr Konto ist nicht freigegeben oder gesperrt.";
case "COLLAB_NOT_ENABLED":
return "Collab-Nutzung ist für Ihr Konto nicht freigeschaltet. Bitte den Admin, die Option zu aktivieren.";
case "INVALID_REQUEST":
return "Die Anfrage war unvollständig. Bitte laden Sie die Seite neu und versuchen Sie es erneut.";
case "IDEMPOTENCY_CONFLICT":
+2 -2
View File
@@ -36,8 +36,8 @@ export function PortalShell({
<div className="flex items-center"><BrandLogo /></div>
</Link>
<div className="flex items-center gap-6 text-sm font-medium">
<span className="hidden md:inline-block text-muted-foreground uppercase tracking-widest text-xs font-bold">{sectionLabel}</span>
<nav aria-label={sectionLabel} className="hidden sm:flex items-center gap-6">
<span className="hidden lg:inline-block text-muted-foreground uppercase tracking-widest text-xs font-bold">{sectionLabel}</span>
<nav aria-label={sectionLabel} className="hidden sm:flex items-center gap-4 lg:gap-6">
{nav.map((item) => (
<Link
key={item.href}