Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Application Completion Workflow with Certificate Generation and Email Notification #130

Merged
merged 14 commits into from
Jul 31, 2024

Conversation

mayura-andrew
Copy link
Member

@mayura-andrew mayura-andrew commented Jul 11, 2024

Purpose

The purpose of this PR is to fix #122

Goals

  • Enable admins to change the application status to 'COMPLETE'.
  • Notify mentees via email upon status change.
  • Generate a completion certificate for each mentee and attach it to the notification email.

Approach

To achieve the above goals, the following steps were taken:

  • Integrated the pdf-lib library (version 1.17.1) to modify and generate completion certificates in PDF format.
  • Updated utils.ts to support sending emails with PDF attachments.
  • Created a separate function dedicated to handling the PDF generation and email notification logic
  • Created a new folder to store certificates

Screenshots

Checklist

  • This PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.
  • I have read and understood the development best practices guidelines ( http://bit.ly/sef-best-practices )
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

Related PRs

Test environment

  • OS: Linux Mint 21.3
  • Browser Firefox
  • Version 128.0
  • Nodejs 20.15.0

Learning

During the development of this feature, I explored several resources to understand how to effectively use the pdf-lib library for PDF manipulation and how to attach files to emails programmatically. This included reviewing documentation, blog posts, and tutorials related to pdf-lib and email handling in Node.js applications.

src/utils.ts Outdated
const pdfFileName = await generateCertificate(
name,
'./src/certificates/certificate_template.pdf',
`./src/certificates/${name}_certificate.pdf`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we use a unique id here? There might be a chance of having the same name. Also you need to update the certificate_id field of the mentee with file path as well.

Suggested change
`./src/certificates/${name}_certificate.pdf`
`./src/certificates/${name}_certificate.pdf`

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay sure

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
here I used uuid library to generate unique values

@mayura-andrew mayura-andrew self-assigned this Jul 11, 2024
@@ -12,7 +12,8 @@ export enum EmailStatusTypes {
export enum ApplicationStatus {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we rename this to MenteeStatus and create separate one form Mentors? Cuz mentors don't need a completed state.

Suggested change
export enum ApplicationStatus {
export enum MenteeStatus {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, could we avoid changing this? There is a lot of refactoring involved.

mayura-andrew and others added 5 commits July 13, 2024 11:29
This commit updates the Mentee entity to use the UUID data type for the `certificate_id` column instead of the `bigint` data type. This change ensures compatibility with the UUID data type in the database and improves data integrity.

Co-authored-by: Dileepa Mabulage <[email protected]>
Copy link
Member

@anjula-sack anjula-sack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you resolve the conflicts? @mayura-andrew

@mayura-andrew
Copy link
Member Author

Can you resolve the conflicts? @mayura-andrew
I'm working on this

package.json Outdated
"passport-linkedin-oauth2": "github:auth0/passport-linkedin-oauth2#v3.0.0",
"pg": "^8.10.0",
"reflect-metadata": "^0.1.13",
"ts-node": "^10.9.1",
"typeorm": "^0.3.16"
"typeorm": "^0.3.16",
"uuid": "^10.0.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@anjula-sack anjula-sack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! @mayura-andrew

@anjula-sack anjula-sack merged commit 21df4b8 into sef-global:main Jul 31, 2024
1 check passed
@mayura-andrew mayura-andrew mentioned this pull request Jul 31, 2024
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add "COMPLETE" state for applications.
2 participants