import { notFound } from 'next/navigation' import { getItem } from '@/lib/actions' import { canEditList } from '@/lib/permissions' import { getServerSession } from 'next-auth' import { authOptions } from '@/pages/api/auth/[...nextauth]' import ItemDetail from '@/components/ItemDetail' import Link from 'next/link' import { ArrowLeft, Edit } from 'lucide-react' import DeleteItemButton from '@/components/DeleteItemButton' import ToggleItemButton from '@/components/ToggleItemButton' export const dynamic = 'force-dynamic' interface PageProps { params: { id: string itemId: string } } export default async function ItemDetailPage({ params }: PageProps) { const session = await getServerSession(authOptions) if (!session?.user?.id) { notFound() } const itemData = await getItem(params.itemId) if (!itemData || itemData.listId !== params.id) { notFound() } // Type assertion for the item with list relation const item = itemData as typeof itemData & { list: { title: string color: string ownerId: string } } // Check if user can edit this list const canEdit = await canEditList(session.user.id, params.id) return (
{/* Header Actions */}
Back to List
{canEdit && ( <> Edit )}
{/* Item Detail */}
) }