import dotenv from "dotenv";
import {
    sendWelcomeEmail,
    sendVerificationEmail,
    sendWebsiteSubmissionEmail,
    sendAIWebsiteSubmissionEmail,
    sendDirectorySubmissionEmail,
    sendJobSubmissionEmail
} from "./utils/emailService.js";
import { sendForgetEmail } from "./utils/forgetEmailService.js";

dotenv.config();

const TO_EMAIL = "developer0031@gmail.com";

async function runTests() {
    console.log(`🚀 Starting email tests to ${TO_EMAIL}...`);

    try {
        // 1. Welcome Email
        console.log("1️⃣ Sending Welcome Email...");
        await sendWelcomeEmail(TO_EMAIL, "Developer Test");

        // 2. Verification Email
        console.log("2️⃣ Sending Verification Email...");
        await sendVerificationEmail(TO_EMAIL, "Developer Test", "test-verification-token-123");

        // 3. Website Submission Email
        console.log("3️⃣ Sending Website Submission Email...");
        await sendWebsiteSubmissionEmail(TO_EMAIL, {
            userName: "Developer Test",
            websiteTitle: "Test Website Project",
            websiteUrl: "https://test-website.com",
            category: "Portfolio",
            submissionDate: new Date(),
            paymentOrderID: "ORDER-WEB-123",
            paymentAmount: "49.00",
            paymentCurrency: "USD"
        });

        // 4. AI Website Submission Email
        console.log("4️⃣ Sending AI Website Submission Email...");
        await sendAIWebsiteSubmissionEmail(TO_EMAIL, {
            userName: "Developer Test",
            websiteTitle: "Test AI Project",
            websiteUrl: "https://ai-test-project.com",
            category: "AI Tool",
            pricingOption: "Free",
            submissionDate: new Date(),
            paymentOrderID: "ORDER-AI-123",
            paymentAmount: "29.00",
            paymentCurrency: "USD"
        });

        // 5. Directory Submission Email
        console.log("5️⃣ Sending Directory Submission Email...");
        await sendDirectorySubmissionEmail(TO_EMAIL, {
            userName: "Developer Test",
            companyTitle: "Test Company Inc.",
            websiteUrl: "https://test-company.com",
            profile: "https://linkedin.com/company/test",
            country: "United States",
            submissionDate: new Date(),
            paymentOrderID: "ORDER-DIR-123",
            paymentAmount: "99.00",
            paymentCurrency: "USD"
        });

        // 6. Job Submission Email
        console.log("6️⃣ Sending Job Submission Email...");
        await sendJobSubmissionEmail(TO_EMAIL, {
            userName: "Developer Test",
            jobTitle: "Senior Frontend Developer",
            companyName: "Tech Giants Ltd.",
            jobType: "Full-time",
            category: "Development",
            submissionDate: new Date(),
            paymentOrderID: "ORDER-JOB-123",
            paymentAmount: "199.00",
            paymentCurrency: "USD"
        });

        // 7. Forget Email
        console.log("7️⃣ Sending Forget Email...");
        await sendForgetEmail(TO_EMAIL, "Forget Password - CSSAwwwards", "Click here to reset your password: https://cssawwwards.com/reset/token123", "Developer Test");

        console.log("\n✅ All test emails queued for sending!");

    } catch (error) {
        console.error("\n❌ Error running tests:", error);
    }
}

runTests();
