using Web.Api.Common;
using MediatR;

namespace Web.Api.Endpoints.Studio.Crew;

/// <summary>크루원 추가를 위한 회원 검색</summary>
internal sealed class CrewMemberSearch : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapGet("api/studio/crew/member/search", async (
            int channelID,
            string q,
            int crewID,
            ISender sender,
            CancellationToken ct
        ) => {
            var data = await sender.Send(new Application.Features.Api.Crew.SearchMember.Query(channelID, q, crewID), ct);
            return ApiResponse.Ok(data);
        })
        .WithTags("StudioCrew")
        .RequireAuthorization();
    }
}