"use client"; import * as React from "react"; interface SuggestedQuestion { id: string; text: string; priority: number; } const DEFAULT_QUESTIONS: SuggestedQuestion[] = [ { id: "1", text: "How can I get started?", priority: 1 }, { id: "2", text: "What features are available?", priority: 2 }, { id: "3", text: "How do I contact support?", priority: 3 }, { id: "4", text: "Tell me about pricing", priority: 4 }, { id: "5", text: "Can you help me with setup?", priority: 5 }, ]; interface SuggestedQuestionsProps { onQuestionSelect: (question: string) => void; context?: string; maxQuestions?: number; className?: string; variant?: "chips" | "list" | "grid"; disabled?: boolean; } export function SuggestedQuestions({ onQuestionSelect, context = "welcome", maxQuestions = 3, className = "", variant = "chips", disabled = false, }: SuggestedQuestionsProps) { const [isVisible, setIsVisible] = React.useState(false); // Animation effect React.useEffect(() => { const timer = setTimeout(() => setIsVisible(true), 100); return () => clearTimeout(timer); }, []); // Get suggested questions const suggestedQuestions = React.useMemo(() => { return DEFAULT_QUESTIONS.slice(0, maxQuestions); }, [maxQuestions]); const handleQuestionClick = React.useCallback( (question: SuggestedQuestion) => { if (disabled) return; onQuestionSelect(question.text); }, [onQuestionSelect, disabled] ); const handleKeyDown = React.useCallback( (event: React.KeyboardEvent, question: SuggestedQuestion) => { if (event.key === "Enter" || event.key === " ") { event.preventDefault(); handleQuestionClick(question); } }, [handleQuestionClick] ); if (variant === "chips") { return (
{suggestedQuestions.map((question, index) => ( ))}
); } if (variant === "list") { return (
{suggestedQuestions.map((question, index) => ( ))}
); } // Grid variant return (
{suggestedQuestions.map((question, index) => ( ))}
); } export default SuggestedQuestions;