import { useParams } from 'react-router';
import { DEFAULT_JELLYFIN_SECTION, isJellyfinSection, type JellyfinSectionId } from './shared';

// The URL names the section; nothing else does. JellyfinScreen redirects anything unrecognised, so the
// fallback here only covers the instant before that lands.

export function useJellyfinSection(): JellyfinSectionId {
  const { section } = useParams();
  return isJellyfinSection(section) ? section : DEFAULT_JELLYFIN_SECTION;
}
