import { useState, useMemo } from 'react'; import { Link } from 'react-router-dom'; import { useContent, usePermissions } from '@/hooks'; import { Layout, MessageSquare, RefreshCw, Loader2, TrendingUp, Clock, Grid3X3, Shield, Hash, } from 'lucide-react'; import { CreateCellDialog } from './CreateCellDialog'; import { Button } from '@/components/ui/button'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; import { CypherImage } from './ui/CypherImage'; import { RelevanceIndicator } from './ui/relevance-indicator'; import { ModerationToggle } from './ui/moderation-toggle'; import { sortCells, SortOption } from '@/utils/sorting'; import type { Cell } from '@opchan/core'; import { useForum } from '@/hooks'; import { ShareButton } from './ui/ShareButton'; // Empty State Component const EmptyState: React.FC<{ canCreateCell: boolean }> = ({ canCreateCell, }) => { return (
{/* Visual Element */}
{/* Floating elements */}
{/* Content */}

No Cells Found

{canCreateCell ? (

Ready to start your own decentralized community?

) : (

Connect your wallet and verify ownership to create cells

)}
); }; // Separate component to properly use hooks const CellItem: React.FC<{ cell: Cell }> = ({ cell }) => { const { content } = useForum(); const isPending = content.pending.isPending(cell.id); return (

{cell.name}

{cell.relevanceScore !== undefined && ( )}
{isPending && (
syncing…
)}

{cell.description}

{cell.postCount || 0} posts {cell.activeMemberCount || 0} members
); }; const CellList = () => { const { cellsWithStats } = useContent(); const content = useContent(); const { canCreateCell } = usePermissions(); const [sortOption, setSortOption] = useState('relevance'); // Apply sorting to cells const sortedCells = useMemo(() => { return sortCells(cellsWithStats, sortOption); }, [cellsWithStats, sortOption]); if (!cellsWithStats.length) { return (

Loading Cells...

); } const hasCells = sortedCells.length > 0; return (

Decentralized Cells

Discover communities built on Bitcoin Ordinals

{/* Only show controls when cells exist */} {hasCells && (
{canCreateCell && }
)}
{!hasCells ? ( ) : ( sortedCells.map(cell => ) )}
); }; export default CellList;