import { Controller, Get, UseGuards, Req } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { AuthGuard } from '@nestjs/passport';
import { IssuerStatsService } from '../../../application/services/issuer-stats.service';

@ApiTags('Issuer Stats')
@Controller('issuers/me')
@UseGuards(AuthGuard('jwt'))
@ApiBearerAuth()
export class IssuerStatsController {
  constructor(private readonly issuerStatsService: IssuerStatsService) {}

  @Get('stats')
  @ApiOperation({ summary: 'Get issuer dashboard stats' })
  async getStats(@Req() req: any) {
    const stats = await this.issuerStatsService.getDashboardStats(req.user.issuerId);
    return { code: 0, data: stats };
  }

  @Get('credit')
  @ApiOperation({ summary: 'Get issuer credit score details' })
  async getCreditDetails(@Req() req: any) {
    const credit = await this.issuerStatsService.getCreditDetails(req.user.issuerId);
    return { code: 0, data: credit };
  }
}
