using MediatR;
using Web.Api.Common;

namespace Web.Api.Endpoints.Popup;

internal sealed class Items : IEndpoint
{
    public sealed record Request(
        string Code
    );

    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapPost("api/popups", async (
            Request request,
            ISender sender,
            CancellationToken ct
        ) => {
            return ApiResponse.Ok(
                await sender.Send(new Application.Features.Api.Popup.GetAll.Query(request.Code), ct)
            );
        })
        .WithTags("Popup")
        .AllowAnonymous();
    }
}