using Web.Api.Common;
using MediatR;

namespace Web.Api.Endpoints.Donation;

/// <summary>채널의 활성 크루 세션 + 크루원 조회 (시청자용, 인증 불필요)</summary>
internal sealed class CrewActiveForChannel : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapGet("api/donation/crew/active/{channelSID}", async (
            string channelSID,
            ISender sender,
            CancellationToken ct
        ) => {
            var data = await sender.Send(new Application.Features.Api.Crew.GetActiveCrewForChannel.Query(channelSID), ct);
            return ApiResponse.Ok(data);
        })
        .WithTags("Donation")
        .AllowAnonymous();
    }
}