feat(search): pass matchData from server load to DocumentList
Some checks failed
CI / Unit & Component Tests (push) Failing after 2m46s
CI / Backend Unit Tests (push) Failing after 2m49s
CI / Unit & Component Tests (pull_request) Failing after 2m32s
CI / Backend Unit Tests (pull_request) Failing after 2m36s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-15 18:34:54 +02:00
parent 93c78433cf
commit ddb87db6b7
3 changed files with 26 additions and 2 deletions

View File

@@ -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<string, SearchMatchData>;
} | null;
const documents: Document[] = searchResult?.documents ?? [];
const total: number = searchResult?.total ?? 0;
const matchData: Record<string, SearchMatchData> = 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<string, SearchMatchData>,
stats: null,
incompleteDocs: [],
recentDocs: [],

View File

@@ -140,6 +140,7 @@ const showRightColumn = $derived(data.canWrite || (data.incompleteDocs?.length ?
total={data.total ?? 0}
q={q}
sort={sort}
matchData={data.matchData ?? {}}
/>
{/if}
</main>

View File

@@ -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,