import { useState } from "react"; import type { Channel } from "@/types/Channel"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { ScrollArea } from "@/components/ui/scroll-area"; import { Separator } from "@/components/ui/separator"; import { createChannel } from "@/api"; interface Props { channels: Channel[]; activeId: string | null; onSelect: (id: string) => void; onChannelCreated: () => void; } export function ChannelSidebar({ channels, activeId, onSelect, onChannelCreated }: Props) { const [newName, setNewName] = useState(""); const [creating, setCreating] = useState(false); async function handleCreate() { if (!newName.trim()) return; setCreating(true); await createChannel({ name: newName.trim(), description: "" }); setNewName(""); setCreating(false); onChannelCreated(); } return (
Colony
{channels.map((ch) => ( ))}
setNewName(e.target.value)} onKeyDown={(e) => e.key === "Enter" && handleCreate()} className="text-sm h-8" />
); }