feat: Implement core e-learning pages for My Courses, Classroom, and Course Detail.

This commit is contained in:
supalerk-ar66 2026-01-29 17:52:52 +07:00
parent 90a8cb6509
commit 7eafa0f79e
4 changed files with 25 additions and 14 deletions

View file

@ -42,22 +42,29 @@ const isLoading = ref(false)
const loadEnrolledCourses = async () => {
isLoading.value = true
const apiStatus = activeFilter.value === 'all'
? undefined
: activeFilter.value === 'completed'
// FIX: For 'progress' tab, we want both ENROLLED and IN_PROGRESS.
// Since API takes single status, we fetch ALL and filter locally for 'progress'.
const apiStatus = activeFilter.value === 'completed'
? 'COMPLETED'
: 'IN_PROGRESS'
: undefined // 'all' or 'progress' -> fetch all
const res = await fetchEnrolledCourses({
status: apiStatus
})
if (res.success) {
enrolledCourses.value = (res.data || []).map(item => ({
let courses = (res.data || [])
// Local filter for 'progress' tab to exclude completed
if (activeFilter.value === 'progress') {
courses = courses.filter(c => c.status !== 'COMPLETED')
}
enrolledCourses.value = courses.map(item => ({
id: item.course_id,
enrollment_id: item.id,
title: getLocalizedText(item.course.title),
progress: 0,
progress: item.progress_percentage || 0,
completed: item.status === 'COMPLETED',
thumbnail_url: item.course.thumbnail_url
}))