import { Controller, Get, Query, UseGuards } from '@nestjs/common';
import { DashboardService } from './dashboard.service';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
import { CurrentUser } from '../../common/decorators/current-user.decorator';

@Controller('dashboard')
@UseGuards(JwtAuthGuard)
export class DashboardController {
  constructor(private readonly dashboardService: DashboardService) {}

  @Get('overview')
  getOverview(@CurrentUser() user: { id: number; email: string }) {
    return this.dashboardService.getOverview(user.id);
  }

  @Get('activity')
  getRecentActivity(@CurrentUser() user: { id: number; email: string }) {
    return this.dashboardService.getRecentActivity(user.id);
  }

  @Get('chart')
  getMonthlyChart(
    @CurrentUser() user: { id: number; email: string },
    @Query('year') year: string,
  ) {
    const y = year ? Number(year) : new Date().getFullYear();
    return this.dashboardService.getMonthlyChart(user.id, y);
  }
}
