All files / src/hooks recycleData.ts

100% Statements 12/12
100% Branches 2/2
100% Functions 7/7
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27          4468x 4468x 4468x     4468x       3x 3x 3x         430x 430x 182x      
import { useCoreRecycledataListQuery } from "@/api/apiStore.gen";
import { useProjectId } from "./project";
import { useCurrentGroupId } from "./flowsheetObjects";
 
export function useRecycleData() {
  const projectId = useProjectId();
  const groupId = useCurrentGroupId();
  const { data: recycleData } = useCoreRecycledataListQuery({
    group: groupId,
  });
  return recycleData || [];
}
 
export function useObjectRecycleData() {
  const recycleData = useRecycleData();
  return (simulationObjectId: number) => {
    return recycleData.find((r) => r.simulationObject === simulationObjectId);
  };
}
 
export function useObjectConnectedToRecycle() {
  const recycleData = useRecycleData();
  return (simulationObjectId: number) => {
    return recycleData.some((r) => r.tearObject === simulationObjectId);
  };
}