import { Body, Controller, Delete, Get, Param, Patch, Post, Query, UseGuards } from "@nestjs/common";
import { Tenant } from "../../common/decorators/tenant.decorator";
import { JwtAuthGuard } from "../../common/guards/jwt-auth.guard";
import { CreateScheduleEventDto } from "./dto/create-schedule-event.dto";
import { ScheduleQueryDto } from "./dto/schedule-query.dto";
import { UpdateScheduleEventDto } from "./dto/update-schedule-event.dto";
import { ScheduleService } from "./schedule.service";

@UseGuards(JwtAuthGuard)
@Controller("schedule")
export class ScheduleController {
  constructor(private readonly scheduleService: ScheduleService) {}

  @Get()
  findAll(@Tenant() companyId: string, @Query() query: ScheduleQueryDto) {
    return this.scheduleService.findAll(companyId, query);
  }

  @Get("stats")
  getStats(@Tenant() companyId: string) {
    return this.scheduleService.getStats(companyId);
  }

  @Get(":id")
  findOne(@Tenant() companyId: string, @Param("id") id: string) {
    return this.scheduleService.findOne(companyId, id);
  }

  @Post()
  create(@Tenant() companyId: string, @Body() dto: CreateScheduleEventDto) {
    return this.scheduleService.create(companyId, dto);
  }

  @Patch(":id")
  update(@Tenant() companyId: string, @Param("id") id: string, @Body() dto: UpdateScheduleEventDto) {
    return this.scheduleService.update(companyId, id, dto);
  }

  @Delete(":id")
  remove(@Tenant() companyId: string, @Param("id") id: string) {
    return this.scheduleService.remove(companyId, id);
  }
}
