diff --git a/src/app/libraries/[libraryId]/page.tsx b/src/app/libraries/[libraryId]/page.tsx index c346a51..3731c57 100644 --- a/src/app/libraries/[libraryId]/page.tsx +++ b/src/app/libraries/[libraryId]/page.tsx @@ -1,6 +1,8 @@ import { PaginatedSeriesGrid } from "@/components/library/PaginatedSeriesGrid"; import { LibraryService } from "@/lib/services/library.service"; import { PreferencesService } from "@/lib/services/preferences.service"; +import { revalidatePath } from "next/cache"; +import { RefreshButton } from "@/components/library/RefreshButton"; interface PageProps { params: { libraryId: string }; @@ -9,6 +11,20 @@ interface PageProps { const PAGE_SIZE = 20; +async function refreshLibrary(libraryId: string) { + "use server"; + + try { + await LibraryService.clearLibrarySeriesCache(libraryId); + + revalidatePath(`/libraries/${libraryId}`); + return { success: true }; + } catch (error) { + console.error("Erreur lors du rafraîchissement:", error); + return { success: false, error: "Erreur lors du rafraîchissement de la bibliothèque" }; + } +} + async function getLibrarySeries(libraryId: string, page: number = 1, unreadOnly: boolean = false) { try { const pageIndex = page - 1; @@ -46,11 +62,14 @@ export default async function LibraryPage({ params, searchParams }: PageProps) {
- {series.totalElements} série{series.totalElements > 1 ? "s" : ""} -
- )} ++ {series.totalElements} série{series.totalElements > 1 ? "s" : ""} +
+ )} +{error instanceof Error ? error.message : "Erreur lors de la récupération des séries"} diff --git a/src/app/series/[seriesId]/page.tsx b/src/app/series/[seriesId]/page.tsx index 8ff71a4..429a9d2 100644 --- a/src/app/series/[seriesId]/page.tsx +++ b/src/app/series/[seriesId]/page.tsx @@ -2,6 +2,8 @@ import { PaginatedBookGrid } from "@/components/series/PaginatedBookGrid"; import { SeriesHeader } from "@/components/series/SeriesHeader"; import { SeriesService } from "@/lib/services/series.service"; import { PreferencesService } from "@/lib/services/preferences.service"; +import { revalidatePath } from "next/cache"; +import { RefreshButton } from "@/components/library/RefreshButton"; interface PageProps { params: { seriesId: string }; @@ -23,6 +25,20 @@ async function getSeriesBooks(seriesId: string, page: number = 1, unreadOnly: bo } } +async function refreshSeries(seriesId: string) { + "use server"; + + try { + await SeriesService.clearSeriesBooksCache(seriesId); + await SeriesService.clearSeriesCache(seriesId); + revalidatePath(`/series/${seriesId}`); + return { success: true }; + } catch (error) { + console.error("Erreur lors du rafraîchissement:", error); + return { success: false, error: "Erreur lors du rafraîchissement de la série" }; + } +} + export default async function SeriesPage({ params, searchParams }: PageProps) { const currentPage = searchParams.page ? parseInt(searchParams.page) : 1; const preferences = await PreferencesService.getPreferences(); @@ -36,7 +52,7 @@ export default async function SeriesPage({ params, searchParams }: PageProps) { return (