From 11f6f9e2a23a622557f4d0daafbe3779e389fc40 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 20 Mar 2026 12:11:42 +0100 Subject: [PATCH] refactor(frontend): apply formatDate utility and fix derived/error handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace 5 inline Intl.DateTimeFormat blocks with formatDate() across home, conversations, persons detail, and document detail pages - Fix coCorrespondents: $derived(() => ...) → $derived.by(...) — the old form typed the value as a function, breaking template call sites - Persons list: throw error on API failure instead of silently returning [] Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/routes/+page.svelte | 3 ++- frontend/src/routes/conversations/+page.svelte | 3 ++- frontend/src/routes/documents/[id]/+page.svelte | 3 ++- frontend/src/routes/persons/+page.server.ts | 10 ++++++++-- frontend/src/routes/persons/[id]/+page.svelte | 11 ++++++----- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index 849fe795..55c1be94 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -5,6 +5,7 @@ import TagInput from '$lib/components/TagInput.svelte'; import { slide } from 'svelte/transition'; import { untrack } from 'svelte'; import { m } from '$lib/paraglide/messages.js'; +import { formatDate } from '$lib/utils/date'; let { data } = $props(); @@ -240,7 +241,7 @@ $effect(() => {
- {doc.documentDate ? new Intl.DateTimeFormat('de-DE', { day: 'numeric', month: 'long', year: 'numeric' }).format(new Date(doc.documentDate + 'T12:00:00')) : '—'} + {doc.documentDate ? formatDate(doc.documentDate) : '—'}
{#if doc.location}
diff --git a/frontend/src/routes/conversations/+page.svelte b/frontend/src/routes/conversations/+page.svelte index a22c2881..775649a1 100644 --- a/frontend/src/routes/conversations/+page.svelte +++ b/frontend/src/routes/conversations/+page.svelte @@ -3,6 +3,7 @@ import PersonTypeahead from '$lib/components/PersonTypeahead.svelte'; import { untrack } from 'svelte'; import { m } from '$lib/paraglide/messages.js'; + import { formatDate } from '$lib/utils/date'; let { data } = $props(); @@ -231,7 +232,7 @@ : 'text-gray-500'}" > - {doc.documentDate ? new Intl.DateTimeFormat('de-DE', { day: 'numeric', month: 'long', year: 'numeric' }).format(new Date(doc.documentDate + 'T12:00:00')) : '—'} + {doc.documentDate ? formatDate(doc.documentDate) : '—'} {#if doc.location} diff --git a/frontend/src/routes/documents/[id]/+page.svelte b/frontend/src/routes/documents/[id]/+page.svelte index 35556a13..a9903485 100644 --- a/frontend/src/routes/documents/[id]/+page.svelte +++ b/frontend/src/routes/documents/[id]/+page.svelte @@ -1,5 +1,6 @@