import { RefreshCw, ShieldCheck, WifiOff, Zap } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import type { SyncStateDto } from '../../api/library'; import { libraryStatusDisplayTrackCount, libraryStatusIsReady, } from '../../utils/library/libraryReady'; import type { LibraryServerConnection } from '../../hooks/useLibraryIndexSync'; interface ServerLibraryIndexControlsProps { status: SyncStateDto | null; connection: LibraryServerConnection; progressLabel: string | null; busy: boolean; actionsDisabled: boolean; onFullSync: () => void; onDeltaSync: () => void; onVerify: () => void; onCancel: () => void; } export default function ServerLibraryIndexControls({ status, connection, progressLabel, busy, actionsDisabled, onFullSync, onDeltaSync, onVerify, onCancel, }: ServerLibraryIndexControlsProps) { const { t } = useTranslation(); const phaseLabel = (() => { if (connection === 'offline') { return t('settings.libraryIndexServerOffline'); } if (progressLabel) return progressLabel; if (!status) return t('settings.libraryIndexStatusIdle'); if (libraryStatusIsReady(status)) { return t('settings.libraryIndexStatusReady', { count: libraryStatusDisplayTrackCount(status), }); } switch (status.syncPhase) { case 'initial_sync': return t('settings.libraryIndexStatusInitial'); case 'error': return t('settings.libraryIndexStatusError'); case 'probing': return t('settings.libraryIndexStatusProbing'); default: return t('settings.libraryIndexStatusIdle'); } })(); return (
{connection === 'offline' && ( {t('settings.libraryIndexServerDeferred')} )} {busy && ( {t('settings.libraryIndexServerSyncing')} )} {phaseLabel}
{busy && ( )}
); }