package com.ikon.projectmanagement.controller;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import com.ikon.projectmanagement.api.WorkingDayApi;
import com.ikon.projectmanagement.dto.response.WorkingDaysResponseDto;
import com.ikon.projectmanagement.service.WorkingDayService;

import lombok.RequiredArgsConstructor;

@RestController
@RequiredArgsConstructor
public class WorkingDayController implements WorkingDayApi {

    private final WorkingDayService workingDayService;

    @Override
    public ResponseEntity<Page<WorkingDaysResponseDto>> getAllWorkingDays(
            @RequestHeader("Authorization") String accessToken, Pageable pageable) {

        Page<WorkingDaysResponseDto> workingDaysList = workingDayService.getAllWorkingDays(pageable);
        return ResponseEntity.ok(workingDaysList);
    }

    @Override
    public ResponseEntity<WorkingDaysResponseDto> getWorkingDaysByYear(
            @RequestHeader("Authorization") String accessToken, @PathVariable String year) {
        WorkingDaysResponseDto workingDays = workingDayService.getWorkingDaysByYear(year);
        return ResponseEntity.ok(workingDays);
    }
}
