using Application.Abstractions.Messaging;
﻿using Application.Abstractions.Identity;

namespace Application.Features.Director.Users.Get
{
    public sealed class Handler(IIdentityUserReader userReader) : IQueryHandler<Query, List<Response>>
    {
        public async Task<List<Response>> Handle(Query request, CancellationToken ct)
        {
            var users = await userReader.GetAllUserAsync(ct);

            return [..users.Select(user => new Response
            {
                ID = user.ID,
                Name = user.FullName,
                Email = user.Email,
                Phone = user.PhoneNumber,
                IsDeleted = user.IsDeleted,
                EmailConfirmed = user.EmailConfirmed,
                LockoutEnd = user.LockoutEnabled,
                Roles = user.Roles
            })];
        }
    }
}