import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
  IsString, IsInt, IsOptional, IsDateString, IsIn, Min,
} from 'class-validator';

export class CreateSegmentFareDto {
  @ApiProperty({ example: 'route-uuid' })
  @IsString()
  routeId: string;

  @ApiProperty({ example: 1 })
  @IsInt() @Min(0)
  originStopSequence: number;

  @ApiProperty({ example: 5 })
  @IsInt() @Min(1)
  destinationStopSequence: number;

  @ApiProperty({ example: 'seat-class-uuid' })
  @IsString()
  seatClassId: string;

  @ApiProperty({ example: 35000, description: 'Base fare in minor units (e.g. 350.00 ETB = 35000)' })
  @IsInt() @Min(0)
  baseFareMinor: number;

  @ApiPropertyOptional({ example: 'LOCAL', enum: ['LOCAL', 'INTERNATIONAL'] })
  @IsOptional()
  @IsIn(['LOCAL', 'INTERNATIONAL'])
  nationality?: string;

  @ApiPropertyOptional({ example: 'ETB', default: 'ETB' })
  @IsOptional()
  @IsString()
  currency?: string;

  @ApiProperty({ example: '2025-01-01T00:00:00.000Z' })
  @IsDateString()
  validFrom: string;

  @ApiPropertyOptional({ example: '2026-12-31T23:59:59.000Z' })
  @IsOptional()
  @IsDateString()
  validUntil?: string;
}

export class UpdateSegmentFareDto {
  @ApiPropertyOptional({ example: 40000 })
  @IsOptional()
  @IsInt() @Min(0)
  baseFareMinor?: number;

  @ApiPropertyOptional({ example: 'ETB' })
  @IsOptional()
  @IsString()
  currency?: string;

  @ApiPropertyOptional({ example: '2025-06-01T00:00:00.000Z' })
  @IsOptional()
  @IsDateString()
  validFrom?: string;

  @ApiPropertyOptional({ example: '2026-12-31T23:59:59.000Z' })
  @IsOptional()
  @IsDateString()
  validUntil?: string;
}
