'use client' import { useState, useRef, useEffect } from 'react' import { Send, BookOpen, X } from 'lucide-react' import { getNotebookIcon } from '@/lib/notebook-icon' import { Button } from '@/components/ui/button' import { Textarea } from '@/components/ui/textarea' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select" import { cn } from '@/lib/utils' import { Badge } from '@/components/ui/badge' import { useLanguage } from '@/lib/i18n' interface ChatInputProps { onSend: (message: string, notebookId?: string) => void isLoading?: boolean notebooks: any[] currentNotebookId?: string | null } export function ChatInput({ onSend, isLoading, notebooks, currentNotebookId }: ChatInputProps) { const { t } = useLanguage() const [input, setInput] = useState('') const [selectedNotebook, setSelectedNotebook] = useState(currentNotebookId || undefined) const textareaRef = useRef(null) useEffect(() => { if (currentNotebookId) { setSelectedNotebook(currentNotebookId) } }, [currentNotebookId]) const handleSend = () => { if (!input.trim() || isLoading) return onSend(input, selectedNotebook) setInput('') if (textareaRef.current) { textareaRef.current.style.height = 'auto' } } const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault() handleSend() } } useEffect(() => { if (textareaRef.current) { textareaRef.current.style.height = 'auto' textareaRef.current.style.height = `${textareaRef.current.scrollHeight}px` } }, [input]) return (
{/* Input Area */}