Feat: library name on library pages
This commit is contained in:
@@ -18,8 +18,9 @@ async function getLibrarySeries(libraryId: string, page: number = 1, unreadOnly:
|
|||||||
PAGE_SIZE,
|
PAGE_SIZE,
|
||||||
unreadOnly
|
unreadOnly
|
||||||
);
|
);
|
||||||
|
const library = await LibraryService.getLibrary(libraryId);
|
||||||
|
|
||||||
return { data: series };
|
return { data: series, library };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error instanceof Error ? error : new Error("Erreur lors de la récupération des séries");
|
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";
|
const unreadOnly = searchParams.unread === "true";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data: series } = await getLibrarySeries(params.libraryId, currentPage, unreadOnly);
|
const { data: series, library } = await getLibrarySeries(
|
||||||
|
params.libraryId,
|
||||||
|
currentPage,
|
||||||
|
unreadOnly
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container py-8 space-y-8">
|
<div className="container py-8 space-y-8">
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
<h1 className="text-3xl font-bold">Séries</h1>
|
<h1 className="text-3xl font-bold">{library.name}</h1>
|
||||||
{series.totalElements > 0 && (
|
{series.totalElements > 0 && (
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
{series.totalElements} série{series.totalElements > 1 ? "s" : ""}
|
{series.totalElements} série{series.totalElements > 1 ? "s" : ""}
|
||||||
|
|||||||
@@ -19,6 +19,15 @@ export class LibraryService extends BaseApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async getLibrary(libraryId: string): Promise<Library> {
|
||||||
|
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(
|
static async getLibrarySeries(
|
||||||
libraryId: string,
|
libraryId: string,
|
||||||
page: number = 0,
|
page: number = 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user