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.

630 B
Raw Blame
import { useQuery } from "@tanstack/react-query";
import { useTranslation } from "react-i18next";
import getLabelsByTask from "@/fetchers/label/get-labels-by-task";
import { localeCompareSort } from "@/lib/format";

function useGetLabelsByTask(taskId: string) {
  const { i18n } = useTranslation();
  const locale = i18n.resolvedLanguage || i18n.language;

  return useQuery({
    queryKey: ["labels", taskId],
    queryFn: () => getLabelsByTask({ taskId }),
    select: (labels) =>
      [...labels].sort((a, b) => localeCompareSort(a.name, b.name, locale)),
    refetchOnMount: true,
  });
}

export default useGetLabelsByTask;