import {
  Body,
  Controller,
  Delete,
  Get,
  HttpCode,
  Param,
  ParseUUIDPipe,
  Post,
  Query,
} from "@nestjs/common";
import { ApiOperation, ApiTags } from "@nestjs/swagger";

import { BookingsService } from "./bookings.service";
import { CreateBookingDto } from "./dto/create-booking.dto";
import { FilterBookingDto } from "./dto/filter-booking.dto";

@ApiTags("bookings")
// @UseGuards(JwtAuthGuard) — TODO: integrate @edr/auth
@Controller("bookings")
export class BookingsController {
  constructor(private readonly bookingsService: BookingsService) {}

  @Post()
  @ApiOperation({ summary: "Create a new freight booking" })
  create(@Body() dto: CreateBookingDto) {
    return this.bookingsService.create(dto);
  }

  @Get()
  @ApiOperation({ summary: "List freight bookings (paginated)" })
  findAll(@Query() filter: FilterBookingDto) {
    return this.bookingsService.findAll(filter);
  }

  @Get(":id")
  @ApiOperation({ summary: "Get a freight booking by ID" })
  findOne(@Param("id", ParseUUIDPipe) id: string) {
    return this.bookingsService.findById(id);
  }

  @Delete(":id")
  @HttpCode(204)
  @ApiOperation({ summary: "Soft-delete a freight booking" })
  remove(@Param("id", ParseUUIDPipe) id: string) {
    return this.bookingsService.remove(id);
  }
}
