feat: update components for multi-user support
- Add sharing indicator to ListCard showing collaborator count - Add permission badge and share button to ListDetailView - Disable editing in ItemForm for viewers with visual feedback - Add permission checks to item detail and edit pages - Hide edit/delete buttons for viewers on item detail page - Pass permission and collaborator data through component hierarchy - Update navigation to include profile and invitations links (already done in previous tasks) Implements task 15 from user-auth-and-sharing spec
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { notFound } from 'next/navigation'
|
||||
import { getItem } from '@/lib/actions'
|
||||
import { canEditList } from '@/lib/permissions'
|
||||
import { auth } from '@/auth'
|
||||
import ItemForm from '@/components/ItemForm'
|
||||
import Link from 'next/link'
|
||||
import { ArrowLeft } from 'lucide-react'
|
||||
@@ -14,12 +16,20 @@ interface PageProps {
|
||||
}
|
||||
|
||||
export default async function EditItemPage({ params }: PageProps) {
|
||||
const session = await auth()
|
||||
if (!session?.user?.id) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
const item = await getItem(params.itemId)
|
||||
|
||||
if (!item || item.listId !== params.id) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
// Check if user can edit this list
|
||||
const canEdit = await canEditList(session.user.id, params.id)
|
||||
|
||||
return (
|
||||
<main className="container mx-auto px-4 sm:px-6 py-6 sm:py-8 max-w-3xl">
|
||||
{/* Header */}
|
||||
@@ -36,7 +46,7 @@ export default async function EditItemPage({ params }: PageProps) {
|
||||
|
||||
{/* 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" />
|
||||
<ItemForm listId={params.id} item={item} mode="edit" canEdit={canEdit} />
|
||||
</div>
|
||||
</main>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user