Users: Display driver headshot template if user doesn't have avatar

This commit is contained in:
2025-01-30 21:08:59 +01:00
parent 6ebe30e949
commit 2dc170561d
5 changed files with 21 additions and 12 deletions

View File

@ -1,4 +1,4 @@
import type { User } from "$lib/schema";
import type { Graphic, User } from "$lib/schema";
import type { PageServerLoad } from "./$types";
export const load: PageServerLoad = async ({ fetch, locals }) => {
@ -14,7 +14,21 @@ 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(),
};
};