using Web.Api.Common;
using Application.Abstractions.Messaging;

namespace Web.Api.Endpoints.Attendance;

internal sealed class List : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapGet("api/attendance/list", async (
            int page,
            ushort perPage,
            DateTime? date,
            string? sortBy,
            ISender sender,
            CancellationToken ct
        ) => {
            var data = await sender.Send(new Application.Features.Api.Attendance.GetList.Query(page, perPage, date, sortBy), ct);

            return ApiResponse.Ok(data);
        })
        .WithTags("Attendance");
    }
}
