import { ApiPropertyOptional } from '@nestjs/swagger';
import {
  IsString,
  IsOptional,
  IsDate,
  IsEnum,
  IsInt,
  IsBoolean,
  Min,
  Max,
  MaxLength,
} from 'class-validator';
import { Type } from 'class-transformer';
import { TimeEntryType } from '@prisma/client';

export class UpdateTimeEntryDto {
  @ApiPropertyOptional({
    description: 'Clock-in time',
    example: '2024-01-15T08:00:00.000Z',
  })
  @IsOptional()
  @Type(() => Date)
  @IsDate()
  clockIn?: Date;

  @ApiPropertyOptional({
    description: 'Clock-out time',
    example: '2024-01-15T17:00:00.000Z',
  })
  @IsOptional()
  @Type(() => Date)
  @IsDate()
  clockOut?: Date;

  @ApiPropertyOptional({
    description: 'Total break time in minutes',
    example: 45,
    minimum: 0,
    maximum: 480,
  })
  @IsOptional()
  @IsInt()
  @Min(0)
  @Max(480)
  breakMinutes?: number;

  @ApiPropertyOptional({
    description: 'Type of time entry',
    enum: TimeEntryType,
    example: TimeEntryType.CORRECTION,
  })
  @IsOptional()
  @IsEnum(TimeEntryType)
  type?: TimeEntryType;

  @ApiPropertyOptional({
    description: 'Note or reason for the correction',
    example: 'Correction: Wrong clock-out time entered',
    maxLength: 500,
  })
  @IsOptional()
  @IsString()
  @MaxLength(500)
  note?: string;

  @ApiPropertyOptional({
    description: 'Lock the entry to prevent further modifications',
    example: true,
  })
  @IsOptional()
  @IsBoolean()
  isLocked?: boolean;
}
