using Web.Api.Common;
using Web.Api.Extensions;
using Application.Abstractions.Messaging;
using System.Security.Claims;

namespace Web.Api.Endpoints.Attendance;

internal sealed class Calendar : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapGet("api/attendance/calendar", async (
            int year,
            int month,
            ClaimsPrincipal user,
            ISender sender,
            CancellationToken ct
        ) => {
            var memberID = user.GetMemberID();
            var data = await sender.Send(new Application.Features.Api.Attendance.GetCalendar.Query(memberID, year, month), ct);

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