using Indotalent.ConfigBackEnd.Extensions;
using Indotalent.Features.Sales.InvoiceReport.Cqrs;
using MediatR;
using Microsoft.AspNetCore.Authentication.JwtBearer;

namespace Indotalent.Features.Sales.InvoiceReport;

public static class InvoiceReportEndpoint
{
    public static void MapInvoiceReportEndpoints(this IEndpointRouteBuilder app)
    {
        var group = app.MapGroup("/invoice-report").WithTags("InvoiceReports")
            .RequireAuthorization(policy => policy.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
            .RequireAuthenticatedUser());

        group.MapGet("/", async (IMediator mediator) =>
        {
            var result = await mediator.Send(new GetInvoiceReportListQuery());
            return result.ToApiResponse("Invoice report list retrieved successfully");
        })
        .WithName("GetInvoiceReportList");
    }
}