/**
 * Quick Email Preview Generator
 * 
 * Generates preview URLs immediately without creating real requests
 */

import { emailNotificationService } from '../services/emailNotification.service';

async function generatePreviews() {
  console.log('\n' + '═'.repeat(80));
  console.log('  📧 EMAIL PREVIEW GENERATOR');
  console.log('═'.repeat(80) + '\n');

  // Sample data
  const initiator = {
    userId: 'user-1',
    email: 'john.doe@royalenfield.com',
    displayName: 'John Doe'
  };

  const approver = {
    userId: 'user-2',
    email: 'jane.smith@royalenfield.com',
    displayName: 'Jane Smith'
  };

  const requestData = {
    requestNumber: 'REQ-2025-12-0013',
    title: 'Equipment Purchase Request',
    description: '<p>Need approval for <strong>new equipment</strong></p>',
    requestType: 'Purchase',
    priority: 'HIGH',
    createdAt: new Date(),
    tatHours: 48,
    totalApprovers: 1
  };

  try {
    console.log('Generating email previews...\n');

    // 1. Request Created
    console.log('1️⃣  Request Created Email...');
    await emailNotificationService.sendRequestCreated(
      requestData,
      initiator,
      approver
    );

    console.log('\n');

    // 2. Approval Request
    console.log('2️⃣  Approval Request Email...');
    await emailNotificationService.sendApprovalRequest(
      requestData,
      approver,
      initiator,
      false
    );

    console.log('\n');
    console.log('═'.repeat(80));
    console.log('✅ Preview URLs generated above!');
    console.log('═'.repeat(80));
    console.log('\n💡 Click the preview URLs to see the emails\n');

  } catch (error) {
    console.error('❌ Error:', error);
    throw error;
  }
}

generatePreviews()
  .then(() => process.exit(0))
  .catch(() => process.exit(1));

