feat: Implement instructor course and lesson management with dedicated views for quizzes, videos, and admin categories.

This commit is contained in:
Missez 2026-01-30 10:56:48 +07:00
parent 344e1e4341
commit 878a17f922
9 changed files with 903 additions and 399 deletions

View file

@ -26,12 +26,16 @@
label="ชื่อหลักสูตร (ภาษาไทย) *"
outlined
:rules="[val => !!val || 'กรุณากรอกชื่อหลักสูตร']"
lazy-rules="ondemand"
hide-bottom-space
/>
<q-input
v-model="form.title.en"
label="ชื่อหลักสูตร (English) *"
outlined
:rules="[val => !!val || 'Please enter course title']"
lazy-rules="ondemand"
hide-bottom-space
/>
</div>
@ -42,6 +46,8 @@
outlined
hint="ใช้สำหรับ URL เช่น javascript-basics"
:rules="[val => !!val || 'กรุณากรอก slug']"
lazy-rules="ondemand"
hide-bottom-space
/>
<q-select
v-model="form.category_id"
@ -94,6 +100,8 @@
outlined
prefix="฿"
:rules="[val => form.is_free || val > 0 || 'กรุณากรอกราคา']"
lazy-rules="ondemand"
hide-bottom-space
/>
<q-toggle
v-model="form.have_certificate"
@ -102,32 +110,6 @@
/>
</div>
<!-- Thumbnail -->
<q-separator class="my-6" />
<h2 class="text-lg font-semibold text-primary-600 mb-4">ปภาพปก</h2>
<div class="mb-6">
<q-input
v-model="form.thumbnail_url"
label="URL รูปภาพปก *"
outlined
:rules="[val => !!val || 'กรุณากรอก URL รูปภาพปก']"
>
<template v-slot:prepend>
<q-icon name="image" />
</template>
</q-input>
</div>
<!-- Preview thumbnail if exists -->
<div v-if="form.thumbnail_url" class="mb-6">
<img
:src="form.thumbnail_url"
alt="Thumbnail preview"
class="max-w-xs rounded-lg shadow"
@error="form.thumbnail_url = ''"
/>
</div>
<!-- Actions -->
<div class="flex justify-end gap-3 mt-8">
@ -172,7 +154,6 @@ const form = ref<CreateCourseRequest>({
title: { th: '', en: '' },
slug: '',
description: { th: '', en: '' },
thumbnail_url: null,
price: 0,
is_free: true,
have_certificate: true
@ -214,19 +195,25 @@ const handleSubmit = async () => {
form.value.price = 0;
}
await instructorService.createCourse(form.value);
const response = await instructorService.createCourse(form.value);
$q.notify({
type: 'positive',
message: 'สร้างหลักสูตรสำเร็จ',
message: response.message,
position: 'top'
});
navigateTo('/instructor/courses');
// Redirect to course edit page
// Note: Assuming response.data contains the created course with ID
if (response.data && response.data.id) {
router.push(`/instructor/courses/${response.data.id}/edit`);
} else {
navigateTo('/instructor/courses');
}
} catch (error: any) {
$q.notify({
type: 'negative',
message: error.message || 'เกิดข้อผิดพลาด กรุณาลองใหม่',
message: error.data?.error?.message || error.data?.message || 'เกิดข้อผิดพลาด กรุณาลองใหม่',
position: 'top'
});
} finally {