ui, server handling improvements

This commit is contained in:
2024-12-23 18:47:22 -08:00
parent 32927dfd55
commit 03fb89dc8b
12 changed files with 106 additions and 115 deletions

View File

@@ -1,10 +1,15 @@
import type { PageLoad } from './$types';
import type { ClientDetails } from '$lib/types/clients';
import { clientDetailsToConfig } from '$lib/clients';
import { error } from '@sveltejs/kit';
export const load: PageLoad = async ({ fetch, params }) => {
const res = await fetch(`/api/clients/${params.id}`);
const client = (await res.json()) as ClientDetails;
const resJson = await res.json();
if (!res.ok) {
return error(res.status, resJson['message']);
}
const client = resJson as ClientDetails;
const config = clientDetailsToConfig(client);
return { client, config };