import React from "react";
import StorageUnitInstance from "./storageUnitInstance/storageUnitInstance";
import StorageContentUi from "../../ui3d/StorageContentUi";
import { useSceneContext } from "../../../scene/sceneContext";
import { useViewSceneStore } from "../../../../store/builder/store";

function StorageUnitInstances() {
    const { storageUnitStore } = useSceneContext();
    const { storageUnits } = storageUnitStore();
    const { viewSceneLabels } = useViewSceneStore();

    return (
        <>
            {storageUnits.map((storageUnit: StorageUnitStatus) => (
                <React.Fragment key={storageUnit.modelUuid}>
                    <StorageUnitInstance storageUnit={storageUnit} />
                    {viewSceneLabels && <StorageContentUi storageUnit={storageUnit} />}
                </React.Fragment>
            ))}
        </>
    );
}

export default StorageUnitInstances;
