blob: b6b923ebf01fa8c59e8cd30080532b513aabec07 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
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
};
}
};
|