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

Add complete status #145

Merged
merged 18 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
a9d954c
chore: Add pdf-lib dependency for generating certificates, Add COMPLE…
mayura-andrew Jul 11, 2024
afac5d8
Merge branch 'main' into add-complete-status
mayura-andrew Jul 11, 2024
28012ed
chore: Add uuid dependency for generating unique identifiers
mayura-andrew Jul 13, 2024
89fb972
chore: Update npm scripts and database configuration
mayura-andrew Jul 13, 2024
08caab7
chore: Update dbConfig to disable synchronization
mayura-andrew Jul 13, 2024
0e4a52f
Merge branch 'main' into add-complete-status
mayura-andrew Jul 13, 2024
37e1ab0
feat: Update Mentee entity to use UUID for certificate_id
mayura-andrew Jul 13, 2024
6943990
Merge branch 'main' into add-complete-status
mayura-andrew Jul 14, 2024
6236907
Merge branch 'main' into add-complete-status
mayura-andrew Jul 20, 2024
769cd41
Merge branch 'main' into add-complete-status
mayura-andrew Jul 21, 2024
a933df7
Merge branch 'sef-global:main' into add-complete-status
mayura-andrew Jul 28, 2024
008fa39
feat: Update Mentee entity to use UUID for certificate_id
mayura-andrew Jul 28, 2024
b0bce78
Merge branch 'sef-global:main' into add-complete-status
mayura-andrew Jul 31, 2024
7010463
chore: Update package dependencies and remove unused entities
mayura-andrew Jul 31, 2024
765ff9e
feat: Update certificate generation path
mayura-andrew Jul 31, 2024
96af9b9
Update certificate generation path
mayura-andrew Jul 31, 2024
ec04026
Merge branch 'main' into add-complete-status
mayura-andrew Jul 31, 2024
3f5e282
feat: Update certificate generation path
mayura-andrew Aug 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import type { Response } from 'express'
import type Mentor from './entities/mentor.entity'
import path from 'path'
import fs from 'fs'
import multer from 'multer'
import ejs from 'ejs'
import { ApplicationStatus } from './enums'
import { generateCertificate } from './services/admin/generateCertificate'
import { randomUUID } from 'crypto'

export const signAndSetCookie = (res: Response, uuid: string): void => {
const token = jwt.sign({ userId: uuid }, JWT_SECRET ?? '')

Expand Down Expand Up @@ -66,7 +68,7 @@
subject: string
message: string
}
): any => {

Check warning on line 71 in src/utils.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
const templatePath = path.join(__dirname, 'templates', `${templateName}.ejs`)

return new Promise<string>((resolve, reject) => {
Expand Down Expand Up @@ -176,11 +178,23 @@
Thank you again for considering our program and for the time you invested in your application. We wish you all the best in your future endeavours.`
}
case ApplicationStatus.COMPLETED: {
const certificatesDir = path.join(__dirname, 'certificates')

if (!fs.existsSync(certificatesDir)) {
fs.mkdirSync(certificatesDir)
}

const templatePath = path.join(
__dirname,
'templates',
'certificateTemplate.pdf'
)

const uniqueId = randomUUID()
const pdfFileName = await generateCertificate(
name,
'./src/certificates/certificate_template.pdf',
`./src/certificates/mentee/${uniqueId}_certificate.pdf`
templatePath,
path.join(certificatesDir, `${uniqueId}_certificate.pdf`)
)
return {
subject: 'Congratulations! You have completed ScholarX',
Expand Down
Loading