Some checks failed
CI / Unit & Component Tests (pull_request) Successful in 2m19s
CI / Backend Unit Tests (pull_request) Successful in 2m11s
CI / E2E Tests (pull_request) Failing after 29m32s
CI / Unit & Component Tests (push) Successful in 2m21s
CI / Backend Unit Tests (push) Successful in 2m12s
CI / E2E Tests (push) Failing after 28m54s
Home page shows "Needs metadata" card when incomplete documents exist. /enrich list shows all incomplete documents; /enrich/[id] provides a split PDF-preview + compact form view with Skip / Save / Save & reviewed actions that auto-advance through the queue. New document page gets Save vs Save & reviewed split. Edit page gets "Mark for review" secondary button to push a document back into the queue. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
69 lines
2.1 KiB
TypeScript
69 lines
2.1 KiB
TypeScript
import { redirect } from '@sveltejs/kit';
|
|
import { createApiClient } from '$lib/api.server';
|
|
|
|
export async function load({ url, fetch }) {
|
|
const q = url.searchParams.get('q') || '';
|
|
const from = url.searchParams.get('from') || '';
|
|
const to = url.searchParams.get('to') || '';
|
|
const senderId = url.searchParams.get('senderId') || '';
|
|
const receiverId = url.searchParams.get('receiverId') || '';
|
|
const tags = url.searchParams.getAll('tag');
|
|
|
|
const api = createApiClient(fetch);
|
|
|
|
try {
|
|
const [docsResult, personsResult, incompleteCountResult] = await Promise.all([
|
|
api.GET('/api/documents/search', {
|
|
params: {
|
|
query: {
|
|
q: q || undefined,
|
|
from: from || undefined,
|
|
to: to || undefined,
|
|
senderId: senderId || undefined,
|
|
receiverId: receiverId || undefined,
|
|
tag: tags.length ? tags : undefined
|
|
}
|
|
}
|
|
}),
|
|
api.GET('/api/persons'),
|
|
api.GET('/api/documents/incomplete-count')
|
|
]);
|
|
|
|
if (docsResult.response.status === 401 || personsResult.response.status === 401) {
|
|
throw redirect(302, '/login');
|
|
}
|
|
|
|
const documents = docsResult.data ?? [];
|
|
const allPersons: { id: string; firstName: string; lastName: string }[] =
|
|
personsResult.data ?? [];
|
|
|
|
const senderObj = allPersons.find((p) => p.id === senderId);
|
|
const receiverObj = allPersons.find((p) => p.id === receiverId);
|
|
|
|
const incompleteCount = incompleteCountResult.response.ok
|
|
? (incompleteCountResult.data?.count ?? 0)
|
|
: 0;
|
|
|
|
return {
|
|
documents,
|
|
incompleteCount,
|
|
initialValues: {
|
|
senderName: senderObj ? `${senderObj.firstName} ${senderObj.lastName}` : '',
|
|
receiverName: receiverObj ? `${receiverObj.firstName} ${receiverObj.lastName}` : ''
|
|
},
|
|
filters: { q, from, to, senderId, receiverId, tags },
|
|
error: null as string | null
|
|
};
|
|
} catch (e) {
|
|
if ((e as { status?: number }).status) throw e;
|
|
console.error('Error loading data:', e);
|
|
return {
|
|
documents: [],
|
|
incompleteCount: 0,
|
|
initialValues: { senderName: '', receiverName: '' },
|
|
filters: { q, from, to, senderId, receiverId, tags },
|
|
error: 'Daten konnten nicht geladen werden.' as string | null
|
|
};
|
|
}
|
|
}
|