Skip to content

Commit

Permalink
Merge pull request #100 from HarkerRobo/pr-fix
Browse files Browse the repository at this point in the history
Update PR System
  • Loading branch information
25DanielG authored Jan 4, 2025
2 parents 0b3a920 + 9490b49 commit 1888fa8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions routers/member/purchase.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const express = require("express"),
email = require("../../helpers/email");

const MENTOR_EMAIL = config.users.mentor;
const ADMIN_EMAILS = config.users.admins;

const PURCHASE_FIELDS = {
purchase_id: "Purchase ID",
Expand Down Expand Up @@ -307,6 +308,25 @@ router.post(
submitted_by: safeString(req.auth.info.email),
draft: Boolean(safeString(req.body.draft)),
});

const subject = "New purchase request awaiting approval";
const text = `A new purchase request (#${purchase.purchase_id}) is awaiting your approval.
View it here: https://${config.server.domain}/member/purchase/view/${purchase.purchase_id}`;

const html = `A new purchase request (#${purchase.purchase_id}) is awaiting your approval.<br/>
<a href="https://${config.server.domain}/member/purchase/view/${purchase.purchase_id}">
Click here to view the request</a>`;

for (const adminEmail of ADMIN_EMAILS) {
await email.sendMail(
config.automail.auth.address,
adminEmail,
subject,
text,
html
);
}

res.redirect("view/" + purchase.purchase_id);
} catch (err) {
console.error(err);
Expand Down

0 comments on commit 1888fa8

Please sign in to comment.