using System.Security.Claims;
using Web.Api.Common;
using Web.Api.Extensions;
using MediatR;

namespace Web.Api.Endpoints.Donation;

/// <summary>크루원 동의 정보 조회 (동의 페이지용)</summary>
internal sealed class CrewConsentInfo : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapGet("api/crew/consent/info/{crewSessionID}", async (
            int crewSessionID,
            ClaimsPrincipal user,
            ISender sender,
            CancellationToken ct
        ) => {
            var memberID = user.GetRequiredMemberID();
            var data = await sender.Send(new Application.Features.Api.Crew.GetConsentInfo.Query(crewSessionID, memberID), ct);
            return ApiResponse.Ok(data);
        })
        .WithTags("Crew")
        .RequireAuthorization();
    }
}