import { Controller, Get, Post, Put, Delete, Body, Param, UseGuards } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { BedRoomsService } from './bed-rooms.service';
import { JwtAuthGuard } from '../common/guards/jwt-auth.guard';
import { RolesGuard } from '../common/guards/roles.guard';
import { Roles } from '../common/decorators/roles.decorator';

@ApiTags('Bed Rooms')
@Controller()
export class BedRoomsController {
  constructor(private bedRoomsService: BedRoomsService) {}

  @Get('bed-rooms')
  findAll() {
    return this.bedRoomsService.findAll();
  }

  @ApiBearerAuth()
  @UseGuards(JwtAuthGuard, RolesGuard)
  @Roles('SUPER_ADMIN', 'ADMIN')
  @Get('admin/bed-rooms')
  adminFindAll() {
    return this.bedRoomsService.adminFindAll();
  }

  @ApiBearerAuth()
  @UseGuards(JwtAuthGuard, RolesGuard)
  @Roles('SUPER_ADMIN', 'ADMIN')
  @Post('admin/bed-rooms')
  create(@Body() data: { name: string; kelas: string; capacity: number; orderNo?: number; status?: boolean }) {
    return this.bedRoomsService.create(data);
  }

  @ApiBearerAuth()
  @UseGuards(JwtAuthGuard, RolesGuard)
  @Roles('SUPER_ADMIN', 'ADMIN')
  @Put('admin/bed-rooms/:id')
  update(@Param('id') id: string, @Body() data: { name?: string; kelas?: string; capacity?: number; orderNo?: number; status?: boolean }) {
    return this.bedRoomsService.update(+id, data);
  }

  @ApiBearerAuth()
  @UseGuards(JwtAuthGuard, RolesGuard)
  @Roles('SUPER_ADMIN', 'ADMIN')
  @Delete('admin/bed-rooms/:id')
  remove(@Param('id') id: string) {
    return this.bedRoomsService.remove(+id);
  }
}
