Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions app/pages/rooms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- Navbar -->
<nav class="sticky top-16 z-50 bg-white border-b border-slate-200 p-3 shadow-sm no-print">
<div class="container mx-auto flex items-center">
<UButton icon="i-lucide-arrow-left" label="ย้อนกลับ" color="gray" variant="ghost" size="lg" to="/" class="font-bold text-md cursor-pointer hover:bg-slate-100" />

Check warning on line 6 in app/pages/rooms.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 22)

'class' should be on a new line

Check warning on line 6 in app/pages/rooms.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 22)

'to' should be on a new line

Check warning on line 6 in app/pages/rooms.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 22)

'size' should be on a new line

Check warning on line 6 in app/pages/rooms.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 22)

'variant' should be on a new line

Check warning on line 6 in app/pages/rooms.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 22)

'color' should be on a new line

Check warning on line 6 in app/pages/rooms.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 22)

'label' should be on a new line
</div>
</nav>

Expand Down Expand Up @@ -143,9 +143,7 @@
<p class="font-bold text-slate-900 truncate max-w-[160px]">
{{ room.room_name }}
</p>
<p v-if="room.building" class="text-md text-slate-500 truncate max-w-[160px]">
{{ room.building }}
</p>

</td>

<!-- Slots -->
Expand Down Expand Up @@ -416,15 +414,13 @@

const formData = ref({
room_name: '',
building: '',
description: ''
})

const openAddModal = () => {
editingRoom.value = null
formData.value = {
room_name: '',
building: '',
description: ''
}
modalOpen.value = true
Expand All @@ -434,7 +430,6 @@
editingRoom.value = room
formData.value = {
room_name: room.room_name,
building: room.building || '',
description: room.description || ''
}
modalOpen.value = true
Expand Down
2 changes: 1 addition & 1 deletion app/pages/sections/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="container mx-auto px-4">
<div class="flex items-center justify-between h-16">
<div class="flex items-center gap-4">
<UButton icon="i-lucide-arrow-left" color="gray" variant="ghost" to="/sections" />

Check warning on line 8 in app/pages/sections/[id].vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 22)

'to' should be on a new line

Check warning on line 8 in app/pages/sections/[id].vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 22)

'variant' should be on a new line

Check warning on line 8 in app/pages/sections/[id].vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 22)

'color' should be on a new line
<h2 class="text-xl font-bold text-slate-800">
ตารางเรียน - {{ section?.section_name || 'Loading...' }}
</h2>
Expand All @@ -20,7 +20,7 @@
<!-- Profile Card -->
<div class="flex-1 bg-white p-6 rounded-2xl border border-slate-200 shadow-sm flex items-center gap-6">
<div
class="w-20 h-20 rounded-full bg-blue-100 text-slate-800 font-bold flex items-center justify-center text-3xl shadow-sm border border-blue-200">

Check warning on line 23 in app/pages/sections/[id].vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 22)

Expected 1 line break before closing bracket, but no line breaks found
<!-- Show initial of section -->
{{ section?.section_name ? section.section_name.substring(0, 2) : 'S' }}
</div>
Expand Down Expand Up @@ -605,7 +605,7 @@

const { data: rooms } = await useFetch('/api/rooms')
const roomOptions = computed(() => {
const opts = rooms.value?.map(r => ({ value: r.id_room, label: `${r.room_name}${r.building ? ` (${r.building})` : ''}` })) || []
const opts = rooms.value?.map(r => ({ value: r.id_room, label: r.room_name })) || []
return [{ value: null, label: 'ไม่ระบุห้อง' }, ...opts]
})

Expand Down
2 changes: 1 addition & 1 deletion app/pages/teacher/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ const roomOptions = computed(() => {
{ label: 'ไม่ระบุห้อง', value: null },
...rooms.value.map(r => ({
value: r.id_room,
label: `${r.room_name}${r.building ? ` (${r.building})` : ''}`
label: r.room_name
}))
]
})
Expand Down
2 changes: 0 additions & 2 deletions server/api/rooms/[id].js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ export default defineEventHandler(async (event) => {
const stmt = db.prepare(`
UPDATE rooms
SET room_name = COALESCE(?, room_name),
building = COALESCE(?, building),
description = COALESCE(?, description)
WHERE id_room = ?
`)

const result = stmt.run(
body.room_name || null,
body.building !== undefined ? body.building : null,
body.description !== undefined ? body.description : null,
id
)
Expand Down
6 changes: 2 additions & 4 deletions server/api/rooms/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,18 @@ export default defineEventHandler(async (event) => {

try {
const stmt = db.prepare(`
INSERT INTO rooms (room_name, building, description)
VALUES (?, ?, ?)
INSERT INTO rooms (room_name, description)
VALUES (?, ?)
`)

const result = stmt.run(
body.room_name,
body.building || null,
body.description || null
)

return {
id_room: result.lastInsertRowid,
room_name: body.room_name,
building: body.building || null,
description: body.description || null,
created_at: new Date().toISOString()
}
Expand Down
Binary file modified server/data/data.db
Binary file not shown.
2 changes: 1 addition & 1 deletion server/utils/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ db.exec(`
CREATE TABLE IF NOT EXISTS rooms (
id_room INTEGER PRIMARY KEY AUTOINCREMENT,
room_name TEXT NOT NULL UNIQUE,
building TEXT,
description TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);`)
Expand Down Expand Up @@ -318,6 +317,7 @@ try {
safeDropColumn('teachers', 'name')
safeDropColumn('calendar_events', 'teacher_name')
safeDropColumn('rooms', 'capacity')
safeDropColumn('rooms', 'building')
safeDropColumn('Subjects', 'id_room')
safeDropColumn('teachers', 'subject')

Expand Down
Loading