-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1591 from gtech-mulearn/dev
dev
- Loading branch information
Showing
5 changed files
with
225 additions
and
29 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions
29
src/modules/Dashboard/modules/Profile/components/Certificate/Certificate.module.css
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,29 @@ | ||
.certificate_container { | ||
display: flex; | ||
align-items: center; /* Centers horizontally */ | ||
justify-content: center; /* Centers vertically */ | ||
margin-top: 20px; | ||
} | ||
|
||
.certificate { | ||
padding: 20px; | ||
border: 2px solid #000; | ||
border-radius: 10px; | ||
width: 80%; | ||
text-align: center; | ||
background-color: #20151d; | ||
} | ||
|
||
.certificate h1 { | ||
font-size: 24px; | ||
font-weight: bold; | ||
} | ||
|
||
.certificate p { | ||
font-size: 18px; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.certificate strong { | ||
font-weight: bold; | ||
} |
121 changes: 121 additions & 0 deletions
121
src/modules/Dashboard/modules/Profile/components/Certificate/Certificate.tsx
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,121 @@ | ||
import React, { useRef, useEffect } from "react"; | ||
import html2canvas from "html2canvas"; | ||
import MulearnBrand from "../../assets/svg/MulearnBrand"; | ||
|
||
type CertificateProps = { | ||
name: string; | ||
muid: string; | ||
level: number; | ||
karma: number; | ||
interestGroups: string[]; | ||
}; | ||
|
||
const Certificate: React.FC<CertificateProps> = ({ | ||
name, | ||
muid, | ||
level, | ||
karma, | ||
interestGroups | ||
}) => { | ||
const pdfElement = useRef<HTMLDivElement>(null); | ||
|
||
useEffect(() => { | ||
handleDownloadPDF(); | ||
}, []); | ||
|
||
const handleDownloadPDF = () => { | ||
html2canvas(pdfElement.current!).then(canvas => { | ||
const imgData = canvas.toDataURL("image/png"); | ||
// Create a link element | ||
const link = document.createElement("a"); | ||
// Set the download attribute with a filename | ||
link.download = "Certificate.png"; | ||
// Set the href attribute to the image data URL | ||
link.href = imgData; | ||
// Append the link to the document body (this is necessary for Firefox) | ||
document.body.appendChild(link); | ||
// Trigger the download | ||
link.click(); | ||
// Remove the link from the document | ||
document.body.removeChild(link); | ||
}); | ||
}; | ||
// MODIFY THIS RETURN TO STYLE THE CERTIFICATE | ||
return ( | ||
<> | ||
<div | ||
style={{ | ||
display: "flex", | ||
alignItems: "center", // Centers horizontally | ||
justifyContent: "center", // Centers vertically | ||
margin: "50px" | ||
}} | ||
ref={pdfElement} | ||
> | ||
<div | ||
style={{ | ||
padding: "20px", | ||
border: "2px solid #000", | ||
borderRadius: "10px", | ||
width: "80%", | ||
textAlign: "center", | ||
backgroundColor: "#20151d", | ||
color: "#fff" | ||
}} | ||
id="certificate" | ||
> | ||
<div | ||
style={{ | ||
display: "flex", | ||
alignContent: "end", | ||
justifyContent: "end" | ||
}} | ||
> | ||
<MulearnBrand /> | ||
</div> | ||
<h1 | ||
style={{ | ||
fontSize: "32px", | ||
fontWeight: "bold", | ||
textDecoration: "underline" | ||
}} | ||
> | ||
Certificate of Achievement | ||
</h1> | ||
<div | ||
style={{ | ||
display: "flex", | ||
alignContent: "center", | ||
justifyContent: "center", | ||
paddingTop: "50px" | ||
}} | ||
> | ||
This is to certify that {name + " "} | ||
has successfully achieved Level: {level + " "} | ||
with a total of {karma} Karma points | ||
<br /> | ||
and is actively participating in the following interest | ||
groups: | ||
{" " + interestGroups.join(", ") + " "} | ||
</div> | ||
muID: {muid} | ||
<div | ||
style={{ | ||
display: "flex", | ||
paddingTop: "50px" | ||
}} | ||
> | ||
<br /> | ||
Signature: __________________________ | ||
<br /> | ||
muLearn Team | ||
<br /> | ||
Dated: {new Date().toLocaleDateString()} | ||
</div> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default Certificate; |
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