forked from CSI-KJSCE/BOS-React-
Update server and frontend files, add new uploads
This commit is contained in:
@@ -46,11 +46,32 @@ const meetingSchema = new mongoose.Schema({
|
||||
});
|
||||
const Meeting = mongoose.model("Meeting", meetingSchema);
|
||||
|
||||
app.get("/api/meetings", async (req, res) => {
|
||||
try {
|
||||
const meetings = await Meeting.find(); // Fetching all meetings
|
||||
|
||||
// Format agenda in HTML for each meeting
|
||||
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 }; // Add formatted agenda to each meeting
|
||||
});
|
||||
|
||||
res.json(formattedMeetings); // Send formatted meetings
|
||||
} catch (error) {
|
||||
console.error("Error fetching meetings:", error);
|
||||
res.status(500).json({ error: "Error fetching meetings" });
|
||||
}
|
||||
});
|
||||
|
||||
// API to send email
|
||||
app.post("/api/send-email", upload.array("attachments"), async (req, res) => {
|
||||
try {
|
||||
const { program, department, subject, body, agenda, date, startTime, endTime, recipients } = req.body;
|
||||
const files = req.files;
|
||||
|
||||
console.log({ program, department, subject, body, agenda, date, startTime, endTime, recipients, files });
|
||||
|
||||
if (!program || !department || !subject || !body || !date || !startTime || !endTime || !recipients) {
|
||||
return res.status(400).json({ error: "All fields are required!" });
|
||||
|
||||
Reference in New Issue
Block a user