using Web.Api.Common;
using MediatR;

namespace Web.Api.Endpoints.Studio.Crew;

/// <summary>크루 세션 목록 (스튜디오 전용)</summary>
internal sealed class CrewList : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        /// 크루 후원 세션 목록 (날짜/금액/참여자 정렬, 페이징, 상태 포함)
        app.MapGet("api/studio/crew/list/{channelID}", async (
            int channelID,
            ISender sender,
            CancellationToken ct,
            string? sortBy = null,
            string? sortDir = null,
            int page = 1,
            ushort perPage = 20
        ) => {
            var data = await sender.Send(new Application.Features.Api.Crew.GetCrewList.Query(channelID, sortBy, sortDir, page, perPage), ct);
            return ApiResponse.Ok(data);
        })
        .WithTags("StudioCrew")
        .RequireAuthorization();
    }
}