import React, { useState } from 'react'; import { Link } from 'react-router-dom'; import { Plus, TrendingUp, Users, Eye } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { useForumData, useForumSelectors, useAuth, usePermissions, } from '@/hooks'; import { CypherImage } from '@/components/ui/CypherImage'; import { CreateCellDialog } from '@/components/CreateCellDialog'; import { useUserDisplay } from '@/hooks'; const FeedSidebar: React.FC = () => { // ✅ Use reactive hooks for data const forumData = useForumData(); const selectors = useForumSelectors(forumData); const { currentUser, verificationStatus } = useAuth(); const { canCreateCell } = usePermissions(); const [showCreateCell, setShowCreateCell] = useState(false); // Get user display information using the hook const { displayName, hasENS, hasOrdinal } = useUserDisplay( currentUser?.address || '' ); // ✅ Get pre-computed stats and trending data from selectors const stats = selectors.selectStats(); // Use cellsWithStats from forumData to get post counts const { cellsWithStats } = forumData; const trendingCells = cellsWithStats .sort((a, b) => b.recentActivity - a.recentActivity) .slice(0, 5); // User's verification status display const getVerificationBadge = () => { if (verificationStatus.level === 'verified-owner') { return { text: 'Verified Owner', color: 'bg-green-500' }; } else if (verificationStatus.level === 'verified-basic') { return { text: 'Verified', color: 'bg-blue-500' }; } else if (hasENS) { return { text: 'ENS User', color: 'bg-purple-500' }; } else if (hasOrdinal) { return { text: 'Ordinal User', color: 'bg-orange-500' }; } return { text: 'Unverified', color: 'bg-gray-500' }; }; const verificationBadge = getVerificationBadge(); return (
{/* User Status Card */} {currentUser && ( Your Status
{displayName}
{verificationBadge.text}
{verificationStatus.level === 'unverified' && (
Read-only mode. Verify wallet to participate.
)} {verificationStatus.level === 'verified-basic' && !hasOrdinal && (
Read-only mode. Acquire Ordinals to post.
)}
)} {/* Forum Stats */} Forum Stats
{stats.totalCells}
Cells
{stats.totalPosts}
Posts
{stats.totalComments}
Comments
{/* Trending Cells */} Trending Cells {trendingCells.map(cell => (
{cell.name}
{cell.postCount} posts • {cell.activeUsers} members
))} {trendingCells.length === 0 && (
No active cells yet
)}
{/* Quick Actions */} {canCreateCell && ( Quick Actions )} {/* Create Cell Dialog */}
); }; export default FeedSidebar;