"use client" import {useEffect, useState} from "react" import { useParams, useRouter } from "next/navigation" import Image from "next/image" import { ArrowLeft, ChevronLeft, ChevronRight, Home } from "lucide-react" import { Button } from "@/components/ui/button" import { ThemeToggle } from "@/components/theme-toggle" import {useGetMangaChapterImages, useMarkAsRead} from "@/api/mangamochi"; export default function ChapterReaderPage() { const params = useParams() const router = useRouter() const mangaId = Number(params.id) const chapterNumber = Number(params.chapterNumber) const { data, isLoading } = useGetMangaChapterImages(chapterNumber); const { mutate } = useMarkAsRead(); const [currentPage, setCurrentPage] = useState(1) useEffect(() => { if (!data) { return; } if (currentPage === data.chapterImageKeys.length) { mutate({chapterId: chapterNumber}); } }, [data, mutate, currentPage]); if (!data) { return (

Manga not found

) } const goToNextPage = () => { if (currentPage < data?.chapterImageKeys.length) { setCurrentPage(currentPage + 1) window.scrollTo({ top: 0, behavior: "smooth" }) } } const goToPreviousPage = () => { if (currentPage > 1) { setCurrentPage(currentPage - 1) window.scrollTo({ top: 0, behavior: "smooth" }) } } return (
{/* Header */}

{data.mangaTitle}

Chapter {chapterNumber}

Page {currentPage} / {data.chapterImageKeys.length}
{/* Reader Content */}
{/* Mobile title */}

{data.mangaTitle}

Chapter {chapterNumber}

{/* Manga Page */}
{`Page
{/* Navigation Controls */}
{/* Page Navigation */}
{currentPage} / {data.chapterImageKeys.length}
{/*/!* Chapter Navigation *!/*/} {/*{(currentPage === data.chapterImageKeys.length || currentPage === 1) && (*/} {/*
*/} {/* */} {/* */} {/* Previous Chapter*/} {/* */} {/* */} {/* Next Chapter*/} {/* */} {/* */} {/*
*/} {/*)}*/}
) }