import { Body, Controller, Get, Param, Patch, Post, UseGuards } from '@nestjs/common';
import { InternalAccessGuard } from '../common/internal-access.guard';
import { ProjectsService } from './projects.service';

@Controller('projects')
export class ProjectsController {
  constructor(private readonly projects: ProjectsService) {}

  @Get()
  list() { return this.projects.listPublic(); }

  @Get(':slug')
  bySlug(@Param('slug') slug: string) { return this.projects.getPublicBySlug(slug); }

  @UseGuards(InternalAccessGuard)
  @Post()
  create(@Body() body: Record<string, unknown>) { return this.projects.createProject(body); }

  @UseGuards(InternalAccessGuard)
  @Patch(':id')
  update(@Param('id') id: string, @Body() body: Record<string, unknown>) { return this.projects.updateProject(id, body); }

  @UseGuards(InternalAccessGuard)
  @Post(':id/milestones')
  milestone(@Param('id') id: string, @Body() body: Record<string, unknown>) { return this.projects.createMilestone(id, body); }
}
