import { Controller, Get, Query } from '@nestjs/common';
import { createZodDto } from 'nestjs-zod';
import {
  ReportMetaQuerySchema,
  ReportAbcQuerySchema,
  type ReportMetaResponse,
  type ReportCarteiraResponse,
  type ReportAbcResponse,
} from '@sar/api-interface';
import { ReportsService } from './reports.service';

class ReportMetaQueryDto extends createZodDto(ReportMetaQuerySchema) {}
class ReportAbcQueryDto extends createZodDto(ReportAbcQuerySchema) {}

@Controller({ path: 'reports' })
export class ReportsController {
  constructor(private readonly reports: ReportsService) {}

  @Get('meta')
  meta(@Query() query: ReportMetaQueryDto): Promise<ReportMetaResponse> {
    return this.reports.metaVsRealizado(ReportMetaQuerySchema.parse(query));
  }

  @Get('carteira')
  carteira(): Promise<ReportCarteiraResponse> {
    return this.reports.carteira();
  }

  @Get('abc')
  abc(@Query() query: ReportAbcQueryDto): Promise<ReportAbcResponse> {
    return this.reports.abcProdutos(ReportAbcQuerySchema.parse(query));
  }
}
