2026-02-27 04:29:51 +00:00
|
|
|
import { useState } from "react";
|
|
|
|
|
import { useProjects } from "../../hooks/useProjects";
|
2026-08-09 11:35:42 -07:00
|
|
|
import ProjectRow from "./ProjectRow";
|
2026-02-27 04:29:51 +00:00
|
|
|
import AddProjectDialog from "./AddProjectDialog";
|
2026-08-09 11:35:42 -07:00
|
|
|
import Button from "../ui/Button";
|
2026-02-27 04:29:51 +00:00
|
|
|
|
|
|
|
|
export default function ProjectList() {
|
|
|
|
|
const { projects } = useProjects();
|
|
|
|
|
const [showAdd, setShowAdd] = useState(false);
|
|
|
|
|
|
|
|
|
|
return (
|
2026-08-09 11:35:42 -07:00
|
|
|
<div className="p-2">
|
|
|
|
|
<div className="flex items-center justify-between px-1 py-1 mb-1.5">
|
|
|
|
|
<span className="text-[11px] font-semibold uppercase tracking-wide text-[var(--text-secondary)]">
|
2026-02-27 04:29:51 +00:00
|
|
|
Projects
|
|
|
|
|
</span>
|
2026-08-09 11:35:42 -07:00
|
|
|
<Button onClick={() => setShowAdd(true)} aria-label="Add project">
|
|
|
|
|
+ Add
|
|
|
|
|
</Button>
|
2026-02-27 04:29:51 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{projects.length === 0 ? (
|
2026-08-09 11:35:42 -07:00
|
|
|
<p className="px-1 text-xs text-[var(--text-secondary)]">
|
|
|
|
|
No projects yet — use “+ Add” to create one.
|
2026-02-27 04:29:51 +00:00
|
|
|
</p>
|
|
|
|
|
) : (
|
2026-08-09 11:35:42 -07:00
|
|
|
<div className="flex flex-col gap-0.5">
|
2026-02-27 04:29:51 +00:00
|
|
|
{projects.map((project) => (
|
2026-08-09 11:35:42 -07:00
|
|
|
<ProjectRow key={project.id} project={project} />
|
2026-02-27 04:29:51 +00:00
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{showAdd && <AddProjectDialog onClose={() => setShowAdd(false)} />}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|