import { Controller, Get, Post, Body, HttpCode, HttpStatus, Param } from '@nestjs/common';
import { ApiTags, ApiResponse, ApiOperation } from '@nestjs/swagger';
import { SponsorService } from './SponsorService';
import { GetEntitySponsorshipPricingResultDTO } from './dtos/GetEntitySponsorshipPricingResultDTO';
import { GetSponsorsOutputDTO } from './dtos/GetSponsorsOutputDTO';
import { CreateSponsorInputDTO } from './dtos/CreateSponsorInputDTO';
import { CreateSponsorOutputDTO } from './dtos/CreateSponsorOutputDTO';
import { GetSponsorDashboardQueryParamsDTO } from './dtos/GetSponsorDashboardQueryParamsDTO';
import { SponsorDashboardDTO } from './dtos/SponsorDashboardDTO';
import { GetSponsorSponsorshipsQueryParamsDTO } from './dtos/GetSponsorSponsorshipsQueryParamsDTO';
import { SponsorSponsorshipsDTO } from './dtos/SponsorSponsorshipsDTO';

@ApiTags('sponsors')
@Controller('sponsors')
export class SponsorController {
  constructor(private readonly sponsorService: SponsorService) {}

  @Get('pricing')
  @ApiOperation({ summary: 'Get sponsorship pricing for an entity' })
  @ApiResponse({ status: 200, description: 'Sponsorship pricing', type: GetEntitySponsorshipPricingResultDTO })
  async getEntitySponsorshipPricing(): Promise<GetEntitySponsorshipPricingResultDTO> {
    return this.sponsorService.getEntitySponsorshipPricing();
  }

  @Get()
  @ApiOperation({ summary: 'Get all sponsors' })
  @ApiResponse({ status: 200, description: 'List of sponsors', type: GetSponsorsOutputDTO })
  async getSponsors(): Promise<GetSponsorsOutputDTO> {
    return this.sponsorService.getSponsors();
  }

  @Post()
  @HttpCode(HttpStatus.CREATED)
  @ApiOperation({ summary: 'Create a new sponsor' })
  @ApiResponse({ status: 201, description: 'Sponsor created', type: CreateSponsorOutputDTO })
  async createSponsor(@Body() input: CreateSponsorInputDTO): Promise<CreateSponsorOutputDTO> {
    return this.sponsorService.createSponsor(input);
  }

  // Add other Sponsor endpoints here based on other presenters
  @Get('dashboard/:sponsorId')
  @ApiOperation({ summary: 'Get sponsor dashboard metrics and sponsored leagues' })
  @ApiResponse({ status: 200, description: 'Sponsor dashboard data', type: SponsorDashboardDTO })
  @ApiResponse({ status: 404, description: 'Sponsor not found' })
  async getSponsorDashboard(@Param('sponsorId') sponsorId: string): Promise<SponsorDashboardDTO | null> {
    return this.sponsorService.getSponsorDashboard({ sponsorId } as GetSponsorDashboardQueryParamsDTO);
  }
  @Get(':sponsorId/sponsorships')
  @ApiOperation({ summary: 'Get all sponsorships for a given sponsor' })
  @ApiResponse({ status: 200, description: 'List of sponsorships', type: SponsorSponsorshipsDTO })
  @ApiResponse({ status: 404, description: 'Sponsor not found' })
  async getSponsorSponsorships(@Param('sponsorId') sponsorId: string): Promise<SponsorSponsorshipsDTO | null> {
    return this.sponsorService.getSponsorSponsorships({ sponsorId } as GetSponsorSponsorshipsQueryParamsDTO);
  }
}
