import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsArray, IsBoolean, IsOptional, IsString, ValidateNested } from 'class-validator';
import { Type } from 'class-transformer';
import { CreateBlogTranslationDto } from './create-blog.dto';

export class UpdateBlogDto {
  @ApiPropertyOptional({ description: 'Publication status', example: false, default: false })
  @IsBoolean()
  @IsOptional()
  isPublished?: boolean;

  @ApiPropertyOptional({ description: 'Blog tags', type: [String], example: ['technology', 'programming'] })
  @IsArray()
  @IsString({ each: true })
  @IsOptional()
  tags?: string[];

  @ApiPropertyOptional({ description: 'Featured image URL', example: 'https://example.com/image.jpg' })
  @IsString()
  @IsOptional()
  featuredImageUrl?: string;

  @ApiPropertyOptional({
    description: 'Blog translations',
    type: [CreateBlogTranslationDto],
    example: [
      { language: 'en', title: 'My First Blog', content: '# Hello World' },
      { language: 'np', title: 'मेरो पहिलो ब्लग', content: '# नमस्ते संसार' },
    ],
  })
  @ValidateNested({ each: true })
  @Type(() => CreateBlogTranslationDto)
  @IsOptional()
  translations?: CreateBlogTranslationDto[];

  @ApiPropertyOptional({ description: 'Author names', example: 'John Doe' })
  @IsString({ each: true })
  @IsOptional()
  authorNames?: string[];

  @ApiPropertyOptional({ description: 'Blog slug', example: 'my-first-blog' })
  @IsString()
  @IsOptional()
  slug?: string;
}
