import { useId, useState, type ReactNode } from "react"; import { useQuery } from "@tanstack/react-query"; import { ChevronRight } from "lucide-react"; import type { Issue, Project } from "@paperclipai/shared"; import { issuesApi } from "@/api/issues"; import { queryKeys } from "@/lib/queryKeys"; import { cn } from "@/lib/utils"; import { taskStatusIconProps } from "@/lib/task-status-presentation"; import { RecentTaskNavItem } from "./RecentTaskNavItem"; import { StatusIcon } from "./StatusIcon"; export function SidebarProjectTasks({ project, userId, children, renderTask }: { project: Pick; userId?: string | null; children: ReactNode; renderTask?: (task: Issue) => ReactNode; }) { const [expanded, setExpanded] = useState(false); const contentId = useId(); const { data: tasks, isPending, error } = useQuery({ queryKey: [...queryKeys.issues.listByProject(project.companyId, project.id), "sidebar-tasks", userId ?? "__local_board__"], queryFn: ({ signal }) => issuesApi.list(project.companyId, { projectId: project.id, includeReadState: true, limit: 12, sortField: "updated", sortDir: "desc", }, { signal }), enabled: expanded, }); return
{children}
{expanded &&
{isPending ?

Loading tasks…

: error ?

Couldn’t load tasks.

: tasks?.length ? tasks.map(task =>
{renderTask ? renderTask(task) : } />}
) :

No tasks yet.

}
}
; }