import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
  IsString,
  IsOptional,
  IsEnum,
  IsInt,
  Min,
} from 'class-validator';
import { SQCDMCategory, KPIStatus, Trend } from '@prisma/client';

/**
 * DTO for creating a new morning meeting topic (KPI)
 */
export class CreateTopicDto {
  @ApiProperty({
    description: 'SQCDM category for the topic',
    enum: SQCDMCategory,
    example: 'QUALITY',
  })
  @IsEnum(SQCDMCategory)
  category: SQCDMCategory;

  @ApiProperty({
    description: 'Topic title/name',
    example: 'Fehlerquote',
  })
  @IsString()
  title: string;

  @ApiPropertyOptional({
    description: 'Current value of the KPI',
    example: '2.5',
  })
  @IsOptional()
  @IsString()
  value?: string;

  @ApiPropertyOptional({
    description: 'Target value for the KPI',
    example: '2.0',
  })
  @IsOptional()
  @IsString()
  target?: string;

  @ApiPropertyOptional({
    description: 'Unit of measurement',
    example: '%',
  })
  @IsOptional()
  @IsString()
  unit?: string;

  @ApiPropertyOptional({
    description: 'KPI status (traffic light)',
    enum: KPIStatus,
    default: 'NEUTRAL',
  })
  @IsOptional()
  @IsEnum(KPIStatus)
  status?: KPIStatus;

  @ApiPropertyOptional({
    description: 'Trend direction',
    enum: Trend,
  })
  @IsOptional()
  @IsEnum(Trend)
  trend?: Trend;

  @ApiPropertyOptional({
    description: 'Sort order within category',
    example: 0,
  })
  @IsOptional()
  @IsInt()
  @Min(0)
  sortOrder?: number;

  @ApiPropertyOptional({
    description: 'Additional notes for the topic',
    example: 'Production line A had issues',
  })
  @IsOptional()
  @IsString()
  note?: string;
}
