import { Controller, Get, UseGuards } from '@nestjs/common';
import { CurrentUser } from '../auth/decorators/current-user.decorator.js';
import { Roles } from '../auth/decorators/roles.decorator.js';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard.js';
import { RolesGuard } from '../auth/guards/roles.guard.js';
import type { SafeUser } from '../auth/types/auth.types.js';
import { DashboardService } from './dashboard.service.js';
import type { DashboardResponse } from './types/dashboard.types.js';

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

  @Get()
  @Roles('ADMIN', 'SALES_USER')
  getOverview(
    @CurrentUser() currentUser: SafeUser,
  ): Promise<DashboardResponse> {
    return this.dashboardService.getOverview(currentUser);
  }
}
