import { Body, Controller, Param, ParseUUIDPipe, Post } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { BookingsService } from './bookings.service';
import { AllocateContainersDto } from './dto/allocate-containers.dto';
import { AllocationManage } from '../../common/booking-guards';

@ApiTags('bookings')
@Controller('bookings')
@ApiBearerAuth()
export class BookingAllocationController {
  constructor(private readonly bookingsService: BookingsService) {}

  @Post(':bookingId/allocate-containers')
  @AllocationManage()
  @ApiOperation({ summary: 'Allocate containers to vehicles' })
  async allocateContainers(
    @Param('bookingId', ParseUUIDPipe) bookingId: string,
    @Body() dto: AllocateContainersDto,
  ) {
    return this.bookingsService.allocateContainers(bookingId, dto.allocations);
  }
}
