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

namespace Indotalent.Features.Purchase.PurchaseReturnReport;

public static class PurchaseReturnReportEndpoint
{
    public static void MapPurchaseReturnReportEndpoints(this IEndpointRouteBuilder app)
    {
        var group = app.MapGroup("/purchase-return-report").WithTags("PurchaseReturnReports")
            .RequireAuthorization(policy => policy.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
            .RequireAuthenticatedUser());

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