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

namespace Indotalent.Features.Inventory.StockReport;

public static class StockReportEndpoint
{
    public static void MapStockReportEndpoints(this IEndpointRouteBuilder app)
    {
        var group = app.MapGroup("/stock-report").WithTags("StockReports")
            .RequireAuthorization(policy => policy.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
            .RequireAuthenticatedUser());

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