updated layout comparsion
This commit is contained in:
@@ -3,10 +3,12 @@ import { useActionHandler } from "../actions/useActionHandler";
|
||||
import { usePlayButtonStore, useResetButtonStore } from "../../../store/ui/usePlayButtonStore";
|
||||
import { determineExecutionOrder } from "./functions/determineExecutionOrder";
|
||||
import { useSceneContext } from "../../scene/sceneContext";
|
||||
import SimulationHandler from "./SimulationHandler1";
|
||||
import SimulationHandler from "./simulationHandler";
|
||||
import { useParams } from "react-router-dom";
|
||||
import { useSimulationManager } from "../../../store/rough/useSimulationManagerStore";
|
||||
import { getSimulationDataApi } from "../../../services/simulation/comparison/getSimulationDataApi";
|
||||
import { getProductApi } from "../../../services/simulation/products/getProductApi";
|
||||
import { useIsComparing } from "../../../store/builder/store";
|
||||
|
||||
function Simulator() {
|
||||
const { productStore, versionStore } = useSceneContext();
|
||||
@@ -16,7 +18,8 @@ function Simulator() {
|
||||
const { isReset } = useResetButtonStore();
|
||||
const { projectId } = useParams();
|
||||
const { selectedVersion } = versionStore();
|
||||
const { addSimulationRecord } = useSimulationManager();
|
||||
const { setIsComparing } = useIsComparing();
|
||||
const { addSimulationRecords } = useSimulationManager();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPlaying || isReset || !selectedProduct.productUuid) return;
|
||||
@@ -34,28 +37,26 @@ function Simulator() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!projectId || !selectedVersion || !selectedProduct?.productUuid) return;
|
||||
const fetchSimulateData = async () => {
|
||||
const getData = await getSimulationDataApi(projectId, selectedVersion.versionId, selectedProduct?.productUuid);
|
||||
getSimulationDataApi(projectId, selectedVersion.versionId, selectedProduct?.productUuid).then((getData) => {
|
||||
getProductApi(selectedProduct.productUuid, projectId, selectedVersion.versionId).then((product) => {
|
||||
if (!product) return;
|
||||
const getSimulate = getData?.data;
|
||||
|
||||
const product = getProductById(selectedProduct.productUuid);
|
||||
if (!product) return;
|
||||
const products: ProductsSchema = [product];
|
||||
const getSimulate = getData?.data;
|
||||
|
||||
if (getData.message !== "Simulated data not found" && getSimulate && getSimulate.productTimestamp === products[0]?.timestamp) {
|
||||
addSimulationRecord(projectId, selectedVersion?.versionId || "", selectedProduct?.productUuid || "", getSimulate.data);
|
||||
echo.log("Simulation data is up to date");
|
||||
return;
|
||||
} else {
|
||||
}
|
||||
};
|
||||
fetchSimulateData();
|
||||
if (getData.message !== "Simulated data not found" && getSimulate && getSimulate.productTimestamp === product?.timestamp) {
|
||||
addSimulationRecords(projectId, selectedVersion?.versionId || "", selectedProduct?.productUuid || "", getSimulate.data);
|
||||
echo.warn("Simulation data is up to date");
|
||||
return;
|
||||
} else {
|
||||
setIsComparing(false);
|
||||
echo.warn("Please run the simulation before comparing.");
|
||||
}
|
||||
});
|
||||
});
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
}, [selectedProduct, projectId]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <simulationHandler/> */}
|
||||
<SimulationHandler />
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user