import {
  IsEnum,
  IsNotEmpty,
  IsNumber,
  IsOptional,
  IsString,
} from "class-validator"
import { ApiProperty } from "@nestjs/swagger"

export enum CanceledBy {
  DRIVER = "driver",
  CUSTOMER = "customer",
  DISPATCHER = "dispatcher",
  ADMIN = "admin",
  SUPER_ADMIN = "super_admin",
}

export class CreateTripCancellationDto {
  @ApiProperty({ example: 1, description: "The ID of the trip being canceled" })
  @IsNotEmpty()
  @IsNumber()
  trip_id: number

  @ApiProperty({
    example: "driver",
    description:
      "The role of the entity that canceled the trip (super_admin, admin, driver, customer, dispatcher)",
    enum: CanceledBy,
  })
  @IsNotEmpty()
  @IsEnum(CanceledBy)
  canceled_by: CanceledBy

  @ApiProperty({
    example: 1,
    description: "The ID of the entity that canceled the trip",
    required: false,
  })
  @IsOptional()
  @IsNumber()
  canceled_by_id?: number

  @ApiProperty({
    example: 1,
    description: "The ID of the reason for cancellation",
    required: false,
  })
  @IsOptional()
  @IsNumber()
  reason_id?: number

  @ApiProperty({
    example: "Other reason",
    description: "The other reason for cancellation",
    required: false,
  })
  @IsOptional()
  @IsString()
  other_input?: string
}
