/**
 * Booking Export DTO
 *
 * Defines export format options
 */

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsEnum, IsOptional, IsArray, IsString } from 'class-validator';

export enum ExportFormat {
  CSV = 'csv',
  EXCEL = 'excel',
  JSON = 'json',
}

export enum ExportField {
  BOOKING_NUMBER = 'bookingNumber',
  STATUS = 'status',
  CREATED_AT = 'createdAt',
  CARRIER = 'carrier',
  ORIGIN = 'origin',
  DESTINATION = 'destination',
  ETD = 'etd',
  ETA = 'eta',
  SHIPPER = 'shipper',
  CONSIGNEE = 'consignee',
  CONTAINER_TYPE = 'containerType',
  CONTAINER_COUNT = 'containerCount',
  TOTAL_TEUS = 'totalTEUs',
  PRICE = 'price',
}

export class BookingExportDto {
  @ApiProperty({
    description: 'Export format',
    enum: ExportFormat,
    example: ExportFormat.CSV,
  })
  @IsEnum(ExportFormat)
  format: ExportFormat;

  @ApiPropertyOptional({
    description: 'Fields to include in export (if omitted, all fields included)',
    enum: ExportField,
    isArray: true,
    example: [
      ExportField.BOOKING_NUMBER,
      ExportField.STATUS,
      ExportField.CARRIER,
      ExportField.ORIGIN,
      ExportField.DESTINATION,
    ],
  })
  @IsOptional()
  @IsArray()
  @IsEnum(ExportField, { each: true })
  fields?: ExportField[];

  @ApiPropertyOptional({
    description: 'Booking IDs to export (if omitted, exports filtered bookings)',
    isArray: true,
    example: ['550e8400-e29b-41d4-a716-446655440000'],
  })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  bookingIds?: string[];
}
