import {
  IsString,
  IsOptional,
  IsEnum,
  IsArray,
  IsUUID,
  IsNumber,
  IsBoolean,
  IsDate,
} from 'class-validator';
import {
  ArticleStatus,
  LiveBlogStatus,
  ImagePosition,
  ImageSize,
  VideoPosition,
} from './entities';

export class CreateArticleDto {
  @IsString()
  title: string;

  @IsString()
  content: string;

  @IsOptional()
  @IsString()
  excerpt?: string;

  @IsOptional()
  @IsString()
  slug?: string;

  @IsOptional()
  @IsString()
  featuredImage?: string;

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  tags?: string[];

  @IsOptional()
  @IsEnum(ArticleStatus)
  status?: ArticleStatus;

  @IsOptional()
  @IsString()
  strapiId?: string;

  @IsOptional()
  @IsUUID()
  authorId?: string;

  @IsOptional()
  @IsUUID()
  categoryId?: string;

  @IsOptional()
  @IsEnum(ImagePosition)
  imagePosition?: ImagePosition;

  @IsOptional()
  @IsEnum(ImageSize)
  imageSize?: ImageSize;

  @IsOptional()
  @IsString()
  videoUrl?: string;

  @IsOptional()
  @IsEnum(VideoPosition)
  videoPosition?: VideoPosition;

  @IsOptional()
  @IsString()
  videoCaption?: string;
}

export class UpdateArticleDto {
  @IsOptional()
  @IsString()
  title?: string;

  @IsOptional()
  @IsString()
  content?: string;

  @IsOptional()
  @IsString()
  excerpt?: string;

  @IsOptional()
  @IsString()
  slug?: string;

  @IsOptional()
  @IsString()
  featuredImage?: string;

  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  tags?: string[];

  @IsOptional()
  @IsEnum(ArticleStatus)
  status?: ArticleStatus;

  @IsOptional()
  @IsString()
  strapiId?: string;

  @IsOptional()
  @IsUUID()
  authorId?: string;

  @IsOptional()
  @IsUUID()
  categoryId?: string;

  @IsOptional()
  @IsEnum(ImagePosition)
  imagePosition?: ImagePosition;

  @IsOptional()
  @IsEnum(ImageSize)
  imageSize?: ImageSize;

  @IsOptional()
  @IsString()
  videoUrl?: string;

  @IsOptional()
  @IsEnum(VideoPosition)
  videoPosition?: VideoPosition;

  @IsOptional()
  @IsString()
  videoCaption?: string;
}

export class FindArticlesDto {
  @IsOptional()
  @IsString()
  category?: string;

  @IsOptional()
  @IsString()
  author?: string;

  @IsOptional()
  @IsString()
  tag?: string;

  @IsOptional()
  @IsString()
  status?: string;

  @IsOptional()
  @IsString()
  search?: string;

  @IsOptional()
  @IsNumber()
  page?: number;

  @IsOptional()
  limit?: number;
}

export class CreateLiveBlogDto {
  @IsString()
  title: string;

  @IsString()
  slug: string;

  @IsOptional()
  @IsString()
  description?: string;

  @IsOptional()
  @IsEnum(LiveBlogStatus)
  status?: LiveBlogStatus;

  @IsOptional()
  @IsBoolean()
  isPinned?: boolean;

  @IsOptional()
  @IsString()
  strapiId?: string;

  @IsOptional()
  @IsUUID()
  authorId?: string;

  @IsOptional()
  @IsUUID()
  categoryId?: string;

  @IsOptional()
  @IsString()
  featuredImage?: string;

  @IsOptional()
  @IsEnum(ImagePosition)
  imagePosition?: ImagePosition;

  @IsOptional()
  @IsEnum(ImageSize)
  imageSize?: ImageSize;

  @IsOptional()
  @IsString()
  videoUrl?: string;

  @IsOptional()
  @IsEnum(VideoPosition)
  videoPosition?: VideoPosition;

  @IsOptional()
  @IsString()
  videoCaption?: string;
}

export class UpdateLiveBlogDto {
  @IsOptional()
  @IsString()
  title?: string;

  @IsOptional()
  @IsString()
  slug?: string;

  @IsOptional()
  @IsString()
  description?: string;

  @IsOptional()
  @IsEnum(LiveBlogStatus)
  status?: LiveBlogStatus;

  @IsOptional()
  @IsBoolean()
  isPinned?: boolean;

  @IsOptional()
  @IsString()
  strapiId?: string;

  @IsOptional()
  @IsUUID()
  authorId?: string;

  @IsOptional()
  @IsUUID()
  categoryId?: string;

  @IsOptional()
  @IsString()
  featuredImage?: string;

  @IsOptional()
  @IsEnum(ImagePosition)
  imagePosition?: ImagePosition;

  @IsOptional()
  @IsEnum(ImageSize)
  imageSize?: ImageSize;

  @IsOptional()
  @IsString()
  videoUrl?: string;

  @IsOptional()
  @IsEnum(VideoPosition)
  videoPosition?: VideoPosition;

  @IsOptional()
  @IsString()
  videoCaption?: string;
}

export class CreateLiveBlogUpdateDto {
  @IsString()
  content: string;

  @IsOptional()
  @IsBoolean()
  isPinned?: boolean;

  @IsOptional()
  @IsUUID()
  authorId?: string;

  @IsOptional()
  @IsDate()
  scheduledAt?: Date;

  @IsOptional()
  @IsString()
  strapiId?: string;
}

export class UpdateLiveBlogUpdateDto {
  @IsOptional()
  @IsString()
  content?: string;

  @IsOptional()
  @IsBoolean()
  isPinned?: boolean;

  @IsOptional()
  @IsUUID()
  authorId?: string;

  @IsOptional()
  @IsDate()
  scheduledAt?: Date;

  @IsOptional()
  @IsString()
  strapiId?: string;
}

export class FindLiveBlogsDto {
  @IsOptional()
  @IsString()
  category?: string;

  @IsOptional()
  @IsString()
  author?: string;

  @IsOptional()
  @IsString()
  status?: string;

  @IsOptional()
  @IsBoolean()
  isPinned?: boolean;

  @IsOptional()
  @IsString()
  search?: string;

  @IsOptional()
  @IsNumber()
  page?: number;

  @IsOptional()
  limit?: number;
}
