import { Body, Controller, Delete, Get, Param, Patch, Post, UseGuards } from '@nestjs/common';
import { ShiftsService } from './shifts.service';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';

@Controller('hr/shifts')
@UseGuards(JwtAuthGuard)
export class ShiftsController {
  constructor(private service: ShiftsService) {}

  @Get()
  findAll() {
    return this.service.findAll();
  }

  @Get(':id')
  findById(@Param('id') id: string) {
    return this.service.findById(parseInt(id, 10));
  }

  @Post()
  create(
    @Body()
    body: {
      name: string;
      startTime: string;
      endTime: string;
      breakMinutes?: number;
      workDays?: string;
    },
  ) {
    return this.service.create(body);
  }

  @Patch(':id')
  update(
    @Param('id') id: string,
    @Body()
    body: {
      name?: string;
      startTime?: string;
      endTime?: string;
      breakMinutes?: number;
      workDays?: string;
    },
  ) {
    return this.service.update(parseInt(id, 10), body);
  }

  @Delete(':id')
  delete(@Param('id') id: string) {
    return this.service.delete(parseInt(id, 10));
  }
}
