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.

670 B
Raw Blame
import type { ProjectWithTasks } from "@/types/project";
import { findTaskColumn } from "./find-task-column";

export function getVisualTaskPlacement(
  project: ProjectWithTasks,
  activeId: string,
) {
  const column = findTaskColumn(project, activeId);
  if (!column) return null;

  const index = column.tasks.findIndex((task) => task.id === activeId);
  const nextTask = column.tasks[index + 1];
  if (nextTask) return { overId: nextTask.id, insertAfterTarget: false };

  const previousTask = column.tasks[index - 1];
  if (previousTask) return { overId: previousTask.id, insertAfterTarget: true };

  return { overId: column.id, insertAfterTarget: undefined };
}