diff --git a/components/CollectionListing.tsx b/components/CollectionListing.tsx index 2eb3a75..d25ffbe 100644 --- a/components/CollectionListing.tsx +++ b/components/CollectionListing.tsx @@ -27,6 +27,7 @@ const DragDropWithNestingTree = () => { hasChildren: false, isExpanded: false, data: { + id: collection.id, name: collection.name, description: collection.description, color: collection.color, @@ -72,70 +73,6 @@ const DragDropWithNestingTree = () => { collections[0] && setTree(initialTree); }, [collections]); - const getIcon = ( - item: ExtendedTreeItem, - onExpand: (id: ItemId) => void, - onCollapse: (id: ItemId) => void - ) => { - if (item.children && item.children.length > 0) { - return item.isExpanded ? ( - - ) : ( - - ); - } - // return ; - }; - - const renderItem = ({ - item, - onExpand, - onCollapse, - provided, - }: RenderItemParams) => { - const collection = item.data; - - return ( -
- {getIcon(item as ExtendedTreeItem, onExpand, onCollapse)} - - -
- -

{collection.name}

- - {collection.isPublic ? ( - - ) : undefined} -
- {collection._count?.links} -
-
- -
- ); - }; - const onExpand = (itemId: ItemId) => { if (tree) { setTree((currentTree) => @@ -180,3 +117,68 @@ const DragDropWithNestingTree = () => { }; export default DragDropWithNestingTree; + +const renderItem = ({ + item, + onExpand, + onCollapse, + provided, +}: RenderItemParams) => { + const collection = item.data; + + return ( +
+ {Icon(item as ExtendedTreeItem, onExpand, onCollapse)} + + +
+ +

{collection.name}

+ + {collection.isPublic ? ( + + ) : undefined} +
+ {collection._count?.links} +
+
+ +
+ ); +}; + +const Icon = ( + item: ExtendedTreeItem, + onExpand: (id: ItemId) => void, + onCollapse: (id: ItemId) => void +) => { + if (item.children && item.children.length > 0) { + return item.isExpanded ? ( + + ) : ( + + ); + } + // return ; + return <>; +};