using Indotalent.ConfigBackEnd.Extensions;
using Indotalent.Features.Purchase.PaymentDisburseReport.Cqrs;
using MediatR;
using Microsoft.AspNetCore.Authentication.JwtBearer;

namespace Indotalent.Features.Purchase.PaymentDisburseReport;

public static class PaymentDisburseReportEndpoint
{
    public static void MapPaymentDisburseReportEndpoints(this IEndpointRouteBuilder app)
    {
        var group = app.MapGroup("/payment-disburse-report").WithTags("PaymentDisburseReports")
            .RequireAuthorization(policy => policy.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
            .RequireAuthenticatedUser());

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