removed consoles in comparing layouts
This commit is contained in:
@@ -3,14 +3,10 @@ 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 "./SimulationHandler";
|
||||
import SimulationHandler from "./SimulationHandler1";
|
||||
import { useParams } from "react-router-dom";
|
||||
import {
|
||||
getSimulationData,
|
||||
saveSimulationData,
|
||||
} from "../../../components/layout/scenes/functions/simulationStorage";
|
||||
import { useSimulationManager } from "../../../store/rough/useSimulationManagerStore";
|
||||
import { useSimulateId } from "../../../store/builder/store";
|
||||
import { getSimulationDataApi } from "../../../services/simulation/comparison/getSimulationDataApi";
|
||||
|
||||
function Simulator() {
|
||||
const { productStore, versionStore } = useSceneContext();
|
||||
@@ -20,8 +16,7 @@ function Simulator() {
|
||||
const { isReset } = useResetButtonStore();
|
||||
const { projectId } = useParams();
|
||||
const { selectedVersion } = versionStore();
|
||||
const { setSimulateId } = useSimulateId();
|
||||
const { addSimulationRecords } = useSimulationManager();
|
||||
const { addSimulationRecord } = useSimulationManager();
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPlaying || isReset || !selectedProduct.productUuid) return;
|
||||
@@ -34,52 +29,28 @@ function Simulator() {
|
||||
executionOrder.forEach((action) => {
|
||||
handleAction(action);
|
||||
});
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [products, isPlaying, isReset, selectedProduct]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!projectId || !selectedVersion || !selectedProduct?.productUuid) return;
|
||||
const fetchSimulateData = async () => {
|
||||
const getData = await getSimulationData(
|
||||
projectId,
|
||||
selectedVersion.versionId,
|
||||
selectedProduct?.productUuid
|
||||
);
|
||||
const getData = await getSimulationDataApi(projectId, selectedVersion.versionId, selectedProduct?.productUuid);
|
||||
|
||||
const product = getProductById(selectedProduct.productUuid);
|
||||
if (!product) return;
|
||||
const products: ProductsSchema = [product];
|
||||
const getSimulate = getData?.data;
|
||||
// console.log("getSimulate: ", getSimulate);
|
||||
if (getData && getSimulate && getSimulate.productTimestamp === products[0]?.timestamp) {
|
||||
setSimulateId(getSimulate._id);
|
||||
// console.log(" getSimulate.data: ", getSimulate.data);
|
||||
addSimulationRecords(
|
||||
projectId,
|
||||
selectedVersion?.versionId || "",
|
||||
selectedProduct?.productUuid || "",
|
||||
getSimulate.data // ✅ this is already an array
|
||||
);
|
||||
|
||||
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 {
|
||||
//call create API
|
||||
const data = {
|
||||
projectId: projectId,
|
||||
versionId: selectedVersion.versionId,
|
||||
productUuid: selectedProduct.productUuid,
|
||||
simulateData: useSimulationManager
|
||||
.getState()
|
||||
.getProductById(
|
||||
projectId,
|
||||
selectedVersion?.versionId,
|
||||
selectedProduct.productUuid
|
||||
)?.simulateData,
|
||||
};
|
||||
const simulations = await saveSimulationData(data);
|
||||
// console.log("simulations: ", simulations);
|
||||
echo.log("Simulation data saved successfully");
|
||||
}
|
||||
};
|
||||
fetchSimulateData();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user