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

// ── Projects ──────────────────────────────────────

export class CreateProjectDto {
  @ApiProperty({ example: 'Deadpool' })
  @IsString()
  title: string;

  @ApiProperty({ example: 'https://example.com/deadpool.jpg' })
  @IsString()
  image: string;

  @ApiProperty({
    example: ['Official Turkish Voice', 'Character Voice Acting'],
  })
  @IsArray()
  @IsString({ each: true })
  roles: string[];

  @ApiPropertyOptional({ example: '#FF5733' })
  @IsOptional()
  @IsString()
  color?: string;

  @ApiPropertyOptional({ example: 0 })
  @IsOptional()
  @IsInt()
  @Min(0)
  sortOrder?: number;
}

export class UpdateProjectDto {
  @ApiPropertyOptional({ example: 'Deadpool 3' })
  @IsOptional()
  @IsString()
  title?: string;

  @ApiPropertyOptional({ example: 'https://example.com/deadpool3.jpg' })
  @IsOptional()
  @IsString()
  image?: string;

  @ApiPropertyOptional({ example: ['Official Turkish Voice'] })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  roles?: string[];

  @ApiPropertyOptional({ example: '#C70039' })
  @IsOptional()
  @IsString()
  color?: string;

  @ApiPropertyOptional({ example: 1 })
  @IsOptional()
  @IsInt()
  @Min(0)
  sortOrder?: number;

  @ApiPropertyOptional({ example: true })
  @IsOptional()
  @IsBoolean()
  isActive?: boolean;
}

export class ReorderProjectsDto {
  @ApiProperty({
    example: [
      { id: 'uuid-1', sortOrder: 0 },
      { id: 'uuid-2', sortOrder: 1 },
    ],
  })
  @IsArray()
  items: { id: string; sortOrder: number }[];
}

// ── Site Content ──────────────────────────────────

export class UpdateSiteContentDto {
  @ApiProperty({ example: { title: 'Hello', desc: 'World' } })
  @IsObject()
  content: Record<string, any>;
}

// ── Clients ──────────────────────────────────────

export class CreateClientDto {
  @ApiProperty({ example: 'Netflix' })
  @IsString()
  name: string;

  @ApiProperty({ example: 'https://example.com/netflix-logo.png' })
  @IsString()
  logo: string;

  @ApiPropertyOptional({ example: 'https://netflix.com' })
  @IsOptional()
  @IsString()
  website?: string;

  @ApiPropertyOptional({ example: 0 })
  @IsOptional()
  @IsInt()
  @Min(0)
  sortOrder?: number;
}

export class UpdateClientDto {
  @ApiPropertyOptional({ example: 'Netflix' })
  @IsOptional()
  @IsString()
  name?: string;

  @ApiPropertyOptional({ example: 'https://example.com/netflix-logo.png' })
  @IsOptional()
  @IsString()
  logo?: string;

  @ApiPropertyOptional({ example: 'https://netflix.com' })
  @IsOptional()
  @IsString()
  website?: string;

  @ApiPropertyOptional({ example: 0 })
  @IsOptional()
  @IsInt()
  @Min(0)
  sortOrder?: number;

  @ApiPropertyOptional({ example: true })
  @IsOptional()
  @IsBoolean()
  isActive?: boolean;
}
