edit: response.message
This commit is contained in:
parent
d7f824f353
commit
7de5457170
21 changed files with 227 additions and 127 deletions
|
|
@ -430,7 +430,7 @@ const saveLesson = async () => {
|
|||
navigateTo(`/instructor/courses/${courseId}/structure`);
|
||||
} catch (error) {
|
||||
console.error('Failed to save lesson:', error);
|
||||
$q.notify({ type: 'negative', message: 'ไม่สามารถบันทึกได้', position: 'top' });
|
||||
$q.notify({ type: 'negative', message: (error as any).data?.error?.message || (error as any).data?.message || 'ไม่สามารถบันทึกได้', position: 'top' });
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,20 @@
|
|||
autogrow
|
||||
rows="3"
|
||||
/>
|
||||
<q-card-section class="flex justify-end gap-2">
|
||||
<q-btn
|
||||
flat
|
||||
label="ยกเลิก"
|
||||
@click="navigateTo(`/instructor/courses/${courseId}/structure`)"
|
||||
/>
|
||||
<q-btn
|
||||
color="primary"
|
||||
label="บันทึก"
|
||||
icon="save"
|
||||
:loading="saving"
|
||||
@click="saveLesson"
|
||||
/>
|
||||
</q-card-section>
|
||||
</div>
|
||||
</q-card-section>
|
||||
|
||||
|
|
@ -182,20 +196,7 @@
|
|||
|
||||
<!-- Actions -->
|
||||
<q-separator />
|
||||
<q-card-section class="flex justify-end gap-2">
|
||||
<q-btn
|
||||
flat
|
||||
label="ยกเลิก"
|
||||
@click="navigateTo(`/instructor/courses/${courseId}/structure`)"
|
||||
/>
|
||||
<q-btn
|
||||
color="primary"
|
||||
label="บันทึก"
|
||||
icon="save"
|
||||
:loading="saving"
|
||||
@click="saveLesson"
|
||||
/>
|
||||
</q-card-section>
|
||||
|
||||
</q-card>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,8 @@
|
|||
|
||||
<!-- Status Badges -->
|
||||
<div class="flex gap-2">
|
||||
<q-badge v-if="course.is_free" color="purple">เผยแพร่</q-badge>
|
||||
<q-badge v-if="course.is_free" color="purple">ฟรี</q-badge>
|
||||
<q-badge v-else color="purple">เสียเงิน</q-badge>
|
||||
<q-badge :color="getStatusColor(course.status)">
|
||||
{{ getStatusLabel(course.status) }}
|
||||
</q-badge>
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@
|
|||
:rules="[val => !!val || 'กรุณากรอกชื่อบทเรียน']"
|
||||
lazy-rules="ondemand"
|
||||
hide-bottom-space
|
||||
class="mb-4"
|
||||
/>
|
||||
<q-input
|
||||
v-model="lessonForm.title.en"
|
||||
|
|
|
|||
|
|
@ -197,6 +197,7 @@ const handleSubmit = async () => {
|
|||
|
||||
const response = await instructorService.createCourse(form.value);
|
||||
|
||||
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: response.message,
|
||||
|
|
@ -206,9 +207,9 @@ const handleSubmit = async () => {
|
|||
// 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`);
|
||||
await navigateTo(`/instructor/courses/${response.data.id}`);
|
||||
} else {
|
||||
navigateTo('/instructor/courses');
|
||||
await navigateTo('/instructor/courses');
|
||||
}
|
||||
} catch (error: any) {
|
||||
$q.notify({
|
||||
|
|
|
|||
|
|
@ -100,9 +100,9 @@
|
|||
<div class="flex justify-between items-start mb-2">
|
||||
<h3 class="font-semibold text-gray-900 line-clamp-2">{{ course.title.th }}</h3>
|
||||
<q-badge :color="getStatusColor(course.status)" class="ml-2">
|
||||
{{ getStatusLabel(course.status) }}
|
||||
</q-badge>
|
||||
</div>
|
||||
{{ getStatusLabel(course.status) }}
|
||||
</q-badge>
|
||||
</div>
|
||||
|
||||
<p class="text-sm text-gray-500 line-clamp-2 mb-3">
|
||||
{{ course.description.th }}
|
||||
|
|
@ -277,18 +277,18 @@ const confirmDelete = (course: CourseResponse) => {
|
|||
persistent: true
|
||||
}).onOk(async () => {
|
||||
try {
|
||||
await instructorService.deleteCourse(course.id);
|
||||
const response = await instructorService.deleteCourse(course.id);
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: 'ลบหลักสูตรสำเร็จ',
|
||||
message: response.message || 'ลบหลักสูตรสำเร็จ',
|
||||
position: 'top'
|
||||
});
|
||||
// Refresh list
|
||||
fetchCourses();
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: 'ไม่สามารถลบหลักสูตรได้',
|
||||
message: error.data?.message || 'ไม่สามารถลบหลักสูตรได้',
|
||||
position: 'top'
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue