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

namespace Indotalent.Features.Purchase.BillReport;

public static class BillReportEndpoint
{
    public static void MapBillReportEndpoints(this IEndpointRouteBuilder app)
    {
        var group = app.MapGroup("/bill-report").WithTags("BillReports")
            .RequireAuthorization(policy => policy.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
            .RequireAuthenticatedUser());

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