import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsString, IsOptional, IsUUID, IsArray } from 'class-validator';
import { PartialType } from '@nestjs/mapped-types';
import { PesRecipientResponseDto } from './pes-recipient.dto';

export class CreatePesRecipientGroupDto {
  @ApiProperty({ example: 'Engineering Group', description: 'Name of the recipient group' })
  @IsString()
  name: string;

  @ApiPropertyOptional({ example: 'Group for engineering department', description: 'Description of the group' })
  @IsOptional()
  @IsString()
  description?: string;

  @ApiPropertyOptional({ example: 'Engineering', description: 'Department name' })
  @IsOptional()
  @IsString()
  department?: string;

  @ApiProperty({ example: '', description: 'Verified User ID who created this group' })
  @IsUUID()
  verifiedUserId: string;

  @ApiPropertyOptional({ example: ['1b2d3f45-6789-4aab-bccd-ef0123456789'], description: 'IDs of recipients to add' })
  @IsOptional()
   @IsUUID('4', { each: true })
  recipientIds?: string[];
}

export class UpdatePesRecipientGroupDto extends PartialType(CreatePesRecipientGroupDto) {}

export class PesRecipientGroupResponseDto {
  @ApiProperty({ example: '1b2d3f45-6789-4aab-bccd-ef0123456789', description: 'ID of the recipient group' })
  id: string;

  @ApiProperty({ example: 'Engineering Group', description: 'Name of the recipient group' })
  name: string;

  @ApiProperty({ example: 'Group for engineering department', required: false })
  description?: string;

  @ApiProperty({ example: 'Engineering', required: false })
  department?: string;

  @ApiProperty({ type: () => [PesRecipientResponseDto] })
  recipients: PesRecipientResponseDto[];

  @ApiProperty({ example: '2023-10-01T12:00:00Z', description: 'Creation timestamp of the group' })
  createdAt: Date;

  @ApiProperty({ example: '2023-10-01T12:00:00Z', description: 'Last update timestamp of the group' })
  updatedAt: Date;

  constructor(partial: Partial<PesRecipientGroupResponseDto>) {
    Object.assign(this, partial);
  }
}
