Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

711 B
Raw Blame
import { useQuery, useQueryClient } from "@tanstack/react-query";
import getProject from "@/fetchers/project/get-project";
import type getProjects from "@/fetchers/project/get-projects";

function useGetProject({
  id,
  workspaceId,
}: {
  id: string;
  workspaceId: string;
}) {
  const queryClient = useQueryClient();

  return useQuery({
    queryFn: () => getProject({ id, workspaceId }),
    queryKey: ["projects", workspaceId, id],
    enabled: !!id,
    placeholderData: () =>
      queryClient
        .getQueryData<Awaited<ReturnType<typeof getProjects>>>([
          "projects",
          workspaceId,
        ])
        ?.find((project) => project.id === id),
  });
}

export default useGetProject;