import {
  Controller,
  Get,
  Param,
  ParseUUIDPipe,
  UseGuards,
} from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';

import { CurrentUser } from '../../auth/decorators/current-user.decorator';
import { SessionGuard } from '../../auth/guards/session.guard';

import { PlayersService } from './players.service';

@ApiTags('servers')
@Controller('servers/:serverId/players')
@UseGuards(SessionGuard)
export class PlayersController {
  constructor(private readonly playersService: PlayersService) {}

  @Get()
  @ApiOperation({ summary: 'List online players, whitelist, and operators' })
  @ApiResponse({ status: 200, description: 'Player overview' })
  list(
    @CurrentUser() user: { id: string },
    @Param('serverId', ParseUUIDPipe) serverId: string,
  ) {
    return this.playersService.listPlayers(user.id, serverId);
  }
}
