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:
parent
c982ab2c05
commit
0eb9b522f6
6 changed files with 109 additions and 38 deletions
|
|
@ -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),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue