import { IsString, IsInt, IsBoolean, IsOptional, IsArray, ValidateNested } from 'class-validator';
import { Type } from 'class-transformer';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';

export class AgentPassengerDto {
  @ApiProperty() @IsString() fullName: string;
  @ApiProperty() @IsString() phone: string;
  @ApiProperty() @IsString() email: string;
  @ApiProperty() @IsString() seatId: string;
  @ApiPropertyOptional() @IsOptional() @IsString() idDocumentType?: string;
  @ApiPropertyOptional() @IsOptional() @IsString() idDocumentNumber?: string;
}

export class CreateAgentBookingDto {
  @ApiProperty() @IsString() agentId: string;
  @ApiProperty({ example: 'schedule-uuid' }) @IsString() scheduleId: string;
  @ApiProperty({ type: [AgentPassengerDto] }) @IsArray() @ValidateNested({ each: true }) @Type(() => AgentPassengerDto) passengers: AgentPassengerDto[];
  @ApiProperty() @IsString() paymentMethod: string;
  @ApiPropertyOptional() @IsOptional() @IsInt() cashReceived?: number;
  @ApiPropertyOptional() @IsOptional() @IsBoolean() paperTicket?: boolean;
  @ApiPropertyOptional() @IsOptional() @IsString() serviceClass?: string;
}

export class OpenShiftDto {
  @ApiProperty() @IsString() agentId: string;
  @ApiPropertyOptional() @IsOptional() @IsInt() openingBalance?: number;
}

export class CloseShiftDto {
  @ApiProperty() @IsString() shiftId: string;
  @ApiProperty() @IsInt() closingBalance: number;
  @ApiPropertyOptional() @IsOptional() @IsString() notes?: string;
}
