using Web.Api.Common;
using MediatR;

namespace Web.Api.Endpoints.Donation;

/// <summary>크루원 참여 동의</summary>
internal sealed class CrewSessionConsent : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        /// 크루원 동의 체크. 전원 동의 시 Ready 전환 + AppHub 실시간 현황
        app.MapPost("api/crew/session/consent", async (
            Application.Features.Api.Crew.ConsentSession.Command body,
            ISender sender,
            CancellationToken ct
        ) => {
            var data = await sender.Send(body, ct);
            return ApiResponse.Ok(data);
        })
        .WithTags("Crew")
        .RequireAuthorization();
    }
}