import { Controller, Get, Param, Query } from '@nestjs/common';
import { FilterTimeGroupDto } from './dto/filter-time-group.dto';
import { Pagination } from 'src/core/response';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { TimeGroupEntity } from '../domain/entities/time-group.entity';
import { TimeGroupReadOrchestrator } from '../domain/usecases/time-group-read.orchestrator';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
import { Public } from 'src/core/guards';

@ApiTags(`${MODULE_NAME.TIME_GROUPS.split('-').join(' ')} - read`)
@Controller(`v1/${MODULE_NAME.TIME_GROUPS}`)
@Public(false)
@ApiBearerAuth('JWT')
export class TimeGroupReadController {
  constructor(private orchestrator: TimeGroupReadOrchestrator) {}

  @Get()
  @Pagination()
  async index(
    @Query() params: FilterTimeGroupDto,
  ): Promise<PaginationResponse<TimeGroupEntity>> {
    return await this.orchestrator.index(params);
  }

  @Get(':id')
  async detail(@Param('id') id: string): Promise<TimeGroupEntity> {
    return await this.orchestrator.detail(id);
  }
}

@ApiTags(`${MODULE_NAME.TIME_GROUPS.split('-').join(' ')} List- read`)
// @Controller(`v1/${MODULE_NAME.TIME_GROUPS}-list`)
@Controller(``)
@Public()
export class TimeGroupPublicReadController {
  constructor(private orchestrator: TimeGroupReadOrchestrator) {}

  @Get('v1/time-group-list-by-items')
  @Pagination()
  async indexPublic(
    @Query() params: FilterTimeGroupDto,
  ): Promise<PaginationResponse<TimeGroupEntity>> {
    return await this.orchestrator.indexPublic(params);
  }
}
