import { Controller, Get, Query } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';

import { BookingStaff } from '../../common/booking-guards';
import { FREIGHT_PERMS } from '../../seed/freight-permissions.registry';
import { WarehouseInventoryService } from './warehouse-inventory.service';

@ApiTags('warehouse-loadings')
@ApiBearerAuth()
@Controller('warehouse-loadings')
@BookingStaff(FREIGHT_PERMS.warehouseInventory.view)
export class WarehouseLoadingsController {
  constructor(private readonly inventoryService: WarehouseInventoryService) {}

  @Get()
  @ApiOperation({ summary: 'List wagon loading records' })
  findAll(@Query('bookingId') bookingId?: string, @Query('wagonId') wagonId?: string) {
    return this.inventoryService.findLoadings({ bookingId, wagonId });
  }
}
