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.

768 B
Raw Blame
import { useShortcut } from "@/lib/shortcuts/use-shortcut";
import { useUserPreferencesStore } from "@/store/user-preferences";
import { type ProjectView, tasksViewFor } from "./project-views";

export function useProjectViewShortcuts(
  goToView: (view: ProjectView) => void,
  currentView: ProjectView,
  enabled: boolean,
) {
  const taskLayout = useUserPreferencesStore((state) => state.taskLayout);
  const viewMode = useUserPreferencesStore((state) => state.viewMode);

  useShortcut(
    "toggleLayout",
    () => goToView(currentView === "list" ? "board" : "list"),
    { enabled },
  );
  useShortcut("goToTasks", () => goToView(tasksViewFor(taskLayout, viewMode)), {
    enabled,
  });
  useShortcut("goToBacklog", () => goToView("backlog"), { enabled });
}