const Meeting = require("../models/Meeting");

exports.getMeetings = async (req, res) => {
  try {
    const meetings = await Meeting.find();
    const formattedMeetings = meetings.map((meeting) => {
      const formattedAgenda = meeting.agenda
        ? meeting.agenda.map((item, index) => `<li>${index + 1}. ${item}</li>`).join("")
        : "<li>No agenda provided</li>";
      return { ...meeting.toObject(), formattedAgenda };
    });

    res.json(formattedMeetings);
  } catch (error) {
    console.error("Error fetching meetings:", error);
    res.status(500).json({ error: "Error fetching meetings" });
  }
};
