import { Body, Controller, Get, Param, Post, UseGuards } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { PromosService } from './promos.service';
import { CreatePromotionDto } from './promos.dto';
import { JwtGuard } from '../../common/jwt.guard';

@ApiTags('Promotions')
@Controller('promos')
export class PromosController {
  constructor(private service: PromosService) {}
  @Get()                  @ApiOperation({ summary: 'Get active promotions' })       getActive() { return this.service.getActive(); }
  @Get('validate/:code')  @ApiOperation({ summary: 'Validate a promo code' })       validate(@Param('code') code: string) { return this.service.validate(code); }
  @Post() @UseGuards(JwtGuard) @ApiBearerAuth('JWT-auth') @ApiOperation({ summary: 'Create promotion (admin)' }) create(@Body() dto: CreatePromotionDto) { return this.service.create(dto); }
}
