feat(search): pass matchData from server load to DocumentList
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import type { components } from '$lib/generated/api';
|
|||||||
type IncompleteDocumentDTO = components['schemas']['IncompleteDocumentDTO'];
|
type IncompleteDocumentDTO = components['schemas']['IncompleteDocumentDTO'];
|
||||||
type StatsDTO = components['schemas']['StatsDTO'];
|
type StatsDTO = components['schemas']['StatsDTO'];
|
||||||
type Document = components['schemas']['Document'];
|
type Document = components['schemas']['Document'];
|
||||||
|
type SearchMatchData = components['schemas']['SearchMatchData'];
|
||||||
|
|
||||||
export async function load({ url, fetch }) {
|
export async function load({ url, fetch }) {
|
||||||
const q = url.searchParams.get('q') || '';
|
const q = url.searchParams.get('q') || '';
|
||||||
@@ -60,9 +61,14 @@ export async function load({ url, fetch }) {
|
|||||||
throw redirect(302, '/login');
|
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 documents: Document[] = searchResult?.documents ?? [];
|
||||||
const total: number = searchResult?.total ?? 0;
|
const total: number = searchResult?.total ?? 0;
|
||||||
|
const matchData: Record<string, SearchMatchData> = searchResult?.matchData ?? {};
|
||||||
const allPersons = (personsResult.data ?? []) as {
|
const allPersons = (personsResult.data ?? []) as {
|
||||||
id: string;
|
id: string;
|
||||||
firstName: string;
|
firstName: string;
|
||||||
@@ -99,6 +105,7 @@ export async function load({ url, fetch }) {
|
|||||||
isDashboard,
|
isDashboard,
|
||||||
documents,
|
documents,
|
||||||
total,
|
total,
|
||||||
|
matchData,
|
||||||
stats,
|
stats,
|
||||||
incompleteDocs,
|
incompleteDocs,
|
||||||
recentDocs,
|
recentDocs,
|
||||||
@@ -116,6 +123,7 @@ export async function load({ url, fetch }) {
|
|||||||
isDashboard,
|
isDashboard,
|
||||||
documents: [],
|
documents: [],
|
||||||
total: 0,
|
total: 0,
|
||||||
|
matchData: {} as Record<string, SearchMatchData>,
|
||||||
stats: null,
|
stats: null,
|
||||||
incompleteDocs: [],
|
incompleteDocs: [],
|
||||||
recentDocs: [],
|
recentDocs: [],
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ const showRightColumn = $derived(data.canWrite || (data.incompleteDocs?.length ?
|
|||||||
total={data.total ?? 0}
|
total={data.total ?? 0}
|
||||||
q={q}
|
q={q}
|
||||||
sort={sort}
|
sort={sort}
|
||||||
|
matchData={data.matchData ?? {}}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -22,8 +22,23 @@ const emptyData = {
|
|||||||
canWrite: true,
|
canWrite: true,
|
||||||
canAnnotate: false,
|
canAnnotate: false,
|
||||||
isDashboard: 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: [],
|
documents: [],
|
||||||
|
total: 0,
|
||||||
|
matchData: {} as Record<
|
||||||
|
string,
|
||||||
|
import('$lib/generated/api').components['schemas']['SearchMatchData']
|
||||||
|
>,
|
||||||
incompleteDocs: [],
|
incompleteDocs: [],
|
||||||
recentDocs: [],
|
recentDocs: [],
|
||||||
stats: null,
|
stats: null,
|
||||||
|
|||||||
Reference in New Issue
Block a user