import React, { useState, useRef, useEffect } from "react"; import { useTranslation } from "react-i18next"; import { useToast } from "../Shared/ToastContext"; interface AutoSuggestNextActionBoxProps { onAddAction: (actionDescription: string) => void; onDismiss: () => void; projectName: string; } const AutoSuggestNextActionBox: React.FC = ({ onAddAction, onDismiss, projectName, }) => { const [actionDescription, setActionDescription] = useState(""); const [isFocused, setIsFocused] = useState(false); const inputRef = useRef(null); const { t } = useTranslation(); const { showSuccessToast } = useToast(); useEffect(() => { // Focus the input when component mounts setTimeout(() => { inputRef.current?.focus(); }, 100); }, []); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); if (actionDescription.trim()) { onAddAction(actionDescription.trim()); showSuccessToast(t('success.nextActionAdded')); setActionDescription(""); } }; const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === "Escape") { onDismiss(); } }; return (

{t('profile.nextActionPrompt', 'What\'s the very next physical action for this project?')}

setActionDescription(e.target.value)} onFocus={() => setIsFocused(true)} onBlur={() => setIsFocused(false)} onKeyDown={handleKeyDown} placeholder={t('profile.nextActionPlaceholder', 'e.g., Call John to schedule meeting, Research competitors online, Create project folder...')} className={`w-full px-4 py-3 border rounded-lg shadow-sm transition-all duration-200 focus:outline-none bg-white dark:bg-gray-800 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 ${ isFocused ? 'border-blue-400 ring-2 ring-blue-100 dark:ring-blue-900/50' : 'border-blue-200 dark:border-blue-700 hover:border-blue-300 dark:hover:border-blue-600' }`} /> {actionDescription && (
Enter
)}

{t('profile.nextActionHint', 'Think of the smallest, most concrete step you can take right now to move this project forward.')}

); }; export default AutoSuggestNextActionBox;