Files
Todo/app/list/[id]/item/[itemId]/edit/page.tsx
Paul Bailey 0bb293e101 feat: implement list ownership and access control
- Modified createList to assign ownerId to authenticated user
- Updated getLists to filter by user access (owner or collaborator)
- Added ownership checks to updateList (owner or editor can update)
- Added ownership checks to deleteList (only owner can delete)
- Implemented access control for all item operations (create, update, delete, toggle)
- Updated getItem, searchItems, and getItemsByFilter to enforce access control
- Added dynamic rendering to pages that use authentication
- Cascade deletion already handled by database schema (onDelete: Cascade)

Requirements: 4.1, 4.2, 4.3, 4.5
2025-12-02 00:48:47 +00:00

44 lines
1.3 KiB
TypeScript

import { notFound } from 'next/navigation'
import { getItem } from '@/lib/actions'
import ItemForm from '@/components/ItemForm'
import Link from 'next/link'
import { ArrowLeft } from 'lucide-react'
export const dynamic = 'force-dynamic'
interface PageProps {
params: {
id: string
itemId: string
}
}
export default async function EditItemPage({ params }: PageProps) {
const item = await getItem(params.itemId)
if (!item || item.listId !== params.id) {
notFound()
}
return (
<main className="container mx-auto px-4 sm:px-6 py-6 sm:py-8 max-w-3xl">
{/* Header */}
<div className="flex items-center gap-3 sm:gap-4 mb-6">
<Link
href={`/list/${params.id}/item/${params.itemId}`}
className="flex items-center gap-2 text-gray-600 hover:text-gray-900 active:text-black transition-colors tap-target-sm text-sm sm:text-base"
>
<ArrowLeft size={20} className="flex-shrink-0" />
<span>Back</span>
</Link>
<h1 className="text-xl sm:text-2xl lg:text-3xl font-bold text-gray-900">Edit Task</h1>
</div>
{/* Form */}
<div className="bg-white rounded-lg shadow-sm border border-gray-200 p-5 sm:p-6 lg:p-8">
<ItemForm listId={params.id} item={item} mode="edit" />
</div>
</main>
)
}