using ColaFlow.Modules.Identity.Domain.Aggregates.Users.Events;
using MediatR;
using Microsoft.Extensions.Logging;

namespace ColaFlow.Modules.Identity.Application.EventHandlers;

public sealed class UserRemovedFromTenantEventHandler(ILogger<UserRemovedFromTenantEventHandler> logger)
    : INotificationHandler<UserRemovedFromTenantEvent>
{
    public Task Handle(UserRemovedFromTenantEvent notification, CancellationToken cancellationToken)
    {
        logger.LogInformation(
            "User {UserId} removed from tenant {TenantId}. Removed by: {RemovedBy}. Reason: {Reason}",
            notification.UserId,
            notification.TenantId.Value,
            notification.RemovedBy,
            notification.Reason);

        // Future: Send notification to user
        // Future: Audit log

        return Task.CompletedTask;
    }
}
