fix: harden download history and attempt ledger

This commit is contained in:
Leon Tonhäuser committed 2026-08-10 16:45:40 +02:00
1 parent 510fde7afa
commit ba673ad732
19 files changed
+2287 -311

No files matched your search

@@ -63,17 +63,6 @@ export function UsageHistoryContent({ history }: Readonly<{ history: UsageHistor
</div>
) : null}
</dl>
{usage.attempts.length === 0 ? (
<p className="usage-attempt-empty">
Keine Auslieferungsversuche auf dieser Auslieferungsseite.
</p>
) : (
<ol className="usage-attempts" aria-label={`Auslieferungen für ${usage.filename}`}>
{usage.attempts.map((attempt) => (
<AttemptRow attempt={attempt} key={attempt.downloadId} />
))}
</ol>
)}
</article>
</li>
))}
@@ -81,21 +70,47 @@ export function UsageHistoryContent({ history }: Readonly<{ history: UsageHistor
)}
<HistoryPagination history={history} />
<section className="usage-attempt-history" aria-labelledby="usage-attempt-title">
<h2 id="usage-attempt-title">Downloadversuche</h2>
{history.attempts.length === 0 ? (
<p className="usage-attempt-empty">Noch keine Downloadversuche erfasst.</p>
) : (
<ol className="usage-attempts" aria-label="Downloadversuche Ihrer Redaktion">
{history.attempts.map((attempt) => (
<AttemptRow attempt={attempt} key={attempt.downloadId} />
))}
</ol>
)}
</section>
<AttemptPagination history={history} />
</section>
);
}
function AttemptRow({ attempt }: Readonly<{ attempt: UsageHistoryAttempt }>) {
const displayedAt = attempt.finishedAt ?? attempt.requestedAt;
return (
<li>
<time dateTime={attempt.finishedAt.toISOString()}>
{formatBerlinDateTime(attempt.finishedAt)}
<time dateTime={displayedAt.toISOString()}>
{formatBerlinDateTime(displayedAt)}
</time>
<span className="usage-attempt-context">
<strong>{attempt.filename}</strong>
<small>
{attempt.albumName} · {attempt.purpose}
{attempt.reference ? ` · ${attempt.reference}` : ""}
</small>
</span>
<strong>{statusLabel(attempt.status)}</strong>
<span>{attempt.repeat ? "Wiederholter Abruf" : "Neue Nutzung"}</span>
<span>{byteFormatter.format(attempt.transferredBytes)}</span>
<b>{priceFormatter.format(attempt.billableCents / 100)}</b>
<span>
{attempt.repeat ? "Wiederholter Abruf" : "Neue Nutzung"} ·{" "}
{byteFormatter.format(attempt.transferredBytes)}
</span>
<span className="usage-attempt-price">
<b>{priceFormatter.format(attempt.billableCents / 100)}</b>
<small>Nutzungspreis {priceFormatter.format(attempt.priceCents / 100)}</small>
</span>
</li>
);
}
@@ -142,6 +157,8 @@ function AttemptPagination({ history }: Readonly<{ history: UsageHistoryPage }>)
function statusLabel(status: UsageHistoryAttempt["status"]): string {
const labels: Record<UsageHistoryAttempt["status"], string> = {
authorized: "Autorisiert",
streaming: "Wird ausgeliefert",
completed: "Abgeschlossen",
interrupted: "Unterbrochen",
failed_before_delivery: "Vor Auslieferung fehlgeschlagen",