import type { ReactNode } from 'react'; import { useTranslation } from 'react-i18next'; import { retryBlockingMigration } from '../hooks/useMigrationOrchestrator'; import { useMigrationStore } from '../store/migrationStore'; function MigrationModal() { const { t } = useTranslation(); const phase = useMigrationStore(s => s.phase); const step = useMigrationStore(s => s.step); const progress = useMigrationStore(s => s.progress); const genreTagsProgress = useMigrationStore(s => s.genreTagsProgress); const inspect = useMigrationStore(s => s.inspect); const error = useMigrationStore(s => s.lastError); const isGenreTags = step === 'genreTags'; const migratedRows = (inspect?.library.totalLegacyRows ?? 0) + (inspect?.analysis.totalLegacyRows ?? 0); return (
{isGenreTags ? t('migration.genreTagsBody') : t('migration.preparingBody')}
> )} {phase === 'running' && ( <>{isGenreTags ? t('migration.genreTagsBody') : (progress ? `${progress.stage} - ${progress.table}` : t('migration.working'))}
{isGenreTags ? (genreTagsProgress ? `${genreTagsProgress.done} / ${genreTagsProgress.total}` : t('migration.working')) : (progress ? `${progress.done} / ${progress.total}` : t('migration.working'))}
{!isGenreTags && inspect?.hasSkippedUnknownServerRows ? ({t('migration.skippedRows')}
) : null} > )} {phase === 'error' && ( <>{String(error ?? '').slice(0, 200)}
{t('migration.completeRows', { count: migratedRows })}
> )}