import { IsEnum, IsOptional, IsString, IsDate, IsNumber } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { AppointmentStatus } from 'common/enum/appointment.enum';
import { Transform } from 'class-transformer';

export class UpdateAppointmentDto {
  @ApiPropertyOptional({ description: 'Full name of the person', example: 'John Doe' })
  @IsOptional()
  @IsString()
  fullName?: string;

  @ApiPropertyOptional({ description: 'Title of the appointment', example: 'Cyber Consultation' })
  @IsOptional()
  @IsString()
  title?: string;

  @ApiPropertyOptional({ description: 'Additional notes about the appointment', example: 'Facebook ID hack' })
  @IsOptional()
  @IsString()
  notes?: string;

  @ApiPropertyOptional({ description: 'Date of the appointment', example: '2024-02-25T10:00:00.000Z' })
  @IsOptional()
  @IsDate()
  @Transform(({ value }) => new Date(value), { toClassOnly: true })
  appointmentDate?: Date;

  @ApiPropertyOptional({ description: 'Time of the appointment (HH:mm format)', example: '14:30' })
  @IsOptional()
  @IsString()
  appointmentTime?: string;

  @ApiPropertyOptional({ description: 'Duration of the appointment in minutes', example: 30 })
  @IsOptional()
  @IsNumber()
  duration?: number;

  @ApiPropertyOptional({ description: 'Phone number', example: 1234567890 })
  @IsOptional()
  @IsNumber()
  phone?: number;

  @ApiPropertyOptional({
    description: 'The updated status of the appointment',
    enum: AppointmentStatus,
    example: AppointmentStatus.PENDING,
  })
  @IsOptional()
  @IsEnum(AppointmentStatus)
  status?: AppointmentStatus;
}
