import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import {
  IsString,
  IsOptional,
  IsEnum,
  IsUrl,
  MaxLength,
} from 'class-validator';
import { S3StatusType } from '@prisma/client';

/**
 * DTO for updating a S3 status entry
 */
export class UpdateS3StatusDto {
  @ApiProperty({
    description: 'Status value (GREEN, YELLOW, RED, NOT_APPLICABLE)',
    enum: S3StatusType,
    example: S3StatusType.GREEN,
  })
  @IsEnum(S3StatusType)
  status: S3StatusType;

  @ApiPropertyOptional({
    description: 'URL to the uploaded photo',
    example: '/uploads/s3/photo-123.jpg',
  })
  @IsOptional()
  @IsString()
  photo?: string;

  @ApiPropertyOptional({
    description: 'Note or comment for this status entry',
    example: 'Werkzeugablage wurde neu organisiert',
    maxLength: 1000,
  })
  @IsOptional()
  @IsString()
  @MaxLength(1000)
  note?: string;
}

/**
 * DTO for batch updating multiple status entries
 */
export class BatchUpdateS3StatusDto {
  @ApiProperty({
    description: 'Array of status updates',
    type: 'array',
    items: {
      type: 'object',
      properties: {
        id: { type: 'string', description: 'Status entry ID' },
        status: { enum: ['GREEN', 'YELLOW', 'RED', 'NOT_APPLICABLE'] },
        photo: { type: 'string', nullable: true },
        note: { type: 'string', nullable: true },
      },
    },
  })
  updates: Array<{
    id: string;
    status: S3StatusType;
    photo?: string;
    note?: string;
  }>;
}

/**
 * DTO for updating a category
 */
export class UpdateS3CategoryDto {
  @ApiPropertyOptional({
    description: 'Category name',
    example: 'Werkzeugablage',
  })
  @IsOptional()
  @IsString()
  name?: string;

  @ApiPropertyOptional({
    description: 'Sort order for display',
    example: 1,
  })
  @IsOptional()
  sortOrder?: number;
}

/**
 * DTO for updating a plan
 */
export class UpdateS3PlanDto {
  @ApiPropertyOptional({
    description: 'Whether the plan is active',
    example: true,
  })
  @IsOptional()
  isActive?: boolean;
}
