package com.ikon.projectmanagement.controller;

import com.ikon.projectmanagement.api.IssueApi;
import com.ikon.projectmanagement.dto.request.IssueCreateRequestDto;
import com.ikon.projectmanagement.dto.response.IssueResponseDto;
import com.ikon.projectmanagement.service.IssueService;

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

import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class IssueController implements IssueApi {

    private final IssueService issueService;

    @Override
    public ResponseEntity<IssueResponseDto> createIssue(
            String accessToken,
            IssueCreateRequestDto issueCreateRequestDto) {

        IssueResponseDto createdIssue = issueService.createIssue(issueCreateRequestDto);

        return ResponseEntity
                .status(HttpStatus.CREATED)
                .body(createdIssue);
    }

    @Override
    public ResponseEntity<List<IssueResponseDto>> getAllIssues(
            String accessToken,UUID projectIdentifier) {

        return ResponseEntity.ok(
                issueService.getAllIssues(projectIdentifier));
    }

    @Override
    public ResponseEntity<IssueResponseDto> getIssueById(
            String accessToken,
            UUID issueId) {

        return ResponseEntity.ok(
                issueService.getIssueById(issueId));
    }

    @Override
    public ResponseEntity<IssueResponseDto> updateIssue(
            String accessToken,
            UUID issueId,
            IssueCreateRequestDto issueCreateRequestDto) {

        return ResponseEntity.ok(
                issueService.updateIssue(issueId, issueCreateRequestDto));
    }

    // @Override
    // public ResponseEntity<Void> deleteIssue(
    //         String accessToken,
    //         UUID issueId) {

    //     issueService.deleteIssue(issueId);
    //     return ResponseEntity.noContent().build();
    // }

    // @Override
    // public ResponseEntity<List<IssueResponseDto>> getIssuesByProject(
    //         String accessToken,
    //         UUID projectIdentifier) {

    //     return ResponseEntity.ok(
    //             issueService.getIssuesByProject(projectIdentifier));
    // }
}