From f49969e147818fded82038e0f13d4adbb70c100a Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Mon, 13 Jan 2025 21:02:19 -0500 Subject: [PATCH] Modify messages --- controller/offerLetter.js | 75 ++++++++++++++++++++++++++++++++++++ controller/verifyEmployer.js | 2 +- routes/verifyRoute.js | 2 + 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 controller/offerLetter.js diff --git a/controller/offerLetter.js b/controller/offerLetter.js new file mode 100644 index 0000000..7003ea3 --- /dev/null +++ b/controller/offerLetter.js @@ -0,0 +1,75 @@ +import nodemailer from "nodemailer"; + +export const offerLetter = async (req, res)=>{ + + const employee_name = req.body.firstname + " " + req.body.lastname; // "EMPLOYEE NAME"; + const signatory_name = req.body.signatory_name; + const approve_link = "https://digifi-employer.chiefsoft.net"; + const approve_password = req.body.signatory_password; //"1234567890"; + const application_uid = req.body.application_uid; + const signatory_email = req.body.signatory_email; + + const mainHtml = ` + Dear, Banji, + + We are happy to present your loan offer with the details below: + + Loan Offer + Loan Amount: N1,000,000 + Tenor: 12 months + Monthly Interest rate: 5% + Management Fee (taken upfront): 1% + Insurance fee (taken upfront): 1% + Installment payment: N112,825.41 + Next repayment date: February 12, 2025 + Total repayment: N1,353,904.92 + Accept Loan Offer + + ***Loan Offer Approval (You are to login with this to your portal to approve the loan ) + + If you have any questions or concerns about this email, please get in touch with our finance department at processingbank@email.com. Kind Regards, + + Finance team, + Processing Bank + `; + + try { + console.log("verifyEmployer REQ-----------------------------------------"); + console.log(req.body); + console.log("verifyEmployer REQ========================================="); + + const transporter = nodemailer.createTransport({ + service: "gmail", + host: "smtp.gmail.com", + port: 587, + secure: false, + auth: { + user: "message@chiefsoft.com", + pass: "may12002!", + }, + }); +// async..await is not allowed in global scope, must use a wrapper + async function main() { + // send mail with defined transport object + const info = await transporter.sendMail({ + from: '"Support ChiefSoft 👻" ', // sender address + to: signatory_email, // list of receivers + bcc: "ameye@chiefsoft.com, victor.ebuka@chiefsoft.com", // list of receivers + subject: "Bank Loan Offer ✔", // Subject line + text: "Hello "+signatory_name+"?", // plain text body + html: mainHtml, // html body + }); + console.log("Message sent: %s", info.messageId); + // Message sent: + } + main().catch(console.error); + + return res.json({res : 'sent'}); + + } + catch(error){ + res.status(500).json({error: "Internal Server error"}); + } + + +} \ No newline at end of file diff --git a/controller/verifyEmployer.js b/controller/verifyEmployer.js index 12c94a2..19f003e 100644 --- a/controller/verifyEmployer.js +++ b/controller/verifyEmployer.js @@ -27,7 +27,7 @@ export const verifyEmployer = async (req, res)=>{ "This serves as an employer’s commitment to notify you that your staff ("+employee_name+") who holds the position of software engineer in your organization took a loan facility from our bank and has prompted us to notify you so as to confirm his existence as a staff of your organization." + " Please click on the link below to confirm this before we can approve his loan\n " + "

\n" + - "***Employer commitment link (You are to login with this email address and default password "+approve_password+" )\n " + + "***Employer commitment link (You are to login with this email address and default password "+approve_password+" )\n " + "

\n" + "If you have any questions or concerns with respect to this email, please contact our finance department at "+req.body.processing_bank_email+".\n \n Kind Regards,

\n" + "Finance team,
"+req.body.processing_bank_name+"
\n"; diff --git a/routes/verifyRoute.js b/routes/verifyRoute.js index 92c249b..4e032ec 100644 --- a/routes/verifyRoute.js +++ b/routes/verifyRoute.js @@ -1,9 +1,11 @@ import express from "express" import { fetch } from "../controller/verifyController.js" import { verifyEmployer } from "../controller/verifyEmployer.js" +import { offerLetter } from "../controller/offerLetter.js"; const verify_route = express.Router(); verify_route.post("/bvn",fetch); verify_route.post("/employer",verifyEmployer); +verify_route.post("/offer",offerLetter); export default verify_route; \ No newline at end of file