All files / src/pages/flowsheet-page/pinch-analysis PinchAnalysis.tsx

75.75% Statements 25/33
100% Branches 8/8
50% Functions 1/2
86.95% Lines 20/23

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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52                            24x 24x 24x 24x   24x 1x 24x   24x 3x 24x   24x         24x     17x 39x 17x   13x         50x 24x   58x 58x      
import { useState } from "react";
import { useSearchParam } from "@/hooks/searchParams";
import { PinchLeftSideBar } from "../flowsheet/LeftSideBar/PinchLeftSideBar";
import { ResizablePanel } from "../flowsheet/Resizables";
import HenDiagramsPage from "./hen-generation/HENDiagramsPage";
import PinchTabs from "./PinchTabs";
import SegmentTable from "./SegmentTable";
import TargetsPage from "./TargetsPage";
import UtilityInputTable from "./UtilityInput";
 
function EmptyTab({ name }: { name: string }) {
  return <div className="">{name}</div>;
}
 
export default function PinchAnalysis() {
  const [tab] = useSearchParam("pinchTab", "streams");
  const [editing, setEditing] = useState(false);
  const [excludedSegments, setExcludedSegments] = useState<number[]>([]);
 
  const handleEdit = () => {
    setEditing(true);
  };
 
  const handleNotEdit = () => {
    setEditing(false);
  };
 
  const tabs = {
    streams: <SegmentTable setExcludedSegments={setExcludedSegments} />,
    utilities: <UtilityInputTable handleEdit={handleEdit} />,
    targets: <TargetsPage />,
    hens: <HenDiagramsPage />,
  };
 
  return (
    <>
      <PinchLeftSideBar tab={tab}></PinchLeftSideBar>
      <ResizablePanel.MiddlePanel>
        <div className="h-full p-4 flex flex-col gap-4 overflow-hidden">
          <PinchTabs
            handleNotEdit={handleNotEdit}
            editing={editing}
            excludedSegments={excludedSegments}
            setExcludedSegments={setExcludedSegments}
          />
          {tabs[tab!]}
        </div>
      </ResizablePanel.MiddlePanel>
    </>
  );
}