edit: response.message
This commit is contained in:
parent
d7f824f353
commit
7de5457170
21 changed files with 227 additions and 127 deletions
|
|
@ -224,7 +224,7 @@ const fetchCategories = async () => {
|
|||
} catch (error) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: 'ไม่สามารถโหลดข้อมูลหมวดหมู่ได้',
|
||||
message: (error as any).data?.message || 'ไม่สามารถโหลดข้อมูลหมวดหมู่ได้',
|
||||
position: 'top'
|
||||
});
|
||||
} finally {
|
||||
|
|
@ -270,32 +270,32 @@ const handleSave = async () => {
|
|||
saving.value = true;
|
||||
try {
|
||||
if (isEditing.value && editingId.value) {
|
||||
await adminService.updateCategory(editingId.value, {
|
||||
const response = await adminService.updateCategory(editingId.value, {
|
||||
id: editingId.value,
|
||||
...form.value
|
||||
});
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: 'แก้ไขหมวดหมู่สำเร็จ',
|
||||
message: response.message || 'แก้ไขหมวดหมู่สำเร็จ',
|
||||
position: 'top'
|
||||
});
|
||||
} else {
|
||||
await adminService.createCategory({
|
||||
const response = await adminService.createCategory({
|
||||
...form.value,
|
||||
created_by: parseInt(authStore.user?.id || '0')
|
||||
});
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: 'เพิ่มหมวดหมู่สำเร็จ',
|
||||
message: response.message || 'เพิ่มหมวดหมู่สำเร็จ',
|
||||
position: 'top'
|
||||
});
|
||||
}
|
||||
showModal.value = false;
|
||||
fetchCategories();
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: 'เกิดข้อผิดพลาด กรุณาลองใหม่',
|
||||
message: error.data?.message || 'เกิดข้อผิดพลาด กรุณาลองใหม่',
|
||||
position: 'top'
|
||||
});
|
||||
} finally {
|
||||
|
|
@ -311,17 +311,17 @@ const confirmDelete = (category: CategoryResponse) => {
|
|||
persistent: true
|
||||
}).onOk(async () => {
|
||||
try {
|
||||
await adminService.deleteCategory(category.id);
|
||||
const response = await adminService.deleteCategory(category.id);
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: 'ลบหมวดหมู่สำเร็จ',
|
||||
message: response.message || 'ลบหมวดหมู่สำเร็จ',
|
||||
position: 'top'
|
||||
});
|
||||
fetchCategories();
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: 'เกิดข้อผิดพลาดในการลบ',
|
||||
message: error.data?.message || 'เกิดข้อผิดพลาดในการลบ',
|
||||
position: 'top'
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ const fetchCourse = async () => {
|
|||
const courseId = Number(route.params.id);
|
||||
course.value = await adminService.getCourseForReview(courseId);
|
||||
} catch (err) {
|
||||
error.value = 'ไม่สามารถโหลดข้อมูลคอร์สได้';
|
||||
error.value = (err as any).data?.message || 'ไม่สามารถโหลดข้อมูลคอร์สได้';
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
|
@ -395,17 +395,17 @@ const confirmApprove = () => {
|
|||
}).onOk(async () => {
|
||||
actionLoading.value = true;
|
||||
try {
|
||||
await adminService.approveCourse(course.value!.id);
|
||||
const response = await adminService.approveCourse(course.value!.id);
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: 'อนุมัติคอร์สสำเร็จ',
|
||||
message: response.message || 'อนุมัติคอร์สสำเร็จ',
|
||||
position: 'top'
|
||||
});
|
||||
router.push('/admin/courses/pending');
|
||||
} catch (err) {
|
||||
} catch (err: any) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: 'เกิดข้อผิดพลาดในการอนุมัติคอร์ส',
|
||||
message: err.data?.message || 'เกิดข้อผิดพลาดในการอนุมัติคอร์ส',
|
||||
position: 'top'
|
||||
});
|
||||
} finally {
|
||||
|
|
@ -419,18 +419,18 @@ const confirmReject = async () => {
|
|||
|
||||
actionLoading.value = true;
|
||||
try {
|
||||
await adminService.rejectCourse(course.value.id, rejectReason.value);
|
||||
const response = await adminService.rejectCourse(course.value.id, rejectReason.value);
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: 'ปฏิเสธคอร์สสำเร็จ',
|
||||
message: response.message || 'ปฏิเสธคอร์สสำเร็จ',
|
||||
position: 'top'
|
||||
});
|
||||
showRejectModal.value = false;
|
||||
router.push('/admin/courses/pending');
|
||||
} catch (err) {
|
||||
} catch (err: any) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: 'เกิดข้อผิดพลาดในการปฏิเสธคอร์ส',
|
||||
message: err.data?.message || 'เกิดข้อผิดพลาดในการปฏิเสธคอร์ส',
|
||||
position: 'top'
|
||||
});
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ const fetchPendingCourses = async () => {
|
|||
} catch (error) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: 'ไม่สามารถโหลดข้อมูลคอร์สได้',
|
||||
message: (error as any).data?.message || 'ไม่สามารถโหลดข้อมูลคอร์สได้',
|
||||
position: 'top'
|
||||
});
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
<div class="flex justify-between items-center">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-gray-900">
|
||||
สวัสดี, {{ authStore.user?.fullName || 'ผู้ดูแลระบบ' }}
|
||||
สวัสดี, {{ authStore.user?.firstName }} {{ authStore.user?.lastName }}
|
||||
</h1>
|
||||
<p class="text-gray-600 mt-2">ยินดีต้อนรับกลับสู่ระบบ</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="text-right">
|
||||
<div class="text-sm font-semibold text-gray-900">{{ authStore.user?.fullName || 'ผู้ดูแลระบบ' }}</div>
|
||||
<div class="text-sm font-semibold text-gray-900">{{ authStore.user?.firstName }} {{ authStore.user?.lastName }}</div>
|
||||
<div class="text-xs text-gray-500">{{ authStore.user?.role || 'ADMIN' }}</div>
|
||||
</div>
|
||||
<div
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
<!-- User Info Header -->
|
||||
<q-item class="bg-primary-50">
|
||||
<q-item-section>
|
||||
<q-item-label class="text-weight-bold">{{ authStore.user?.fullName }}</q-item-label>
|
||||
<q-item-label class="text-weight-bold">{{ authStore.user?.firstName }} {{ authStore.user?.lastName }}</q-item-label>
|
||||
<q-item-label caption>{{ authStore.user?.email }}</q-item-label>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
|
|
@ -85,8 +85,8 @@
|
|||
</div>
|
||||
<!-- Recent Courses -->
|
||||
<div class="card">
|
||||
<h2 class="text-xl font-semibold mb-4">หลักสูตรล่าสุด</h2>
|
||||
<div class="space-y-4">
|
||||
<h2 class="text-xl font-semibold mb-4">Dashboard</h2>
|
||||
<!-- <div class="space-y-4">
|
||||
<div class="flex items-center gap-4 p-4 bg-gray-50 rounded-lg">
|
||||
<div class="w-16 h-16 bg-primary-100 rounded-lg flex items-center justify-center">
|
||||
<q-icon name="code" size="32px" class="text-primary-600" />
|
||||
|
|
@ -97,7 +97,7 @@
|
|||
</div>
|
||||
<q-btn flat color="primary" label="ดูรายละเอียด" />
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@
|
|||
icon="download"
|
||||
@click="exportExcel"
|
||||
/>
|
||||
<q-btn
|
||||
<!-- <q-btn
|
||||
color="primary"
|
||||
label="+ เพิ่มผู้ใช้ใหม่"
|
||||
@click="showAddModal = true"
|
||||
/>
|
||||
/> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -279,7 +279,7 @@ const fetchUsers = async () => {
|
|||
} catch (error) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: 'ไม่สามารถโหลดข้อมูลผู้ใช้ได้',
|
||||
message: (error as any).data?.message || 'ไม่สามารถโหลดข้อมูลผู้ใช้ได้',
|
||||
position: 'top'
|
||||
});
|
||||
} finally {
|
||||
|
|
@ -326,7 +326,7 @@ const changeRole = (user: AdminUserResponse) => {
|
|||
message: `เลือก Role ใหม่สำหรับ ${user.profile.first_name}`,
|
||||
options: {
|
||||
type: 'radio',
|
||||
model: roleIds[user.role.code],
|
||||
model: roleIds[user.role.code] as any,
|
||||
items: [
|
||||
{ label: 'Instructor', value: 1 },
|
||||
{ label: 'Student', value: 2 },
|
||||
|
|
@ -337,17 +337,17 @@ const changeRole = (user: AdminUserResponse) => {
|
|||
persistent: true
|
||||
}).onOk(async (roleId: number) => {
|
||||
try {
|
||||
await adminService.updateUserRole(user.id, roleId);
|
||||
const response = await adminService.updateUserRole(user.id, roleId);
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: 'เปลี่ยน Role สำเร็จ',
|
||||
message: response.message || 'เปลี่ยน Role สำเร็จ',
|
||||
position: 'top'
|
||||
});
|
||||
fetchUsers();
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: 'เกิดข้อผิดพลาดในการเปลี่ยน Role',
|
||||
message: error.data?.message || 'เกิดข้อผิดพลาดในการเปลี่ยน Role',
|
||||
position: 'top'
|
||||
});
|
||||
}
|
||||
|
|
@ -362,17 +362,17 @@ const confirmDelete = (user: AdminUserResponse) => {
|
|||
persistent: true
|
||||
}).onOk(async () => {
|
||||
try {
|
||||
await adminService.deleteUser(user.id);
|
||||
const response = await adminService.deleteUser(user.id);
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: 'ลบผู้ใช้สำเร็จ',
|
||||
message: response.message || 'ลบผู้ใช้สำเร็จ',
|
||||
position: 'top'
|
||||
});
|
||||
fetchUsers();
|
||||
} 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