import { useEffect, useState } from "react"; import { Link } from "react-router-dom"; import { prettyPrintTime } from "../../../libs/time"; import type { Project } from "../../api/routes/projects"; export function Projects() { const [projects, setProjects] = useState([]); useEffect(() => { async function getProjects() { try { const res = await fetch("/api/projects"); if (!res.ok) { throw new Error(`HTTP error! status: ${res.status}`); } const data = await res.json(); setProjects(data.projects); } catch (error) { console.error("Error fetching projects:", error); setProjects([]); } } getProjects(); }, []); return (

Projects

{projects.length === 0 ? (
No projects found
) : (
{projects.map((project) => ( {`${project.projectName}

{project.projectName}

Total Time:{" "} {prettyPrintTime( project.totalTakesTime * 1000, )}
))}
)}
); }