import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { CargoUnitOfMeasure } from '@edr/types';

export class BookingReferenceYardDto {
  @ApiProperty({ format: 'uuid' })
  id!: string;

  @ApiProperty({ example: 'Mojo Dry Port' })
  name!: string;

  @ApiProperty({ example: 'MOJO' })
  code!: string;

  @ApiProperty({ example: 'Ethiopia' })
  country!: string;
}

export class BookingReferenceContainerTypeDto {
  @ApiProperty({ format: 'uuid' })
  id!: string;

  @ApiProperty({ example: 'Dry' })
  name!: string;

  @ApiProperty({ example: '20GP' })
  code!: string;

  @ApiProperty()
  is_reefer!: boolean;

  @ApiProperty({ example: 0.5, description: 'Wagon fraction per container' })
  wagons_per_unit!: number;
}

export class BookingReferenceContainerSizeGroupDto {
  @ApiProperty({ example: '20ft' })
  size!: string;

  @ApiProperty({ type: [BookingReferenceContainerTypeDto] })
  types!: BookingReferenceContainerTypeDto[];
}

export class BookingReferenceServiceDto {
  @ApiProperty({ format: 'uuid' })
  id!: string;

  @ApiProperty({ example: 'Rail Transport Only' })
  name!: string;

  @ApiProperty({ example: 'RAIL' })
  code!: string;
}

export class BookingReferenceShippingLineDto {
  @ApiProperty({ format: 'uuid' })
  id!: string;

  @ApiProperty({ example: 'MSC' })
  name!: string;

  @ApiProperty({ example: 'MSC' })
  code!: string;
}

export class BookingReferenceCargoTypeChildDto {
  @ApiProperty({ format: 'uuid' })
  id!: string;

  @ApiProperty({ example: 'Coffee' })
  name!: string;

  @ApiProperty({ example: 'BULK_COFFEE' })
  code!: string;

  @ApiProperty()
  show_free_text_box!: boolean;

  @ApiProperty({ enum: CargoUnitOfMeasure, nullable: true, required: false })
  unit_of_measure?: CargoUnitOfMeasure | null;
}

export class BookingReferenceCargoTypeGroupDto {
  @ApiProperty({ format: 'uuid' })
  id!: string;

  @ApiProperty({ example: 'Bulk Cargo' })
  name!: string;

  @ApiProperty({ example: 'BULK' })
  code!: string;

  @ApiPropertyOptional({ type: [BookingReferenceCargoTypeChildDto] })
  children?: BookingReferenceCargoTypeChildDto[];
}

export class BookingReferenceDataDto {
  @ApiProperty({ type: [BookingReferenceYardDto] })
  yard!: BookingReferenceYardDto[];

  @ApiProperty({ type: [BookingReferenceContainerSizeGroupDto] })
  containers!: BookingReferenceContainerSizeGroupDto[];

  @ApiProperty({ type: [BookingReferenceServiceDto] })
  service!: BookingReferenceServiceDto[];

  @ApiProperty({ type: [BookingReferenceShippingLineDto] })
  shipping_line!: BookingReferenceShippingLineDto[];

  @ApiProperty({ type: [BookingReferenceCargoTypeGroupDto] })
  cargo_type!: BookingReferenceCargoTypeGroupDto[];
}
