"use client"; import { Icons } from "@midday/ui/icons"; import { useEffect, useRef, useState } from "react"; import { useDocsChat } from "./docs-chat-provider"; type HeroChatInputProps = { onSubmit: (message: string) => void; }; const suggestionsRow1 = [ "How do I create an invoice?", "Connect my bank account", "Set up recurring invoices", "Track time on projects", "Export transactions to CSV", "Create a new customer", "View my dashboard", ]; const suggestionsRow2 = [ "What's my runway?", "Show burn rate analysis", "View profit margins", "Match receipts automatically", "Send invoice reminder", "Add a new project", "Check account balances", ]; const suggestionsRow3 = [ "Revenue vs last quarter", "Categorize my expenses", "Upload to document vault", "Track billable hours", "Generate financial report", "View overdue invoices", "Export for accountant", ]; export function HeroChatInput({ onSubmit }: HeroChatInputProps) { const { isChatOpen } = useDocsChat(); const [input, setInput] = useState(""); const inputRef = useRef(null); // Autofocus input when chat is active (including on initial load with ?chat=true) useEffect(() => { if (isChatOpen && inputRef.current) { const timer = setTimeout(() => { inputRef.current?.focus(); }, 100); return () => clearTimeout(timer); } }, [isChatOpen]); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (!input.trim()) return; onSubmit(input.trim()); setInput(""); }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Enter" && !e.nativeEvent.isComposing) { e.preventDefault(); handleSubmit(e); } }; const handleSuggestion = (suggestion: string) => { onSubmit(suggestion); }; const SuggestionButton = ({ suggestion }: { suggestion: string }) => ( ); return (
setInput(e.target.value)} onKeyDown={handleKeyDown} placeholder="Ask anything" className="w-full bg-transparent px-4 py-3.5 md:py-4 pr-12 text-sm outline-none placeholder:text-[rgba(102,102,102,0.5)]" />
{/* Mobile Suggestions - simple grid */}
{["Create invoice", "Connect bank", "Track time", "View reports"].map( (suggestion) => ( ), )}
{/* Animated Suggestions - desktop only */}
{/* Gradient fade masks */}
{/* Row 1 - moves left */}
{suggestionsRow1.map((suggestion) => ( ))}
{/* Row 2 - moves right */}
{suggestionsRow2.map((suggestion) => ( ))}
{/* Row 3 - moves left (slower) */}
{suggestionsRow3.map((suggestion) => ( ))}
); }