import React from 'react' import Link from 'next/link' import { Flashcard } from '@/lib/services/flashcards' import { getCEFRColor, getFlashcardImageUrl, getPartOfSpeechDisplay } from '@/lib/utils/flashcardUtils' import { BluePlayButton } from '@/components/shared/BluePlayButton' interface FlashcardCardProps { flashcard: Flashcard searchTerm?: string onEdit: () => void onDelete: () => void onFavorite: () => void onImageGenerate: () => void isGenerating?: boolean generationProgress?: string highlightSearchTerm?: (text: string, term: string) => React.ReactNode } export const FlashcardCard: React.FC = ({ flashcard, searchTerm = '', onEdit, onDelete, onFavorite, onImageGenerate, isGenerating = false, generationProgress = '', highlightSearchTerm = (text: string) => text }) => { const hasExampleImage = (card: Flashcard): boolean => { return card.hasExampleImage || !!getFlashcardImageUrl(card) } const getExampleImage = (card: Flashcard): string | null => { return getFlashcardImageUrl(card) } return (
{/* CEFR標註 - 只在桌面版顯示 */}
{flashcard.cefr || 'A1'}
{/* 手機版布局 */}
{/* 頂部區域:圖片和詞彙信息 */}
{/* 圖片區域 */}
{hasExampleImage(flashcard) ? ( {`${flashcard.word} ) : (
{isGenerating ? (
) : ( )}
)}
{/* 詞彙信息 */}

{searchTerm ? highlightSearchTerm(flashcard.word || '未設定', searchTerm) : (flashcard.word || '未設定')}

{searchTerm ? highlightSearchTerm(flashcard.translation || '未設定', searchTerm) : (flashcard.translation || '未設定')}

{/* 底部操作區域 */}
{/* 左側:CEFR + 詞性 + 播放按鈕 */}
{flashcard.cefr || 'A1'} {getPartOfSpeechDisplay(flashcard.partOfSpeech)} {flashcard.word && ( )}
{/* 右側:操作按鈕 */}
{/* 桌面版布局 */}
{/* 圖片區域 */}
{hasExampleImage(flashcard) ? ( {`${flashcard.word} ) : (
{isGenerating ? (
{generationProgress}
) : (
新增例句圖
)}
)}
{/* 詞卡信息 */}

{searchTerm ? highlightSearchTerm(flashcard.word || '未設定', searchTerm) : (flashcard.word || '未設定')}

{getPartOfSpeechDisplay(flashcard.partOfSpeech)}
{searchTerm ? highlightSearchTerm(flashcard.translation || '未設定', searchTerm) : (flashcard.translation || '未設定')} {flashcard.pronunciation && (
{flashcard.pronunciation} {flashcard.word && ( )}
)}
創建: {new Date(flashcard.createdAt).toLocaleDateString()}
{/* 桌面版操作按鈕 */}
詳細
) }