'use client' import { useState } from 'react' import Link from 'next/link' export default function LearnPage() { const [currentCardIndex, setCurrentCardIndex] = useState(0) const [isFlipped, setIsFlipped] = useState(false) const [mode, setMode] = useState<'flip' | 'quiz'>('flip') const [score, setScore] = useState({ correct: 0, total: 0 }) const [selectedAnswer, setSelectedAnswer] = useState(null) const [showResult, setShowResult] = useState(false) // Mock data const cards = [ { id: 1, word: 'negotiate', partOfSpeech: 'verb', pronunciation: '/nɪˈɡoʊʃieɪt/', translation: '協商、談判', definition: 'To discuss something with someone in order to reach an agreement', example: 'We need to negotiate a better deal with our suppliers.', exampleTranslation: '我們需要與供應商協商更好的交易。', synonyms: ['bargain', 'discuss', 'mediate'], difficulty: 'intermediate' }, { id: 2, word: 'perspective', partOfSpeech: 'noun', pronunciation: '/pərˈspektɪv/', translation: '觀點、看法', definition: 'A particular way of considering something', example: 'From my perspective, this is the best solution.', exampleTranslation: '從我的角度來看,這是最好的解決方案。', synonyms: ['viewpoint', 'outlook', 'stance'], difficulty: 'intermediate' }, { id: 3, word: 'accomplish', partOfSpeech: 'verb', pronunciation: '/əˈkɒmplɪʃ/', translation: '完成、達成', definition: 'To finish something successfully or to achieve something', example: 'She accomplished her goal of running a marathon.', exampleTranslation: '她完成了跑馬拉松的目標。', synonyms: ['achieve', 'complete', 'fulfill'], difficulty: 'intermediate' } ] const currentCard = cards[currentCardIndex] // Quiz mode options const quizOptions = [ '協商、談判', '觀點、看法', '完成、達成', '建議、提議' ] const handleFlip = () => { setIsFlipped(!isFlipped) } const handleNext = () => { if (currentCardIndex < cards.length - 1) { setCurrentCardIndex(currentCardIndex + 1) setIsFlipped(false) setSelectedAnswer(null) setShowResult(false) } } const handlePrevious = () => { if (currentCardIndex > 0) { setCurrentCardIndex(currentCardIndex - 1) setIsFlipped(false) setSelectedAnswer(null) setShowResult(false) } } const handleDifficultyRate = (rating: number) => { // Mock rating logic console.log(`Rated ${rating} for ${currentCard.word}`) handleNext() } const handleQuizAnswer = (answer: string) => { setSelectedAnswer(answer) setShowResult(true) if (answer === currentCard.translation) { setScore({ ...score, correct: score.correct + 1, total: score.total + 1 }) } else { setScore({ ...score, total: score.total + 1 }) } } return (
{/* Navigation */}
{/* Progress Bar */}
進度 {currentCardIndex + 1} / {cards.length}
{/* Mode Toggle */}
{mode === 'flip' ? ( /* Flip Card Mode */
{/* Front of card */}
{currentCard.word}
{currentCard.partOfSpeech}
{currentCard.pronunciation}
點擊翻轉查看答案
{/* Back of card */}
翻譯
{currentCard.translation}
定義
{currentCard.definition}
例句
{currentCard.example}
{currentCard.exampleTranslation}
同義詞
{currentCard.synonyms.map((syn, idx) => ( {syn} ))}
{/* Difficulty Rating */} {isFlipped && (
這個單字對你來說難度如何?
)}
) : ( /* Quiz Mode */
選擇正確的翻譯
{currentCard.word}
{currentCard.pronunciation}
{quizOptions.map((option, idx) => ( ))}
{showResult && (
例句
{currentCard.example}
{currentCard.exampleTranslation}
)}
正確率:{score.total > 0 ? Math.round((score.correct / score.total) * 100) : 0}% ({score.correct}/{score.total})
)} {/* Navigation Buttons */}
) }