import { getLibrary } from '@/lib/libraries' import { notFound, redirect } from 'next/navigation' import { getServerSession } from '@/lib/auth' import { getPermittedLibraryIds } from '@/lib/users' import GamesView from '@/components/games/GamesView' import MixedView from '@/components/mixed/MixedView' import MoviesView from '@/components/movies/MoviesView' import TvView from '@/components/tv/TvView' import ScanLibraryButton from '@/components/ScanLibraryButton' interface Props { params: Promise<{ id: string }> searchParams: Promise<{ path?: string }> } export default async function LibraryPage({ params, searchParams }: Props) { const { id } = await params const { path: subpath } = await searchParams const session = await getServerSession() if (!session.userId) redirect('/login') const library = getLibrary(id) if (!library) notFound() if (session.role !== 'admin') { const permitted = getPermittedLibraryIds(session.userId) if (!permitted.includes(id)) notFound() } return (