import { useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import { useEnrichmentPrimary } from '../music-network'; import { renderPresetIcon } from './settings/musicNetwork/presetIcon'; /** * Sidebar status indicator for the enrichment primary (the account that drives * love/similar/stats). Mirrors the old Last.fm indicator: green when connected, * red on session error, click → Integrations. Hidden when no primary is set. */ export default function MusicNetworkIndicator() { const { t } = useTranslation(); const navigate = useNavigate(); const ep = useEnrichmentPrimary(); if (!ep) return null; const { account: primary, icon } = ep; const subtitle = primary.sessionError ? t('musicNetwork.statusError') : primary.username ? `@${primary.username}` : t('musicNetwork.statusConnected'); const tooltip = primary.sessionError ? t('musicNetwork.statusError') : primary.username ? `${primary.label} · @${primary.username}` : primary.label; return (
navigate('/settings', { state: { tab: 'integrations' } })} data-tooltip={tooltip} data-tooltip-pos="bottom" >
{renderPresetIcon(icon, 11)} {primary.label} {subtitle}
); }