socket and api integerated successfully
This commit is contained in:
@@ -46,7 +46,7 @@ const SelectedAisleProperties: React.FC = () => {
|
||||
const updateBackend = (updatedAisle: Aisle) => {
|
||||
if (updatedAisle && projectId) {
|
||||
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 (
|
||||
<div className={`versionSaved`}>
|
||||
@@ -105,7 +103,7 @@ const VersionSaved = () => {
|
||||
placeholder="Enter new version name"
|
||||
/>
|
||||
<div className="label">
|
||||
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",
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -135,7 +135,7 @@ function AisleCreator() {
|
||||
|
||||
const addAilseToBackend = (aisle: Aisle) => {
|
||||
if (projectId) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ function Line({ points }: Readonly<LineProps>) {
|
||||
if (projectId && asset) {
|
||||
|
||||
removeWallAsset(asset.modelUuid);
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
@@ -142,7 +142,7 @@ function Line({ points }: Readonly<LineProps>) {
|
||||
}
|
||||
}
|
||||
})
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
@@ -185,7 +185,7 @@ function Line({ points }: Readonly<LineProps>) {
|
||||
if (removedFloors.length > 0) {
|
||||
removedFloors.forEach(floor => {
|
||||
if (projectId) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
@@ -226,7 +226,7 @@ function Line({ points }: Readonly<LineProps>) {
|
||||
if (updatedFloors.length > 0) {
|
||||
updatedFloors.forEach(floor => {
|
||||
if (projectId) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
@@ -274,7 +274,7 @@ function Line({ points }: Readonly<LineProps>) {
|
||||
if (removedZones.length > 0) {
|
||||
removedZones.forEach(zone => {
|
||||
if (projectId) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
@@ -315,7 +315,7 @@ function Line({ points }: Readonly<LineProps>) {
|
||||
if (updatedZones.length > 0) {
|
||||
updatedZones.forEach(zone => {
|
||||
if (projectId) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
@@ -452,7 +452,7 @@ function Line({ points }: Readonly<LineProps>) {
|
||||
});
|
||||
|
||||
if (projectId && updatedWallAsset) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
// API
|
||||
|
||||
upsertWallAssetApi(projectId, selectedVersion?.versionId || '', updatedWallAsset);
|
||||
@@ -474,7 +474,7 @@ function Line({ points }: Readonly<LineProps>) {
|
||||
});
|
||||
}
|
||||
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
@@ -519,7 +519,7 @@ function Line({ points }: Readonly<LineProps>) {
|
||||
|
||||
if (updatedFloors.length > 0 && projectId) {
|
||||
updatedFloors.forEach(updatedFloor => {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
@@ -564,7 +564,7 @@ function Line({ points }: Readonly<LineProps>) {
|
||||
|
||||
if (updatedZones.length > 0 && projectId) {
|
||||
updatedZones.forEach(updatedZone => {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -62,7 +62,7 @@ function WallAssetCreator() {
|
||||
|
||||
addWallAsset(newWallAsset);
|
||||
if (projectId) {
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// API
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,18 +1,32 @@
|
||||
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,
|
||||
controls: React.RefObject<CameraControls>,
|
||||
socket: Socket,
|
||||
position: THREE.Vector3,
|
||||
rotation: THREE.Euler,
|
||||
projectId?: string
|
||||
) {
|
||||
const { userId, organization } = getUserData();
|
||||
if (!controls.current) return;
|
||||
if (!controls.current || !projectId) return;
|
||||
const target = controls.current.getTarget(new THREE.Vector3());
|
||||
|
||||
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,
|
||||
@@ -24,3 +38,4 @@ export default function updateCamPosition(
|
||||
};
|
||||
socket.emit("v1:Camera:set", camData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,11 +49,19 @@ 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);
|
||||
|
||||
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,
|
||||
@@ -63,6 +72,7 @@ export default function Controls() {
|
||||
projectId
|
||||
};
|
||||
socket.emit('v1:Camera:set', camData)
|
||||
}
|
||||
|
||||
setResetCamera(false);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -426,7 +426,7 @@ function MoveControls3D({ boundingBoxRef }: any) {
|
||||
userId
|
||||
};
|
||||
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
// REST
|
||||
|
||||
setAssetsApi({
|
||||
|
||||
@@ -370,7 +370,7 @@ function RotateControls3D() {
|
||||
userId
|
||||
};
|
||||
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
// REST
|
||||
|
||||
setAssetsApi({
|
||||
|
||||
@@ -285,7 +285,7 @@ const SelectionControls3D: React.FC = () => {
|
||||
if (!asset) return;
|
||||
|
||||
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
|
||||
// REST
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ function TransformControls3D() {
|
||||
}
|
||||
|
||||
|
||||
if (!socket?.active) {
|
||||
if (!socket?.connected) {
|
||||
// API
|
||||
|
||||
setAssetsApi({
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 || '');
|
||||
|
||||
@@ -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 || '');
|
||||
|
||||
@@ -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({
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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}`,
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
export const setCamera = async (
|
||||
organization: string,
|
||||
userId: string,
|
||||
export const setCameraApi = async (
|
||||
projectId: string,
|
||||
position: Object,
|
||||
target: Object,
|
||||
rotation: Object
|
||||
) => {
|
||||
try {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/v1/setCamera`, {
|
||||
const response = await fetch(`${url_Backend_dwinzo}/api/V1/builder/setCamera`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Bearer <access_token>",
|
||||
@@ -17,8 +16,7 @@ export const setCamera = async (
|
||||
refresh_token: localStorage.getItem("refreshToken") || "",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
organization,
|
||||
userId,
|
||||
projectId,
|
||||
position,
|
||||
target,
|
||||
rotation,
|
||||
@@ -26,7 +24,6 @@ export const setCamera = async (
|
||||
});
|
||||
const newAccessToken = response.headers.get("x-access-token");
|
||||
if (newAccessToken) {
|
||||
//console.log("New token received:", newAccessToken);
|
||||
localStorage.setItem("token", newAccessToken);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user