From bb29cac49632f4b9684b32225c05d6171ff7ae88 Mon Sep 17 00:00:00 2001 From: Marcel Date: Wed, 15 Apr 2026 18:34:54 +0200 Subject: [PATCH] feat(search): pass matchData from server load to DocumentList Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/routes/+page.server.ts | 10 +++++++++- frontend/src/routes/+page.svelte | 1 + frontend/src/routes/page.svelte.spec.ts | 17 ++++++++++++++++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/frontend/src/routes/+page.server.ts b/frontend/src/routes/+page.server.ts index da2a12e2..e1386db8 100644 --- a/frontend/src/routes/+page.server.ts +++ b/frontend/src/routes/+page.server.ts @@ -5,6 +5,7 @@ import type { components } from '$lib/generated/api'; type IncompleteDocumentDTO = components['schemas']['IncompleteDocumentDTO']; type StatsDTO = components['schemas']['StatsDTO']; type Document = components['schemas']['Document']; +type SearchMatchData = components['schemas']['SearchMatchData']; export async function load({ url, fetch }) { const q = url.searchParams.get('q') || ''; @@ -60,9 +61,14 @@ export async function load({ url, fetch }) { throw redirect(302, '/login'); } - const searchResult = docsResult?.data as { documents?: Document[]; total?: number } | null; + const searchResult = docsResult?.data as { + documents?: Document[]; + total?: number; + matchData?: Record; + } | null; const documents: Document[] = searchResult?.documents ?? []; const total: number = searchResult?.total ?? 0; + const matchData: Record = searchResult?.matchData ?? {}; const allPersons = (personsResult.data ?? []) as { id: string; firstName: string; @@ -99,6 +105,7 @@ export async function load({ url, fetch }) { isDashboard, documents, total, + matchData, stats, incompleteDocs, recentDocs, @@ -116,6 +123,7 @@ export async function load({ url, fetch }) { isDashboard, documents: [], total: 0, + matchData: {} as Record, stats: null, incompleteDocs: [], recentDocs: [], diff --git a/frontend/src/routes/+page.svelte b/frontend/src/routes/+page.svelte index ff5c7ebd..bbdfae44 100644 --- a/frontend/src/routes/+page.svelte +++ b/frontend/src/routes/+page.svelte @@ -140,6 +140,7 @@ const showRightColumn = $derived(data.canWrite || (data.incompleteDocs?.length ? total={data.total ?? 0} q={q} sort={sort} + matchData={data.matchData ?? {}} /> {/if} diff --git a/frontend/src/routes/page.svelte.spec.ts b/frontend/src/routes/page.svelte.spec.ts index 28f58d3f..9b577a12 100644 --- a/frontend/src/routes/page.svelte.spec.ts +++ b/frontend/src/routes/page.svelte.spec.ts @@ -22,8 +22,23 @@ const emptyData = { canWrite: true, canAnnotate: false, isDashboard: false, - filters: { q: '', from: '', to: '', senderId: '', receiverId: '', tags: [] }, + filters: { + q: '', + from: '', + to: '', + senderId: '', + receiverId: '', + tags: [], + sort: 'DATE' as const, + dir: 'desc' as const, + tagQ: '' + }, documents: [], + total: 0, + matchData: {} as Record< + string, + import('$lib/generated/api').components['schemas']['SearchMatchData'] + >, incompleteDocs: [], recentDocs: [], stats: null,