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

namespace ColaFlow.Modules.Identity.Application.EventHandlers;

/// <summary>
/// Event handler for InvitationAcceptedEvent - logs acceptance
/// </summary>
public class InvitationAcceptedEventHandler : INotificationHandler<InvitationAcceptedEvent>
{
    private readonly ILogger<InvitationAcceptedEventHandler> _logger;

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

    public Task Handle(InvitationAcceptedEvent notification, CancellationToken cancellationToken)
    {
        _logger.LogInformation(
            "Invitation accepted: Email={Email}, Tenant={TenantId}, Role={Role}",
            notification.Email,
            notification.TenantId,
            notification.Role);

        // Future: Could send welcome email, track conversion metrics, etc.

        return Task.CompletedTask;
    }
}
