"use client"; import { useChatStore } from "@/lib/store"; import { ConversationItem } from "./conversation-item"; import { PersonSwitcher } from "./person-switcher"; interface SidebarProps { isOpen: boolean; onClose: () => void; } export function Sidebar({ isOpen, onClose }: SidebarProps) { const conversations = useChatStore((s) => s.conversations); const activeId = useChatStore((s) => s.activeConversationId); const createConversation = useChatStore((s) => s.createConversation); const switchConversation = useChatStore((s) => s.switchConversation); const sorted = [...conversations].sort( (a, b) => b.lastMessageAt - a.lastMessageAt ); const handleNew = () => { createConversation(); onClose(); }; const handleSwitch = (id: string) => { switchConversation(id); onClose(); }; return ( <> {/* Backdrop on mobile */} {isOpen && (
)} > ); }