feat(#145): add DashboardRecentDocuments widget component

Shows recently reviewed documents as a dashboard widget with formatted
dates. Renders nothing when the list is empty.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-03-29 00:42:54 +01:00
parent 1d08522df8
commit df79eec5cc
2 changed files with 105 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
<script lang="ts">
type Document = {
id: string;
title: string;
documentDate?: string;
sender?: { id: string; firstName: string; lastName: string };
};
interface Props {
recentDocs: Document[];
}
let { recentDocs }: Props = $props();
function formatDate(dateStr: string): string {
return new Intl.DateTimeFormat('de-DE', {
day: 'numeric',
month: 'long',
year: 'numeric'
}).format(new Date(dateStr + 'T12:00:00'));
}
</script>
{#if recentDocs.length > 0}
<div data-testid="dashboard-recent-docs" class="border-brand-sand rounded-sm border bg-white p-6">
<h2 class="mb-4 font-sans text-xs font-bold tracking-widest text-gray-400 uppercase">
Zuletzt hinzugefügt
</h2>
{#each recentDocs as doc (doc.id)}
<div class="border-brand-sand flex items-center justify-between border-b py-2 last:border-0">
<a
href="/documents/{doc.id}"
class="font-serif text-sm text-ink hover:text-brand-navy hover:underline"
>
{doc.title}
</a>
{#if doc.documentDate}
<span
data-testid="doc-date-{doc.id}"
class="ml-2 shrink-0 font-sans text-xs text-gray-400"
>
{formatDate(doc.documentDate)}
</span>
{/if}
</div>
{/each}
</div>
{/if}