import { Controller, Post, Body, Get, Param, HttpStatus, HttpCode } from '@nestjs/common';
import { DisputeService } from './dispute.service';
import { Dispute, DisputeEvent } from '@prisma/client';

@Controller('disputes')
export class DisputeController {
  constructor(private readonly disputeService: DisputeService) {}

  @Post()
  async createDispute(@Body() disputeData: Partial<Dispute>): Promise<Dispute> {
    return this.disputeService.createDispute(disputeData);
  }

  @Get(':id')
  async getDispute(@Param('id') id: number): Promise<Dispute | null> {
    return this.disputeService.getDisputeById(id);
  }

  @Post(':id/evidence')
  async addEvidence(
    @Param('id') disputeId: number,
    @Body() evidenceData: any
  ): Promise<DisputeEvent> {
    return this.disputeService.addEvidence(disputeId, evidenceData);
  }

  @Post(':id/status')
  @HttpCode(HttpStatus.OK)
  async updateStatus(
    @Param('id') disputeId: number,
    @Body() statusData: { status: string }
  ): Promise<Dispute> {
    return this.disputeService.updateDisputeStatus(disputeId, statusData.status);
  }

  @Post(':id/resolve')
  async resolveDispute(
    @Param('id') disputeId: number,
    @Body() decisionData: any
  ): Promise<Dispute> {
    return this.disputeService.resolveDispute(disputeId, decisionData);
  }
}