import { AlertStage, AlertType, AttackType } from 'common/enum/alert.enum';
import { Expose } from 'class-transformer';
import { ApiProperty } from '@nestjs/swagger';
import { Alert } from '../entity/alert.entity';

export class AlertResponseDto extends Alert {
  @ApiProperty()
  @Expose()
  id: string;

  @ApiProperty()
  @Expose()
  title: string;

  @ApiProperty()
  @Expose()
  description: string;

  @ApiProperty()
  @Expose()
  source: string;

  @ApiProperty({ required: false })
  @Expose()
  sourceUrl: string;

  @ApiProperty({ type: Date, required: false })
  @Expose()
  attackTime: Date;

  @ApiProperty()
  @Expose()
  targetCountry: string;

  @ApiProperty()
  @Expose()
  targetOrganization: string;

  @ApiProperty({ required: false })
  @Expose()
  attackerInfo: string;

  @ApiProperty({ enum: AttackType })
  @Expose()
  attackType: AttackType;

  @ApiProperty({ enum: AlertStage })
  @Expose()
  stage: AlertStage;

  @ApiProperty({ enum: AlertType })
  @Expose()
  type: AlertType;

  @ApiProperty()
  @Expose()
  isVerified: boolean;

  @ApiProperty({ required: false })
  @Expose()
  verifiedBy: string;

  @ApiProperty({ type: Date, required: false })
  @Expose()
  verifiedAt: Date;

  @ApiProperty({ required: false })
  @Expose()
  score: number;

  @ApiProperty({ required: false })
  @Expose()
  severity: number;

  @ApiProperty()
  @Expose()
  isRelevantToNepal: boolean;

  @ApiProperty()
  @Expose()
  sentToNewsletter: boolean;

  @ApiProperty({ required: false })
  @Expose()
  newsletterId: string;

  @ApiProperty({ required: false })
  @Expose()
  posterName: string;

  @ApiProperty({ required: false })
  @Expose()
  posterUrl: string;

  @ApiProperty({ type: Date })
  @Expose()
  createdAt: Date;

  @ApiProperty({ type: Date })
  @Expose()
  updatedAt: Date;
}

export class MetaPagination {
  @ApiProperty()
  total: number;

  @ApiProperty()
  page: number;

  @ApiProperty()
  limit: number;

  @ApiProperty()
  totalPages: number;
}

export class IAlertResponsePaginated {
  @ApiProperty({ type: [AlertResponseDto] })
  @Expose()
  data: AlertResponseDto[];

  @ApiProperty({ type: MetaPagination })
  @Expose()
  meta: MetaPagination;
}
