diff --git a/src/controllers/confirmationController.js b/src/controllers/confirmationController.js index a2b690b4..f8449cc0 100644 --- a/src/controllers/confirmationController.js +++ b/src/controllers/confirmationController.js @@ -1,14 +1,14 @@ import PageController from './pageController.js' -import yaml from 'js-yaml'; -import fs from 'fs'; +import yaml from 'js-yaml' +import fs from 'fs' const templateFile = 'src/assets/emailTemplates/newEndpoint.yml' -const templateContent = fs.readFileSync(templateFile, 'utf8'); -const template = yaml.load(templateContent); +const templateContent = fs.readFileSync(templateFile, 'utf8') +const template = yaml.load(templateContent) class confirmationController extends PageController { - locals(req, res, next) { + locals (req, res, next) { const name = req.sessionModel.get('name') const email = req.sessionModel.get('email') const organisation = req.sessionModel.get('lpa') @@ -17,9 +17,9 @@ class confirmationController extends PageController { const endpoint = req.sessionModel.get('endpoint-url') const recipient = 'digitalland@levellingup.gov.uk' - const templateVars = { name, organisation, email, endpoint, documentationUrl, dataset }; - const subject = template.subject.replace(/\${(.*?)}/g, (match, key) => templateVars[key]); - const body = template.body.replace(/\${(.*?)}/g, (match, key) => templateVars[key]); + const templateVars = { name, organisation, email, endpoint, documentationUrl, dataset } + const subject = template.subject.replace(/\${(.*?)}/g, (match, key) => templateVars[key]) + const body = template.body.replace(/\${(.*?)}/g, (match, key) => templateVars[key]) req.form.options.mailTo = `mailto:${recipient}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`