import React, { useState } from 'react' import { Modal } from '@/components/ui/Modal' import { ContentBlock } from '@/components/shared/ContentBlock' import { getCEFRColor } from '@/lib/utils/flashcardUtils' import { BluePlayButton } from '@/components/shared/BluePlayButton' import { useWordAnalysis } from '@/hooks/word/useWordAnalysis' import type { WordAnalysis } from '@/lib/types/word' interface WordPopupProps { selectedWord: string | null analysis: Record isOpen: boolean onClose: () => void onSaveWord?: (word: string, analysis: WordAnalysis) => Promise<{ success: boolean; error?: string }> isSaving?: boolean } export const WordPopup: React.FC = ({ selectedWord, analysis, isOpen, onClose, onSaveWord, isSaving = false }) => { const { getWordProperty } = useWordAnalysis() if (!selectedWord || !analysis?.[selectedWord]) { return null } const wordAnalysis = analysis[selectedWord] const handleSaveWord = async () => { if (onSaveWord) { await onSaveWord(selectedWord, wordAnalysis) } } return ( {/* Header */}

{getWordProperty(wordAnalysis, 'word')}

{getWordProperty(wordAnalysis, 'partOfSpeech')}
{getWordProperty(wordAnalysis, 'pronunciation')}
{getWordProperty(wordAnalysis, 'cefr')}
{/* Content */}
{/* Translation */}

{getWordProperty(wordAnalysis, 'translation')}

{/* Definition */}

{getWordProperty(wordAnalysis, 'definition')}

{/* Example */} {(() => { const example = getWordProperty(wordAnalysis, 'example') return example && example !== 'null' && example !== 'undefined' })() && (

"{getWordProperty(wordAnalysis, 'example')}"

{getWordProperty(wordAnalysis, 'exampleTranslation')}

)} {/* Synonyms */} {(() => { const synonyms = getWordProperty(wordAnalysis, 'synonyms') return synonyms && Array.isArray(synonyms) && synonyms.length > 0 })() && (
{getWordProperty(wordAnalysis, 'synonyms')?.map((synonym: string, index: number) => ( {synonym} ))}
)}
{/* Save Button */} {onSaveWord && (
)}
) }