using TeleWave.Application.Common.Models;

namespace TeleWave.Application.Common.Interfaces;

public sealed record CurrentUserProfile(Guid Id, string UserName, string Role, bool IsBlocked);

public sealed record UserSummaryDto(
    Guid Id,
    string UserName,
    string Role,
    bool IsBlocked,
    DateTimeOffset CreatedAt
);

public interface IIdentityService
{
    /// <summary>Создаёт пользователя и назначает роль по умолчанию (см. Infrastructure/Identity/RoleNames).</summary>
    Task<Result<Guid>> CreateUserAsync(
        string userName,
        string password,
        CancellationToken cancellationToken
    );

    Task<Result<AuthenticatedUser>> ValidateCredentialsAsync(
        string userName,
        string password,
        CancellationToken cancellationToken
    );

    Task<CurrentUserProfile?> GetProfileAsync(Guid userId, CancellationToken cancellationToken);

    Task<Result> ChangePasswordAsync(
        Guid userId,
        string currentPassword,
        string newPassword,
        CancellationToken cancellationToken
    );

    /// <summary>Сброс пароля администратором — без текущего пароля (для чужого аккаунта).</summary>
    Task<Result> ResetPasswordAsync(
        Guid userId,
        string newPassword,
        CancellationToken cancellationToken
    );

    Task<Result> ChangeUserNameAsync(
        Guid userId,
        string newUserName,
        CancellationToken cancellationToken
    );

    /// <summary>Удаляет аккаунт (самоудаление или удаление админом).</summary>
    Task<Result> DeleteUserAsync(Guid userId, CancellationToken cancellationToken);

    Task<Result> BlockUserAsync(Guid userId, CancellationToken cancellationToken);

    Task<Result> UnblockUserAsync(Guid userId, CancellationToken cancellationToken);

    Task<PagedList<UserSummaryDto>> ListUsersAsync(
        UserListFilter filter,
        CancellationToken cancellationToken
    );
}
