import { ApiProperty } from "@nestjs/swagger"
import { IsInt, IsOptional, IsString, IsIn } from "class-validator"
import { messageKey } from "../../../constants/message-keys"
import { validationMessage } from "../../../utils/helpers"

export class MyMisDto {
  @ApiProperty({
    description: "ID for update case",
    example: 1,
    required: false,
  })
  @IsOptional()
  @IsInt({
    message: validationMessage(messageKey.field_type_validation_error, {
      ":field": "id",
      ":type": "integer",
    }),
  })
  id?: number

  @ApiProperty({
    description: "Month (1-12)",
    example: 1,
    required: true,
  })
  @IsInt({
    message: validationMessage(messageKey.field_type_validation_error, {
      ":field": "month",
      ":type": "integer",
    }),
  })
  month: number

  @ApiProperty({
    description: "Year",
    example: 2024,
    required: true,
  })
  @IsInt({
    message: validationMessage(messageKey.field_type_validation_error, {
      ":field": "year",
      ":type": "integer",
    }),
  })
  year: number

  @ApiProperty({
    description: "Business tasks",
    example: "Completed project analysis",
    required: false,
  })
  @IsOptional()
  @IsString({
    message: validationMessage(messageKey.field_type_validation_error, {
      ":field": "business_tasks",
      ":type": "string",
    }),
  })
  business_tasks?: string

  @ApiProperty({
    description: "Technical tasks",
    example: "Implemented new features",
    required: false,
  })
  @IsOptional()
  @IsString({
    message: validationMessage(messageKey.field_type_validation_error, {
      ":field": "technical_tasks",
      ":type": "string",
    }),
  })
  technical_tasks?: string

  @ApiProperty({
    description: "Personal tasks",
    example: "Attended training sessions",
    required: false,
  })
  @IsOptional()
  @IsString({
    message: validationMessage(messageKey.field_type_validation_error, {
      ":field": "personal_tasks",
      ":type": "string",
    }),
  })
  personal_tasks?: string

  @ApiProperty({
    description: "Status",
    example: "pending",
    enum: ["pending", "draft", "submitted"],
    required: true,
  })
  @IsString({
    message: validationMessage(messageKey.field_type_validation_error, {
      ":field": "status",
      ":type": "string",
    }),
  })
  @IsIn(["pending", "draft", "submitted"], {
    message: validationMessage(messageKey.field_type_validation_error, {
      ":field": "status",
      ":values": "pending, draft, submitted",
    }),
  })
  status: string
}
