using DoliMiddlewareApi.Dtos.query.Setup;
using DoliMiddlewareApi.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace DoliMiddlewareApi.Controllers;

[ApiController]
[Route("api/[controller]")]
[Authorize]
public class SetupController(SetupService setupService) : ControllerBase
{
    [HttpGet("payment-types")]
    [ProducesResponseType(typeof(List<PaymentTypeDto>), StatusCodes.Status200OK)]
    [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)]
    public async Task<ActionResult<List<PaymentTypeDto>>> GetPaymentTypes()
    {
        var paymentTypes = await setupService.GetPaymentTypesAsync();
        return Ok(paymentTypes);
    }

    [HttpGet("countries")]
    [ProducesResponseType(typeof(List<CountryDto>), StatusCodes.Status200OK)]
    [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)]
    public async Task<ActionResult<List<CountryDto>>> GetCountries()
    {
        var countries = await setupService.GetCountriesAsync();
        return Ok(countries);
    }

    [HttpGet("civilities")]
    [ProducesResponseType(typeof(List<CivilityDto>), StatusCodes.Status200OK)]
    [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)]
    public async Task<ActionResult<List<CivilityDto>>> GetCivilities()
    {
        var civilities = await setupService.GetCivilitiesAsync();
        return Ok(civilities);
    }

    [HttpGet("contact-types")]
    [ProducesResponseType(typeof(List<ContactTypeDto>), StatusCodes.Status200OK)]
    [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)]
    public async Task<ActionResult<List<ContactTypeDto>>> GetContactTypes()
    {
        var contactTypes = await setupService.GetContactTypesAsync();
        return Ok(contactTypes);
    }

    [HttpGet("payment-terms")]
    [ProducesResponseType(typeof(List<PaymentTermDto>), StatusCodes.Status200OK)]
    [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)]
    public async Task<ActionResult<List<PaymentTermDto>>> GetPaymentTerms()
    {
        var paymentTerms = await setupService.GetPaymentTermsAsync();
        return Ok(paymentTerms);
    }

    [HttpGet("company")]
    [ProducesResponseType(typeof(CompanyDto), StatusCodes.Status200OK)]
    [ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)]
    public async Task<ActionResult<CompanyDto>> GetCompany()
    {
        var company = await setupService.GetCompanyAsync();
        return Ok(company);
    }
}