import { Transform } from 'class-transformer';
import { IsEnum, IsMongoId, IsOptional, IsString, MaxLength } from 'class-validator';
import {
  COLLABORATION_ATTACHMENT_TYPES,
  COLLABORATION_TYPES,
  CollaborationAttachmentType,
  CollaborationType,
} from '../schemas/collaboration-request.schema';

export class CreateCollaborationRequestDto {
  @IsOptional()
  @IsMongoId()
  targetUserId?: string;

  @IsOptional()
  @Transform(({ value }) => (typeof value === 'string' ? value.trim().toLowerCase() : value))
  @IsEnum(COLLABORATION_TYPES)
  collaborationType?: CollaborationType;

  @IsOptional()
  @Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
  @IsString()
  @MaxLength(1000)
  message?: string;

  @IsOptional()
  @Transform(({ value }) => (typeof value === 'string' ? value.trim() : value))
  @IsString()
  @MaxLength(500)
  attachmentUrl?: string;

  @IsOptional()
  @Transform(({ value }) => (typeof value === 'string' ? value.trim().toLowerCase() : value))
  @IsEnum(COLLABORATION_ATTACHMENT_TYPES)
  attachmentType?: CollaborationAttachmentType;
}
