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

namespace ColaFlow.Modules.Identity.Application.EventHandlers;

/// <summary>
/// Event handler for UserInvitedEvent - logs invitation
/// </summary>
public class UserInvitedEventHandler : INotificationHandler<UserInvitedEvent>
{
    private readonly ILogger<UserInvitedEventHandler> _logger;

    public UserInvitedEventHandler(ILogger<UserInvitedEventHandler> logger)
    {
        _logger = logger;
    }

    public Task Handle(UserInvitedEvent notification, CancellationToken cancellationToken)
    {
        _logger.LogInformation(
            "User invited: Email={Email}, Tenant={TenantId}, Role={Role}, InvitedBy={InvitedBy}",
            notification.Email,
            notification.TenantId,
            notification.Role,
            notification.InvitedBy);

        // Future: Could add analytics tracking, audit log entry, etc.

        return Task.CompletedTask;
    }
}
