feat: Introduce core e-learning features with new pages for course details, dashboard, authentication, browsing, and learning, supported by a useCourse composable.

This commit is contained in:
supalerk-ar66 2026-01-23 09:47:32 +07:00
parent c982ab2c05
commit 0eb9b522f6
6 changed files with 109 additions and 38 deletions

View file

@ -1,8 +1,8 @@
<script setup lang="ts">
/**
* @file home.vue
* @description Dashboard / Home Page.
* Displays the user's dashboard with a welcome message, current learning progress, and course recommendations.
* @description หนาแดชบอรดหล (Dashboard)
* แสดงขอความตอนร และคอรสแนะนำสำหรบผเรยน
*/
definePageMeta({
@ -26,10 +26,12 @@ const getLocalizedText = (text: string | { th: string; en: string } | undefined)
}
// Recommended Courses State
// ( 3 )
const recommendedCourses = ref<any[]>([])
onMounted(async () => {
// 1. Fetch Categories for mapping
//
const catRes = await fetchCategories()
const catMap = new Map()
if (catRes.success) {
@ -37,12 +39,13 @@ onMounted(async () => {
}
// 2. Fetch All Courses and Randomize
// 3
const res = await fetchCourses()
if (res.success && res.data?.length) {
// Shuffle array
// Shuffle array ()
const shuffled = [...res.data].sort(() => 0.5 - Math.random())
// Pick first 3
// Pick first 3 ( 3 )
recommendedCourses.value = shuffled.slice(0, 3).map((c: any) => ({
id: c.id,
title: getLocalizedText(c.title),