Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go
744 B
Raw Blame
"use client";

import { useQuery } from "@tanstack/react-query";
import { useCurrentMember } from "../permissions/use-current-member";
import { agentListOptions } from "../workspace/queries";
import type { Issue } from "../types";
import { canDeleteIssue } from "./deletion-permissions";

export function useIssueDeletion(wsId: string) {
  const { userId, role } = useCurrentMember(wsId);
  const { data: agents = [] } = useQuery({
    ...agentListOptions(wsId),
    enabled: role === "member",
  });
  return {
    canDelete: (issue: Issue) => canDeleteIssue(issue, userId, role, agents),
    // A guest can delete no issue at all, so menus leave the entry out
    // instead of showing it disabled.
    offersDelete: role !== "guest",
  };
}