package com.ikon.projectmanagement.api;

import com.ikon.projectmanagement.dto.request.ScheduleRequestDto;
import com.ikon.projectmanagement.dto.response.ScheduleResponseDto;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.UUID;

@Tag(name = "Schedule APIs", description = "Schedule management APIs for a project")
@RequestMapping("/api/v1/projects")
public interface ScheduleApi {

    @Operation(summary = "Save schedule", description = "Replaces the full schedule (tasks + dependencies) for a project. Removed tasks are automatically deleted.", responses = {
            @ApiResponse(responseCode = "200", description = "Schedule saved successfully"),
            @ApiResponse(responseCode = "401", description = "Unauthorized"),
            @ApiResponse(responseCode = "404", description = "Project not found"),
            @ApiResponse(responseCode = "500", description = "Internal server error")
    })
    @PutMapping("/{projectIdentifier}/schedules")
    ResponseEntity<ScheduleResponseDto> saveSchedule(
            @RequestHeader("Authorization") String accessToken,
            @PathVariable("projectIdentifier") UUID projectIdentifier,
            @RequestBody ScheduleRequestDto scheduleRequestDto);

    @Operation(summary = "Get schedule", description = "Retrieves the current schedule (tasks + dependencies) for a project.", responses = {
            @ApiResponse(responseCode = "200", description = "Schedule retrieved successfully"),
            @ApiResponse(responseCode = "401", description = "Unauthorized"),
            @ApiResponse(responseCode = "404", description = "Project not found"),
            @ApiResponse(responseCode = "500", description = "Internal server error")
    })
    @GetMapping("/{projectIdentifier}/schedules")
    ResponseEntity<ScheduleResponseDto> getSchedule(
            @RequestHeader("Authorization") String accessToken,
            @PathVariable("projectIdentifier") UUID projectIdentifier);

    @Operation(summary = "Get all schedules", description = "Retrieves schedules for all projects under the current account.", responses = {
            @ApiResponse(responseCode = "200", description = "Schedules retrieved successfully"),
            @ApiResponse(responseCode = "401", description = "Unauthorized"),
            @ApiResponse(responseCode = "500", description = "Internal server error")
    })
    @GetMapping("/schedules")
    ResponseEntity<List<ScheduleResponseDto>> getAllSchedules(
            @RequestHeader("Authorization") String accessToken);
}
