import React from "react";
import MachineInstance from "./machineInstance/machineInstance";
import MachineContentUi from "../../ui3d/MachineContentUi";
import { useSceneContext } from "../../../scene/sceneContext";
import { useViewSceneStore } from "../../../../store/builder/store";

function MachineInstances() {
  const { machineStore } = useSceneContext();
  const { machines } = machineStore();
  const { viewSceneLabels } = useViewSceneStore();

  return (
    <>
      {machines.map((machine: MachineStatus) => (
        <React.Fragment key={machine.modelUuid}>
          <MachineInstance machineDetail={machine} />
          {viewSceneLabels && <MachineContentUi machine={machine} />}
        </React.Fragment>
      ))}
    </>
  );
}

export default MachineInstances;
