const { fetchLiveCampaignProducts } = require("./api");
const { renderCampaignsByCount } = require("./templates");
const fs = require("fs");
const path = require("path");

async function test() {
    const data = await fetchLiveCampaignProducts();
    console.log("Campaign Products:", data);
}

async function testCampaignsByCount() {
  try {
    const outputPath = path.join(__dirname, "../test-output");
    if (!fs.existsSync(outputPath)) {
      fs.mkdirSync(outputPath, { recursive: true });
    }

    // Test 1: Get all campaigns
    console.log("Testing campaigns by count - All campaigns");
    const allCampaignsHtml = await renderCampaignsByCount("");
    fs.writeFileSync(path.join(outputPath, "campaigns-all.html"), allCampaignsHtml);
    console.log("All campaigns rendered to: test-output/campaigns-all.html");

  } catch (error) {
    console.error("Error testing campaigns by count:", error);
  }
}
testCampaignsByCount();
