using Indotalent.ConfigBackEnd.Extensions;
using Indotalent.Features.Inventory.MovementReport.Cqrs;
using MediatR;
using Microsoft.AspNetCore.Authentication.JwtBearer;

namespace Indotalent.Features.Inventory.MovementReport;

public static class MovementReportEndpoint
{
    public static void MapMovementReportEndpoints(this IEndpointRouteBuilder app)
    {
        var group = app.MapGroup("/movement-report").WithTags("MovementReports")
            .RequireAuthorization(policy => policy.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
            .RequireAuthenticatedUser());

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