package com.ikon.projectmanagement.controller;

import com.ikon.projectmanagement.api.MeetingApi;
import com.ikon.projectmanagement.dto.request.MeetingRequestDTO;
import com.ikon.projectmanagement.dto.response.MeetingResponseDTO;
import com.ikon.projectmanagement.service.MeetingService;

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 MeetingController implements MeetingApi {

    private final MeetingService meetingService;

    @Override
    public ResponseEntity<MeetingResponseDTO> createMeeting(
            String accessToken,
            MeetingRequestDTO meetingRequestDTO) {

        MeetingResponseDTO createdMeeting = meetingService.createMeeting(meetingRequestDTO);

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

    @Override
    public ResponseEntity<List<MeetingResponseDTO>> getAllMeetings(
            String accessToken,
            UUID projectIdentifier) {

        return ResponseEntity.ok(
                meetingService.getAllMeetings(projectIdentifier));
    }

   

    @Override
    public ResponseEntity<MeetingResponseDTO> getMeetingById(
            String accessToken,
            UUID meetingId) {

        return ResponseEntity.ok(
                meetingService.getMeetingById(meetingId));
    }

    @Override
    public ResponseEntity<MeetingResponseDTO> updateMeeting(
            String accessToken,
            UUID meetingId,
            MeetingRequestDTO meetingRequestDTO) {

        return ResponseEntity.ok(
                meetingService.updateMeeting(meetingId, meetingRequestDTO));
    }

    @Override
    public ResponseEntity<Void> deleteMeeting(
            String accessToken,
            UUID meetingId) {

        meetingService.deleteMeeting(meetingId);
        return ResponseEntity.noContent().build();
    }
}