feat: Implement core e-learning pages for My Courses, Classroom, and Course Detail.
This commit is contained in:
parent
90a8cb6509
commit
7eafa0f79e
4 changed files with 25 additions and 14 deletions
|
|
@ -412,6 +412,9 @@ const onVideoEnded = async () => {
|
|||
await performSaveProgress(true, false)
|
||||
|
||||
// Call explicit complete endpoint if exists
|
||||
// Call explicit complete endpoint if exists
|
||||
// REMOVED: User requested to remove explicit complete call
|
||||
/*
|
||||
if (currentLesson.value) {
|
||||
const res = await markLessonComplete(courseId.value, currentLesson.value.id)
|
||||
if (res.success) {
|
||||
|
|
@ -422,13 +425,15 @@ const onVideoEnded = async () => {
|
|||
// Refresh course data to update certificate status
|
||||
await loadCourseData()
|
||||
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) => {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ const handleEnroll = async () => {
|
|||
|
||||
if (res.success) {
|
||||
// ถ้าสำเร็จ ให้เปลี่ยนหน้าไปที่ "คอร์สของฉัน" พร้อม params enrolled=true
|
||||
return navigateTo('/dashboard/my-courses?enrolled=true')
|
||||
return navigateTo(`/dashboard/my-courses?enrolled=true&course_id=${course.value.id}`)
|
||||
} else {
|
||||
// กรณี error แสดง alert (อนาคตอาจเปลี่ยนเป็น Toast notification)
|
||||
alert(res.error || 'Failed to enroll')
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -155,8 +155,7 @@
|
|||
|
||||
### 🚀 Pending / Future Work (สิ่งที่ต้องทำต่อ)
|
||||
|
||||
1. **Advanced Features:** ระบบ Reviews/Rating คอร์สเรียน
|
||||
2. **Certificates:** ระบบดาวน์โหลดใบประกาศนียบัตร (ข้อมูล Backend พร้อมแล้ว รอเชื่อมต่อ UI)
|
||||
3. **Payment Gateway:** (ถ้ามีในอนาคต)
|
||||
1. **Certificates:** ระบบดาวน์โหลดใบประกาศนียบัตร (ข้อมูล Backend พร้อมแล้ว รอเชื่อมต่อ UI)
|
||||
2. **Payment Gateway:** (ถ้ามีในอนาคต)
|
||||
|
||||
---
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue