import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import {
  ArrayMinSize,
  IsArray,
  IsInt,
  IsOptional,
  Min,
  ValidateNested,
} from 'class-validator';

export class TagOrderItem {
  @ApiProperty()
  @IsInt()
  @Min(1)
  id!: number;

  @ApiProperty({ required: false, nullable: true, description: 'Move tag to this group (null = ungrouped)' })
  @IsOptional()
  @IsInt()
  @Min(1)
  tagGroupId?: number | null;

  @ApiProperty()
  @IsInt()
  @Min(0)
  sortOrder!: number;
}

export class ReorderTagsDto {
  @ApiProperty({ type: [TagOrderItem] })
  @IsArray()
  @ArrayMinSize(1)
  @ValidateNested({ each: true })
  @Type(() => TagOrderItem)
  items!: TagOrderItem[];
}
