'use client' import { useState } from 'react' import Link from 'next/link' export default function FlashcardsPage() { const [activeTab, setActiveTab] = useState('my-cards') const [selectedSet, setSelectedSet] = useState(null) const [searchTerm, setSearchTerm] = useState('') const [filterTag, setFilterTag] = useState('all') const [selectedCards, setSelectedCards] = useState([]) const [showCheckModal, setShowCheckModal] = useState(false) const [checkingCard, setCheckingCard] = useState(null) const [checkResults, setCheckResults] = useState(null) const [errorReports, setErrorReports] = useState([ { id: 1, cardId: 1, word: 'negotiate', reportType: '發音錯誤', description: '美式發音標記有誤', reportedAt: '2小時前', status: 'pending' }, { id: 2, cardId: 3, word: 'perspective', reportType: '翻譯不準確', description: '翻譯缺少其他常用含義', reportedAt: '1天前', status: 'pending' }, { id: 3, cardId: 5, word: 'implement', reportType: '例句錯誤', description: '例句時態使用不當', reportedAt: '3天前', status: 'pending' } ]) // Mock data const cardSets = [ { id: 1, name: '美劇經典台詞', description: '從熱門美劇中精選的實用對話', cardCount: 45, progress: 60, lastStudied: '2 小時前', tags: ['影視', '口語'], color: 'bg-blue-500' }, { id: 2, name: '商務英文必備', description: '職場溝通和商業會議常用詞彙', cardCount: 30, progress: 30, lastStudied: '昨天', tags: ['商務', '正式'], color: 'bg-purple-500' }, { id: 3, name: '日常對話', description: '生活中最常用的英文表達', cardCount: 25, progress: 80, lastStudied: '3 天前', tags: ['日常', '基礎'], color: 'bg-green-500' }, { id: 4, name: 'TOEFL 核心詞彙', description: '托福考試高頻詞彙整理', cardCount: 100, progress: 15, lastStudied: '1 週前', tags: ['考試', '學術'], color: 'bg-orange-500' }, { id: 5, name: '科技新聞詞彙', description: '科技領域專業術語和流行用語', cardCount: 35, progress: 45, lastStudied: '5 天前', tags: ['科技', '專業'], color: 'bg-indigo-500' } ] const flashcards = [ { id: 1, word: 'negotiate', translation: '協商', definition: 'To discuss something with someone in order to reach an agreement', partOfSpeech: 'verb', pronunciation: '/nɪˈɡoʊʃieɪt/', example: 'We need to negotiate a better deal with our suppliers.', setId: 1, mastery: 80, nextReview: '明天' }, { id: 2, word: 'accomplish', translation: '完成', definition: 'To finish something successfully or to achieve something', partOfSpeech: 'verb', pronunciation: '/əˈkɒmplɪʃ/', example: 'She accomplished her goal of running a marathon.', setId: 1, mastery: 60, nextReview: '今天' }, { id: 3, word: 'perspective', translation: '觀點', definition: 'A particular way of considering something', partOfSpeech: 'noun', pronunciation: '/pərˈspektɪv/', example: 'From my perspective, this is the best solution.', setId: 2, mastery: 90, nextReview: '3天後' }, { id: 4, word: 'substantial', translation: '大量的', definition: 'Large in size, value, or importance', partOfSpeech: 'adjective', pronunciation: '/səbˈstænʃəl/', example: 'The company made a substantial profit last year.', setId: 2, mastery: 40, nextReview: '今天' }, { id: 5, word: 'implement', translation: '實施', definition: 'To put a decision, plan, or agreement into effect', partOfSpeech: 'verb', pronunciation: '/ˈɪmplɪment/', example: 'We need to implement new safety measures.', setId: 3, mastery: 70, nextReview: '明天' }, ] const tags = ['all', '影視', '商務', '日常', '考試', '科技', '口語', '正式', '基礎', '學術', '專業'] const filteredSets = cardSets.filter(set => set.name.toLowerCase().includes(searchTerm.toLowerCase()) || set.description.toLowerCase().includes(searchTerm.toLowerCase()) ) const filteredCards = flashcards.filter(card => card.word.toLowerCase().includes(searchTerm.toLowerCase()) || card.translation.includes(searchTerm) ) return (
{/* Navigation */}
{/* Header */}

我的詞卡庫

管理和組織您的學習詞卡

{/* Search and Filter */}
setSearchTerm(e.target.value)} placeholder="搜尋詞卡或卡組..." className="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-primary focus:border-transparent outline-none" />
{/* Tabs */}
{activeTab === 'my-cards' && (

共 {filteredSets.length} 個卡組

{filteredSets.map(set => (
setSelectedSet(set.id)} >

{set.name}

{set.description}

{set.tags.map(tag => ( {tag} ))}
進度 {set.progress}%
{set.cardCount} 個詞卡 {set.lastStudied}
開始學習
))} {/* Add New Set Card */}

創建新卡組

組織您的學習內容

)} {activeTab === 'all-cards' && (

共 {filteredCards.length} 個詞卡

{selectedCards.length > 0 && ( )}
{filteredCards.map(card => (
{ if (e.target.checked) { setSelectedCards([...selectedCards, card.id]) } else { setSelectedCards(selectedCards.filter(id => id !== card.id)) } }} className="h-4 w-4 text-primary focus:ring-primary border-gray-300 rounded" />
{ setCheckingCard(card) setCheckResults(null) setShowCheckModal(true) }} className="cursor-pointer hover:text-primary transition-colors" >
{card.word}
{card.translation}
掌握度
{card.mastery}%
下次複習
{card.nextReview}
))}
)} {activeTab === 'favorites' && (

還沒有收藏的詞卡

在學習時點擊愛心圖標來收藏詞卡

開始學習
)} {activeTab === 'error-reports' && (

錯誤回報清單 ({errorReports.filter(r => r.status === 'pending').length} 個待處理)

{errorReports.filter(r => r.status === 'pending').length > 0 && ( )}
{errorReports.length === 0 ? (

沒有錯誤回報

所有詞卡內容都正確無誤!

) : (
{errorReports.map(report => (

{report.word}

{report.status === 'pending' ? '待處理' : '已解決'} {report.reportType}

{report.description}

回報時間:{report.reportedAt}
{report.status === 'pending' && ( <> )}
))}
)}
)}
{/* Stats Summary */}
234
總詞卡數
156
已掌握
23
待複習
67%
總體掌握
{/* Smart Check Modal */} {showCheckModal && (

🤖 智能檢測

{!checkResults ? ( // 檢測前

{checkingCard?.isErrorList ? `即將檢測 ${checkingCard.reports.length} 個錯誤回報` : checkingCard?.errorReport ? `正在檢測錯誤回報:${checkingCard.errorReport.reportType}` : checkingCard ? `正在檢測詞卡「${checkingCard.word}」的內容...` : `即將檢測 ${selectedCards.length} 個詞卡的內容正確性`}

{checkingCard && !checkingCard.isErrorList && (
{checkingCard.errorReport && (
錯誤回報:{checkingCard.errorReport.reportType}
{checkingCard.errorReport.description}
)}
單字:{checkingCard.word}
翻譯:{checkingCard.translation}
定義:{checkingCard.definition}
詞性:{checkingCard.partOfSpeech}
發音:{checkingCard.pronunciation}
例句:{checkingCard.example}
)} {checkingCard?.isErrorList && (
錯誤清單:
{checkingCard.reports.map((report, idx) => (
{report.word}
{report.reportType}: {report.description}
))}
)}
) : ( // 檢測結果

檢測完成

{checkResults.isErrorList ? `已檢測 ${checkResults.totalChecked} 個錯誤回報,發現 ${checkResults.errors.length} 個問題` : `已檢測 ${checkResults.totalChecked} 個詞卡,發現 ${checkResults.errors.length} 個問題`}

{checkResults.errors.length > 0 && (

📝 發現的問題:

{checkResults.errors.map((error, idx) => (
{error.field}
原始: {error.original}
建議: {error.corrected}
{error.reason}
))}
)} {checkResults.suggestions.length > 0 && (

💡 改進建議:

    {checkResults.suggestions.map((suggestion, idx) => (
  • {suggestion}
  • ))}
)}
)}
)}
) }