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

namespace Indotalent.Features.Sales.SalesReturnReport;

public static class SalesReturnReportEndpoint
{
    public static void MapSalesReturnReportEndpoints(this IEndpointRouteBuilder app)
    {
        var group = app.MapGroup("/sales-return-report").WithTags("SalesReturnReports")
            .RequireAuthorization(policy => policy.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
            .RequireAuthenticatedUser());

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