diff --git a/src/lib/api/projects.ts b/src/lib/api/projects.ts index bd5ce35de..7869bf5d0 100644 --- a/src/lib/api/projects.ts +++ b/src/lib/api/projects.ts @@ -66,9 +66,13 @@ export async function list( /** * Get a list of all projects owned by the user */ -export async function getOwned(userId: number): Promise { +export async function getOwned( + userId: number, + query?: string, +): Promise { const endpoint = new URL("projects/", BASE_API_URL); endpoint.searchParams.set("user", String(userId)); + endpoint.searchParams.set("query", query); const projects = await getAll(endpoint); return projects.filter((project) => project.user === userId); } @@ -76,9 +80,13 @@ export async function getOwned(userId: number): Promise { /** * Get a list of all projects shared with the user */ -export async function getShared(userId: number): Promise { +export async function getShared( + userId: number, + query?: string, +): Promise { const endpoint = new URL("projects/", BASE_API_URL); endpoint.searchParams.set("user", String(userId)); + endpoint.searchParams.set("query", query); const projects = await getAll(endpoint); return projects.filter((project) => project.user !== userId); } diff --git a/src/routes/app/projects/+page.ts b/src/routes/app/projects/+page.ts index d5f991405..887a5d8a7 100644 --- a/src/routes/app/projects/+page.ts +++ b/src/routes/app/projects/+page.ts @@ -5,11 +5,12 @@ export async function load({ url, parent, fetch }) { const { me } = await parent(); const params = Object.fromEntries(url.searchParams.entries()); const list = params.list ?? "owned"; + const query = params.query; let projects: Project[]; if (list === "owned") { - projects = await getOwned(me.id); + projects = await getOwned(me.id, query); } else if (list === "shared") { - projects = await getShared(me.id); + projects = await getShared(me.id, query); } return {