import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { motion } from "framer-motion"; import { KeyboardEvent, useRef, useEffect } from "react"; interface SentenceBuilderProps { currentWord: string; successfulRounds: number; sentence: string[]; playerInput: string; isAiThinking: boolean; onInputChange: (value: string) => void; onSubmitWord: (e: React.FormEvent) => void; onMakeGuess: () => void; } export const SentenceBuilder = ({ currentWord, successfulRounds, sentence, playerInput, isAiThinking, onInputChange, onSubmitWord, onMakeGuess, }: SentenceBuilderProps) => { const inputRef = useRef(null); useEffect(() => { setTimeout(() => { inputRef.current?.focus(); }, 100); }, []); const handleKeyDown = (e: KeyboardEvent) => { if (e.shiftKey && e.key === 'Enter') { e.preventDefault(); if (sentence.length > 0 && !isAiThinking) { onMakeGuess(); } } }; return (

Build a Description

Take turns with AI to describe your word without using the word itself!

{currentWord}

{successfulRounds > 0 && (

Successful rounds: {successfulRounds}

)}

{sentence.length > 0 ? sentence.join(" ") : "Start your sentence..."}

onInputChange(e.target.value.replace(/\s/g, ''))} onKeyDown={handleKeyDown} placeholder="Enter your word..." className="mb-4" disabled={isAiThinking} />
); };