import { Body, Controller, Param, Post, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { CurrentUser } from '../../common/decorators/current-user.decorator';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
import { JwtPayload } from '../../common/interfaces/jwt-payload.interface';
import { CollaborationRequestsService } from './collaboration-requests.service';
import { CreateCollaborationRequestDto } from './dto/create-collaboration-request.dto';

@ApiTags('Post Collaboration Requests')
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Controller('posts')
export class PostsCollaborationRequestsController {
  constructor(private readonly collaborationRequestsService: CollaborationRequestsService) {}

  @Post(':postId/collaboration-requests')
  async create(
    @CurrentUser() user: JwtPayload,
    @Param('postId') postId: string,
    @Body() dto: CreateCollaborationRequestDto,
  ) {
    return this.collaborationRequestsService.create(user.sub, postId, dto);
  }
}
