import { getLibrary } from '@/lib/libraries' import { notFound, redirect } from 'next/navigation' import { getServerSession } from '@/lib/auth' import { getLibraryAccessLevel } from '@/lib/users' import ComicsView from '@/components/comics/ComicsView' 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() let readOnly = false if (session.role !== 'admin') { const accessLevel = getLibraryAccessLevel(session.userId, id) if (!accessLevel) notFound() readOnly = accessLevel === 'read' } return (