File

src/trips/dto/create-trip.dto.ts

Index

Properties

Properties

Optional driverId
Type : string
Decorators :
@ApiPropertyOptional({description: 'Driver assigned to the trip — can be assigned later.'})
@IsOptional()
@IsString()
Optional endDate
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsDateString()
Optional laneId
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
Optional loadingBayId
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
Optional notes
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsString()
Optional orderIds
Type : string[]
Decorators :
@ApiPropertyOptional({type: undefined})
@IsOptional()
@IsArray()
@IsString({each: true})
Optional podRequired
Type : boolean
Decorators :
@ApiPropertyOptional({description: 'Require proof of delivery (photo + signature) before trip can be completed'})
@IsOptional()
@IsBoolean()
Optional startDate
Type : string
Decorators :
@ApiPropertyOptional()
@IsOptional()
@IsDateString()
Optional stops
Type : CreateTripStopDto[]
Decorators :
@ApiPropertyOptional({type: undefined})
@IsOptional()
@IsArray()
@ValidateNested({each: true})
@Type(undefined)
vehicleId
Type : string
Decorators :
@ApiProperty({description: 'Vehicle assigned to the trip — required.'})
@IsString()
@IsNotEmpty({message: 'A trip must have a vehicle assigned.'})
import {
  IsNotEmpty,
  IsString,
  IsOptional,
  IsDateString,
  IsArray,
  IsBoolean,
  ValidateNested,
  IsNumber,
  IsInt,
} from 'class-validator';
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Type } from 'class-transformer';

export class CreateTripStopDto {
  @ApiProperty()
  @IsInt()
  sequence: number;

  @ApiProperty({ example: 'PICKUP' })
  @IsString()
  @IsNotEmpty()
  stopType: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  name?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  address?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  city?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  state?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  zipCode?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsNumber()
  lat?: number;

  @ApiPropertyOptional()
  @IsOptional()
  @IsNumber()
  lng?: number;

  @ApiPropertyOptional()
  @IsOptional()
  @IsDateString()
  plannedArrival?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsDateString()
  plannedDeparture?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  notes?: string;
}

export class CreateTripDto {
  // A trip without a vehicle or driver is meaningless — there's nothing
  // to dispatch and the dispatch Gantt has nothing to render. Make
  // both required at the DTO layer so this never gets through.
  @ApiProperty({ description: 'Vehicle assigned to the trip — required.' })
  @IsString()
  @IsNotEmpty({ message: 'A trip must have a vehicle assigned.' })
  vehicleId!: string;

  @ApiPropertyOptional({ description: 'Driver assigned to the trip — can be assigned later.' })
  @IsOptional()
  @IsString()
  driverId?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsDateString()
  startDate?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsDateString()
  endDate?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  notes?: string;

  @ApiPropertyOptional({ description: 'Require proof of delivery (photo + signature) before trip can be completed' })
  @IsOptional()
  @IsBoolean()
  podRequired?: boolean;

  @ApiPropertyOptional({ type: [CreateTripStopDto] })
  @IsOptional()
  @IsArray()
  @ValidateNested({ each: true })
  @Type(() => CreateTripStopDto)
  stops?: CreateTripStopDto[];

  @ApiPropertyOptional({ type: [String] })
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  orderIds?: string[];

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  loadingBayId?: string;

  @ApiPropertyOptional()
  @IsOptional()
  @IsString()
  laneId?: string;
}

results matching ""

    No results matching ""