Skip to content

Commit

Permalink
participation certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
satwikrprabhu committed Jul 28, 2024
1 parent 08c14b1 commit 1426ba5
Show file tree
Hide file tree
Showing 8 changed files with 501 additions and 188 deletions.
574 changes: 420 additions & 154 deletions prisma/seed.ts

Large diffs are not rendered by default.

33 changes: 17 additions & 16 deletions src/certificates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ import * as nodemailer from "nodemailer";
import htmlToImage from "node-html-to-image";
import { getCount, getUser, updateCount } from "./utils/email";

let certificateSentSuccess = 1094;
let certificateSentSuccess = 0;
let certificateSentError = 0;

async function generateCertificate(
Expand All @@ -143,7 +143,7 @@ async function generateCertificate(
eventName: string
): Promise<string> {
try {
const templatePath = path.join(__dirname, "certificate.html");
const templatePath = path.join(__dirname, "templates/certificate.html");
let html = fs.readFileSync(templatePath, "utf-8");

// Replace {{name}} with participant name
Expand All @@ -165,7 +165,7 @@ async function generateCertificate(
let imagePaths: string[] = [];
if (Array.isArray(imageBuffer)) {
imagePaths = imageBuffer.map((buffer, index) => {
const imagePath = path.join(__dirname, `certificate_${index}.png`);
const imagePath = path.join(__dirname, `src/certificate_${index}.png`);
fs.writeFileSync(imagePath, buffer);
return imagePath;
});
Expand Down Expand Up @@ -193,8 +193,8 @@ async function sendEmailWithAttachment(
const count = await getCount();
const user = getUser(count);
const transporter = nodemailer.createTransport({
port: 465,
host: "smtp.gmail.com",
port: 465,
auth: {
user: user,
pass: process.env.EMAIL_SERVER_PASSWORD as string,
Expand All @@ -203,7 +203,7 @@ async function sendEmailWithAttachment(

// Compose the email
const mailOptions = {
from: user,
from: process.env.EMAIL_FROM as string,
to: participantEmail,
subject: subject,
text: text,
Expand All @@ -224,19 +224,19 @@ const sendCertificate = async (
eventName: string,
participantEmail: string
) => {
const emailText = `Hi ${participantName},
const emailText = `Hi ${participantName},
Thank you for your active participation in Incridea, held during April 26th-29th at NMAMIT, Nitte.
Thank you for your active participation in Incridea, held from February 22nd-24th at NMAMIT, Nitte.
Your captivating performance aligned perfectly with our theme: 'Tides Of Change', creating ripples of inspiration and change. Let's continue to ignite the creativity and imagination through Incridea in the years to come.❤️
Your captivating performance perfectly aligned with our theme, 'Dice of Destiny', casting a spell of chance and fortune. Let's continue to embrace the unpredictable twists of creativity and imagination through Incridea in the years to come.❤️
Please find your Participation Certificate attached herewith.
Please find your participation certificate attached.
Warm Regards,
Team Incridea
Check out the Official Aftermovie '23 down below 👇
https://youtu.be/8Veb3u0xEoE
Check out the Official Aftermovie '24 down below 👇
https://youtu.be/YoWeuaSMytk
Find more updates and highlights of the fest on our Instagram page @incridea 👇
https://instagram.com/incridea
Expand Down Expand Up @@ -277,6 +277,7 @@ async function sendParticipationCertificate() {
},
},
});

// participationData ={
// name: "Participant Name";
// eventName: "Event Name";
Expand All @@ -300,7 +301,7 @@ async function sendParticipationCertificate() {
(acc, val) => acc.concat(val),
[]
);
for (let i = 1094; i < flattenedParticipationData.length; i++) {
for (let i = 0; i < flattenedParticipationData.length; i++) {
const participant = flattenedParticipationData[i];
try {
await sendCertificate(
Expand Down Expand Up @@ -332,10 +333,10 @@ async function sendParticipationCertificate() {
);
}

// await fs.writeFileSync(
// "./participation.json",
// JSON.stringify(flattenedParticipationData)
// );
await fs.writeFileSync(
"./participation.json",
JSON.stringify(flattenedParticipationData)
);
}

sendParticipationCertificate()
Expand Down
1 change: 1 addition & 0 deletions src/models/Card/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const DayTypeEnum = builder.enumType(DayType, {
name: "DayType",
});

//for easter eggs scanned using QR codes around the college for Publcity Committee
builder.mutationField("createCard",(t) =>
t.prismaField({
type:"Card",
Expand Down
2 changes: 1 addition & 1 deletion src/models/Judge/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ builder.mutationField("createJudge", (t) =>
}
if (!args.email.endsWith("@incridea.in"))
throw new Error("Email should end with @incridea.in");

//Creates a new judge credential
const judge = await ctx.prisma.judge.create({
data: {
User: {
Expand Down
1 change: 1 addition & 0 deletions src/models/Level/mutation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { builder } from "../../builder";

//add level
//Levels for custom easter eggs need to be added manually in the database
builder.mutationField("addLevel", (t) =>
t.prismaField({
type: "Level",
Expand Down
4 changes: 4 additions & 0 deletions src/models/PaymentOrder/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ builder.mutationField("createPaymentOrder", (t) =>
},
});
}
//set amount for external colleges
let amount = 350;
//set amount for nmamit.in email
if (user.email.endsWith("nmamit.in")) {
amount = 250;
} else {
Expand All @@ -77,6 +79,7 @@ builder.mutationField("createPaymentOrder", (t) =>
College: true,
},
});

if (userData?.College?.type === "OTHER") {
amount = 150;
}
Expand All @@ -86,6 +89,7 @@ builder.mutationField("createPaymentOrder", (t) =>

const currency = "INR";
const options = {
//setting the commisison to 2% for the payment gateway
amount: (Math.ceil(amount / 0.98) * 100).toString(),
currency,
payment_capture,
Expand Down
4 changes: 4 additions & 0 deletions src/models/ProniteRegistration/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ builder.mutationField("registerPronite", (t) =>
const authUser = await ctx.user;

if (!authUser) throw new Error("Not authenticated");
// ID of pronite email used for scanning
if (authUser.id != 5181)
throw new Error("permission denied, wrong account");
if (!["PARTICIPANT", "ORGANIZER", "BRANCH_REP","ADMIN","JURY"].includes(user.role)) {
throw new Error("User did not register for the fest");
}

//set day here for pronite
const pronite = await ctx.prisma.proniteRegistration.findUnique({
where: {
userId_proniteDay: {
Expand All @@ -46,6 +49,7 @@ builder.mutationField("registerPronite", (t) =>
});
throw new Error(`User already registered for pronite at ${date}`);
}
//set day here for pronite
const createdPronite = await ctx.prisma.proniteRegistration.create({
data: {
userId: Number(args.userId),
Expand Down
70 changes: 53 additions & 17 deletions src/templates/certificate.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,93 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="" />

<title>Participation Certificate</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Raleway:ital,wght@0,100..900;1,100..900&display=swap');
* {
margin: 0;
padding: 0;
}
.background {
position: relative;
background-image: url("https://res.cloudinary.com/nexttrek/image/upload/c_scale,w_2160/v1688184131/Incridea/PARTICIPATION_final_buyvko.png");
background-color: #cccccc;
/* background-image: url("https://res.cloudinary.com/dfhg1joox/image/upload/v1718946999/pya21yngjtywworaebiy.jpg"); */
background-image: url("https://res.cloudinary.com/dfhg1joox/image/upload/v1722062123/qqgtml9wknn55dgcy6ky.jpg");
background-color: transparent;
display: flex;
width: 1080px;
height: 763.5px;
height: 764.5px;
background-repeat: no-repeat;
background-size: cover;
}
.content {
position: absolute;
top: 450px;
font-size: 22px;
padding: 15px 60px;
text-align: center;
top: 385px;
left: 320px;
font-size: 24px;
padding: 10px 50px;
text-align: justify;
-moz-text-align-last: center;
text-align-last: center;
line-height: 35px;
font-family: 'Raleway', sans-serif;
}
.custom-text {
text-transform: uppercase;
font-weight: 600;
font-weight: 700;
font-size: 24px;
line-height: 35px;
font-family: 'Raleway', sans-serif;
}
.image {
height: 50px;
height:47px;
position: absolute;
top: -35px;
top: -32px;
left: 8px;
}
</style>
</head>

<body class="background">
<div class="content">
THIS IS TO CERTIFY THAT MR/MS
<span class="custom-text">{{name}}</span><span> OF</span>
<span class="custom-text">{{college}}</span> HAS PARTICIPATED ACTIVELY IN
<pre style="text-align: center;
font-size: 24px;
line-height: 35px;
font-family: 'Raleway', sans-serif;" >THIS IS TO CERTIFY THAT </pre>
MR/MS <span class="custom-text">{{name}}</span><span> OF</span>
<span class="custom-text">{{college}}</span> HAS PARTICIPATED IN
<span class="custom-text">{{event}}</span> DURING
<span style="position: relative; width: 130px; display: inline-flex"
><img
<span style="position: relative; width: 120px; display: inline-flex"
>
<img
class="image"
src="https://res.cloudinary.com/nexttrek/image/upload/v1688186046/Incridea/logo-black_enaoeg.png"
alt="INCRIDEA LOGO"
/></span>
‘23 HELD ON APRIL 26TH-29TH AT NMAM INSTITUTE OF TECHNOLOGY, NITTE.
/>
</span>
‘24 HELD BETWEEN FEBRUARY 22<span style="font-size:small; vertical-align:top;">nd</span> - 24<span style="font-size:small; vertical-align:top;">th</span> AT N.M.A.M. INSTITUTE OF TECHNOLOGY, NITTE.
</div>
</body>

<!-- <body class="background">
<div class="content">
<pre style="text-align: center;
font-size: 24px;
line-height: 35px;
text-transform: capitalize;
font-family: 'Raleway', sans-serif;" >This Is To Certify That </pre>
Mr/Ms <span class="custom-text">{{name}}</span><span> OF</span>
<span class="custom-text">{{college}}</span> Has Participated In
<span class="custom-text">{{event}}</span> During
<span style="position: relative; width: 120px; display: inline-flex; text-transform: capitalize;"
>
<img
class="image"
src="https://res.cloudinary.com/nexttrek/image/upload/v1688186046/Incridea/logo-black_enaoeg.png"
alt="INCRIDEA LOGO"
/>
</span>
‘24 Held Between February 22<span style="font-size:small; vertical-align:top;">nd</span> - 24<span style="font-size:small; vertical-align:top;">th</span> At NMAM Institute Of Technology, Nitte.
</div>
</body> -->
</html>

0 comments on commit 1426ba5

Please sign in to comment.