diff --git a/src/app/libraries/page.tsx b/src/app/libraries/page.tsx deleted file mode 100644 index b897862..0000000 --- a/src/app/libraries/page.tsx +++ /dev/null @@ -1,95 +0,0 @@ -"use client"; - -import { useEffect, useState } from "react"; -import { useRouter } from "next/navigation"; -import { KomgaLibrary } from "@/types/komga"; -import { LibraryGrid } from "@/components/library/LibraryGrid"; -import { storageService } from "@/lib/services/storage.service"; - -export default function LibrariesPage() { - const router = useRouter(); - const [libraries, setLibraries] = useState([]); - const [isLoading, setIsLoading] = useState(true); - const [error, setError] = useState(null); - - useEffect(() => { - const fetchLibraries = async () => { - try { - const response = await fetch("/api/komga/libraries"); - if (!response.ok) { - const data = await response.json(); - throw new Error(data.error || "Erreur lors de la récupération des bibliothèques"); - } - - const data = await response.json(); - setLibraries(data); - } catch (error) { - console.error("Erreur:", error); - setError(error instanceof Error ? error.message : "Une erreur est survenue"); - } finally { - setIsLoading(false); - } - }; - - fetchLibraries(); - }, []); - - const handleLibraryClick = (library: KomgaLibrary) => { - router.push(`/libraries/${library.id}`); - }; - - const getLibraryThumbnailUrl = (libraryId: string): string => { - return `/api/komga/thumbnail/libraries/${libraryId}/thumbnail`; - }; - - if (isLoading) { - return ( -
-
-
-

Bibliothèques

-

Chargement des bibliothèques...

-
-
- {[...Array(3)].map((_, i) => ( -
- ))} -
-
-
- ); - } - - if (error) { - return ( -
-
-
-

Bibliothèques

-

Une erreur est survenue

-
-
-

{error}

-
-
-
- ); - } - - return ( -
-
-
-

Bibliothèques

-

Explorez vos bibliothèques Komga

-
- - -
-
- ); -} diff --git a/src/components/layout/Sidebar.tsx b/src/components/layout/Sidebar.tsx index abc791b..2476c78 100644 --- a/src/components/layout/Sidebar.tsx +++ b/src/components/layout/Sidebar.tsx @@ -3,6 +3,8 @@ import Link from "next/link"; import { usePathname, useRouter } from "next/navigation"; import { cn } from "@/lib/utils"; import { authService } from "@/lib/services/auth.service"; +import { useEffect, useState } from "react"; +import { KomgaLibrary } from "@/types/komga"; interface SidebarProps { isOpen: boolean; @@ -11,6 +13,27 @@ interface SidebarProps { export function Sidebar({ isOpen }: SidebarProps) { const pathname = usePathname(); const router = useRouter(); + const [libraries, setLibraries] = useState([]); + const [isLoading, setIsLoading] = useState(true); + + useEffect(() => { + const fetchLibraries = async () => { + try { + const response = await fetch("/api/komga/libraries"); + if (!response.ok) { + throw new Error("Erreur lors de la récupération des bibliothèques"); + } + const data = await response.json(); + setLibraries(data); + } catch (error) { + console.error("Erreur:", error); + } finally { + setIsLoading(false); + } + }; + + fetchLibraries(); + }, []); const handleLogout = () => { authService.logout(); @@ -23,11 +46,6 @@ export function Sidebar({ isOpen }: SidebarProps) { href: "/", icon: Home, }, - { - name: "Bibliothèques", - href: "/libraries", - icon: Library, - }, ]; return ( @@ -37,7 +55,7 @@ export function Sidebar({ isOpen }: SidebarProps) { isOpen ? "translate-x-0" : "-translate-x-full" )} > -
+

Navigation

@@ -57,6 +75,31 @@ export function Sidebar({ isOpen }: SidebarProps) {
+
+
+

Bibliothèques

+ {isLoading ? ( +
Chargement...
+ ) : libraries.length === 0 ? ( +
Aucune bibliothèque
+ ) : ( + libraries.map((library) => ( + + + {library.name} + + )) + )} +
+
+

Configuration