From a3b2d258cf960caacf7abdf3e1c24255e3d913ee Mon Sep 17 00:00:00 2001 From: Jerald-Golden-B Date: Tue, 2 Sep 2025 10:48:58 +0530 Subject: [PATCH] socket and api integerated successfully --- .../properties/SelectedAisleProperties.tsx | 2 +- .../properties/SelectedDecalProperties.tsx | 4 +- .../properties/SelectedFloorProperties.tsx | 8 +- .../properties/SelectedWallProperties.tsx | 6 +- .../versionHisory/VersionSaved.tsx | 18 ++--- .../Decal/decalCreator/decalCreator.tsx | 4 +- .../eventHandler/useDecalEventHandlers.ts | 8 +- .../aisle/aisleCreator/aisleCreator.tsx | 2 +- .../builder/asset/functions/addAssetModel.ts | 4 +- .../model/eventHandlers/useEventHandlers.ts | 2 +- app/src/modules/builder/dfx/LoadBlueprint.tsx | 2 +- .../floor/floorCreator/floorCreator.tsx | 6 +- app/src/modules/builder/line/line.tsx | 20 ++--- app/src/modules/builder/point/point.tsx | 24 +++--- .../builder/wall/wallCreator/wallCreator.tsx | 14 ++-- .../Instances/Instance/wallAssetInstance.tsx | 6 +- .../builder/wallAsset/wallAssetCreator.tsx | 2 +- .../builder/zone/zoneCreator/zoneCreator.tsx | 6 +- .../camera/functions/updateCameraPosition.ts | 51 +++++++----- app/src/modules/scene/camera/switchView.tsx | 4 +- app/src/modules/scene/controls/controls.tsx | 38 +++++---- .../selection2D/moveControls2D.tsx | 10 +-- .../selection2D/selectionControls2D.tsx | 14 ++-- .../selection3D/copyPasteControls3D.tsx | 4 +- .../selection3D/duplicationControls3D.tsx | 5 +- .../selection3D/moveControls3D.tsx | 2 +- .../selection3D/rotateControls3D.tsx | 2 +- .../selection3D/selectionControls3D.tsx | 2 +- .../selection3D/transformControls3D.tsx | 2 +- .../transformControls/transformControls.tsx | 2 +- .../handlers/use2DRedoHandler.ts | 24 +++--- .../handlers/use2DUndoHandler.ts | 24 +++--- .../handlers/use3DRedoHandler.ts | 10 +-- .../handlers/use3DUndoHandler.ts | 10 +-- .../factoryBuilder/camera/getCameraApi.ts | 2 +- .../factoryBuilder/camera/setCameraApi.ts | 77 +++++++++---------- 36 files changed, 221 insertions(+), 200 deletions(-) diff --git a/app/src/components/layout/sidebarRight/properties/SelectedAisleProperties.tsx b/app/src/components/layout/sidebarRight/properties/SelectedAisleProperties.tsx index d51f6ce..e4e993f 100644 --- a/app/src/components/layout/sidebarRight/properties/SelectedAisleProperties.tsx +++ b/app/src/components/layout/sidebarRight/properties/SelectedAisleProperties.tsx @@ -46,7 +46,7 @@ const SelectedAisleProperties: React.FC = () => { const updateBackend = (updatedAisle: Aisle) => { if (updatedAisle && projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API diff --git a/app/src/components/layout/sidebarRight/properties/SelectedDecalProperties.tsx b/app/src/components/layout/sidebarRight/properties/SelectedDecalProperties.tsx index 0abea6d..196b793 100644 --- a/app/src/components/layout/sidebarRight/properties/SelectedDecalProperties.tsx +++ b/app/src/components/layout/sidebarRight/properties/SelectedDecalProperties.tsx @@ -24,7 +24,7 @@ const SelectedDecalProperties = () => { const updateBackend = (updatedData: Wall | Floor) => { if ('wallUuid' in updatedData) { if (projectId && updatedData) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', updatedData); @@ -45,7 +45,7 @@ const SelectedDecalProperties = () => { } } else if ('floorUuid' in updatedData) { if (projectId && updatedData) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertFloorApi(projectId, selectedVersion?.versionId || '', updatedData); diff --git a/app/src/components/layout/sidebarRight/properties/SelectedFloorProperties.tsx b/app/src/components/layout/sidebarRight/properties/SelectedFloorProperties.tsx index 40a84be..bcb51a1 100644 --- a/app/src/components/layout/sidebarRight/properties/SelectedFloorProperties.tsx +++ b/app/src/components/layout/sidebarRight/properties/SelectedFloorProperties.tsx @@ -43,7 +43,7 @@ const SelectedFloorProperties = () => { if (!isNaN(parsed) && floor) { const updatedFloor = updateFloor(floor.floorUuid, { floorDepth: parsed }); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -72,7 +72,7 @@ const SelectedFloorProperties = () => { if (!isNaN(parsed) && floor) { const updatedFloor = updateFloor(floor.floorUuid, { bevelStrength: parsed }); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -100,7 +100,7 @@ const SelectedFloorProperties = () => { if (!floor) return; const updatedFloor = updateFloor(floor.floorUuid, { isBeveled: !floor.isBeveled }); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -128,7 +128,7 @@ const SelectedFloorProperties = () => { const key = activeSurface === "top" ? "topMaterial" : "sideMaterial"; const updatedFloor = updateFloor(floor.floorUuid, { [key]: material.textureId }); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API diff --git a/app/src/components/layout/sidebarRight/properties/SelectedWallProperties.tsx b/app/src/components/layout/sidebarRight/properties/SelectedWallProperties.tsx index 020bbe3..c26265a 100644 --- a/app/src/components/layout/sidebarRight/properties/SelectedWallProperties.tsx +++ b/app/src/components/layout/sidebarRight/properties/SelectedWallProperties.tsx @@ -47,7 +47,7 @@ const SelectedWallProperties = () => { if (!isNaN(height) && wall) { const updatedWall = updateWall(wall.wallUuid, { wallHeight: height }); if (updatedWall && projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -76,7 +76,7 @@ const SelectedWallProperties = () => { if (!isNaN(thickness) && wall) { const updatedWall = updateWall(wall.wallUuid, { wallThickness: thickness }); if (updatedWall && projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -105,7 +105,7 @@ const SelectedWallProperties = () => { const updated = (activeSide === "side1" ? { insideMaterial: material.textureId } : { outsideMaterial: material.textureId }) const updatedWall = updateWall(wall.wallUuid, updated); if (updatedWall && projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API diff --git a/app/src/components/layout/sidebarRight/versionHisory/VersionSaved.tsx b/app/src/components/layout/sidebarRight/versionHisory/VersionSaved.tsx index 44e32df..fb60ecc 100644 --- a/app/src/components/layout/sidebarRight/versionHisory/VersionSaved.tsx +++ b/app/src/components/layout/sidebarRight/versionHisory/VersionSaved.tsx @@ -11,9 +11,9 @@ import { getUserData } from "../../../../functions/getUserData"; import { useVersionContext } from "../../../../modules/builder/version/versionContext"; const VersionSaved = () => { - const { versionHistory, addVersion, createNewVersion, setCreateNewVersion } = useVersionHistoryStore(); + const { addVersion, createNewVersion, setCreateNewVersion } = useVersionHistoryStore(); const { selectedVersionStore } = useVersionContext(); - const { setSelectedVersion } = selectedVersionStore(); + const { selectedVersion, setSelectedVersion } = selectedVersionStore(); const [newName, setNewName] = useState(new Date().toLocaleString("en-US", { month: "short", day: "numeric", @@ -26,8 +26,6 @@ const VersionSaved = () => { const { projectId } = useParams(); const { userId } = getUserData(); - const latestVersion = versionHistory?.[0]; - useEffect(() => { if (createNewVersion) { const defaultName = new Date().toLocaleString("en-US", { @@ -43,12 +41,12 @@ const VersionSaved = () => { }, [createNewVersion]); const handleSave = () => { - if (!latestVersion || !projectId) return; + if (!selectedVersion || !projectId) return; - const updatedName = (newName.trim() || latestVersion.versionName) ?? latestVersion.timeStamp; - const updatedDescription = (description.trim() || latestVersion.versionName) ?? latestVersion.timeStamp; + const updatedName = (newName.trim() || selectedVersion.versionName) ?? selectedVersion.timeStamp; + const updatedDescription = (description.trim() || selectedVersion.versionName) ?? selectedVersion.timeStamp; - createVersionApi(projectId, userId, latestVersion.versionId, updatedName, updatedDescription).then((data) => { + createVersionApi(projectId, userId, selectedVersion.versionId, updatedName, updatedDescription).then((data) => { setSaveFinish(true); setCreateNewVersion(false); @@ -84,7 +82,7 @@ const VersionSaved = () => { setCreateNewVersion(false); }; - if (!latestVersion) return null; + if (!selectedVersion) return null; return (
@@ -105,7 +103,7 @@ const VersionSaved = () => { placeholder="Enter new version name" />
- by @{latestVersion.createdBy}{" "}{new Date(latestVersion.timeStamp).toLocaleDateString("en-US", { + by @{selectedVersion.createdBy}{" "}{new Date(selectedVersion.timeStamp).toLocaleDateString("en-US", { year: "numeric", month: "long", day: "2-digit", diff --git a/app/src/modules/builder/Decal/decalCreator/decalCreator.tsx b/app/src/modules/builder/Decal/decalCreator/decalCreator.tsx index ce3b4fb..1870191 100644 --- a/app/src/modules/builder/Decal/decalCreator/decalCreator.tsx +++ b/app/src/modules/builder/Decal/decalCreator/decalCreator.tsx @@ -65,7 +65,7 @@ function DecalCreator() { const updatedWall = getWallById(wallIntersect.object.userData.wallUuid); if (updatedWall) { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', updatedWall); @@ -111,7 +111,7 @@ function DecalCreator() { setTimeout(() => { const updatedFloor = getFloorById(floorIntersect.object.userData.floorUuid); if (projectId && updatedFloor) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertFloorApi(projectId, selectedVersion?.versionId || '', updatedFloor); diff --git a/app/src/modules/builder/Decal/eventHandler/useDecalEventHandlers.ts b/app/src/modules/builder/Decal/eventHandler/useDecalEventHandlers.ts index 1a75fc7..1db359e 100644 --- a/app/src/modules/builder/Decal/eventHandler/useDecalEventHandlers.ts +++ b/app/src/modules/builder/Decal/eventHandler/useDecalEventHandlers.ts @@ -148,7 +148,7 @@ export function useDecalEventHandlers({ const updatedWall = getWallById(parent.wallUuid); if (updatedWall) { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', updatedWall); @@ -174,7 +174,7 @@ export function useDecalEventHandlers({ const updatedFloor = parent; if (projectId && updatedFloor) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertFloorApi(projectId, selectedVersion?.versionId || '', updatedFloor); @@ -203,7 +203,7 @@ export function useDecalEventHandlers({ const updatedWall = removeDecalInWall(decalUuid); if (projectId && updatedWall) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', updatedWall); @@ -226,7 +226,7 @@ export function useDecalEventHandlers({ const updatedFloor = removeDecalInFloor(decalUuid); if (projectId && updatedFloor) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertFloorApi(projectId, selectedVersion?.versionId || '', updatedFloor); diff --git a/app/src/modules/builder/aisle/aisleCreator/aisleCreator.tsx b/app/src/modules/builder/aisle/aisleCreator/aisleCreator.tsx index d7a8d8a..3af6f8f 100644 --- a/app/src/modules/builder/aisle/aisleCreator/aisleCreator.tsx +++ b/app/src/modules/builder/aisle/aisleCreator/aisleCreator.tsx @@ -135,7 +135,7 @@ function AisleCreator() { const addAilseToBackend = (aisle: Aisle) => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API diff --git a/app/src/modules/builder/asset/functions/addAssetModel.ts b/app/src/modules/builder/asset/functions/addAssetModel.ts index fbd519a..6a4496a 100644 --- a/app/src/modules/builder/asset/functions/addAssetModel.ts +++ b/app/src/modules/builder/asset/functions/addAssetModel.ts @@ -440,7 +440,7 @@ async function handleModelLoad( userId: userId, }; - if (!socket?.active) { + if (!socket?.connected) { // API setAssetsApi({ @@ -492,7 +492,7 @@ async function handleModelLoad( userId: userId, }; - if (!socket?.active) { + if (!socket?.connected) { // API setAssetsApi({ diff --git a/app/src/modules/builder/asset/models/model/eventHandlers/useEventHandlers.ts b/app/src/modules/builder/asset/models/model/eventHandlers/useEventHandlers.ts index 3b94eec..43d7ae1 100644 --- a/app/src/modules/builder/asset/models/model/eventHandlers/useEventHandlers.ts +++ b/app/src/modules/builder/asset/models/model/eventHandlers/useEventHandlers.ts @@ -145,7 +145,7 @@ export function useModelEventHandlers({ if (leftDrag.current || toggleView) return; if (activeTool === 'delete' && deletableFloorAsset && deletableFloorAsset.uuid === asset.modelUuid) { - if (!socket?.active) { + if (!socket?.connected) { // REST diff --git a/app/src/modules/builder/dfx/LoadBlueprint.tsx b/app/src/modules/builder/dfx/LoadBlueprint.tsx index 52da573..f960388 100644 --- a/app/src/modules/builder/dfx/LoadBlueprint.tsx +++ b/app/src/modules/builder/dfx/LoadBlueprint.tsx @@ -42,7 +42,7 @@ const DxfFile = () => { if (dfxWallGenerate) { dfxWallGenerate.map((wall: Wall) => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', wall); diff --git a/app/src/modules/builder/floor/floorCreator/floorCreator.tsx b/app/src/modules/builder/floor/floorCreator/floorCreator.tsx index 76c5efb..c5c36d2 100644 --- a/app/src/modules/builder/floor/floorCreator/floorCreator.tsx +++ b/app/src/modules/builder/floor/floorCreator/floorCreator.tsx @@ -120,7 +120,7 @@ function FloorCreator() { }) if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -176,7 +176,7 @@ function FloorCreator() { }) if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -242,7 +242,7 @@ function FloorCreator() { }) if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API diff --git a/app/src/modules/builder/line/line.tsx b/app/src/modules/builder/line/line.tsx index 132a572..51391f8 100644 --- a/app/src/modules/builder/line/line.tsx +++ b/app/src/modules/builder/line/line.tsx @@ -120,7 +120,7 @@ function Line({ points }: Readonly) { if (projectId && asset) { removeWallAsset(asset.modelUuid); - if (!socket?.active) { + if (!socket?.connected) { // API @@ -142,7 +142,7 @@ function Line({ points }: Readonly) { } } }) - if (!socket?.active) { + if (!socket?.connected) { // API @@ -185,7 +185,7 @@ function Line({ points }: Readonly) { if (removedFloors.length > 0) { removedFloors.forEach(floor => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -226,7 +226,7 @@ function Line({ points }: Readonly) { if (updatedFloors.length > 0) { updatedFloors.forEach(floor => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -274,7 +274,7 @@ function Line({ points }: Readonly) { if (removedZones.length > 0) { removedZones.forEach(zone => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -315,7 +315,7 @@ function Line({ points }: Readonly) { if (updatedZones.length > 0) { updatedZones.forEach(zone => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -452,7 +452,7 @@ function Line({ points }: Readonly) { }); if (projectId && updatedWallAsset) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallAssetApi(projectId, selectedVersion?.versionId || '', updatedWallAsset); @@ -474,7 +474,7 @@ function Line({ points }: Readonly) { }); } - if (!socket?.active) { + if (!socket?.connected) { // API @@ -519,7 +519,7 @@ function Line({ points }: Readonly) { if (updatedFloors.length > 0 && projectId) { updatedFloors.forEach(updatedFloor => { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -564,7 +564,7 @@ function Line({ points }: Readonly) { if (updatedZones.length > 0 && projectId) { updatedZones.forEach(updatedZone => { - if (!socket?.active) { + if (!socket?.connected) { // API diff --git a/app/src/modules/builder/point/point.tsx b/app/src/modules/builder/point/point.tsx index ebf2aaa..0b1e3cc 100644 --- a/app/src/modules/builder/point/point.tsx +++ b/app/src/modules/builder/point/point.tsx @@ -190,7 +190,7 @@ function Point({ point }: { readonly point: Point }) { const updatedAisles = getAislesByPointId(point.pointUuid); if (updatedAisles.length > 0 && projectId) { updatedAisles.forEach((updatedAisle) => { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -247,7 +247,7 @@ function Point({ point }: { readonly point: Point }) { }); if (projectId && updatedWallAsset) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallAssetApi(projectId, selectedVersion?.versionId || '', updatedWallAsset); @@ -269,7 +269,7 @@ function Point({ point }: { readonly point: Point }) { }); } - if (!socket?.active) { + if (!socket?.connected) { // API @@ -311,7 +311,7 @@ function Point({ point }: { readonly point: Point }) { const updatedFloors = getFloorsByPointId(point.pointUuid); if (updatedFloors && updatedFloors.length > 0 && projectId) { updatedFloors.forEach((updatedFloor) => { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -353,7 +353,7 @@ function Point({ point }: { readonly point: Point }) { const updatedZones = getZonesByPointId(point.pointUuid); if (updatedZones && updatedZones.length > 0 && projectId) { updatedZones.forEach((updatedZone) => { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -404,7 +404,7 @@ function Point({ point }: { readonly point: Point }) { if (removedAisles.length > 0) { removedAisles.forEach(aisle => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -455,7 +455,7 @@ function Point({ point }: { readonly point: Point }) { if (projectId && asset) { removeWallAsset(asset.modelUuid); - if (!socket?.active) { + if (!socket?.connected) { // API @@ -480,7 +480,7 @@ function Point({ point }: { readonly point: Point }) { }) if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -526,7 +526,7 @@ function Point({ point }: { readonly point: Point }) { if (removedFloors.length > 0) { removedFloors.forEach(floor => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -567,7 +567,7 @@ function Point({ point }: { readonly point: Point }) { if (updatedFloors.length > 0) { updatedFloors.forEach(floor => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -614,7 +614,7 @@ function Point({ point }: { readonly point: Point }) { if (removedZones.length > 0) { removedZones.forEach(zone => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -655,7 +655,7 @@ function Point({ point }: { readonly point: Point }) { if (updatedZones.length > 0) { updatedZones.forEach(zone => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API diff --git a/app/src/modules/builder/wall/wallCreator/wallCreator.tsx b/app/src/modules/builder/wall/wallCreator/wallCreator.tsx index 02c7f0b..a0729fd 100644 --- a/app/src/modules/builder/wall/wallCreator/wallCreator.tsx +++ b/app/src/modules/builder/wall/wallCreator/wallCreator.tsx @@ -94,7 +94,7 @@ function WallCreator() { removeWall(wall.wallUuid); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -151,7 +151,7 @@ function WallCreator() { addWall(wall2); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', wall2); @@ -211,7 +211,7 @@ function WallCreator() { }) if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', wall3); @@ -247,7 +247,7 @@ function WallCreator() { addWall(wall1); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', wall1); @@ -280,7 +280,7 @@ function WallCreator() { addWall(wall2); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', wall2); @@ -344,7 +344,7 @@ function WallCreator() { }) if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', wall3); @@ -430,7 +430,7 @@ function WallCreator() { }) if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', wall); diff --git a/app/src/modules/builder/wallAsset/Instances/Instance/wallAssetInstance.tsx b/app/src/modules/builder/wallAsset/Instances/Instance/wallAssetInstance.tsx index 2f5a9f8..edaaafd 100644 --- a/app/src/modules/builder/wallAsset/Instances/Instance/wallAssetInstance.tsx +++ b/app/src/modules/builder/wallAsset/Instances/Instance/wallAssetInstance.tsx @@ -126,7 +126,7 @@ function WallAssetInstance({ wallAsset }: { wallAsset: WallAsset }) { const updatedWallAsset = getWallAssetById(wallAsset.modelUuid); if (projectId && updatedWallAsset) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -196,7 +196,7 @@ function WallAssetInstance({ wallAsset }: { wallAsset: WallAsset }) { const removedWallAsset = removeWallAsset(wallAsset.modelUuid); if (projectId && removedWallAsset) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -292,7 +292,7 @@ function WallAssetInstance({ wallAsset }: { wallAsset: WallAsset }) { setSelectedWallAsset(null); } }} - onPointerOver={(e) => { + onPointerEnter={(e) => { if (!toggleView) { e.stopPropagation(); let currentObject = e.object as THREE.Object3D; diff --git a/app/src/modules/builder/wallAsset/wallAssetCreator.tsx b/app/src/modules/builder/wallAsset/wallAssetCreator.tsx index bfbeb63..effc0ed 100644 --- a/app/src/modules/builder/wallAsset/wallAssetCreator.tsx +++ b/app/src/modules/builder/wallAsset/wallAssetCreator.tsx @@ -62,7 +62,7 @@ function WallAssetCreator() { addWallAsset(newWallAsset); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API diff --git a/app/src/modules/builder/zone/zoneCreator/zoneCreator.tsx b/app/src/modules/builder/zone/zoneCreator/zoneCreator.tsx index 85ce279..6e9e97c 100644 --- a/app/src/modules/builder/zone/zoneCreator/zoneCreator.tsx +++ b/app/src/modules/builder/zone/zoneCreator/zoneCreator.tsx @@ -118,7 +118,7 @@ function ZoneCreator() { }) if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -172,7 +172,7 @@ function ZoneCreator() { }) if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -236,7 +236,7 @@ function ZoneCreator() { }) if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API diff --git a/app/src/modules/scene/camera/functions/updateCameraPosition.ts b/app/src/modules/scene/camera/functions/updateCameraPosition.ts index fb8c956..b0cc67a 100644 --- a/app/src/modules/scene/camera/functions/updateCameraPosition.ts +++ b/app/src/modules/scene/camera/functions/updateCameraPosition.ts @@ -1,26 +1,41 @@ import { Socket } from "socket.io-client"; import * as THREE from "three"; import { getUserData } from "../../../../functions/getUserData"; +import { CameraControls } from "@react-three/drei"; +import { setCameraApi } from "../../../../services/factoryBuilder/camera/setCameraApi"; export default function updateCamPosition( - controls: any, - socket: Socket, - position: THREE.Vector3, - rotation: THREE.Euler, - projectId?: string + controls: React.RefObject, + socket: Socket, + position: THREE.Vector3, + rotation: THREE.Euler, + projectId?: string ) { - const { userId, organization } = getUserData(); - if (!controls.current) return; - const target = controls.current.getTarget(new THREE.Vector3()); + const { userId, organization } = getUserData(); + if (!controls.current || !projectId) return; + const target = controls.current.getTarget(new THREE.Vector3()); - const camData = { - organization, - userId: userId, - position: position, - target: new THREE.Vector3(target.x, 0, target.z), - rotation: new THREE.Vector3(rotation.x, rotation.y, rotation.z), - socketId: socket.id, - projectId, - }; - socket.emit("v1:Camera:set", camData); + if (!socket?.connected) { + // API + + setCameraApi( + projectId, + position, + new THREE.Vector3(target.x, 0, target.z), + new THREE.Vector3(rotation.x, rotation.y, rotation.z), + ) + } else { + // SOCKET + + const camData = { + organization, + userId: userId, + position: position, + target: new THREE.Vector3(target.x, 0, target.z), + rotation: new THREE.Vector3(rotation.x, rotation.y, rotation.z), + socketId: socket.id, + projectId, + }; + socket.emit("v1:Camera:set", camData); + } } diff --git a/app/src/modules/scene/camera/switchView.tsx b/app/src/modules/scene/camera/switchView.tsx index b9501b3..489d46a 100644 --- a/app/src/modules/scene/camera/switchView.tsx +++ b/app/src/modules/scene/camera/switchView.tsx @@ -4,7 +4,7 @@ import * as THREE from 'three'; import { PerspectiveCamera, OrthographicCamera, CameraControls } from '@react-three/drei'; import { useParams } from "react-router-dom"; import * as CONSTANTS from '../../../types/world/worldConstants'; -import { getCamera } from "../../../services/factoryBuilder/camera/getCameraApi"; +import { getCameraApi } from "../../../services/factoryBuilder/camera/getCameraApi"; import { getUserData } from "../../../functions/getUserData"; import { useToggleView } from "../../../store/builder/store"; @@ -20,7 +20,7 @@ export default function SwitchView() { (controls as any).mouseButtons.right = CONSTANTS.twoDimension.rightMouse; } else { try { - getCamera(organization, localStorage.getItem('userId')!, projectId).then((data) => { + getCameraApi(organization, localStorage.getItem('userId')!, projectId).then((data) => { if (data && data.position && data.target) { (controls as CameraControls)?.setPosition(data.position.x, data.position.y, data.position.z); (controls as CameraControls)?.setTarget(data.target.x, data.target.y, data.target.z); diff --git a/app/src/modules/scene/controls/controls.tsx b/app/src/modules/scene/controls/controls.tsx index 984cfa8..3e9dca3 100644 --- a/app/src/modules/scene/controls/controls.tsx +++ b/app/src/modules/scene/controls/controls.tsx @@ -17,7 +17,8 @@ import CameraShortcutsControls from "../camera/shortcutsControls/cameraShortcuts import { useParams } from "react-router-dom"; import { getUserData } from "../../../functions/getUserData"; -import { getCamera } from "../../../services/factoryBuilder/camera/getCameraApi"; +import { getCameraApi } from "../../../services/factoryBuilder/camera/getCameraApi"; +import { setCameraApi } from "../../../services/factoryBuilder/camera/setCameraApi"; import updateCamPosition from "../camera/functions/updateCameraPosition"; export default function Controls() { @@ -36,7 +37,7 @@ export default function Controls() { (controlsRef.current as any).mouseButtons.right = CONSTANTS.thirdPersonControls.rightMouse; } - getCamera(organization, userId, projectId).then((data) => { + getCameraApi(organization, userId, projectId).then((data) => { if (data && data.position && data.target) { controlsRef.current?.setPosition(data.position.x, data.position.y, data.position.z); controlsRef.current?.setTarget(data.target.x, data.target.y, data.target.z); @@ -48,21 +49,30 @@ export default function Controls() { }, []); useEffect(() => { - if (resetCamera && socket) { + if (resetCamera && projectId) { controlsRef.current?.setPosition(...CONSTANTS.threeDimension.defaultPosition); controlsRef.current?.setTarget(...CONSTANTS.threeDimension.defaultTarget); controlsRef.current?.rotateAzimuthTo(CONSTANTS.threeDimension.defaultAzimuth); - const camData = { - organization, - userId: userId, - position: new THREE.Vector3(...CONSTANTS.threeDimension.defaultPosition), - target: new THREE.Vector3(...CONSTANTS.threeDimension.defaultTarget), - rotation: new THREE.Vector3(...CONSTANTS.threeDimension.defaultRotation), - socketId: socket.id, - projectId - }; - socket.emit('v1:Camera:set', camData) + if (!socket?.connected) { + setCameraApi( + projectId, + new THREE.Vector3(...CONSTANTS.threeDimension.defaultPosition), + new THREE.Vector3(...CONSTANTS.threeDimension.defaultTarget), + new THREE.Vector3(...CONSTANTS.threeDimension.defaultRotation), + ) + } else { + const camData = { + organization, + userId: userId, + position: new THREE.Vector3(...CONSTANTS.threeDimension.defaultPosition), + target: new THREE.Vector3(...CONSTANTS.threeDimension.defaultTarget), + rotation: new THREE.Vector3(...CONSTANTS.threeDimension.defaultRotation), + socketId: socket.id, + projectId + }; + socket.emit('v1:Camera:set', camData) + } setResetCamera(false); } @@ -139,7 +149,7 @@ export default function Controls() { - + diff --git a/app/src/modules/scene/controls/selectionControls/selection2D/moveControls2D.tsx b/app/src/modules/scene/controls/selectionControls/selection2D/moveControls2D.tsx index a072d5e..b87323e 100644 --- a/app/src/modules/scene/controls/selectionControls/selection2D/moveControls2D.tsx +++ b/app/src/modules/scene/controls/selectionControls/selection2D/moveControls2D.tsx @@ -271,7 +271,7 @@ function MoveControls2D({ if (updatedAisles.length > 0 && projectId) { updatedAisles.forEach((updatedAisle) => { - if (!socket?.active) { + if (!socket?.connected) { // API upsertAisleApi(updatedAisle.aisleUuid, updatedAisle.points, updatedAisle.type, projectId, selectedVersion?.versionId || ''); @@ -334,7 +334,7 @@ function MoveControls2D({ }); } - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', updatedWall); @@ -378,7 +378,7 @@ function MoveControls2D({ if (updatedFloors?.length && projectId) { updatedFloors.forEach(updatedFloor => { - if (!socket?.active) { + if (!socket?.connected) { // API upsertFloorApi(projectId, selectedVersion?.versionId || '', updatedFloor); @@ -420,7 +420,7 @@ function MoveControls2D({ if (updatedZones?.length && projectId) { updatedZones.forEach(updatedZone => { - if (!socket?.active) { + if (!socket?.connected) { // API upsertZoneApi(projectId, selectedVersion?.versionId || '', updatedZone); @@ -472,7 +472,7 @@ function MoveControls2D({ rotation: updatedWallAsset.rotation }); - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallAssetApi(projectId, selectedVersion?.versionId || '', updatedWallAsset); diff --git a/app/src/modules/scene/controls/selectionControls/selection2D/selectionControls2D.tsx b/app/src/modules/scene/controls/selectionControls/selection2D/selectionControls2D.tsx index a01e1fb..1b29174 100644 --- a/app/src/modules/scene/controls/selectionControls/selection2D/selectionControls2D.tsx +++ b/app/src/modules/scene/controls/selectionControls/selection2D/selectionControls2D.tsx @@ -241,7 +241,7 @@ const SelectionControls2D: React.FC = () => { if (removedAisles.length > 0) { removedAisles.forEach(aisle => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -284,7 +284,7 @@ const SelectionControls2D: React.FC = () => { removeWallAsset(asset.modelUuid); - if (!socket?.active) { + if (!socket?.connected) { // API @@ -308,7 +308,7 @@ const SelectionControls2D: React.FC = () => { }) if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -345,7 +345,7 @@ const SelectionControls2D: React.FC = () => { if (removedFloors.length > 0) { removedFloors.forEach(floor => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -378,7 +378,7 @@ const SelectionControls2D: React.FC = () => { if (updatedFloors.length > 0) { updatedFloors.forEach(floor => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -416,7 +416,7 @@ const SelectionControls2D: React.FC = () => { if (removedZones.length > 0) { removedZones.forEach(zone => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API @@ -449,7 +449,7 @@ const SelectionControls2D: React.FC = () => { if (updatedZones.length > 0) { updatedZones.forEach(zone => { if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API diff --git a/app/src/modules/scene/controls/selectionControls/selection3D/copyPasteControls3D.tsx b/app/src/modules/scene/controls/selectionControls/selection3D/copyPasteControls3D.tsx index 01130fa..4b9ae71 100644 --- a/app/src/modules/scene/controls/selectionControls/selection3D/copyPasteControls3D.tsx +++ b/app/src/modules/scene/controls/selectionControls/selection3D/copyPasteControls3D.tsx @@ -488,7 +488,7 @@ const CopyPasteControls3D = () => { projectId }; - if (!socket?.active) { + if (!socket?.connected) { // REST setAssetsApi({ @@ -540,7 +540,7 @@ const CopyPasteControls3D = () => { userId }; - if (!socket?.active) { + if (!socket?.connected) { // REST setAssetsApi({ diff --git a/app/src/modules/scene/controls/selectionControls/selection3D/duplicationControls3D.tsx b/app/src/modules/scene/controls/selectionControls/selection3D/duplicationControls3D.tsx index ca37153..17a369e 100644 --- a/app/src/modules/scene/controls/selectionControls/selection3D/duplicationControls3D.tsx +++ b/app/src/modules/scene/controls/selectionControls/selection3D/duplicationControls3D.tsx @@ -557,7 +557,8 @@ const DuplicationControls3D = () => { projectId }; - if (!socket?.active) { + console.log('socket: ', socket); + if (!socket?.connected) { // REST setAssetsApi({ @@ -609,7 +610,7 @@ const DuplicationControls3D = () => { userId }; - if (!socket?.active) { + if (!socket?.connected) { // REST setAssetsApi({ diff --git a/app/src/modules/scene/controls/selectionControls/selection3D/moveControls3D.tsx b/app/src/modules/scene/controls/selectionControls/selection3D/moveControls3D.tsx index a142de5..cb15a43 100644 --- a/app/src/modules/scene/controls/selectionControls/selection3D/moveControls3D.tsx +++ b/app/src/modules/scene/controls/selectionControls/selection3D/moveControls3D.tsx @@ -426,7 +426,7 @@ function MoveControls3D({ boundingBoxRef }: any) { userId }; - if (!socket?.active) { + if (!socket?.connected) { // REST setAssetsApi({ diff --git a/app/src/modules/scene/controls/selectionControls/selection3D/rotateControls3D.tsx b/app/src/modules/scene/controls/selectionControls/selection3D/rotateControls3D.tsx index a9b54f3..4aa8bc6 100644 --- a/app/src/modules/scene/controls/selectionControls/selection3D/rotateControls3D.tsx +++ b/app/src/modules/scene/controls/selectionControls/selection3D/rotateControls3D.tsx @@ -370,7 +370,7 @@ function RotateControls3D() { userId }; - if (!socket?.active) { + if (!socket?.connected) { // REST setAssetsApi({ diff --git a/app/src/modules/scene/controls/selectionControls/selection3D/selectionControls3D.tsx b/app/src/modules/scene/controls/selectionControls/selection3D/selectionControls3D.tsx index 4884acd..d07d3bc 100644 --- a/app/src/modules/scene/controls/selectionControls/selection3D/selectionControls3D.tsx +++ b/app/src/modules/scene/controls/selectionControls/selection3D/selectionControls3D.tsx @@ -285,7 +285,7 @@ const SelectionControls3D: React.FC = () => { if (!asset) return; - if (!socket?.active) { + if (!socket?.connected) { // REST diff --git a/app/src/modules/scene/controls/selectionControls/selection3D/transformControls3D.tsx b/app/src/modules/scene/controls/selectionControls/selection3D/transformControls3D.tsx index 05a883e..e0ede9a 100644 --- a/app/src/modules/scene/controls/selectionControls/selection3D/transformControls3D.tsx +++ b/app/src/modules/scene/controls/selectionControls/selection3D/transformControls3D.tsx @@ -136,7 +136,7 @@ function TransformControls3D() { } - if (!socket?.active) { + if (!socket?.connected) { // API setAssetsApi({ diff --git a/app/src/modules/scene/controls/transformControls/transformControls.tsx b/app/src/modules/scene/controls/transformControls/transformControls.tsx index 851f816..a2676bb 100644 --- a/app/src/modules/scene/controls/transformControls/transformControls.tsx +++ b/app/src/modules/scene/controls/transformControls/transformControls.tsx @@ -110,7 +110,7 @@ export default function TransformControl() { rotation: [selectedFloorAsset.rotation.x, selectedFloorAsset.rotation.y, selectedFloorAsset.rotation.z] as [number, number, number], }); - if (!socket?.active) { + if (!socket?.connected) { // API diff --git a/app/src/modules/scene/controls/undoRedoControls/handlers/use2DRedoHandler.ts b/app/src/modules/scene/controls/undoRedoControls/handlers/use2DRedoHandler.ts index cdfa8a9..bceeeb8 100644 --- a/app/src/modules/scene/controls/undoRedoControls/handlers/use2DRedoHandler.ts +++ b/app/src/modules/scene/controls/undoRedoControls/handlers/use2DRedoHandler.ts @@ -100,7 +100,7 @@ function use2DRedoHandler() { const createWallFromBackend = (wallData: Wall) => { addWall(wallData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', wallData); @@ -124,7 +124,7 @@ function use2DRedoHandler() { const removeWallFromBackend = (wallUuid: string) => { removeWall(wallUuid); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API deleteWallApi(projectId, selectedVersion?.versionId || '', wallUuid); @@ -148,7 +148,7 @@ function use2DRedoHandler() { const updateWallFromBackend = (wallUuid: string, updatedData: Wall) => { updateWall(wallUuid, updatedData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', updatedData); @@ -172,7 +172,7 @@ function use2DRedoHandler() { const createFloorFromBackend = (floorData: Floor) => { addFloor(floorData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertFloorApi(projectId, selectedVersion?.versionId || '', floorData); @@ -196,7 +196,7 @@ function use2DRedoHandler() { const removeFloorFromBackend = (floorUuid: string) => { removeFloor(floorUuid); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API deleteFloorApi(projectId, selectedVersion?.versionId || '', floorUuid); @@ -220,7 +220,7 @@ function use2DRedoHandler() { const updateFloorFromBackend = (floorUuid: string, updatedData: Floor) => { updateFloor(floorUuid, updatedData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertFloorApi(projectId, selectedVersion?.versionId || '', updatedData); @@ -244,7 +244,7 @@ function use2DRedoHandler() { const createZoneFromBackend = (zoneData: Zone) => { addZone(zoneData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertZoneApi(projectId, selectedVersion?.versionId || '', zoneData); @@ -268,7 +268,7 @@ function use2DRedoHandler() { const removeZoneFromBackend = (zoneUuid: string) => { removeZone(zoneUuid); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API deleteZoneApi(projectId, selectedVersion?.versionId || '', zoneUuid); @@ -292,7 +292,7 @@ function use2DRedoHandler() { const updateZoneFromBackend = (zoneUuid: string, updatedData: Zone) => { updateZone(zoneUuid, updatedData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertZoneApi(projectId, selectedVersion?.versionId || '', updatedData); @@ -316,7 +316,7 @@ function use2DRedoHandler() { const createAisleFromBackend = (aisleData: Aisle) => { addAisle(aisleData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertAisleApi(aisleData.aisleUuid, aisleData.points, aisleData.type, projectId, selectedVersion?.versionId || ''); @@ -340,7 +340,7 @@ function use2DRedoHandler() { const removeAisleFromBackend = (aisleUuid: string) => { removeAisle(aisleUuid); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API deleteAisleApi(projectId, selectedVersion?.versionId || '', aisleUuid); @@ -364,7 +364,7 @@ function use2DRedoHandler() { const updateAisleFromBackend = (aisleUuid: string, updatedData: Aisle) => { updateAisle(aisleUuid, updatedData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertAisleApi(updatedData.aisleUuid, updatedData.points, updatedData.type, projectId, selectedVersion?.versionId || ''); diff --git a/app/src/modules/scene/controls/undoRedoControls/handlers/use2DUndoHandler.ts b/app/src/modules/scene/controls/undoRedoControls/handlers/use2DUndoHandler.ts index 16fb689..31725d0 100644 --- a/app/src/modules/scene/controls/undoRedoControls/handlers/use2DUndoHandler.ts +++ b/app/src/modules/scene/controls/undoRedoControls/handlers/use2DUndoHandler.ts @@ -100,7 +100,7 @@ function use2DUndoHandler() { const createWallToBackend = (wallData: Wall) => { addWall(wallData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', wallData); @@ -124,7 +124,7 @@ function use2DUndoHandler() { const removeWallToBackend = (wallUuid: string) => { removeWall(wallUuid); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API deleteWallApi(projectId, selectedVersion?.versionId || '', wallUuid); @@ -148,7 +148,7 @@ function use2DUndoHandler() { const updateWallToBackend = (wallUuid: string, updatedData: Wall) => { updateWall(wallUuid, updatedData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertWallApi(projectId, selectedVersion?.versionId || '', updatedData); @@ -172,7 +172,7 @@ function use2DUndoHandler() { const createFloorToBackend = (floorData: Floor) => { addFloor(floorData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertFloorApi(projectId, selectedVersion?.versionId || '', floorData); @@ -196,7 +196,7 @@ function use2DUndoHandler() { const removeFloorToBackend = (floorUuid: string) => { removeFloor(floorUuid); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API deleteFloorApi(projectId, selectedVersion?.versionId || '', floorUuid); @@ -220,7 +220,7 @@ function use2DUndoHandler() { const updateFloorToBackend = (floorUuid: string, updatedData: Floor) => { updateFloor(floorUuid, updatedData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertFloorApi(projectId, selectedVersion?.versionId || '', updatedData); @@ -244,7 +244,7 @@ function use2DUndoHandler() { const createZoneToBackend = (zoneData: Zone) => { addZone(zoneData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertZoneApi(projectId, selectedVersion?.versionId || '', zoneData); @@ -268,7 +268,7 @@ function use2DUndoHandler() { const removeZoneToBackend = (zoneUuid: string) => { removeZone(zoneUuid); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API deleteZoneApi(projectId, selectedVersion?.versionId || '', zoneUuid); @@ -292,7 +292,7 @@ function use2DUndoHandler() { const updateZoneToBackend = (zoneUuid: string, updatedData: Zone) => { updateZone(zoneUuid, updatedData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertZoneApi(projectId, selectedVersion?.versionId || '', updatedData); @@ -316,7 +316,7 @@ function use2DUndoHandler() { const createAisleToBackend = (aisleData: Aisle) => { addAisle(aisleData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertAisleApi(aisleData.aisleUuid, aisleData.points, aisleData.type, projectId, selectedVersion?.versionId || ''); @@ -340,7 +340,7 @@ function use2DUndoHandler() { const removeAisleToBackend = (aisleUuid: string) => { removeAisle(aisleUuid); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API deleteAisleApi(projectId, selectedVersion?.versionId || '', aisleUuid); @@ -364,7 +364,7 @@ function use2DUndoHandler() { const updateAisleToBackend = (aisleUuid: string, updatedData: Aisle) => { updateAisle(aisleUuid, updatedData); if (projectId) { - if (!socket?.active) { + if (!socket?.connected) { // API upsertAisleApi(updatedData.aisleUuid, updatedData.points, updatedData.type, projectId, selectedVersion?.versionId || ''); diff --git a/app/src/modules/scene/controls/undoRedoControls/handlers/use3DRedoHandler.ts b/app/src/modules/scene/controls/undoRedoControls/handlers/use3DRedoHandler.ts index 4ddf62e..31b5fd4 100644 --- a/app/src/modules/scene/controls/undoRedoControls/handlers/use3DRedoHandler.ts +++ b/app/src/modules/scene/controls/undoRedoControls/handlers/use3DRedoHandler.ts @@ -149,7 +149,7 @@ function use3DRedoHandler() { addEvent(assetData.eventData as EventsSchema); } - if (!socket?.active) { + if (!socket?.connected) { // REST setAssetsApi({ @@ -174,7 +174,7 @@ function use3DRedoHandler() { } const deleteAssetToBackend = (assetData: Asset) => { - if (!socket?.active) { + if (!socket?.connected) { // REST deleteFloorItem(organization, assetData.modelUuid, assetData.modelName); @@ -228,7 +228,7 @@ function use3DRedoHandler() { userId }; - if (!socket?.active) { + if (!socket?.connected) { // REST setAssetsApi({ @@ -275,7 +275,7 @@ function use3DRedoHandler() { addEvent(assetData.eventData as EventsSchema); } - if (!socket?.active) { + if (!socket?.connected) { // REST setAssetsApi({ @@ -323,7 +323,7 @@ function use3DRedoHandler() { addEvent(assetData.eventData as EventsSchema); } - if (!socket?.active) { + if (!socket?.connected) { //REST setAssetsApi({ diff --git a/app/src/modules/scene/controls/undoRedoControls/handlers/use3DUndoHandler.ts b/app/src/modules/scene/controls/undoRedoControls/handlers/use3DUndoHandler.ts index 877dff6..021b006 100644 --- a/app/src/modules/scene/controls/undoRedoControls/handlers/use3DUndoHandler.ts +++ b/app/src/modules/scene/controls/undoRedoControls/handlers/use3DUndoHandler.ts @@ -148,7 +148,7 @@ function use3DUndoHandler() { addEvent(assetData.eventData as EventsSchema); } - if (!socket?.active) { + if (!socket?.connected) { // REST setAssetsApi({ @@ -173,7 +173,7 @@ function use3DUndoHandler() { } const deleteAssetToBackend = (assetData: Asset) => { - if (!socket?.active) { + if (!socket?.connected) { // REST deleteFloorItem(organization, assetData.modelUuid, assetData.modelName); @@ -227,7 +227,7 @@ function use3DUndoHandler() { userId }; - if (!socket?.active) { + if (!socket?.connected) { // REST setAssetsApi({ @@ -251,7 +251,7 @@ function use3DUndoHandler() { } const copyAssetToBackend = (assetData: Asset) => { - if (!socket?.active) { + if (!socket?.connected) { // REST deleteFloorItem(organization, assetData.modelUuid, assetData.modelName); @@ -288,7 +288,7 @@ function use3DUndoHandler() { } const duplicateAssetToBackend = (assetData: Asset) => { - if (!socket?.active) { + if (!socket?.connected) { // REST deleteFloorItem(organization, assetData.modelUuid, assetData.modelName); diff --git a/app/src/services/factoryBuilder/camera/getCameraApi.ts b/app/src/services/factoryBuilder/camera/getCameraApi.ts index 595ac29..2ea25a9 100644 --- a/app/src/services/factoryBuilder/camera/getCameraApi.ts +++ b/app/src/services/factoryBuilder/camera/getCameraApi.ts @@ -1,6 +1,6 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`; -export const getCamera = async (organization: string, userId: string, projectId?: string) => { +export const getCameraApi = async (organization: string, userId: string, projectId?: string) => { try { const response = await fetch( `${url_Backend_dwinzo}/api/V1/cameras/${projectId}`, diff --git a/app/src/services/factoryBuilder/camera/setCameraApi.ts b/app/src/services/factoryBuilder/camera/setCameraApi.ts index bc0d16f..b3a2f78 100644 --- a/app/src/services/factoryBuilder/camera/setCameraApi.ts +++ b/app/src/services/factoryBuilder/camera/setCameraApi.ts @@ -1,47 +1,44 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`; -export const setCamera = async ( - organization: string, - userId: string, - position: Object, - target: Object, - rotation: Object +export const setCameraApi = async ( + projectId: string, + position: Object, + target: Object, + rotation: Object ) => { - try { - const response = await fetch(`${url_Backend_dwinzo}/api/v1/setCamera`, { - method: "POST", - headers: { - Authorization: "Bearer ", - "Content-Type": "application/json", - token: localStorage.getItem("token") || "", - refresh_token: localStorage.getItem("refreshToken") || "", - }, - body: JSON.stringify({ - organization, - userId, - position, - target, - rotation, - }), - }); - const newAccessToken = response.headers.get("x-access-token"); - if (newAccessToken) { - //console.log("New token received:", newAccessToken); - localStorage.setItem("token", newAccessToken); - } + try { + const response = await fetch(`${url_Backend_dwinzo}/api/V1/builder/setCamera`, { + method: "POST", + headers: { + Authorization: "Bearer ", + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", + refresh_token: localStorage.getItem("refreshToken") || "", + }, + body: JSON.stringify({ + projectId, + position, + target, + rotation, + }), + }); + const newAccessToken = response.headers.get("x-access-token"); + if (newAccessToken) { + localStorage.setItem("token", newAccessToken); + } - if (!response.ok) { - console.error("Failed to set Camera Position and Target"); - } + if (!response.ok) { + console.error("Failed to set Camera Position and Target"); + } - const result = await response.json(); - return result; - } catch (error) { - echo.error("Failed to set camera"); - if (error instanceof Error) { - console.log(error.message); - } else { - console.log("An unknown error occurred"); + const result = await response.json(); + return result; + } catch (error) { + echo.error("Failed to set camera"); + if (error instanceof Error) { + console.log(error.message); + } else { + console.log("An unknown error occurred"); + } } - } };