import { Body, Controller, Get, Post, Query, UseGuards } from '@nestjs/common';
import { InternalAccessGuard } from '../common/internal-access.guard';
import { OperationsService } from './operations.service';

@Controller('operations')
export class OperationsController {
  constructor(private readonly service: OperationsService) {}

  @Get('overview') overview(@Query('projectId') projectId?: string) { return this.service.overview(projectId); }
  @Get('farm-units') units(@Query('projectId') projectId?: string) { return this.service.listUnits(projectId); }
  @Get('daily-reports') reports(@Query('projectId') projectId?: string, @Query('limit') limit?: string) { return this.service.listDailyReports(projectId, Number(limit || 30)); }
  @UseGuards(InternalAccessGuard)
  @Post('daily-reports') createReport(@Body() body: Record<string, unknown>) { return this.service.createDailyReport(body); }
}
