Skip to content

Commit

Permalink
search request fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Apr 24, 2024
1 parent 6e49007 commit 5b62400
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/lib/api/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export async function search(
endpoint.searchParams.set("q", query);

for (const [k, v] of Object.entries(options)) {
endpoint.searchParams.set(k, String(v));
if (v) {
endpoint.searchParams.set(k, String(v));
}
}

const resp = await fetch(endpoint, { credentials: "include" });
Expand Down
2 changes: 2 additions & 0 deletions src/lib/api/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import type { User, Org } from "@/api/types/orgAndUser";
import type { Project } from "@/api/types/project";
import type { Page } from "@/api/types/common";

export type { Page } from "@/api/types/common";

export type Access = "public" | "private" | "organization"; // https://www.documentcloud.org/help/api#access-levels

export type Data = Record<string, string[]>;
Expand Down
5 changes: 2 additions & 3 deletions src/routes/(embed)/stories/project-embed.stories.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script context="module" lang="ts">
import type { Project, ProjectMembershipList } from "$lib/api/types";
// legacy css
import "@/style/variables.css";
import "@/style/global.css";
Expand All @@ -11,6 +9,7 @@
import documents from "$lib/api/fixtures/projects/project-documents-expanded.json";
import project from "$lib/api/fixtures/projects/project.json";
import * as mock from "$lib/api/fixtures/mock";
import type { Page, Project, Document } from "@/lib/api/types";
export const meta = {
title: "Embed / Project",
Expand All @@ -21,7 +20,7 @@
const data = {
project: project as Project,
documents: documents as ProjectMembershipList,
documents: documents as Page<{ document: Document; edit_access: boolean }>,
embed: true,
me: null,
org: null,
Expand Down
2 changes: 1 addition & 1 deletion src/routes/app/projects/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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;
const query = params.query ?? "";
let projects: Project[];
if (list === "owned") {
projects = await getOwned(me.id, query);
Expand Down

0 comments on commit 5b62400

Please sign in to comment.