refactor files
This commit is contained in:
29
src/features/toeic/components/QuestionCard.tsx
Normal file
29
src/features/toeic/components/QuestionCard.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
interface QuestionCardProps {
|
||||
question?: string
|
||||
options?: string[]
|
||||
selectedAnswer?: string
|
||||
onSelect?: (answer: string) => void
|
||||
}
|
||||
|
||||
export function QuestionCard({ question, options, selectedAnswer, onSelect }: QuestionCardProps) {
|
||||
return (
|
||||
<div className="rounded-lg border p-4 space-y-3">
|
||||
<p className="font-medium">{question || "Question placeholder"}</p>
|
||||
{options && (
|
||||
<ul className="space-y-2">
|
||||
{options.map((opt) => (
|
||||
<li
|
||||
key={opt}
|
||||
onClick={() => onSelect?.(opt[0])}
|
||||
className={`rounded border p-2 text-sm cursor-pointer hover:bg-gray-50 ${
|
||||
selectedAnswer === opt[0] ? "border-blue-500 bg-blue-50" : ""
|
||||
}`}
|
||||
>
|
||||
{opt}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
227
src/features/toeic/components/TestResult.tsx
Normal file
227
src/features/toeic/components/TestResult.tsx
Normal file
@@ -0,0 +1,227 @@
|
||||
import { useEffect, useRef } from 'react'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useTestStore } from '@/store/test-store'
|
||||
import { useRequireAuth } from '@/hooks/use-require-auth'
|
||||
import { useAuthStore } from '@/store/auth-store'
|
||||
import { saveTestResult } from '@/lib/progress-service'
|
||||
import { useAwardActivity } from '@/hooks/use-gamification'
|
||||
import { XP_REWARDS } from '@/lib/gamification-service'
|
||||
|
||||
function formatTime(s: number) {
|
||||
const m = Math.floor(s / 60)
|
||||
const sec = s % 60
|
||||
if (m === 0) return `${sec}s`
|
||||
return `${m}m ${sec}s`
|
||||
}
|
||||
|
||||
export function TestResult() {
|
||||
const navigate = useNavigate()
|
||||
const { partId, partName, questions, answers, timeUsed, reset } = useTestStore()
|
||||
const { isAuthenticated, isLoading } = useRequireAuth()
|
||||
const user = useAuthStore((s) => s.user)
|
||||
const savedRef = useRef(false)
|
||||
const { mutate: awardActivity } = useAwardActivity()
|
||||
|
||||
useEffect(() => {
|
||||
if (isLoading) return
|
||||
if (!isAuthenticated) navigate({ to: '/toeic' })
|
||||
}, [isLoading, isAuthenticated, navigate])
|
||||
|
||||
// Save test result once when page mounts (fire-and-forget)
|
||||
useEffect(() => {
|
||||
if (!user || savedRef.current || questions.length === 0) return
|
||||
savedRef.current = true
|
||||
awardActivity({ xp: XP_REWARDS.test })
|
||||
saveTestResult(user.id, {
|
||||
partId,
|
||||
partName,
|
||||
score: answers.filter((a, i) => a === questions[i]?.correctAnswer).length,
|
||||
total: questions.length,
|
||||
timeUsed,
|
||||
answers: questions.map((q, i) => ({
|
||||
questionId: q.id,
|
||||
selected: answers[i],
|
||||
correct: answers[i] === q.correctAnswer,
|
||||
})),
|
||||
})
|
||||
}, [user, questions, answers, partId, partName, timeUsed])
|
||||
|
||||
const correct = answers.filter((a, i) => a === questions[i]?.correctAnswer).length
|
||||
const wrong = answers.filter((a, i) => a !== null && a !== questions[i]?.correctAnswer).length
|
||||
const skipped = answers.filter((a) => a === null).length
|
||||
const total = questions.length
|
||||
const percent = total > 0 ? Math.round((correct / total) * 100) : 0
|
||||
|
||||
const circumference = 2 * Math.PI * 52
|
||||
const offset = circumference - (percent / 100) * circumference
|
||||
|
||||
function handleRetry() {
|
||||
navigate({ to: '/toeic/session' })
|
||||
}
|
||||
|
||||
function handleHome() {
|
||||
reset()
|
||||
navigate({ to: '/' })
|
||||
}
|
||||
|
||||
if (questions.length === 0) {
|
||||
return (
|
||||
<div className="px-6 py-8 max-w-6xl mx-auto text-center">
|
||||
<p className="text-slate-500 mb-4">Không có dữ liệu bài thi.</p>
|
||||
<button
|
||||
onClick={() => navigate({ to: '/toeic' })}
|
||||
className="bg-blue-600 text-white px-6 py-2.5 rounded-xl font-semibold text-sm hover:bg-blue-700 transition-colors"
|
||||
>
|
||||
Chọn Part để luyện thi
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="px-4 lg:px-6 py-6 max-w-6xl mx-auto page-enter">
|
||||
{/* Score header */}
|
||||
<div className="bg-white rounded-2xl p-6 border border-slate-200 mb-5">
|
||||
<div className="flex flex-col lg:flex-row items-center gap-6">
|
||||
{/* Circle */}
|
||||
<div className="flex-shrink-0 relative w-32 h-32">
|
||||
<svg className="w-full h-full -rotate-90" viewBox="0 0 120 120">
|
||||
<circle cx="60" cy="60" r="52" fill="none" stroke="#e2e8f0" strokeWidth="8" />
|
||||
<circle
|
||||
cx="60"
|
||||
cy="60"
|
||||
r="52"
|
||||
fill="none"
|
||||
stroke={percent >= 70 ? '#16a34a' : percent >= 50 ? '#2563eb' : '#dc2626'}
|
||||
strokeWidth="8"
|
||||
strokeLinecap="round"
|
||||
strokeDasharray={circumference}
|
||||
strokeDashoffset={offset}
|
||||
className="transition-all duration-700"
|
||||
/>
|
||||
</svg>
|
||||
<div className="absolute inset-0 flex flex-col items-center justify-center">
|
||||
<span className="text-3xl font-extrabold text-slate-800">{correct}/{total}</span>
|
||||
<span className="text-xs text-slate-400 font-medium">điểm</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Stats */}
|
||||
<div className="flex-1 text-center lg:text-left">
|
||||
<div className="text-2xl font-extrabold text-slate-800 mb-1">
|
||||
{percent >= 80 ? 'Xuất sắc!' : percent >= 60 ? 'Hoàn thành!' : 'Cố gắng hơn nhé!'}
|
||||
</div>
|
||||
<div className="text-sm text-slate-400 mb-4">
|
||||
Part {partId} — {partName}
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-3 justify-center lg:justify-start">
|
||||
<div className="bg-green-50 border border-green-100 rounded-xl px-4 py-2 text-center">
|
||||
<div className="text-xl font-extrabold text-green-600">{correct}</div>
|
||||
<div className="text-xs text-slate-400">Đúng</div>
|
||||
</div>
|
||||
<div className="bg-red-50 border border-red-100 rounded-xl px-4 py-2 text-center">
|
||||
<div className="text-xl font-extrabold text-red-600">{wrong}</div>
|
||||
<div className="text-xs text-slate-400">Sai</div>
|
||||
</div>
|
||||
<div className="bg-slate-50 border border-slate-200 rounded-xl px-4 py-2 text-center">
|
||||
<div className="text-xl font-extrabold text-slate-500">{skipped}</div>
|
||||
<div className="text-xs text-slate-400">Bỏ qua</div>
|
||||
</div>
|
||||
<div className="bg-blue-50 border border-blue-100 rounded-xl px-4 py-2 text-center">
|
||||
<div className="text-xl font-extrabold text-blue-600">{formatTime(timeUsed)}</div>
|
||||
<div className="text-xs text-slate-400">Thời gian</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Actions */}
|
||||
<div className="flex lg:flex-col gap-3 flex-shrink-0">
|
||||
<button
|
||||
onClick={handleRetry}
|
||||
className="flex items-center gap-2 px-5 py-2.5 bg-blue-600 text-white rounded-xl text-sm font-semibold hover:bg-blue-700 transition-colors"
|
||||
>
|
||||
<span className="material-symbols-outlined" style={{ fontSize: 18 }}>replay</span>
|
||||
Làm lại
|
||||
</button>
|
||||
<button
|
||||
onClick={handleHome}
|
||||
className="flex items-center gap-2 px-5 py-2.5 border border-slate-200 text-slate-600 rounded-xl text-sm font-semibold hover:bg-slate-50 transition-colors"
|
||||
>
|
||||
<span className="material-symbols-outlined" style={{ fontSize: 18 }}>home</span>
|
||||
Về trang chủ
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Answer review */}
|
||||
<div className="bg-white rounded-2xl border border-slate-200 p-6">
|
||||
<h2 className="text-base font-bold text-slate-800 mb-4">Xem lại đáp án</h2>
|
||||
<div className="space-y-4">
|
||||
{questions.map((q, i) => {
|
||||
const userAnswer = answers[i]
|
||||
const isCorrect = userAnswer === q.correctAnswer
|
||||
const isSkipped = userAnswer === null
|
||||
|
||||
return (
|
||||
<div
|
||||
key={q.id}
|
||||
className={cn(
|
||||
'rounded-xl border p-4',
|
||||
isCorrect ? 'border-green-100 bg-green-50/50' : isSkipped ? 'border-slate-100 bg-slate-50/50' : 'border-red-100 bg-red-50/50',
|
||||
)}
|
||||
>
|
||||
<div className="flex items-start gap-3">
|
||||
<span
|
||||
className={cn(
|
||||
'w-7 h-7 rounded-full flex items-center justify-center text-xs font-bold flex-shrink-0 mt-0.5',
|
||||
isCorrect ? 'bg-green-600 text-white' : isSkipped ? 'bg-slate-400 text-white' : 'bg-red-600 text-white',
|
||||
)}
|
||||
>
|
||||
{i + 1}
|
||||
</span>
|
||||
<div className="flex-1 min-w-0">
|
||||
<p className="text-sm font-medium text-slate-800 mb-2">{q.text}</p>
|
||||
<div className="flex flex-wrap gap-2 mb-2">
|
||||
{q.options.map((opt, j) => (
|
||||
<span
|
||||
key={j}
|
||||
className={cn(
|
||||
'text-xs px-2.5 py-1 rounded-lg font-medium',
|
||||
j === q.correctAnswer
|
||||
? 'bg-green-100 text-green-700 border border-green-200'
|
||||
: j === userAnswer && !isCorrect
|
||||
? 'bg-red-100 text-red-700 border border-red-200 line-through'
|
||||
: 'bg-slate-100 text-slate-500',
|
||||
)}
|
||||
>
|
||||
{['A', 'B', 'C', 'D'][j]}. {opt}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
{q.explanation && (
|
||||
<p className="text-xs text-slate-500 bg-white rounded-lg px-3 py-2 border border-slate-100">
|
||||
<span className="font-semibold text-slate-600">Giải thích: </span>
|
||||
{q.explanation}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<span className="flex-shrink-0">
|
||||
{isCorrect ? (
|
||||
<span className="material-symbols-outlined text-green-600" style={{ fontSize: 20 }}>check_circle</span>
|
||||
) : isSkipped ? (
|
||||
<span className="material-symbols-outlined text-slate-400" style={{ fontSize: 20 }}>remove_circle</span>
|
||||
) : (
|
||||
<span className="material-symbols-outlined text-red-500" style={{ fontSize: 20 }}>cancel</span>
|
||||
)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
207
src/features/toeic/components/TestSession.tsx
Normal file
207
src/features/toeic/components/TestSession.tsx
Normal file
@@ -0,0 +1,207 @@
|
||||
import { useState, useEffect, useCallback } from 'react'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useTestStore } from '@/store/test-store'
|
||||
import { useRequireAuth } from '@/hooks/use-require-auth'
|
||||
|
||||
const TOTAL_SECONDS = 600 // 10 minutes
|
||||
const ANSWER_LABELS = ['A', 'B', 'C', 'D']
|
||||
|
||||
function formatTime(s: number) {
|
||||
return `${String(Math.floor(s / 60)).padStart(2, '0')}:${String(s % 60).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
export function TestSession() {
|
||||
const navigate = useNavigate()
|
||||
const { partId, partName, questions, answers, setAnswer, submitExam } = useTestStore()
|
||||
const [currentQ, setCurrentQ] = useState(0)
|
||||
const [timeLeft, setTimeLeft] = useState(TOTAL_SECONDS)
|
||||
const { isAuthenticated, isLoading } = useRequireAuth()
|
||||
|
||||
const handleSubmit = useCallback(() => {
|
||||
submitExam(TOTAL_SECONDS - timeLeft)
|
||||
navigate({ to: '/toeic/result' })
|
||||
}, [submitExam, navigate, timeLeft])
|
||||
|
||||
// Countdown
|
||||
useEffect(() => {
|
||||
if (questions.length === 0) return
|
||||
const id = setInterval(() => {
|
||||
setTimeLeft((t) => {
|
||||
if (t <= 1) { clearInterval(id); handleSubmit(); return 0 }
|
||||
return t - 1
|
||||
})
|
||||
}, 1000)
|
||||
return () => clearInterval(id)
|
||||
}, [questions.length, handleSubmit])
|
||||
|
||||
// Redirect if no exam started or not authenticated (wait for auth init)
|
||||
useEffect(() => {
|
||||
if (isLoading) return
|
||||
if (!isAuthenticated || questions.length === 0) navigate({ to: '/toeic' })
|
||||
}, [isLoading, isAuthenticated, questions.length, navigate])
|
||||
|
||||
if (questions.length === 0) return null
|
||||
|
||||
const question = questions[currentQ]
|
||||
const answeredCount = answers.filter((a) => a !== null).length
|
||||
const isUrgent = timeLeft < 60
|
||||
|
||||
return (
|
||||
<div className="px-4 lg:px-6 py-6 max-w-6xl mx-auto page-enter">
|
||||
{/* Mobile progress bar */}
|
||||
<div className="lg:hidden mb-4">
|
||||
<div className="flex justify-between text-sm font-semibold mb-2">
|
||||
<span className="text-slate-700">Part {partId} — Câu {currentQ + 1}/{questions.length}</span>
|
||||
<span className={cn('font-bold tabular-nums', isUrgent ? 'text-red-600 timer-urgent' : 'text-blue-600')}>
|
||||
{formatTime(timeLeft)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="h-1.5 w-full rounded-full bg-slate-200">
|
||||
<div
|
||||
className="h-full bg-blue-600 rounded-full transition-all"
|
||||
style={{ width: `${((currentQ + 1) / questions.length) * 100}%` }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-5">
|
||||
{/* Left: Question */}
|
||||
<div className="flex-1 min-w-0">
|
||||
<div className="bg-white rounded-2xl p-6 border border-slate-200 mb-4">
|
||||
<div className="flex items-center gap-2 mb-4">
|
||||
<span className="bg-blue-600 text-white text-xs font-bold px-3 py-1 rounded-full">
|
||||
Câu {currentQ + 1}
|
||||
</span>
|
||||
<span className="text-xs text-slate-400">Part {partId} — {partName}</span>
|
||||
</div>
|
||||
<p className="text-base font-medium text-slate-800 leading-relaxed mb-6">
|
||||
{question.text}
|
||||
</p>
|
||||
<div className="space-y-3">
|
||||
{question.options.map((opt, i) => {
|
||||
const selected = answers[currentQ] === i
|
||||
return (
|
||||
<button
|
||||
key={i}
|
||||
onClick={() => setAnswer(currentQ, i)}
|
||||
className={cn(
|
||||
'w-full flex items-center gap-3 p-4 border-2 rounded-xl text-sm font-medium text-left transition-all',
|
||||
selected
|
||||
? 'border-blue-600 bg-blue-50 text-blue-700'
|
||||
: 'border-slate-200 hover:border-blue-300 hover:bg-blue-50/50 text-slate-700',
|
||||
)}
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
'w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold flex-shrink-0',
|
||||
selected ? 'bg-blue-600 text-white' : 'bg-slate-100 text-slate-500',
|
||||
)}
|
||||
>
|
||||
{ANSWER_LABELS[i]}
|
||||
</span>
|
||||
{opt}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Navigation */}
|
||||
<div className="flex items-center justify-between">
|
||||
<button
|
||||
onClick={() => setCurrentQ((q) => Math.max(0, q - 1))}
|
||||
disabled={currentQ === 0}
|
||||
className="flex items-center gap-2 px-5 py-2.5 border border-slate-200 rounded-xl text-sm font-semibold text-slate-600 hover:bg-slate-50 disabled:opacity-40 disabled:cursor-not-allowed transition-colors"
|
||||
>
|
||||
<span className="material-symbols-outlined" style={{ fontSize: 18 }}>chevron_left</span>
|
||||
Câu trước
|
||||
</button>
|
||||
<span className="text-xs text-slate-400 tabular-nums">{currentQ + 1} / {questions.length}</span>
|
||||
{currentQ < questions.length - 1 ? (
|
||||
<button
|
||||
onClick={() => setCurrentQ((q) => q + 1)}
|
||||
className="flex items-center gap-2 px-5 py-2.5 bg-blue-600 text-white rounded-xl text-sm font-semibold hover:bg-blue-700 transition-colors"
|
||||
>
|
||||
Câu tiếp theo
|
||||
<span className="material-symbols-outlined" style={{ fontSize: 18 }}>chevron_right</span>
|
||||
</button>
|
||||
) : (
|
||||
<button
|
||||
onClick={handleSubmit}
|
||||
className="flex items-center gap-2 px-5 py-2.5 bg-red-600 text-white rounded-xl text-sm font-semibold hover:bg-red-700 transition-colors"
|
||||
>
|
||||
Nộp bài
|
||||
<span className="material-symbols-outlined" style={{ fontSize: 18 }}>send</span>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Right panel — desktop only */}
|
||||
<div className="hidden lg:flex flex-col gap-4 w-60 flex-shrink-0">
|
||||
{/* Timer */}
|
||||
<div className="bg-white rounded-2xl p-5 border border-slate-200 text-center">
|
||||
<div className="text-xs text-slate-400 font-medium mb-2">Thời gian còn lại</div>
|
||||
<div
|
||||
className={cn(
|
||||
'text-5xl font-extrabold tabular-nums mb-1',
|
||||
isUrgent ? 'text-red-600 timer-urgent' : 'text-blue-600',
|
||||
)}
|
||||
>
|
||||
{formatTime(timeLeft)}
|
||||
</div>
|
||||
<div className="text-xs text-slate-400">phút : giây</div>
|
||||
</div>
|
||||
|
||||
{/* Question dots */}
|
||||
<div className="bg-white rounded-2xl p-5 border border-slate-200">
|
||||
<div className="text-xs text-slate-400 font-medium mb-3">
|
||||
Danh sách câu · {answeredCount}/{questions.length} đã trả lời
|
||||
</div>
|
||||
<div className="grid grid-cols-5 gap-2">
|
||||
{questions.map((_, i) => (
|
||||
<button
|
||||
key={i}
|
||||
onClick={() => setCurrentQ(i)}
|
||||
className={cn(
|
||||
'w-8 h-8 rounded-full flex items-center justify-center text-[11px] font-semibold transition-all',
|
||||
i === currentQ
|
||||
? 'border-2 border-blue-600 text-blue-600 shadow-sm shadow-blue-600/20'
|
||||
: answers[i] !== null
|
||||
? 'bg-blue-600 text-white'
|
||||
: 'border-2 border-slate-200 text-slate-400 hover:border-blue-300',
|
||||
)}
|
||||
>
|
||||
{i + 1}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex items-center gap-3 mt-4 text-xs text-slate-400">
|
||||
<span className="w-4 h-4 rounded-full bg-blue-600 inline-block" /> Đã trả lời
|
||||
<span className="w-4 h-4 rounded-full border-2 border-slate-200 inline-block" /> Chưa làm
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={handleSubmit}
|
||||
className="w-full py-3 bg-red-600 text-white rounded-xl font-bold text-sm hover:bg-red-700 transition-colors flex items-center justify-center gap-2"
|
||||
>
|
||||
<span className="material-symbols-outlined" style={{ fontSize: 18 }}>send</span>
|
||||
Nộp bài
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Mobile submit */}
|
||||
<div className="lg:hidden mt-4">
|
||||
<button
|
||||
onClick={handleSubmit}
|
||||
className="w-full py-3.5 bg-red-600 text-white rounded-xl font-bold text-sm hover:bg-red-700 transition-colors"
|
||||
>
|
||||
Nộp bài ngay
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
14
src/features/toeic/components/Timer.tsx
Normal file
14
src/features/toeic/components/Timer.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
interface TimerProps {
|
||||
seconds?: number
|
||||
}
|
||||
|
||||
export function Timer({ seconds = 0 }: TimerProps) {
|
||||
const mins = Math.floor(seconds / 60)
|
||||
const secs = seconds % 60
|
||||
|
||||
return (
|
||||
<div className="font-mono text-lg font-semibold tabular-nums">
|
||||
{String(mins).padStart(2, "0")}:{String(secs).padStart(2, "0")}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
109
src/features/toeic/components/ToeicPractice.tsx
Normal file
109
src/features/toeic/components/ToeicPractice.tsx
Normal file
@@ -0,0 +1,109 @@
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { CircularProgress } from '@/components/CircularProgress'
|
||||
import { useTestStore } from '@/store/test-store'
|
||||
import { TOEIC_PARTS } from '@/temp/local-data'
|
||||
import { fetchQuestions } from '@/hooks/use-questions'
|
||||
import { useRequireAuth } from '@/hooks/use-require-auth'
|
||||
|
||||
export function ToeicPractice() {
|
||||
const navigate = useNavigate()
|
||||
const { startExam } = useTestStore()
|
||||
const [loadingPartId, setLoadingPartId] = useState<number | null>(null)
|
||||
const { requireAuth } = useRequireAuth()
|
||||
|
||||
async function handleSelectPart(partId: number, partName: string) {
|
||||
if (!requireAuth()) return
|
||||
setLoadingPartId(partId)
|
||||
try {
|
||||
const questions = await fetchQuestions(partId, 10)
|
||||
startExam(partId, partName, questions)
|
||||
navigate({ to: '/toeic/session' })
|
||||
} catch (err) {
|
||||
console.error('Failed to load questions:', err)
|
||||
} finally {
|
||||
setLoadingPartId(null)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="px-6 py-8 max-w-6xl mx-auto page-enter">
|
||||
<div className="mb-8">
|
||||
<h1 className="text-3xl font-extrabold text-slate-800 mb-2">Chọn Part TOEIC</h1>
|
||||
<p className="text-slate-500">
|
||||
Hệ thống ôn luyện theo cấu trúc bài thi TOEIC thực tế. Chọn phần cụ thể để bắt đầu.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 lg:grid-cols-4 gap-5">
|
||||
{TOEIC_PARTS.map((part) => (
|
||||
<button
|
||||
key={part.id}
|
||||
onClick={() => handleSelectPart(part.id, part.nameVi)}
|
||||
disabled={loadingPartId !== null}
|
||||
className="bg-white rounded-2xl p-5 border border-slate-200 text-left hover:-translate-y-1 hover:shadow-md transition-all duration-200 group disabled:opacity-70 disabled:cursor-wait"
|
||||
>
|
||||
<div className="flex justify-between items-start mb-5">
|
||||
<div className="w-10 h-10 bg-blue-50 rounded-xl flex items-center justify-center group-hover:bg-blue-600 transition-colors">
|
||||
{loadingPartId === part.id ? (
|
||||
<span className="w-4 h-4 border-2 border-blue-300 border-t-blue-600 rounded-full animate-spin" />
|
||||
) : (
|
||||
<span
|
||||
className="material-symbols-outlined text-blue-600 group-hover:text-white transition-colors"
|
||||
style={{ fontSize: 18 }}
|
||||
>
|
||||
{part.icon}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<CircularProgress percent={part.progressPercent} size={44} />
|
||||
</div>
|
||||
<div className="font-extrabold text-lg text-slate-800 mb-0.5">{part.name}</div>
|
||||
<div className="text-sm font-semibold text-slate-700 mb-2">{part.nameVi}</div>
|
||||
<div className="flex items-center gap-1.5 text-xs text-slate-400">
|
||||
<span className="material-symbols-outlined" style={{ fontSize: 14 }}>list_alt</span>
|
||||
{part.questionCount} câu hỏi
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
|
||||
{/* Full Test card */}
|
||||
<button
|
||||
onClick={() => handleSelectPart(0, 'Full Test')}
|
||||
className="relative rounded-2xl p-5 text-left overflow-hidden hover:-translate-y-1 hover:shadow-xl transition-all duration-200"
|
||||
style={{ background: 'linear-gradient(135deg, #f59e0b, #d97706)' }}
|
||||
>
|
||||
<div className="absolute top-0 right-0 opacity-10">
|
||||
<span className="material-symbols-outlined text-white" style={{ fontSize: 80 }}>
|
||||
workspace_premium
|
||||
</span>
|
||||
</div>
|
||||
<div className="relative z-10">
|
||||
<div className="w-10 h-10 bg-white/20 rounded-xl flex items-center justify-center mb-5">
|
||||
<span className="material-symbols-outlined text-white" style={{ fontSize: 18 }}>
|
||||
military_tech
|
||||
</span>
|
||||
</div>
|
||||
<div className="font-extrabold text-2xl text-white mb-0.5">Full Test</div>
|
||||
<div className="text-sm font-semibold text-amber-50 mb-2">Mô phỏng thi thật 2h</div>
|
||||
<div className="flex items-center gap-1.5 text-xs text-amber-100">
|
||||
<span className="material-symbols-outlined" style={{ fontSize: 14 }}>timer</span>
|
||||
120 phút · 200 câu
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Tip */}
|
||||
<div className="mt-8 bg-blue-50 border border-blue-100 rounded-2xl p-5 flex items-start gap-4">
|
||||
<span className="material-symbols-outlined text-blue-600 flex-shrink-0 mt-0.5">tips_and_updates</span>
|
||||
<div>
|
||||
<div className="font-semibold text-blue-700 text-sm mb-1">Mẹo luyện thi</div>
|
||||
<p className="text-slate-500 text-sm">
|
||||
Bắt đầu từ <strong>Part 5 (Điền từ)</strong> — phần mang lại điểm nhanh nhất vì không phụ thuộc kỹ năng nghe. Mỗi ngày 20 câu, sau 2 tuần bạn sẽ thấy cải thiện rõ rệt.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user