/**
 * Leave DTOs
 * @module HR
 */

import {
  IsString,
  IsOptional,
  IsBoolean,
  IsNumber,
  IsUUID,
  IsDateString,
  IsEnum,
  Min,
} from 'class-validator';
import { LeaveStatus, HalfDayType } from '../entities/leave.entity';

export class CreateLeaveDto {
  @IsUUID()
  companyId: string;

  @IsUUID()
  employeeId: string;

  @IsUUID()
  leaveTypeId: string;

  @IsOptional()
  @IsUUID()
  allocationId?: string;

  @IsDateString()
  dateFrom: string;

  @IsDateString()
  dateTo: string;

  @IsNumber()
  @Min(0)
  daysRequested: number;

  @IsOptional()
  @IsBoolean()
  isHalfDay?: boolean;

  @IsOptional()
  @IsEnum(['morning', 'afternoon'])
  halfDayType?: HalfDayType;

  @IsOptional()
  @IsString()
  requestReason?: string;

  @IsOptional()
  @IsString()
  documentUrl?: string;

  @IsOptional()
  @IsString()
  notes?: string;
}

export class UpdateLeaveDto {
  @IsOptional()
  @IsUUID()
  leaveTypeId?: string;

  @IsOptional()
  @IsUUID()
  allocationId?: string;

  @IsOptional()
  @IsDateString()
  dateFrom?: string;

  @IsOptional()
  @IsDateString()
  dateTo?: string;

  @IsOptional()
  @IsNumber()
  @Min(0)
  daysRequested?: number;

  @IsOptional()
  @IsBoolean()
  isHalfDay?: boolean;

  @IsOptional()
  @IsEnum(['morning', 'afternoon'])
  halfDayType?: HalfDayType;

  @IsOptional()
  @IsString()
  requestReason?: string;

  @IsOptional()
  @IsString()
  documentUrl?: string;

  @IsOptional()
  @IsString()
  notes?: string;
}

export class SubmitLeaveDto {
  @IsOptional()
  @IsString()
  requestReason?: string;
}

export class ApproveLeaveDto {
  @IsOptional()
  @IsString()
  notes?: string;
}

export class RejectLeaveDto {
  @IsString()
  rejectionReason: string;
}

export class CancelLeaveDto {
  @IsOptional()
  @IsString()
  cancellationReason?: string;
}
