import { ApiProperty } from '@nestjs/swagger';
import { Available } from 'src/pointOfInterest/enum/available.enum';
import { Transform } from 'class-transformer';
import { IsArray } from 'class-validator';

export class CreatePlaceDateTradDto {
  @ApiProperty({ enum: Available, enumName: 'Available' })
  available: Available;

  @ApiProperty()
  idTown: number;

  @ApiProperty()
  name: string;

  @ApiProperty({ type: String, description: 'Comma-separated list of category IDs', example: '1,2,3' })
  @IsArray({})
  @Transform(({ value }) => value.split(',').map(Number))
  categoriesId: number[];

  @ApiProperty()
  descriptionES: string;
  @ApiProperty()
  descriptionEN: string;

  @ApiProperty({ type: 'string', format: 'binary' })
  image;

  @ApiProperty({ type: 'decimal' })
  latitude;

  @ApiProperty({ type: 'decimal' })
  longitude;

  @ApiProperty()
  address: string;

  // 24-hour format
  @ApiProperty({ maximum: 24, minimum: 0 })
  openAt: number;
  // 24-hour format
  @ApiProperty({ maximum: 24, minimum: 0 })
  closeAt: number;

  @ApiProperty({ nullable: true, required: false, description: 'Only required if available is CUSTOM' })
  startDate: Date;

  @ApiProperty({ nullable: true, required: false, description: 'Only required if available is CUSTOM' })
  endDate: Date;
}
