import React from 'react' import { Modal } from '@/components/ui/Modal' import { getCEFRColor, getPartOfSpeechDisplay } 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')}

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

中文翻譯

{getWordProperty(wordAnalysis, 'translation')}

{/* Definition */}

英文定義

{getWordProperty(wordAnalysis, 'definition')}

{/* Example */} {getWordProperty(wordAnalysis, 'example') && (

例句

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

{getWordProperty(wordAnalysis, 'exampleTranslation')}

)} {/* Synonyms */} {getWordProperty(wordAnalysis, 'synonyms')?.length > 0 && (

同義詞

{getWordProperty(wordAnalysis, 'synonyms')?.map((synonym: string, index: number) => ( {synonym} ))}
)}
{/* Save Button */} {onSaveWord && (
)}
) }