feat: implement user dashboard with room viewing and booking

This commit is contained in:
2025-06-18 16:17:49 +08:00
parent bc81e4d6fe
commit 95ef4cd617
4 changed files with 284 additions and 3 deletions

View File

@ -0,0 +1,28 @@
import { defineEventHandler } from 'h3';
import { db } from '~/server/db';
import { rooms, roomTypes } from '~/server/db/schema';
import { eq, gt } from 'drizzle-orm';
export default defineEventHandler(async () => {
try {
const availableRooms = await db
.select({
RoomID: rooms.id,
Type: roomTypes.typeName,
Price: rooms.price,
Feature: rooms.feature,
AvailableCount: rooms.availableCount,
})
.from(rooms)
.leftJoin(roomTypes, eq(rooms.typeId, roomTypes.id))
.where(gt(rooms.availableCount, 0));
return availableRooms;
} catch (error) {
console.error('Error fetching rooms:', error);
return createError({
statusCode: 500,
statusMessage: 'Failed to fetch rooms',
});
}
});