import React from 'react' import Link from 'next/link' import { Flashcard } from '@/lib/services/flashcards' import { getCEFRColor, getFlashcardImageUrl, getPartOfSpeechDisplay } from '@/lib/utils/flashcardUtils' 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'}
{/* 手機版布局 */}
{/* 主要內容區 */}

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

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

{getPartOfSpeechDisplay(flashcard.partOfSpeech)} {flashcard.pronunciation && ( {flashcard.pronunciation} )}
{/* 操作按鈕區 */}
{hasExampleImage(flashcard) ? (
) : ( )}
詳細
{/* 桌面版布局 */}
{/* 圖片區域 */}
{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} )}
創建: {new Date(flashcard.createdAt).toLocaleDateString()}
{/* 桌面版操作按鈕 */}
詳細
) }