import React, { useEffect } from 'react'; import { useParams, useNavigate } from 'react-router-dom'; import { Layout } from '../components/Layout/Layout.jsx'; import { Toolbar } from '../components/Toolbar/Toolbar.jsx'; import { useManga } from '../context/MangaContext.jsx'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faStar, faDownload, faEye, faArrowLeft, faRefresh, faBookmark, faShare } from '@fortawesome/free-solid-svg-icons'; export function MangaDetailPage() { const { slug } = useParams(); const navigate = useNavigate(); const { detailedMangas, loading, error, loadMangaDetail, getMangaFromCollection } = useManga(); const manga = detailedMangas[slug]; const collectionManga = getMangaFromCollection(slug); useEffect(() => { // Si on n'a pas les détails du manga, on les charge if (!manga) { loadMangaDetail(slug); } }, [slug, manga, loadMangaDetail]); const handleMangaClick = (mangaSlug) => { navigate(`/manga/${mangaSlug}`); }; const handleAddMangaClick = (query = '') => { navigate(`/add${query ? `?q=${encodeURIComponent(query)}` : ''}`); }; const toolbarConfig = { leftSection: [ { icon: faArrowLeft, onClick: () => navigate(-1) }, { icon: faRefresh, onClick: () => loadMangaDetail(slug) } ], rightSection: [ { icon: faBookmark, onClick: () => {} }, { icon: faShare, onClick: () => {} }, { icon: faDownload, onClick: () => {} } ] }; if (loading) { return
Loading...
; } if (error) { return
{error}
; } // Utiliser les données de base de la collection pendant le chargement des détails const displayManga = manga || collectionManga; if (!displayManga) { return
Manga not found
; } return ( {/* Hero section with manga info */}
{displayManga.title}

{displayManga.title}

{displayManga.status}
{displayManga.rating}
{displayManga.publicationYear} {displayManga.author}
{displayManga.genres.map((genre, index) => ( {genre} ))}

{displayManga.description}

{/* Chapters section - only shown when full details are loaded */} {manga && manga.chapters && (
{Array.from(manga.chapters.entries()).map(([volume, chapters]) => (

Volume {volume || 'Unknown'} ({chapters.length} chapters)

{chapters.map((chapter) => ( ))}
# Title Added Actions
{chapter.number} {chapter.title} {new Date(chapter.createdAt).toLocaleDateString()}
))}
)} ); }