import {
  IsNotEmpty,
  IsOptional,
  IsString,
  IsBoolean,
  IsArray,
  IsUUID,
  IsNumberString,
  MaxLength,
} from 'class-validator';
import { MediaItemDto, MediaListField } from '../../../common/media/media-item.dto';

export class CreateDestinationDto {
  @IsString()
  @IsNotEmpty()
  @MaxLength(255)
  name: string;

  // short_code is auto-derived by the service from `name` and is
  // tenant-unique. Kept optional in the DTO purely as a back-compat
  // hook for seeders / Excel importers that still send one; the UI
  // never collects it.
  @IsString()
  @IsOptional()
  @MaxLength(50)
  short_code?: string;

  @IsString()
  @IsNotEmpty()
  @MaxLength(100)
  country: string;

  @IsString()
  @IsNotEmpty()
  @MaxLength(100)
  city: string;

  @IsUUID()
  @IsOptional()
  currency_id?: string;

  @IsString()
  @IsOptional()
  @MaxLength(100)
  timezone?: string;

  @IsString()
  @IsOptional()
  description?: string;

  @IsString()
  @IsOptional()
  @MaxLength(500)
  image_url?: string;

  @IsBoolean()
  @IsOptional()
  visa_required?: boolean;

  @IsArray()
  @IsOptional()
  @IsString({ each: true })
  tax_types?: string[];

  @IsArray()
  @IsOptional()
  @IsString({ each: true })
  services?: string[];

  // Live USD → base-currency conversion factor. Accepts a numeric
  // string so decimals preserve precision through JSON. Stamped with
  // `rate_updated_at = now()` server-side whenever this changes.
  @IsNumberString()
  @IsOptional()
  usd_to_base_rate?: string;

  @MediaListField()
  media?: MediaItemDto[];
}
