import { MessageSquarePlus, Search, UsersRound, X } from "lucide-react"; import { useMemo, useState } from "react"; import { useNavigate } from "react-router-dom"; import type { Chat, User } from "../api/types"; import { formatMemberCount } from "../lib/format"; import { Avatar } from "./Avatar"; type ChatListProps = { chats: Chat[]; currentUser: User; error: boolean; isLoading: boolean; selectedChatID?: string; onCreateChat: () => void; }; export function ChatList({ chats, currentUser, error, isLoading, selectedChatID, onCreateChat, }: ChatListProps) { const navigate = useNavigate(); const [search, setSearch] = useState(""); const filteredChats = useMemo(() => { const normalized = search.trim().toLocaleLowerCase("ru"); if (!normalized) { return chats; } return chats.filter((chat) => chat.title.toLocaleLowerCase("ru").includes(normalized), ); }, [chats, search]); return ( ); }