using Indotalent.ConfigBackEnd.Extensions;
using Indotalent.Features.Sales.DeliveryReport.Cqrs;
using MediatR;
using Microsoft.AspNetCore.Authentication.JwtBearer;

namespace Indotalent.Features.Sales.DeliveryReport;

public static class DeliveryReportEndpoint
{
    public static void MapDeliveryReportEndpoints(this IEndpointRouteBuilder app)
    {
        var group = app.MapGroup("/delivery-report").WithTags("DeliveryReports")
            .RequireAuthorization(policy => policy.AddAuthenticationSchemes(JwtBearerDefaults.AuthenticationScheme)
            .RequireAuthenticatedUser());

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