import type { MagicLinkNotificationInput, MagicLinkNotificationPort } from '@core/identity/domain/ports/MagicLinkNotificationPort';
import type { Logger } from '@core/shared/domain/Logger';

/**
 * Console adapter for magic link notifications
 * Logs to console for development/testing purposes
 */
export class ConsoleMagicLinkNotificationAdapter implements MagicLinkNotificationPort {
  constructor(private readonly logger: Logger) {}

  async sendMagicLink(input: MagicLinkNotificationInput): Promise<void> {
    this.logger.info('[ConsoleMagicLinkNotificationAdapter] Magic link generated', {
      email: input.email,
      userId: input.userId,
      magicLink: input.magicLink,
      expiresAt: input.expiresAt,
    });

    // In development, log to console
    if (process.env.NODE_ENV === 'development') {
      console.log('\n🔒 PASSWORD RESET MAGIC LINK');
      console.log('='.repeat(50));
      console.log(`📧 Email: ${input.email}`);
      console.log(`👤 User ID: ${input.userId}`);
      console.log(`🔗 Link: ${input.magicLink}`);
      console.log(`⏰ Expires: ${input.expiresAt.toLocaleString()}`);
      console.log('='.repeat(50));
      console.log('⚠️  This would be sent via email in production\n');
    }
  }
}