using MediatR;
using Modules.User.Application.Repositories;

namespace Modules.User.Application.Queries;

public class GetUserDetailQuery : IRequest<Models.UserDetail>
{
    public Guid AccountId { get; set; }
}

public class GetUserDetailQueryHandler(UserContext userContext, IUserQueries userQueries) : IRequestHandler<GetUserDetailQuery, Models.UserDetail>
{
    public async Task<Models.UserDetail> Handle(GetUserDetailQuery request, CancellationToken cancellationToken)
    {
        var sessionId = userContext.GetSessionId();
        return await userQueries.GetUserDetailAsync(request.AccountId, sessionId, cancellationToken)
               ?? new Models.UserDetail();
    }
}