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

@ -412,6 +412,9 @@ const onVideoEnded = async () => {
await performSaveProgress(true, false) await performSaveProgress(true, false)
// Call explicit complete endpoint if exists // Call explicit complete endpoint if exists
// Call explicit complete endpoint if exists
// REMOVED: User requested to remove explicit complete call
/*
if (currentLesson.value) { if (currentLesson.value) {
const res = await markLessonComplete(courseId.value, currentLesson.value.id) const res = await markLessonComplete(courseId.value, currentLesson.value.id)
if (res.success) { if (res.success) {
@ -422,13 +425,15 @@ const onVideoEnded = async () => {
// Refresh course data to update certificate status // Refresh course data to update certificate status
await loadCourseData() await loadCourseData()
alert(t('course.completed') || "ยินดีด้วย! คุณเรียนจบหลักสูตรแล้ว") alert(t('course.completed') || "ยินดีด้วย! คุณเรียนจบหลักสูตรแล้ว")
} else if (res.data.next_lesson_id) {
// Auto-advance removed as per request.
// User will manually select the next lesson from the sidebar.
} }
} }
} }
*/
// Just refresh local state assuming server handles completion via progress
if (currentLesson.value) {
markLessonAsCompletedLocally(currentLesson.value.id)
}
} }
const formatTime = (time: number) => { const formatTime = (time: number) => {

View file

@ -36,7 +36,7 @@ const handleEnroll = async () => {
if (res.success) { if (res.success) {
// "" params enrolled=true // "" params enrolled=true
return navigateTo('/dashboard/my-courses?enrolled=true') return navigateTo(`/dashboard/my-courses?enrolled=true&course_id=${course.value.id}`)
} else { } else {
// error alert ( Toast notification) // error alert ( Toast notification)
alert(res.error || 'Failed to enroll') alert(res.error || 'Failed to enroll')

View file

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

View file

@ -155,8 +155,7 @@
### 🚀 Pending / Future Work (สิ่งที่ต้องทำต่อ) ### 🚀 Pending / Future Work (สิ่งที่ต้องทำต่อ)
1. **Advanced Features:** ระบบ Reviews/Rating คอร์สเรียน 1. **Certificates:** ระบบดาวน์โหลดใบประกาศนียบัตร (ข้อมูล Backend พร้อมแล้ว รอเชื่อมต่อ UI)
2. **Certificates:** ระบบดาวน์โหลดใบประกาศนียบัตร (ข้อมูล Backend พร้อมแล้ว รอเชื่อมต่อ UI) 2. **Payment Gateway:** (ถ้ามีในอนาคต)
3. **Payment Gateway:** (ถ้ามีในอนาคต)
--- ---