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

namespace Web.Api.Endpoints.Studio;

/// <summary>스튜디오 대시보드</summary>
internal sealed class Dashboard : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        app.MapGet("api/studio/dashboard", async (
            ClaimsPrincipal user,
            ISender sender,
            CancellationToken ct
        ) => {
            var memberID = user.GetRequiredMemberID();
            var data = await sender.Send(new Application.Features.Api.Studio.Dashboard.GetDashboard.Query(memberID), ct);

            return ApiResponse.Ok(data);
        })
        .WithTags("StudioDashboard")
        .RequireAuthorization();
    }
}