import { ApiProperty } from "@nestjs/swagger"
import {
  IsNotEmpty,
  IsString,
  IsNumber,
  IsOptional,
  IsEnum,
} from "class-validator"
import { messageKey } from "src/constants/message-keys"
import { validationMessage } from "src/utils/helpers"
import { ChatType } from "../entities/chat-room.entity"

export class SendMessageDto {
  @ApiProperty({
    example: 101,
    description: "ID of the receiver (dispatcher, driver, or customer)",
  })
  @IsNotEmpty({
    message: validationMessage(messageKey.field_required, {
      ":field": "receiver_id",
    }),
  })
  @IsNumber()
  receiver_id: number

  @ApiProperty({
    example: "Hello, I need to discuss the trip schedule",
    description: "Message content to send",
  })
  @IsNotEmpty({
    message: validationMessage(messageKey.field_required, {
      ":field": "message",
    }),
  })
  @IsString()
  message: string

  @ApiProperty({
    example: "driver_customer",
    description: "Type of chat room",
    enum: ChatType,
    required: false,
  })
  @IsOptional()
  @IsEnum(ChatType)
  chat_type?: ChatType

  @ApiProperty({
    example: 123,
    description: "Trip ID for trip-specific chats",
    required: false,
  })
  @IsOptional()
  @IsNumber()
  trip_id?: number
}
