'use client'; import React, { useMemo, useState } from 'react'; import { AppPageLayoutContent } from '@/components/ui/layouts/AppPageLayoutContent'; import { Avatar } from '@/components/ui/avatar'; import { formatDate, makeHumanReadble } from '@/lib'; import { BusterRoutes, createBusterRoute } from '@/routes'; import { BusterList, BusterListColumn, BusterListRow, ListEmptyStateWithButton } from '@/components/ui/list'; import { useMemoizedFn } from '@/hooks'; import { NewCollectionModal } from '@/components/features/modal/NewCollectionModal'; import { BusterCollectionListItem, ShareAssetType } from '@/api/asset_interfaces'; import { CollectionListSelectedPopup } from './CollectionListSelectedPopup'; import { Text } from '@/components/ui/typography'; import { FavoriteStar } from '@/components/features/list'; export const CollectionsListContent: React.FC<{ openNewCollectionModal: boolean; setOpenNewCollectionModal: (open: boolean) => void; isCollectionListFetched: boolean; collectionsList: BusterCollectionListItem[]; }> = React.memo( ({ openNewCollectionModal, setOpenNewCollectionModal, isCollectionListFetched, collectionsList }) => { const onCloseNewCollectionModal = useMemoizedFn(() => { setOpenNewCollectionModal(false); }); return ( <> ); } ); CollectionsListContent.displayName = 'CollectionsListContent'; const columns: BusterListColumn[] = [ { dataIndex: 'name', title: 'Title', render: (v, { id, ...rest }: BusterCollectionListItem) => { return (
{v}
); } }, { dataIndex: 'last_edited', title: 'Last edited', width: 150, render: (v) => formatDate({ date: v, format: 'lll' }) }, { dataIndex: 'sharing', title: 'Sharing', width: 55, render: (v) => makeHumanReadble(v || 'private') }, { dataIndex: 'owner', title: 'Owner', width: 50, render: (owner: BusterCollectionListItem['owner']) => { return ; } } ]; const CollectionList: React.FC<{ collectionsList: BusterCollectionListItem[]; setOpenNewCollectionModal: (v: boolean) => void; loadedCollections: boolean; }> = React.memo(({ collectionsList, setOpenNewCollectionModal, loadedCollections }) => { const [selectedRowKeys, setSelectedRowKeys] = useState([]); const collections: BusterListRow[] = useMemo(() => { return collectionsList.map((collection) => { return { id: collection.id, link: createBusterRoute({ route: BusterRoutes.APP_COLLECTIONS_ID, collectionId: collection.id }), data: collection }; }); }, [collectionsList]); const onSelectChange = useMemoizedFn((selectedRowKeys: string[]) => { setSelectedRowKeys(selectedRowKeys); }); const onOpenNewCollectionModal = useMemoizedFn(() => { setOpenNewCollectionModal(true); }); return (
) : ( <> ) } />
); }); CollectionList.displayName = 'CollectionList';