diff --git a/src/app/libraries/[libraryId]/page.tsx b/src/app/libraries/[libraryId]/page.tsx index 6fdb6b5..a3787eb 100644 --- a/src/app/libraries/[libraryId]/page.tsx +++ b/src/app/libraries/[libraryId]/page.tsx @@ -18,8 +18,9 @@ async function getLibrarySeries(libraryId: string, page: number = 1, unreadOnly: PAGE_SIZE, unreadOnly ); + const library = await LibraryService.getLibrary(libraryId); - return { data: series }; + return { data: series, library }; } catch (error) { throw error instanceof Error ? error : new Error("Erreur lors de la récupération des séries"); } @@ -30,12 +31,16 @@ export default async function LibraryPage({ params, searchParams }: PageProps) { const unreadOnly = searchParams.unread === "true"; try { - const { data: series } = await getLibrarySeries(params.libraryId, currentPage, unreadOnly); + const { data: series, library } = await getLibrarySeries( + params.libraryId, + currentPage, + unreadOnly + ); return (
-

Séries

+

{library.name}

{series.totalElements > 0 && (

{series.totalElements} série{series.totalElements > 1 ? "s" : ""} diff --git a/src/lib/services/library.service.ts b/src/lib/services/library.service.ts index 0b1e89d..101c4f1 100644 --- a/src/lib/services/library.service.ts +++ b/src/lib/services/library.service.ts @@ -19,6 +19,15 @@ export class LibraryService extends BaseApiService { } } + static async getLibrary(libraryId: string): Promise { + const libraries = await this.getLibraries(); + const library = libraries.find((library) => library.id === libraryId); + if (!library) { + throw new Error(`Bibliothèque ${libraryId} non trouvée`); + } + return library; + } + static async getLibrarySeries( libraryId: string, page: number = 0,