import React from 'react'; import { FaEdit, FaHome, FaSearch, FaTrash, FaUserCircle, FaUserFriends, FaUserPlus, } from 'react-icons/fa'; import { Button, EmptyState, Tooltip, NetworkStats } from './FriendshipNetworkComponents'; import { PersonNode, RelationshipEdge } from '../types/network'; import { getRelationshipColor, getRelationshipLabel, RELATIONSHIP_TYPES, RELATIONSHIPS, } from '../types/RelationShipTypes'; interface NetworkSidebarProps { isOpen: boolean; currentNetwork: any; sidebarTab: string; people: PersonNode[]; relationships: RelationshipEdge[]; selectedPersonId: string | null; peopleFilter: string; relationshipFilter: string; relationshipTypeFilter: string; onTabChange: (tab: string) => void; onPeopleFilterChange: (filter: string) => void; onRelationshipFilterChange: (filter: string) => void; onRelationshipTypeFilterChange: (type: string) => void; onAddPerson: () => void; onAddRelationship: () => void; onOpenSettings: () => void; onOpenHelp: () => void; onPersonDelete: (id: string) => void; onRelationshipDelete: (id: string) => void; onOpenPersonDetail: (person: PersonNode) => void; onNavigateBack: () => void; } const NetworkSidebar: React.FC = ({ isOpen, currentNetwork, sidebarTab, people, relationships, selectedPersonId, peopleFilter, relationshipFilter, relationshipTypeFilter, onTabChange, onPeopleFilterChange, onRelationshipFilterChange, onRelationshipTypeFilterChange, onAddPerson, onAddRelationship, onPersonDelete, onRelationshipDelete, onOpenPersonDetail, onNavigateBack, }) => { // Filter logic for people and relationships const filteredPeople = people.filter(person => `${person.firstName} ${person.lastName}`.toLowerCase().includes(peopleFilter.toLowerCase()) ); const filteredRelationships = relationships.filter(rel => { const source = people.find(p => p._id === rel.source); const target = people.find(p => p._id === rel.target); if (!source || !target) return false; const matchesFilter = `${source.firstName} ${source.lastName} ${target.firstName} ${target.lastName}` .toLowerCase() .includes(relationshipFilter.toLowerCase()); const matchesType = relationshipTypeFilter === 'all' || rel.type === relationshipTypeFilter; return matchesFilter && matchesType; }); // Sort people alphabetically const sortedPeople = [...filteredPeople].sort((a, b) => { const nameA = `${a.firstName} ${a.lastName}`.toLowerCase(); const nameB = `${b.firstName} ${b.lastName}`.toLowerCase(); return nameA.localeCompare(nameB); }); return (
{/* Network Header */}

{currentNetwork?.name || 'Relationship Network'}

Visualize your connections

{/* Network Stats */} {/* Action Buttons */}
{/* Sidebar Tabs */}
{/* Tab Content */} {sidebarTab === 'people' && (
onPeopleFilterChange(e.target.value)} />
{sortedPeople.length > 0 ? ( sortedPeople.map(person => { const connectionCount = relationships.filter( r => r.source === person._id || r.target === person._id ).length; return (
0 ? 'border-l-indigo-500' : 'border-l-slate-700' }`} onClick={() => { onOpenPersonDetail(person); }} >

{person.firstName} {person.lastName}

0 ? '#60A5FA' : '#94A3B8', }} > {connectionCount} connection{connectionCount !== 1 ? 's' : ''}
); }) ) : ( } action={ !peopleFilter && ( ) } /> )}
)} {sidebarTab === 'relations' && (
onRelationshipFilterChange(e.target.value)} />
{Object.entries(RELATIONSHIPS).map(([type, relationship]) => ( ))}
{filteredRelationships.length > 0 ? ( filteredRelationships.map(rel => { const source = people.find(p => p._id === rel.source); const target = people.find(p => p._id === rel.target); if (!source || !target) return null; return (
{ e.stopPropagation(); const sourcePerson = people.find(p => p._id === rel.source); if (sourcePerson) onOpenPersonDetail(sourcePerson); }} > {source.firstName} {source.lastName} { e.stopPropagation(); const targetPerson = people.find(p => p._id === rel.target); if (targetPerson) onOpenPersonDetail(targetPerson); }} > {target.firstName} {target.lastName}
{rel.type === 'custom' ? rel.customType : getRelationshipLabel(rel.type)}
); }) ) : ( } action={ !relationshipFilter && relationshipTypeFilter === 'all' && ( ) } /> )}
)}
); }; export default NetworkSidebar;