import {
  Body,
  Controller,
  Delete,
  Get,
  Param,
  Post,
  Put,
  Query,
} from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { ExcludePrivilege, Public } from 'src/core/guards';
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
import {
  GetLabelReportBookmarkDto,
  GetReportBookmarkDto,
} from '../shared/dto/report-bookmark.get.dto';
import { CreateReportBookmarkDto } from '../shared/dto/report-bookmark.create.dto';
import { ReportBookmarkService } from './report-bookmark.service';

@ApiTags(`${MODULE_NAME.REPORT_BOOKMARK.split('-').join(' ')}`)
@Controller(`v1/${MODULE_NAME.REPORT_BOOKMARK}`)
@Public(false)
@ApiBearerAuth('JWT')
export class ReportBookmarkController {
  constructor(private service: ReportBookmarkService) {}

  @Post()
  @ExcludePrivilege()
  async create(@Body() body: CreateReportBookmarkDto) {
    return await this.service.create(body);
  }

  @Get()
  @ExcludePrivilege()
  async getAll(@Query() query: GetReportBookmarkDto) {
    return await this.service.getAll(query);
  }

  // @Get(':id')
  // async get(@Param('id') id: string) {
  //   return await this.service.getOne(id);
  // }

  @Get('label-history')
  @ExcludePrivilege()
  async getAllLabelHistory(@Query() query: GetLabelReportBookmarkDto) {
    return await this.service.getAllLabelHistory(query);
  }

  @Get('applied')
  @ExcludePrivilege()
  async currentApplied(@Query() query: GetLabelReportBookmarkDto) {
    return await this.service.getCurrentAppliedBookmark(query);
  }

  @Put('applied/:id')
  @ExcludePrivilege()
  async applied(@Param('id') id: string) {
    return await this.service.applied(id);
  }

  @Put('unapplied/:id')
  @ExcludePrivilege()
  async unapplied(@Param('id') id: string) {
    return await this.service.unapplied(id);
  }

  @Delete(':id')
  @ExcludePrivilege()
  async delete(@Param('id') id: string) {
    return await this.service.delete(id);
  }
}
