using Web.Api.Common;
using MediatR;

namespace Web.Api.Endpoints.Studio.Crew;

/// <summary>세션 히스토리 목록</summary>
internal sealed class CrewSessionHistory : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapGet("api/studio/crew/session/history/{crewID}", async (
            int crewID,
            ISender sender,
            CancellationToken ct,
            int page = 1,
            ushort perPage = 20
        ) => {
            var data = await sender.Send(new Application.Features.Api.Crew.GetSessionHistory.Query(crewID, page, perPage), ct);
            return ApiResponse.Ok(data);
        })
        .WithTags("StudioCrew")
        .RequireAuthorization();
    }
}