"use client"; /** * /u/me/collections/[id] — single-collection view. * * The whole page is the collection's CollectionScrollCard (carousel of * cover + posts) and an Edit button below it. All editing — title, * description, cover, member posts, delete — lives in the EditCollectionDrawer * so the page itself stays focused on the carousel preview. */ import { use, useEffect, useState } from "react"; import { useRouter } from "next/navigation"; import { ArrowLeft } from "lucide-react"; import { collections, SocialError, type Collection, type Post, } from "@/lib/social"; import { CollectionScrollCard } from "@/components/social/collection-scroll-card"; import { EditCollectionDrawer } from "@/components/social/edit-collection-drawer"; export default function CollectionDetailPage(props: { params: Promise<{ id: string }>; }) { const { id } = use(props.params); const router = useRouter(); const [c, setC] = useState(null); const [posts, setPosts] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [editOpen, setEditOpen] = useState(false); useEffect(() => { let cancelled = false; collections .get(id) .then(({ collection, posts }) => { if (cancelled) return; setC(collection); setPosts(posts ?? []); }) .catch((err) => { setError( err instanceof SocialError ? err.message : "Could not load collection.", ); }) .finally(() => !cancelled && setLoading(false)); return () => { cancelled = true; }; }, [id]); if (loading) return

Loading…

; if (error && !c) return

{error}

; if (!c) return null; return (
setEditOpen(true)} /> setEditOpen(false)} collection={c} currentPosts={posts} onSaved={({ collection, posts: rows }) => { setC(collection); setPosts(rows); }} onDeleted={() => router.push("/u/me/collections")} />
); }