import { ApiProperty } from '@nestjs/swagger';
import { IsArray, IsJSON, IsOptional } from 'class-validator';
import { AssetPropValue } from '../../asset/logic/Props';
import { AssetPropAccountDTO } from '../../asset/dto/block-dto';

export class TaskDTO {
  @ApiProperty({})
  id: string;

  @ApiProperty({})
  num: number;

  @ApiProperty({})
  columnId: string | null;

  @ApiProperty({})
  title: string;

  @ApiProperty({
    type: AssetPropAccountDTO,
  })
  assignedTo: AssetPropAccountDTO | null;

  @ApiProperty({
    default: false,
  })
  isCompleted: boolean;

  @ApiProperty({
    default: false,
  })
  isAttracting: boolean;

  @ApiProperty({})
  index: number | null;

  @ApiProperty()
  result: AssetPropValue;

  @ApiProperty()
  color: string;

  @ApiProperty({ type: Date })
  scheduledAt: string | null;

  @ApiProperty()
  estimatedTime: number | null;

  @ApiProperty()
  actualTime: number | null;

  @ApiProperty({ type: Date })
  createdAt: string;
}

export class TaskWhereParams {
  @IsArray()
  @ApiProperty({})
  ids: number[];
}

export class TaskQueryDTO {
  @ApiProperty({
    description: 'json filter like {"query": "abc", "id": ["abc"] }',
    required: false,
  })
  @IsJSON()
  @IsOptional()
  where?: string;

  @ApiProperty({
    description: 'Limit to count',
    required: false,
  })
  @IsOptional()
  count?: number;

  @ApiProperty({
    description: 'Start from offset',
    required: false,
  })
  @IsOptional()
  offset?: number;

  @ApiProperty({
    description: 'Order by (json)',
    required: false,
  })
  @IsJSON()
  @IsOptional()
  order?: string;
}
