import { client } from '$lib/fetch-client'; import { get_config } from '$lib/config'; import type { PageLoad } from './$types'; function maybeInt(input: string | null, fallback: number): number { if (input === null) return fallback; try { return parseInt(input); } catch { return fallback; } } export const load: PageLoad = async ({ fetch, url }) => { const config = await get_config(); if (config.active_project === undefined) { const projects = await client.GET('/projects', { params: { query: { offset: maybeInt(url.searchParams.get('projects_offset'), 0) } }, fetch }); return { projects: projects.data!, reviews: undefined }; } else { const reviews = await client.GET('/project/{projectid}/reviews', { params: { path: { projectid: config.active_project }, query: { offset: maybeInt(url.searchParams.get('reviews_offset'), 0) } }, fetch }); return { projects: undefined, reviews: reviews.data }; } };