Skeleton: Fetch static data (teams/drivers/races/substitutions) in global layout asynchronously
All checks were successful
Build Formula11 Docker Image / pocketbase-docker (push) Successful in 29s

This commit is contained in:
2025-02-03 22:34:07 +01:00
parent 3bb2e318b1
commit 346fdb3b75
12 changed files with 259 additions and 363 deletions

View File

@ -14,21 +14,7 @@ export const load: PageServerLoad = async ({ fetch, locals }) => {
return users;
};
// TODO: Duplicated code from data/season/+layout.server.ts + racepicks/+page.server.ts
const fetch_graphics = async (): Promise<Graphic[]> => {
const graphics: Graphic[] = await locals.pb
.collection("graphics")
.getFullList({ fetch: fetch });
graphics.map((graphic: Graphic) => {
graphic.file_url = locals.pb.files.getURL(graphic, graphic.file);
});
return graphics;
};
return {
users: await fetch_users(),
graphics: await fetch_graphics(),
};
};

View File

@ -21,7 +21,7 @@
data_value_name: "avatar_url",
label: "Avatar",
valuefun: async (value: string): Promise<string> =>
`<img class='rounded-full w-10 bg-surface-400' src='${value ? value : get_by_value(data.graphics, "name", "driver_headshot_template")?.file_url}'/>`,
`<img class='rounded-full w-10 bg-surface-400' src='${value ? value : get_by_value(await data.graphics, "name", "driver_headshot_template")?.file_url}'/>`,
},
{
data_value_name: "admin",