import { useNavigate } from '@tanstack/react-router'
import { useQuery } from '@tanstack/react-query'
import { fetchTests } from '@/features/toeic/api/test-list-api'
export function ToeicTestList() {
const navigate = useNavigate()
const { data: tests = [], isLoading, error } = useQuery({
queryKey: ['tests'],
queryFn: fetchTests,
})
return (
Đề Thi TOEIC
Chọn đề thi để bắt đầu luyện tập hoặc thi thử toàn bộ.
{isLoading && (
{Array.from({ length: 6 }).map((_, i) => (
))}
)}
{error && (
Không thể tải danh sách đề thi. Vui lòng thử lại.
)}
{!isLoading && !error && tests.length === 0 && (
library_books
Chưa có đề thi nào. Dữ liệu đang được cập nhật.
)}
{tests.length > 0 && (
{tests.map((test) => (
{/* Category badge */}
{test.categoryName && (
{test.categoryName}
)}
{test.title}
{test.description && (
{test.description}
)}
list_alt
{test.totalQuestions} câu
timer
{test.durationMinutes} phút
))}
)}
)
}