import { Controller, Get, Req, UseGuards } from '@nestjs/common';
import { DashboardService } from './dashboard.service';
import { AccountTypesGuard } from '../../common/guards/accountTypes.guard';
import { AccountTypes } from '../../common/decorators/accountType.decorator';
import { AccountType } from '@prisma/client';

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

  @Get()
  // @UseGuards(AccountTypesGuard)
  // @AccountTypes(AccountType.ADMIN)
  async getStats(
    @Req() req: any
  ) {
    const userId = req.user?.sub;
    const userRole = req.user?.role;

    if (userRole === AccountType.MANUFACTURER) {
      return this.dashboardService.getManufacturerStats(userId);
    }
    return this.dashboardService.getStats(userId);
  }

  @Get('manufacturer')
  async getManufacturerStats(
    @Req() req: any
  ) {
    const userId = req.user?.sub;
    return this.dashboardService.getManufacturerStats(userId);
  }
}
