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

import { UpdateRateDto } from './update-rate.dto';

export class SubmitRateChangeDto {
  @ApiProperty({ description: 'The LIVE rate to reprice' })
  @IsUUID()
  rateId!: string;

  @ApiProperty({
    description:
      'Proposed field changes. The live rate keeps its current values until this is approved.',
    type: UpdateRateDto,
  })
  @ValidateNested()
  @Type(() => UpdateRateDto)
  update!: UpdateRateDto;
}

export class DecideRateChangeDto {
  @ApiPropertyOptional({ description: 'Optional note shown to the requester' })
  @IsOptional()
  @IsString()
  @MaxLength(1000)
  decisionNote?: string;
}
