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

namespace Modules.User.Application.Queries.User;

public class CheckNicknameIsUsedQuery : IRequest<bool>
{
    public string Nickname { get; init; } = null!;
}

public class CheckNicknameIsUsedQueryHandler(IUserContext userContext, IUserQueries userQueries)
    : IRequestHandler<CheckNicknameIsUsedQuery, bool>
{
    public async Task<bool> Handle(CheckNicknameIsUsedQuery request, CancellationToken cancellationToken)
    {
        var isInUse = await userQueries.IsNicknameInUse(request.Nickname, cancellationToken);
        return user;
    }
}