refactor(frontend): apply formatDate utility and fix derived/error handling
- Replace 5 inline Intl.DateTimeFormat blocks with formatDate() across home, conversations, persons detail, and document detail pages - Fix coCorrespondents: $derived(() => ...) → $derived.by(...) — the old form typed the value as a function, breaking template call sites - Persons list: throw error on API failure instead of silently returning [] Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import { createApiClient } from '$lib/api.server';
|
||||
import { getErrorMessage } from '$lib/errors';
|
||||
|
||||
export async function load({ url, fetch }) {
|
||||
const q = url.searchParams.get('q') || '';
|
||||
const api = createApiClient(fetch);
|
||||
|
||||
const { data } = await api.GET('/api/persons', {
|
||||
const result = await api.GET('/api/persons', {
|
||||
params: { query: { q: q || undefined } }
|
||||
});
|
||||
|
||||
return { persons: data ?? [], q };
|
||||
if (!result.response.ok) {
|
||||
throw error(result.response.status, getErrorMessage(undefined));
|
||||
}
|
||||
|
||||
return { persons: result.data!, q };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user