import { Loader2, AlertCircle } from "lucide-react"; import { useMyProjects } from "../../../hooks/useProjects"; import type { Project } from "../../../types/project.types"; import { useNavigate } from "react-router-dom"; import * as LucideIcons from 'lucide-react'; import type { LucideProps } from 'lucide-react'; export default function SertificateList() { const { projects, loading, error } = useMyProjects(); const navigate = useNavigate(); const getDynamicIcon = (iconName: string) => { const formatted = iconName.charAt(0).toUpperCase() + iconName.slice(1); const Icon = (LucideIcons as unknown as Record>)[formatted]; return Icon ?? LucideIcons.FolderOpen; }; return (
{/* Header */}

Certificate History

All your earned internship certificates

{/* Loading */} {loading && (
Loading certificates...
)} {/* Error */} {error && !loading && (
{error}
)} {/* Empty */} {!loading && !error && projects.length === 0 && (

No ongoing projects yet.

)} {/* Grid */} {!loading && !error && projects.length > 0 && (
{projects.map((item: Project) => (
navigate(`/intern/certificates/${item.slug}`, { state: { project: item } })} > {/* Thumbnail */}
{(() => { const Icon = getDynamicIcon(item.project_icon); return ; })()}
{/* Info */}

{new Date(item.start_date).toLocaleDateString("id-ID", { year: "numeric", month: "long", })} until {new Date(item.end_date).toLocaleDateString("id-ID", { year: "numeric", month: "long", })}

{item.project_name}

No: {item.status}

))}
)}
); }