-
Notifications
You must be signed in to change notification settings - Fork 44
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
Changes from 7 commits
a9d954c
afac5d8
28012ed
89fb972
08caab7
0e4a52f
37e1ab0
6943990
6236907
769cd41
a933df7
008fa39
b0bce78
7010463
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -12,7 +12,8 @@ export enum EmailStatusTypes { | |||||
export enum ApplicationStatus { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we rename this to
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||
PENDING = 'pending', | ||||||
REJECTED = 'rejected', | ||||||
APPROVED = 'approved' | ||||||
APPROVED = 'approved', | ||||||
COMPLETED = 'completed' | ||||||
} | ||||||
|
||||||
export enum StatusUpdatedBy { | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { PDFDocument, rgb } from 'pdf-lib' | ||
import fs from 'fs' | ||
|
||
export async function generateCertificate( | ||
menteeName: string, | ||
sourcePdfPath: string, | ||
outputPath: string | ||
): Promise<string> { | ||
try { | ||
const existingPdfBytes = fs.readFileSync(sourcePdfPath) | ||
const pdfDoc = await PDFDocument.load(existingPdfBytes) | ||
const page = pdfDoc.getPage(0) | ||
const fontSize = 24 | ||
const datezFontSize = 18 | ||
|
||
page.drawText(menteeName, { | ||
x: 66, | ||
y: page.getHeight() - 220, | ||
size: fontSize, | ||
color: rgb(0, 0, 0) | ||
}) | ||
|
||
const issueDate = new Date().toLocaleDateString() | ||
|
||
page.drawText(issueDate, { | ||
x: 160, | ||
y: page.getHeight() - 476, | ||
size: datezFontSize, | ||
color: rgb(0, 0, 0) | ||
}) | ||
|
||
const pdfBytes = await pdfDoc.save() | ||
|
||
fs.writeFileSync(outputPath, pdfBytes) | ||
return outputPath | ||
} catch (error) { | ||
console.error('Failed to modify the PDF:', error) | ||
throw error | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID