import React, { useEffect, useState } from 'react'; import { useParams, useNavigate } from 'react-router-dom'; import { MockMangaRepository } from '../../infrastructure/api/mockMangaRepository.js'; import { GetMangaDetail } from '../../application/useCases/getMangaDetail.js'; import { Layout } from '../components/Layout/Layout.jsx'; import { Toolbar } from '../components/Toolbar/Toolbar.jsx'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faStar, faDownload, faEye, faArrowLeft, faRefresh, faBookmark, faShare } from '@fortawesome/free-solid-svg-icons'; const mangaRepository = new MockMangaRepository(); const getMangaDetail = new GetMangaDetail(mangaRepository); export function MangaDetailPage() { const { slug } = useParams(); const navigate = useNavigate(); const [manga, setManga] = useState(null); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const handleRefresh = async () => { setLoading(true); try { const mangaDetail = await getMangaDetail.execute(slug); setManga(mangaDetail); } catch (err) { setError('Failed to load manga details'); console.error(err); } finally { setLoading(false); } }; useEffect(() => { handleRefresh(); }, [slug]); 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: handleRefresh } ], rightSection: [ { icon: faBookmark, onClick: () => {} }, { icon: faShare, onClick: () => {} }, { icon: faDownload, onClick: () => {} } ] }; if (loading) { return
Loading...
; } if (error) { return
{error}
; } return ( {/* Hero section with manga info */}
{manga.title}

{manga.title}

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

{manga.description}

{/* Chapters section */}
{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()}
))}
); }