using Common.Security.Infrastructure;
using MediatR;
using Modules.User.Application.Repositories;

namespace Modules.User.Application.Queries.User;

public class GetUserIdQuery : IRequest<Guid?>
{
    public Guid? AccountId { get; init; }
}

public class GetUserIdQueryHandler(UserContext userContext, IUserQueries userQueries)
    : IRequestHandler<GetUserIdQuery, Guid?>
{
    public async Task<Guid?> Handle(GetUserIdQuery request, CancellationToken cancellationToken)
    {
        var accountId = request.AccountId ?? userContext.GetAccountId();
        return await userQueries.GetUsersIdAsync(accountId, cancellationToken);
    }
}