chore(repo): initialize planarchy workspace
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"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<AllocationLike>[];
|
||||
projectDemands: DemandRequirement<AllocationLike>[];
|
||||
// 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<AllocationLike>[],
|
||||
projectDemands: (data?.demands ?? []) as DemandRequirement<AllocationLike>[],
|
||||
project: data?.project ?? null,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user