"use client"; import type { AllocationLike, Assignment, DemandRequirement } from "@planarchy/shared"; import { trpc } from "~/lib/trpc/client.js"; /** * Fetches full project context when a project is being dragged or the panel opens. * Returns the project's resources, their own allocations, and all cross-project allocations. */ // eslint-disable-next-line @typescript-eslint/no-explicit-any type ProjectDragContextResult = { contextResourceIds: string[]; // eslint-disable-next-line @typescript-eslint/no-explicit-any contextAllocations: any[]; projectAssignments: Assignment[]; projectDemands: DemandRequirement[]; // eslint-disable-next-line @typescript-eslint/no-explicit-any project: any | null; }; export function useProjectDragContext(projectId: string | null): ProjectDragContextResult { // eslint-disable-next-line @typescript-eslint/no-explicit-any const { data } = trpc.timeline.getProjectContext.useQuery( { projectId: projectId! }, { enabled: !!projectId, staleTime: 10_000 }, ) as { data: any }; return { contextResourceIds: (data?.resourceIds ?? []) as string[], contextAllocations: data?.allResourceAllocations ?? [], projectAssignments: (data?.assignments ?? []) as Assignment[], projectDemands: (data?.demands ?? []) as DemandRequirement[], project: data?.project ?? null, }; }