-
+
{(() => {
const Icon = getDynamicIcon(item.project_icon);
- return ;
+ return ;
})()}
diff --git a/src/Pages/internify/intern/components/CertificateAvailabe.tsx b/src/Pages/internify/intern/components/CertificateAvailabe.tsx
index cbda7df..2df227f 100644
--- a/src/Pages/internify/intern/components/CertificateAvailabe.tsx
+++ b/src/Pages/internify/intern/components/CertificateAvailabe.tsx
@@ -1,8 +1,9 @@
// CertificateAvailable.tsx
-import { useState } from "react";
+import { useState, useRef } from "react";
import { Download, Link, Printer } from "lucide-react";
import type { ProjectDetail } from "../../../../types/project.types";
import type { Certificate } from "../../../../types/certificate.types";
+import { downloadCertificateAsImage, downloadCertificateAsPdf } from "../../../utils/DownloadImagetoDevice";
interface CertificateAvailableProps {
project: ProjectDetail | null;
@@ -11,6 +12,9 @@ interface CertificateAvailableProps {
export default function CertificateAvailable({ project, certificate }: CertificateAvailableProps) {
const [copied, setCopied] = useState(false);
+ const [downloadingImg, setDownloadingImg] = useState(false);
+ const [downloadingPdf, setDownloadingPdf] = useState(false);
+ const certificateRef = useRef
(null);
const handleCopyLink = () => {
navigator.clipboard.writeText(window.location.href);
@@ -33,12 +37,24 @@ export default function CertificateAvailable({ project, certificate }: Certifica
})()
: "-";
- const handleDownload = () => {
- const a = document.createElement("a");
- a.href = certificate.image_path;
- a.download = `Sertifikat - ${certificate.certificate_no}.png`;
- a.target = "_blank";
- a.click();
+ const handleDownloadImage = async () => {
+ setDownloadingImg(true);
+ await downloadCertificateAsImage(
+ certificateRef.current,
+ `Sertifikat - ${certificate.certificate_no}`,
+ "png",
+ certificate.image_path
+ );
+ setDownloadingImg(false);
+ };
+
+ const handleDownloadPdf = async () => {
+ setDownloadingPdf(true);
+ await downloadCertificateAsPdf(
+ certificateRef.current,
+ `Sertifikat - ${certificate.certificate_no}`
+ );
+ setDownloadingPdf(false);
};
return (
@@ -87,11 +103,12 @@ export default function CertificateAvailable({ project, certificate }: Certifica
{/* Unduh Sertifikat */}
{/* Bagikan ke LinkedIn */}
@@ -101,9 +118,12 @@ export default function CertificateAvailable({ project, certificate }: Certifica
{/* Cetak & Salin Link */}
-