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

namespace Indotalent.Features.Purchase.ReceiveReport;

public static class ReceiveReportEndpoint
{
    public static void MapReceiveReportEndpoints(this IEndpointRouteBuilder app)
    {
        var group = app.MapGroup("/receive-report").WithTags("ReceiveReports")
            .RequireAuthorization(policy => policy.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
            .RequireAuthenticatedUser());

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