All files / src/pages/flowsheet-page/flowsheet/PropertiesSidebar/MachineLearning MachineLearningData.tsx

90% Statements 9/10
88.88% Branches 8/9
50% Functions 1/2
88.88% Lines 8/9

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 53 54 55 56 57                                        24x 24x 24x       24x   22x 22x   22x             22x                                    
import { Button } from "@/ahuora-design-system/ui/button";
import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogFooter,
  DialogHeader,
  DialogTitle,
  DialogTrigger,
  DialogClose,
} from "@/ahuora-design-system/ui/dialog";
import ProgressBar from "./ProgressBar";
import { useSearchParam } from "@/hooks/searchParams";
import UploadCSV from "./UploadCSV";
import ColumnMappings from "./ColumnMappings";
import { useCoreMlListQuery } from "@/api/apiStore.gen";
import SuccesslyTrained from "./SuccesslyTrained";
import Train from "./Train";
 
export default function MachineLearningData() {
  const [objectId] = useSearchParam("object");
  const simulationObject = +(objectId || 0);
  const { data: model } = useCoreMlListQuery({
    simulationObject: simulationObject,
  });
 
  if (!model) return null;
 
  const progress = model?.[0]?.progress ?? 0;
  const modelId = model?.[0]?.id ?? 0;
 
  const options = [
    <UploadCSV simulationObject={simulationObject} progress={progress} />,
    <ColumnMappings modelId={modelId} simulationObject={simulationObject} />,
    <Train />,
    <SuccesslyTrained model={model[0]} />,
  ];
 
  return (
    <Dialog>
      <div className="w-full flex justify-center p-4">
        <DialogTrigger asChild>
          <Button>{progress !== 0 ? "View" : "Set-up"}</Button>
        </DialogTrigger>
      </div>
      <DialogContent
        preventDefault
        className="sm:max-w-[800px] h-[65%] flex flex-col"
        onInteractOutside={(event) => event.preventDefault()}
      >
        <ProgressBar progress={progress} />
        {options[progress]}
      </DialogContent>
    </Dialog>
  );
}