using LiteCqrs;
using TeleWave.Application.Common.Interfaces;
using TeleWave.Application.Common.Models;

namespace TeleWave.Application.Admin.Users.ListUsers;

public sealed class ListUsersQueryHandler(IIdentityService identityService)
    : IQueryHandler<ListUsersQuery, PagedList<UserSummaryDto>>
{
    public Task<PagedList<UserSummaryDto>> Handle(
        ListUsersQuery query,
        CancellationToken cancellationToken
    ) =>
        identityService.ListUsersAsync(
            new UserListFilter(
                query.Page,
                query.PageSize,
                query.Search,
                query.RoleId,
                query.IsBlocked,
                query.Sort,
                query.Desc
            ),
            cancellationToken
        );
}
