fix(documents): WCAG text-size and API error pattern fixes
Some checks failed
CI / Unit & Component Tests (pull_request) Failing after 2m37s
CI / OCR Service Tests (pull_request) Successful in 29s
CI / Unit & Component Tests (push) Failing after 2m44s
CI / OCR Service Tests (push) Successful in 38s
CI / Backend Unit Tests (push) Failing after 2m45s
CI / Backend Unit Tests (pull_request) Failing after 2m45s

- DashboardResumeStrip: text-[10px] → text-xs on collaborator initials (WCAG 1.4.4)
- documents/+page.server.ts: use !result.response.ok per CLAUDE.md; keep narrow try/catch for network-level failures only

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-20 01:17:04 +02:00
parent f2bed92176
commit da2ece986a
2 changed files with 30 additions and 28 deletions

View File

@@ -97,7 +97,7 @@ function safeColor(color: string): string {
</div> </div>
{#each resumeDoc.collaborators.slice(0, 3) as collab (collab.initials + collab.color)} {#each resumeDoc.collaborators.slice(0, 3) as collab (collab.initials + collab.color)}
<span <span
class="-ml-1 inline-flex h-6 w-6 items-center justify-center rounded-full font-sans text-[10px] font-bold text-white ring-2 ring-white" class="-ml-1 inline-flex h-6 w-6 items-center justify-center rounded-full font-sans text-xs font-bold text-white ring-2 ring-white"
style="background:{safeColor(collab.color)}">{collab.initials}</span style="background:{safeColor(collab.color)}">{collab.initials}</span
> >
{/each} {/each}

View File

@@ -1,5 +1,6 @@
import { redirect } from '@sveltejs/kit'; import { redirect } from '@sveltejs/kit';
import { createApiClient } from '$lib/api.server'; import { createApiClient } from '$lib/api.server';
import { getErrorMessage } from '$lib/errors';
import type { components } from '$lib/generated/api'; import type { components } from '$lib/generated/api';
type DocumentSearchItem = components['schemas']['DocumentSearchItem']; type DocumentSearchItem = components['schemas']['DocumentSearchItem'];
@@ -29,8 +30,9 @@ export async function load({ url, fetch }) {
const api = createApiClient(fetch); const api = createApiClient(fetch);
let result;
try { try {
const result = await api.GET('/api/documents/search', { result = await api.GET('/api/documents/search', {
params: { params: {
query: { query: {
q: q || undefined, q: q || undefined,
@@ -46,32 +48,7 @@ export async function load({ url, fetch }) {
} }
} }
}); });
} catch {
if (result.response.status === 401) {
throw redirect(302, '/login');
}
const items: DocumentSearchItem[] = (result.data?.items ?? []) as DocumentSearchItem[];
const total: number = result.data?.total ?? 0;
return {
items,
total,
q,
from,
to,
senderId,
receiverId,
tags,
sort,
dir,
tagQ,
tagOp,
error: null as string | null
};
} catch (e) {
if ((e as { status?: number }).status) throw e;
console.error('Error loading documents:', e);
return { return {
items: [] as DocumentSearchItem[], items: [] as DocumentSearchItem[],
total: 0, total: 0,
@@ -88,4 +65,29 @@ export async function load({ url, fetch }) {
error: 'Daten konnten nicht geladen werden.' as string | null error: 'Daten konnten nicht geladen werden.' as string | null
}; };
} }
if (result.response.status === 401) {
throw redirect(302, '/login');
}
const errorMessage: string | null = !result.response.ok
? (getErrorMessage((result.error as unknown as { code?: string })?.code) ??
'Daten konnten nicht geladen werden.')
: null;
return {
items: (result.data?.items ?? []) as DocumentSearchItem[],
total: result.data?.total ?? 0,
q,
from,
to,
senderId,
receiverId,
tags,
sort,
dir,
tagQ,
tagOp,
error: errorMessage
};
} }