'use client'; import Link from 'next/link'; import { useEffect, useState } from 'react'; import { ShareToX } from './ShareToX'; import { getReadingProgress } from '@ebook/lib/reading-progress'; import { getBookShareText, getReadShareUrl } from '@ebook/lib/share-text'; import { trackEvent } from '@ebook/lib/analytics'; import { CryptoSupport } from './CryptoSupport'; import { BuyEbook } from './BuyEbook'; import { isEnabled } from '@ebook/lib/features'; import { useT } from '@ebook/components/LocaleProvider'; import type { Book } from '@ebook/lib/book-types'; export function BookEnd({ book }: { book: Book }) { const t = useT(); const [readCount, setReadCount] = useState(0); useEffect(() => { const saved = getReadingProgress(); setReadCount(saved?.readChapters.length ?? 0); if (saved && saved.readChapters.length >= book.chapters.length) { trackEvent('book_complete'); } }, [book.chapters.length]); const shareText = `${t('cover.finishedNow', { title: book.title })} 📖\n${book.tagline}\n\n${getBookShareText(book).split('\n').slice(2).join('\n')}`; const done = readCount >= book.chapters.length; return ( ); }