import React from 'react';
import { Download, Loader2, Trash2, AlertCircle } from 'lucide-react';
import { useChapterDownload } from '../offline/useChapterDownload';
import type { DownloadablePage } from '../offline/offlineLibrary';
export interface ApiChapter {
id: number;
number: number;
title: string;
pages: DownloadablePage[];
}
export const ChapterDownloadButton: React.FC<{
mediaId: string;
mediaTitle: string;
chapter: ApiChapter;
}> = ({ mediaId, mediaTitle, chapter }) => {
const meta = {
mediaId,
mediaTitle,
chapterNumber: chapter.number,
chapterTitle: chapter.title,
};
const { status, progress, error, download, remove } = useChapterDownload(meta, chapter.pages);
if (status === 'downloading') {
return (
{Math.round(progress * 100)}%
);
}
if (status === 'downloaded') {
return (
);
}
return (
);
};