import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Query,
} from '@nestjs/common';
import { BookingSlotService } from './booking-slot.service';
import { CreateBookingSlotDto } from './dto/create-booking-slot.dto';
import { UpdateBookingSlotDto } from './dto/update-booking-slot.dto';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { AuthPayload, AuthUser } from 'src/auth/decorators/auth.payload';
import { HistoryBookingSlot } from './dto/search-booking.dto';
// import { Public } from 'src/auth/decorators/public.auth';

@Controller('booking-slot')
@ApiTags('Booking slot API')
@ApiBearerAuth()
export class BookingSlotController {
  constructor(private readonly bookingSlotService: BookingSlotService) { }

  @Post()
  create(
    @Body() createBookingSlotDto: CreateBookingSlotDto,
    @AuthUser() user: AuthPayload,
  ) {
    return this.bookingSlotService.create(createBookingSlotDto, user);
  }

  @Get('/history')
  history(
    @Query() query: HistoryBookingSlot,
    @AuthUser() user: AuthPayload,
  ) {
    return this.bookingSlotService.historyBooking(query, user);
  }

  @Get('/submit/:id')
  submitMyBooking(
    @Param('id') id: string,
    @AuthUser() user: AuthPayload,
  ) {
    return this.bookingSlotService.submitMyBooking(+id, user);
  }

  @Get('/out/:id')
  outMyBooking(@Param('id') id: string, @AuthUser() user: AuthPayload) {
    return this.bookingSlotService.outMyBooking(+id, user);
  }

  @Get(':id')
  findOne(@Param('id') id: string, @AuthUser() user: AuthPayload) {
    return this.bookingSlotService.findOne(+id, user);
  }

  @Patch(':id')
  update(
    @Param('id') id: string,
    @Body() updateBookingSlotDto: UpdateBookingSlotDto,
    @AuthUser() user: AuthPayload,
  ) {
    return this.bookingSlotService.update(+id, updateBookingSlotDto, user);
  }

  @Delete('/cancel/:id')
  cancel(@Param('id') id: string, @AuthUser() user: AuthPayload) {
    return this.bookingSlotService.cancel(+id, user);
  }

  // @Get('/test/sql')
  // @Public()
  // test() {
  //   return this.bookingSlotService.test();
  // }
}
