import { Controller, Get, Query, UseGuards } from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { DashboardService } from './dashboard.service';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
import { CurrentTenant } from '../../common/decorators/tenant.decorator';

@ApiTags('Dashboard')
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Controller('dashboard')
export class DashboardController {
  constructor(private service: DashboardService) {}

  @Get()
  stats(@CurrentTenant() tenantId: string) {
    return this.service.getStats(tenantId);
  }

  @Get('revenue')
  revenue(@CurrentTenant() tenantId: string, @Query('year') year: number) {
    return this.service.getMonthlyRevenue(tenantId, year || new Date().getFullYear());
  }
}
