Skip to content

Commit

Permalink
update collection list call
Browse files Browse the repository at this point in the history
  • Loading branch information
jackiequach committed Dec 19, 2024
1 parent 715717a commit 9388d5c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion mocks/mockEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export const LIMITED_ACCESS_EDITION_PATH = "/edition/6977884";
export const WORK_PATH = "/work/5950e6df-9d99-42fe-8924-1116166a2acb";
export const DOWNLOAD_PATH = "/test-download-pdf";
export const HOME_PATH = "/";
export const COLLECTION_LIST_PATH = "/collection/list";
export const COLLECTION_LIST_PATH = "/collections";
export const INVALID_COLLECTION_PATH = "/collection/invalid-collection";
4 changes: 2 additions & 2 deletions src/__tests__/fixtures/CollectionFixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export const oneCollectionListData: Opds2Feed = {
],
links: [
{
href: "/collection/list?page=1",
href: "/collections?page=1",
rel: ["self", "first", "previous", "next", "last"],
type: "application/opds+json",
},
Expand Down Expand Up @@ -1721,7 +1721,7 @@ export const collectionListData: CollectionResult = {
],
links: [
{
href: "/collection/list?page=1",
href: "/collections?page=1",
rel: ["self", "first", "previous", "next", "last"],
type: "application/opds+json",
},
Expand Down
5 changes: 4 additions & 1 deletion src/lib/api/CollectionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ const collectionUrl = apiUrl + collectionPath;
export const collectionFetcher = async (query: CollectionQuery) => {
const collectionApiQuery = toApiCollectionQuery(query);

const url = new URL(collectionUrl + "/" + query.identifier);
const urlWithIdentifier = query.identifier
? collectionUrl + "/" + query.identifier
: collectionUrl;
const url = new URL(urlWithIdentifier);
url.search = new URLSearchParams(
toLocationQuery(collectionApiQuery)
).toString();
Expand Down
1 change: 0 additions & 1 deletion src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Error from "./_error";
export async function getServerSideProps() {
// Fetch all collections
const collectionResult: CollectionResult = await collectionFetcher({
identifier: "list",
perPage: 8,
});

Expand Down
2 changes: 1 addition & 1 deletion src/types/CollectionQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type ApiCollectionQuery = {
};

export type CollectionQuery = {
identifier: string;
identifier?: string;
page?: number;
perPage?: number;
sort?: string;
Expand Down

0 comments on commit 9388d5c

Please sign in to comment.