From 4422498bc983d2055d91705a320bf9b33caaa548 Mon Sep 17 00:00:00 2001
From: Paul Bailey
Date: Wed, 3 Dec 2025 20:35:16 +0000
Subject: [PATCH] Move permission badge and share button above add task bar
---
app/list/[id]/page.tsx | 22 +++++++-
components/ListDetailView.tsx | 101 ++++++++++++++++++++++++++++++++--
2 files changed, 117 insertions(+), 6 deletions(-)
diff --git a/app/list/[id]/page.tsx b/app/list/[id]/page.tsx
index 73020cd..aac1876 100644
--- a/app/list/[id]/page.tsx
+++ b/app/list/[id]/page.tsx
@@ -58,6 +58,25 @@ export default async function ListDetailPage({ params }: { params: { id: string
+ {/* Permission Badge and Share Button */}
+
+ ({
+ ...c,
+ permission: c.permission as 'editor' | 'viewer'
+ }))}
+ showOnlyHeader={true}
+ />
+
+
{/* Inline Item Creation - only show if user can edit */}
{canEdit && (
@@ -65,7 +84,7 @@ export default async function ListDetailPage({ params }: { params: { id: string
)}
- {/* Search, Filter, and Items List */}
+ {/* Items List */}
)
diff --git a/components/ListDetailView.tsx b/components/ListDetailView.tsx
index 73e737b..d51ec32 100644
--- a/components/ListDetailView.tsx
+++ b/components/ListDetailView.tsx
@@ -41,6 +41,8 @@ interface ListDetailViewProps {
email: string
}
}>
+ showOnlyHeader?: boolean
+ showOnlyItems?: boolean
}
export default function ListDetailView({
@@ -52,17 +54,22 @@ export default function ListDetailView({
ownerId = '',
ownerName = null,
ownerEmail = '',
- collaborators = []
+ collaborators = [],
+ showOnlyHeader = false,
+ showOnlyItems = false
}: ListDetailViewProps) {
const [isShareModalOpen, setIsShareModalOpen] = useState(false)
- // Use scroll position preservation hook
- useScrollPosition({ key: `list-${listId}` })
+ // Conditionally use hooks based on view mode
+ const shouldUseHooks = !showOnlyHeader
+
+ // Use scroll position preservation hook (only for items view)
+ useScrollPosition({ key: shouldUseHooks ? `list-${listId}` : 'disabled' })
- // Use real-time sync hook to poll for updates
+ // Use real-time sync hook to poll for updates (only for items view)
useRealtimeSync({
listId,
- enabled: true,
+ enabled: shouldUseHooks,
pollInterval: 1000, // Poll every 1 second for faster updates
})
@@ -70,6 +77,90 @@ export default function ListDetailView({
const completedItems = useMemo(() => initialItems.filter(item => item.completed), [initialItems])
const incompleteItems = useMemo(() => initialItems.filter(item => !item.completed), [initialItems])
+ // If showing only header, return just the permission badge and share button
+ if (showOnlyHeader) {
+ return (
+ <>
+ {(permission || canShare) && (
+
+ {permission && (
+
+ )}
+ {canShare && (
+
+ )}
+
+ )}
+
+ {/* Share Modal */}
+ setIsShareModalOpen(false)}
+ listId={listId}
+ listTitle={listTitle}
+ isOwner={permission === 'owner'}
+ ownerId={ownerId}
+ ownerName={ownerName}
+ ownerEmail={ownerEmail}
+ initialCollaborators={collaborators}
+ />
+ >
+ )
+ }
+
+ // If showing only items, return just the items list
+ if (showOnlyItems) {
+ return (
+
+ {/* Incomplete Items */}
+ {incompleteItems.length > 0 && (
+
+
+ To Do ({incompleteItems.length})
+
+
+ {incompleteItems.map((item) => (
+
+ ))}
+
+
+ )}
+
+ {/* Completed Items */}
+ {completedItems.length > 0 && (
+
+
+ Completed ({completedItems.length})
+
+
+ {completedItems.map((item) => (
+
+ ))}
+
+
+ )}
+
+ {/* Empty State */}
+ {initialItems.length === 0 && (
+
+ )}
+
+ )
+ }
+
+ // Default: show everything (for backward compatibility)
return (
{/* Permission Badge and Share Button */}