import { useState } from "react"; import { CheckCircle2, FolderArchive, Loader2 } from "lucide-react"; import { useProjectCertificates } from "../../../hooks/useCertificates"; import { useProjectDetail } from "../../../hooks/useProjects"; import { useParams } from "react-router-dom"; import { downloadAllCertificatesZip } from "../../utils/Certificates"; import CertResultTable from "./components/CertResultTable"; export default function CertificateResult() { const { slug } = useParams<{ slug: string }>(); const [zipping, setZipping] = useState(false); const [zipProgress, setZipProgress] = useState<{ done: number; total: number } | null>(null); const { project, loading: projectLoading, error: projectError } = useProjectDetail(slug ?? ""); const { certificates, loading: certLoading, error: certError } = useProjectCertificates(project?.id ?? 0); const loading = projectLoading || certLoading; const error = projectError || certError; const handleDownloadZip = async () => { if (!project || certificates.length === 0) return; setZipping(true); setZipProgress({ done: 0, total: certificates.length }); try { await downloadAllCertificatesZip( certificates, project.certificate_template ?? "", project.project_name, (done, total) => setZipProgress({ done, total }) ); } catch (err) { console.error("Gagal download ZIP:", err); } finally { setZipping(false); setZipProgress(null); } }; if (loading) return (

Certificates

View and download internship certificates

); if (error) return
Gagal memuat data sertifikat.
; return (
{/* Page Header */}

Certificates

Administrate, issue, and track professional certifications for all interns.

{/* Success Hero */}

{certificates.length} Certificates has been Generated!

The validation engine has processed all engineering credentials. You can now publish them to the public registry or download the batch for offline distribution.

{/* Table */}
); }