import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
import { DropdownOptionsService } from './dropdown-options.service';
import { JwtAuthGuard } from '../common/guards/jwt-auth.guard';
import { RolesGuard } from '../common/guards/roles.guard';
import { Roles } from '../common/decorators/roles.decorator';
import { Role } from '../common/roles/role.enum';

@Controller('dropdown-options')
@UseGuards(JwtAuthGuard)
export class DropdownOptionsController {
    constructor(private readonly service: DropdownOptionsService) {}

    @Get()
    findByCategory(@Query('category') category: string) {
        return this.service.findByCategory(category);
    }

    @Post()
    @UseGuards(RolesGuard)
    @Roles(Role.ADMIN)
    create(@Body() body: { category: string; value: string }) {
        return this.service.create(body.category, body.value);
    }
}
