refactor: Remove unnecessary console logs and improve code consistency across multiple components
This commit is contained in:
parent
45e50ff11c
commit
d57ee378aa
|
@ -26,7 +26,6 @@ const DashboardProjects: React.FC = () => {
|
|||
{}
|
||||
);
|
||||
const [projectDuplicateData, setProjectDuplicateData] = useState<Object>({});
|
||||
console.log("projectDuplicateData: ", projectDuplicateData);
|
||||
const [isSearchActive, setIsSearchActive] = useState<boolean>(false);
|
||||
const [activeFolder, setActiveFolder] = useState<string>("myProjects");
|
||||
const { projectSocket } = useSocketStore();
|
||||
|
|
|
@ -19,7 +19,6 @@ import {
|
|||
} from "../../../../store/builder/store";
|
||||
import { setEnvironment } from "../../../../services/factoryBuilder/environment/setEnvironment";
|
||||
import * as CONSTANTS from "../../../../types/world/worldConstants";
|
||||
import { validateBBox } from "@turf/helpers";
|
||||
import { useParams } from "react-router-dom";
|
||||
const GlobalProperties: React.FC = () => {
|
||||
const { toggleView, setToggleView } = useToggleView();
|
||||
|
|
|
@ -12,7 +12,7 @@ import Scene from "../../../modules/scene/scene";
|
|||
import { useComparisonProduct } from "../../../store/simulation/useSimulationStore";
|
||||
|
||||
const CompareLayOut = () => {
|
||||
const { comparisonProduct, setComparisonProduct } = useComparisonProduct();
|
||||
const { comparisonProduct, setComparisonProduct, clearComparisonProduct } = useComparisonProduct();
|
||||
const { products } = useProductStore();
|
||||
const { setLoadingProgress } = useLoadingProgress();
|
||||
const [width, setWidth] = useState("50vw");
|
||||
|
@ -63,6 +63,7 @@ const CompareLayOut = () => {
|
|||
if (finalWidthVw <= 10) {
|
||||
setWidth("0px");
|
||||
setIsVersionSaved(false);
|
||||
clearComparisonProduct();
|
||||
} else {
|
||||
setWidth(`${finalWidthVw}vw`);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,9 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
|||
const { setSelectedFloorItem } = useSelectedFloorItem();
|
||||
const { selectedItem, setSelectedItem } = useSelectedItem();
|
||||
const { projectId } = useParams();
|
||||
const email = localStorage.getItem("email");
|
||||
const organization = email!.split("@")[1].split(".")[0];
|
||||
const userId = localStorage.getItem("userId")!;
|
||||
|
||||
const loader = new GLTFLoader();
|
||||
const dracoLoader = new DRACOLoader();
|
||||
|
@ -41,8 +44,6 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
|||
loader.setDRACOLoader(dracoLoader);
|
||||
|
||||
useEffect(() => {
|
||||
const email = localStorage.getItem("email");
|
||||
const organization = email!.split("@")[1].split(".")[0];
|
||||
|
||||
let totalAssets = 0;
|
||||
let loadedAssets = 0;
|
||||
|
@ -254,7 +255,6 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
|||
};
|
||||
}, []);
|
||||
|
||||
const userId = localStorage.getItem("userId");
|
||||
useEffect(() => {
|
||||
const canvasElement = gl.domElement;
|
||||
const onDrop = (event: any) => {
|
||||
|
@ -265,8 +265,7 @@ function AssetsGroup({ floorGroup, plane }: { readonly floorGroup: RefGroup, rea
|
|||
pointer.x = (event.clientX / window.innerWidth) * 2 - 1;
|
||||
pointer.y = -(event.clientY / window.innerHeight) * 2 + 1;
|
||||
|
||||
addAssetModel(raycaster, camera, pointer, floorGroup, socket, selectedItem, setSelectedItem, addEvent, addAsset, plane, projectId ?? undefined, // convert null to undefined
|
||||
userId ?? undefined);
|
||||
addAssetModel(raycaster, camera, pointer, floorGroup, socket, selectedItem, setSelectedItem, addEvent, addAsset, plane, projectId, userId);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -53,15 +53,15 @@ async function addAssetModel(
|
|||
intersectPoint =
|
||||
intersectedFloor.distance < intersectedPlane.distance
|
||||
? new THREE.Vector3(
|
||||
intersectedFloor.point.x,
|
||||
Math.round(intersectedFloor.point.y),
|
||||
intersectedFloor.point.z
|
||||
)
|
||||
intersectedFloor.point.x,
|
||||
Math.round(intersectedFloor.point.y),
|
||||
intersectedFloor.point.z
|
||||
)
|
||||
: new THREE.Vector3(
|
||||
intersectedPlane.point.x,
|
||||
0,
|
||||
intersectedPlane.point.z
|
||||
);
|
||||
intersectedPlane.point.x,
|
||||
0,
|
||||
intersectedPlane.point.z
|
||||
);
|
||||
} else if (intersectedFloor) {
|
||||
intersectPoint = new THREE.Vector3(
|
||||
intersectedFloor.point.x,
|
||||
|
@ -111,7 +111,9 @@ async function addAssetModel(
|
|||
selectedItem,
|
||||
addEvent,
|
||||
addAsset,
|
||||
socket
|
||||
socket,
|
||||
projectId,
|
||||
userId
|
||||
);
|
||||
});
|
||||
} else {
|
||||
|
@ -129,7 +131,9 @@ async function addAssetModel(
|
|||
selectedItem,
|
||||
addEvent,
|
||||
addAsset,
|
||||
socket
|
||||
socket,
|
||||
projectId,
|
||||
userId
|
||||
);
|
||||
}
|
||||
);
|
||||
|
|
|
@ -156,16 +156,13 @@ export default function Builder() {
|
|||
const organization = email!.split("@")[1].split(".")[0];
|
||||
|
||||
async function fetchVisibility() {
|
||||
const visibility = await findEnvironment(
|
||||
organization,
|
||||
localStorage.getItem("userId")!,projectId
|
||||
);
|
||||
if (visibility) {
|
||||
setRoofVisibility(visibility.roofVisibility);
|
||||
setWallVisibility(visibility.wallVisibility);
|
||||
setShadows(visibility.shadowVisibility);
|
||||
setRenderDistance(visibility.renderDistance);
|
||||
setLimitDistance(visibility.limitDistance);
|
||||
const data = await findEnvironment(organization, localStorage.getItem("userId")!, projectId);
|
||||
if (data) {
|
||||
setRoofVisibility(data.roofVisibility);
|
||||
setWallVisibility(data.wallVisibility);
|
||||
setShadows(data.shadowVisibility);
|
||||
setRenderDistance(data.renderDistance);
|
||||
setLimitDistance(data.limitDistance);
|
||||
}
|
||||
}
|
||||
fetchVisibility();
|
||||
|
|
|
@ -92,14 +92,12 @@ export default function SocketResponses({
|
|||
});
|
||||
|
||||
socket.on("v1:model-asset:response:add", async (data: any) => {
|
||||
//
|
||||
if (socket.id === data.socketId) {
|
||||
return;
|
||||
}
|
||||
if (organization !== data.organization) {
|
||||
return;
|
||||
}
|
||||
console.log('data.data: ', data);
|
||||
if (data.message === "Model created successfully") {
|
||||
try {
|
||||
|
||||
|
|
|
@ -30,7 +30,10 @@ export default function Controls() {
|
|||
}
|
||||
const email = localStorage.getItem("email");
|
||||
const organization = email!.split("@")[1].split(".")[0];
|
||||
getCamera(organization, localStorage.getItem("userId")!,projectId).then((data) => {
|
||||
const userId = localStorage.getItem("userId")!;
|
||||
|
||||
getCamera(organization, userId, projectId).then((data) => {
|
||||
// console.log('data: ', 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);
|
||||
|
@ -80,7 +83,7 @@ export default function Controls() {
|
|||
if (hasInteracted && controlsRef.current && state.camera.position && !toggleView) {
|
||||
const position = state.camera.position;
|
||||
if (position.x === 0 && position.y === 0 && position.z === 0) return;
|
||||
updateCamPosition(controlsRef, socket, position, state.camera.rotation,projectId);
|
||||
updateCamPosition(controlsRef, socket, position, state.camera.rotation, projectId);
|
||||
stopInterval();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@ export const getFloorAssets = async (organization: string,projectId?:string) =>
|
|||
}
|
||||
|
||||
const result = await response.json();
|
||||
console.log('result: ', result);
|
||||
// console.log('result: ', result);
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import { setCamera } from "./setCameraApi";
|
||||
import * as THREE from "three";
|
||||
|
||||
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 getCamera = async (organization: string, userId: string, projectId?: string) => {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${url_Backend_dwinzo}/api/V1/cameras/${projectId}`,
|
||||
|
@ -23,7 +20,6 @@ export const getCamera = async (organization: string, userId: string,projectId?:
|
|||
}
|
||||
|
||||
const result = await response.json();
|
||||
// console.log('result: ', result);
|
||||
if (result === "user not found") {
|
||||
return null;
|
||||
} else {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { setEnvironment } from "./setEnvironment";
|
||||
|
||||
let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}`;
|
||||
|
||||
|
@ -23,22 +22,7 @@ export const findEnvironment = async (organization: string, userId: string, proj
|
|||
}
|
||||
|
||||
const result = await response.json();
|
||||
// console.log('resultgetenv: ', result);
|
||||
if (result === "user not found") {
|
||||
const userpos = setEnvironment(
|
||||
organization,
|
||||
userId,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
40,
|
||||
true,
|
||||
projectId
|
||||
);
|
||||
return userpos;
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
} catch (error) {
|
||||
echo.error("Failed to find env");
|
||||
if (error instanceof Error) {
|
||||
|
|
|
@ -3,9 +3,9 @@ let url_Backend_dwinzo = `http://${process.env.REACT_APP_SERVER_REST_API_BASE_UR
|
|||
export const setEnvironment = async (
|
||||
organization: string,
|
||||
userId: string,
|
||||
wallVisibility: Boolean,
|
||||
roofVisibility: Boolean,
|
||||
shadowVisibility: Boolean,
|
||||
wallVisibility: boolean,
|
||||
roofVisibility: boolean,
|
||||
shadowVisibility: boolean,
|
||||
renderDistance: number,
|
||||
limitDistance: boolean,
|
||||
projectId?: string
|
||||
|
|
|
@ -21,7 +21,7 @@ export const getZonesApi = async (organization: string, projectId?: string) => {
|
|||
}
|
||||
|
||||
const result = await response.json();
|
||||
console.log('result:zone ', result);
|
||||
// console.log('result:zone ', result);
|
||||
|
||||
return result;
|
||||
} catch (error) {
|
||||
|
|
Loading…
Reference in New Issue