-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: send email notification when a file upload to internal team
- Loading branch information
1 parent
093ba15
commit be4e25a
Showing
25 changed files
with
425 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import * as Sentry from '@sentry/nextjs'; | ||
import getConfig from 'next/config'; | ||
import toTitleCase from '../../../utils/formatString'; | ||
import config from '../../../config'; | ||
|
||
const CHES_API_URL = config.get('CHES_API_URL'); | ||
const namespace = getConfig()?.publicRuntimeConfig?.OPENSHIFT_APP_NAMESPACE; | ||
|
||
const sendEmail = async ( | ||
token: string, | ||
|
@@ -11,14 +14,15 @@ const sendEmail = async ( | |
tag: string, | ||
emailCC: string[] = [] | ||
) => { | ||
const environment = toTitleCase(namespace?.split('-')[1] || 'Dev'); | ||
try { | ||
const request = { | ||
bodyType: 'html', | ||
body, | ||
cc: emailCC, | ||
delayTs: 0, | ||
encoding: 'utf-8', | ||
from: 'CCBC Portal <[email protected]>', | ||
from: `CCBC Portal ${environment !== 'Prod' && environment} <[email protected]>`, | ||
priority: 'normal', | ||
subject, | ||
to: emailTo, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import * as Sentry from '@sentry/nextjs'; | ||
import getConfig from 'next/config'; | ||
import toTitleCase from '../../../utils/formatString'; | ||
import config from '../../../config'; | ||
|
||
const CHES_API_URL = config.get('CHES_API_URL'); | ||
const namespace = getConfig()?.publicRuntimeConfig?.OPENSHIFT_APP_NAMESPACE; | ||
|
||
export interface Context { | ||
to: string[]; | ||
|
@@ -19,13 +22,14 @@ const sendEmailMerge = async ( | |
subject: string, | ||
contexts: Contexts | ||
) => { | ||
const environment = toTitleCase(namespace?.split('-')[1] || 'Dev'); | ||
try { | ||
const request = { | ||
bodyType: 'html', | ||
body, | ||
contexts, | ||
encoding: 'utf-8', | ||
from: 'CCBC Portal <[email protected]>', | ||
from: `CCBC Portal ${environment !== 'Prod' && environment} <[email protected]>`, | ||
priority: 'normal', | ||
subject, | ||
attachments: [], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { | ||
EmailTemplate, | ||
EmailTemplateProvider, | ||
} from '../handleEmailNotification'; | ||
|
||
const notifyDocumentUpload: EmailTemplateProvider = ( | ||
applicationId: string, | ||
url: string, | ||
initiator: any, | ||
params: any | ||
): EmailTemplate => { | ||
const { ccbcNumber, documentType, timestamp, documentNames } = params; | ||
|
||
const section = { | ||
'Claim & Progress Report': 'project?section=claimsReport', | ||
'Community Progress Report': 'project?section=communityProgressReport', | ||
'Milestone Report': 'project?section=milestoneReport', | ||
'Statement of Work': 'project?section=projectInformation', | ||
}; | ||
|
||
const link = `<a href='${url}/analyst/application/${applicationId}/${section[documentType] ?? 'rfi'}'>${ccbcNumber}</a>`; | ||
return { | ||
emailTo: [112, 10, 111], | ||
emailCC: [], | ||
tag: 'document-upload-notification', | ||
subject: `${documentType} uploaded in Portal`, | ||
body: ` | ||
<h1>${documentType} uploaded in Portal</h1> | ||
<p>Notification: A ${documentType} has been uploaded in the Portal for ${link} on ${timestamp}.</p> | ||
<ul> | ||
${documentNames.map((file) => `<li><em>${file}</em></li>`).join('')} | ||
</ul> | ||
`, | ||
}; | ||
}; | ||
|
||
export default notifyDocumentUpload; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.