diff --git a/app/package-lock.json b/app/package-lock.json index a752e9c..fff13e1 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -10133,6 +10133,7 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/dxf-parser/-/dxf-parser-1.1.2.tgz", "integrity": "sha512-GPTumUvRkounlIazLIyJMmTWt+nlg+ksS0Hdm8jWvejmZKBTz6gvHTam76wRm4PQMma5sgKLThblQyeIJcH79Q==", + "license": "MIT", "dependencies": { "loglevel": "^1.7.1" } diff --git a/app/src/components/Dashboard/SidePannel.tsx b/app/src/components/Dashboard/SidePannel.tsx index d1786a1..2e6c1ea 100644 --- a/app/src/components/Dashboard/SidePannel.tsx +++ b/app/src/components/Dashboard/SidePannel.tsx @@ -41,9 +41,8 @@ const SidePannel: React.FC = ({ setActiveTab, activeTab }) => { try { const projectId = generateProjectId(); useSocketStore.getState().initializeSocket(email, organization, token); - console.log("projectId: ", projectId); - navigate(`/${projectId}`); - setLoadingProgress(1); + + //API for creating new Project // const project = await createProject( // projectId, @@ -60,6 +59,18 @@ const SidePannel: React.FC = ({ setActiveTab, activeTab }) => { }; console.log("projectSocket: ", projectSocket); if (projectSocket) { + // console.log('addProject: ', addProject); + const handleResponse = (data: any) => { + console.log('Project add response:', data); + if (data.message === "Project created successfully") { + setLoadingProgress(1) + navigate(`/${data.data.projectId}`); + } + projectSocket.off("v1-project:response:add", handleResponse); // Clean up + }; + projectSocket.on("v1-project:response:add", handleResponse); + + console.log('addProject: ', addProject); projectSocket.emit("v1:project:add", addProject); } else { console.error("Socket is not connected."); diff --git a/app/src/components/layout/sidebarRight/properties/GlobalProperties.tsx b/app/src/components/layout/sidebarRight/properties/GlobalProperties.tsx index 0422e2b..191bb15 100644 --- a/app/src/components/layout/sidebarRight/properties/GlobalProperties.tsx +++ b/app/src/components/layout/sidebarRight/properties/GlobalProperties.tsx @@ -20,6 +20,7 @@ import { 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(); const { selectedWallItem, setSelectedWallItem } = useSelectedWallItem(); @@ -37,6 +38,7 @@ const GlobalProperties: React.FC = () => { const [limitGridDistance, setLimitGridDistance] = useState(false); const [gridDistance, setGridDistance] = useState(3); + const { projectId } = useParams(); const optimizeScene = async (value: any) => { const email = localStorage.getItem("email"); @@ -49,7 +51,8 @@ const GlobalProperties: React.FC = () => { roofVisibility, shadows, 30, - true + true, + projectId ); setRenderDistance(30); setLimitDistance(true); @@ -67,7 +70,8 @@ const GlobalProperties: React.FC = () => { roofVisibility, shadows, 75, - !limitDistance + !limitDistance, + projectId ); setRenderDistance(75); } else { @@ -78,7 +82,8 @@ const GlobalProperties: React.FC = () => { roofVisibility, shadows, renderDistance, - !limitDistance + !limitDistance, + projectId ); } setLimitDistance(!limitDistance); @@ -111,7 +116,8 @@ const GlobalProperties: React.FC = () => { roofVisibility, shadows, value, - limitDistance + limitDistance, + projectId ); }; @@ -128,7 +134,8 @@ const GlobalProperties: React.FC = () => { !roofVisibility, shadows, renderDistance, - limitDistance + limitDistance, + projectId ); // @@ -157,7 +164,7 @@ const GlobalProperties: React.FC = () => { roofVisibility, shadows, renderDistance, - limitDistance + limitDistance,projectId ); // @@ -186,7 +193,8 @@ const GlobalProperties: React.FC = () => { roofVisibility, !shadows, renderDistance, - limitDistance + limitDistance, + projectId ); // diff --git a/app/src/components/layout/sidebarRight/properties/ZoneProperties.tsx b/app/src/components/layout/sidebarRight/properties/ZoneProperties.tsx index e116c15..35f3bb5 100644 --- a/app/src/components/layout/sidebarRight/properties/ZoneProperties.tsx +++ b/app/src/components/layout/sidebarRight/properties/ZoneProperties.tsx @@ -28,7 +28,7 @@ const ZoneProperties: React.FC = () => { const organization = email?.split("@")[1]?.split(".")[0]; let zonesdata = { - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, viewPortposition: zonePosition, viewPortCenter: zoneTarget, }; @@ -52,7 +52,7 @@ const ZoneProperties: React.FC = () => { const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0]; const zonesdata = { - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, zoneName: newName, }; // Call your API to update the zone @@ -61,7 +61,7 @@ const ZoneProperties: React.FC = () => { if (response.message === "updated successfully") { setZones((prevZones: any[]) => prevZones.map((zone) => - zone.zoneId === selectedZone.zoneId + zone.zoneUuid === selectedZone.zoneUuid ? { ...zone, zoneName: newName } : zone ) @@ -80,7 +80,7 @@ const ZoneProperties: React.FC = () => { return zones.some( (zone: any) => zone.zoneName.trim().toLowerCase() === name.trim().toLowerCase() && - zone.zoneId !== selectedZone.zoneId + zone.zoneUuid !== selectedZone.zoneUuid ); }; diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx index 742569c..27ac2f9 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/BarChartInput.tsx @@ -7,6 +7,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone import { useWidgetStore } from "../../../../../store/useWidgetStore"; import axios from "axios"; import RenameInput from "../../../../ui/inputs/RenameInput"; +import { useParams } from "react-router-dom"; type Props = {}; @@ -24,6 +25,8 @@ const BarChartInput = (props: Props) => { const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0]; const [isLoading, setLoading] = useState(true); + const { projectId } = useParams(); + useEffect(() => { const fetchZoneData = async () => { @@ -50,7 +53,15 @@ const BarChartInput = (props: Props) => { if (selectedChartId.id !== "") { try { const response = await axios.get( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}` + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + } ); if (response.status === 200) { setSelections(response.data.Data.measurements); @@ -83,10 +94,18 @@ const BarChartInput = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + }, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, panel: selectedChartId.panel, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx index 6b3559c..4d858ff 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FleetEfficiencyInputComponent.tsx @@ -87,10 +87,10 @@ const FleetEfficiencyInputComponent = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/floatwidget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/floatWidget/save`, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, header: inputName, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx index 166070e..9fc36b9 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/FlotingWidgetInput.tsx @@ -86,10 +86,10 @@ const FlotingWidgetInput = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/floatwidget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/floatWidget/save`, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, header: inputName, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx index 49d4525..330560f 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/LineGrapInput.tsx @@ -123,6 +123,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone import { useWidgetStore } from "../../../../../store/useWidgetStore"; import axios from "axios"; import RenameInput from "../../../../ui/inputs/RenameInput"; +import { useParams } from "react-router-dom"; type Props = {}; @@ -140,6 +141,7 @@ const LineGrapInput = (props: Props) => { const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0]; const [isLoading, setLoading] = useState(true); + const { projectId } = useParams(); useEffect(() => { const fetchZoneData = async () => { @@ -166,7 +168,15 @@ const LineGrapInput = (props: Props) => { if (selectedChartId.id !== "") { try { const response = await axios.get( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}` + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + } ); if (response.status === 200) { setSelections(response.data.Data.measurements); @@ -199,10 +209,18 @@ const LineGrapInput = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + }, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, panel: selectedChartId.panel, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx index aa0acaa..a78e391 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/PieChartInput.tsx @@ -7,6 +7,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone import { useWidgetStore } from "../../../../../store/useWidgetStore"; import axios from "axios"; import RenameInput from "../../../../ui/inputs/RenameInput"; +import { useParams } from "react-router-dom"; type Props = {}; @@ -24,6 +25,8 @@ const PieChartInput = (props: Props) => { const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0]; const [isLoading, setLoading] = useState(true); + const { projectId } = useParams(); + useEffect(() => { const fetchZoneData = async () => { @@ -50,7 +53,15 @@ const PieChartInput = (props: Props) => { if (selectedChartId.id !== "") { try { const response = await axios.get( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}` + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + } ); if (response.status === 200) { setSelections(response.data.Data.measurements); @@ -83,10 +94,18 @@ const PieChartInput = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + }, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, panel: selectedChartId.panel, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx index 2f1fdb5..15ecee5 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress1Input.tsx @@ -7,6 +7,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone import { useWidgetStore } from "../../../../../store/useWidgetStore"; import axios from "axios"; import RenameInput from "../../../../ui/inputs/RenameInput"; +import { useParams } from "react-router-dom"; type Props = {}; @@ -24,6 +25,8 @@ const Progress1Input = (props: Props) => { const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0]; const [isLoading, setLoading] = useState(true); + const { projectId } = useParams(); + useEffect(() => { const fetchZoneData = async () => { @@ -50,7 +53,15 @@ const Progress1Input = (props: Props) => { if (selectedChartId.id !== "") { try { const response = await axios.get( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}` + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + } ); if (response.status === 200) { setSelections(response.data.Data.measurements); @@ -83,10 +94,18 @@ const Progress1Input = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + }, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, panel: selectedChartId.panel, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx index 2d2e089..842821c 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Progress2Input.tsx @@ -7,6 +7,7 @@ import { useSelectedZoneStore } from "../../../../../store/visualization/useZone import { useWidgetStore } from "../../../../../store/useWidgetStore"; import axios from "axios"; import RenameInput from "../../../../ui/inputs/RenameInput"; +import { useParams } from "react-router-dom"; type Props = {}; @@ -24,6 +25,8 @@ const Progress2Input = (props: Props) => { const email = localStorage.getItem("email") || ""; const organization = email?.split("@")[1]?.split(".")[0]; const [isLoading, setLoading] = useState(true); + const { projectId } = useParams(); + useEffect(() => { const fetchZoneData = async () => { @@ -50,7 +53,15 @@ const Progress2Input = (props: Props) => { if (selectedChartId.id !== "") { try { const response = await axios.get( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/WidgetData/${selectedChartId.id}/${organization}` + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/data?widgetID=${selectedChartId.id}&zoneUuid=${selectedZone.zoneUuid}&projectId=${projectId}`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + } ); if (response.status === 200) { setSelections(response.data.Data.measurements); @@ -83,10 +94,18 @@ const Progress2Input = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/widget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget/save`, + { + headers: { + Authorization: "Bearer ", // Replace with actual token + "Content-Type": "application/json", + token: localStorage.getItem("token") || "", // Coerce null to empty string + refresh_token: localStorage.getItem("refreshToken") || "", + }, + }, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, panel: selectedChartId.panel, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx index 6c8eda4..b963c8c 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/WarehouseThroughputInputComponent.tsx @@ -84,10 +84,10 @@ const WarehouseThroughputInputComponent = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/floatwidget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/floatWidget/save`, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, header: inputName, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx index 0723c80..10c905c 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget2InputCard3D.tsx @@ -83,10 +83,10 @@ const Widget2InputCard3D = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/3dwidget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget3d/save`, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, widgetName: inputName, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx index 2e2b051..d9e4314 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget3InputCard3D.tsx @@ -80,10 +80,10 @@ const Widget3InputCard3D = () => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/3dwidget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget3d/save`, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, widgetName: inputName, diff --git a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx index cc8d9ca..2498d3d 100644 --- a/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx +++ b/app/src/components/layout/sidebarRight/visualization/IotInputCards/Widget4InputCard3D.tsx @@ -83,10 +83,10 @@ const Widget4InputCard3D = (props: Props) => { ) => { try { const response = await axios.post( - `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/v2/3dwidget/save`, + `http://${process.env.REACT_APP_SERVER_REST_API_BASE_URL}/api/V1/widget3d/save`, { organization: organization, - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, widget: { id: selectedChartId.id, widgetName: inputName, diff --git a/app/src/components/ui/Tools.tsx b/app/src/components/ui/Tools.tsx index fcc40b8..b36b00f 100644 --- a/app/src/components/ui/Tools.tsx +++ b/app/src/components/ui/Tools.tsx @@ -37,6 +37,7 @@ import { use3DWidget, useFloatingWidget, } from "../../store/visualization/useDroppedObjectsStore"; +import { useParams } from "react-router-dom"; // Utility component const ToolButton = ({ @@ -89,6 +90,7 @@ const Tools: React.FC = () => { const dropdownRef = useRef(null); const [openDrop, setOpenDrop] = useState(false); + const { projectId } = useParams(); // 1. Set UI toggles on initial render useEffect(() => { @@ -257,6 +259,7 @@ const Tools: React.FC = () => { selectedZone, templates, visualizationSocket, + projectId }) } /> diff --git a/app/src/components/ui/list/DropDownList.tsx b/app/src/components/ui/list/DropDownList.tsx index 77c9c4b..8c76aba 100644 --- a/app/src/components/ui/list/DropDownList.tsx +++ b/app/src/components/ui/list/DropDownList.tsx @@ -17,7 +17,7 @@ interface DropDownListProps { } interface Zone { - zoneId: string; + zoneUuid: string; zoneName: string; points: [number, number, number][]; // polygon vertices } @@ -93,7 +93,7 @@ const DropDownList: React.FC = ({ })); return { - id: zone.zoneId, + id: zone.zoneUuid, name: zone.zoneName, assets: assetsInZone, }; diff --git a/app/src/components/ui/list/List.tsx b/app/src/components/ui/list/List.tsx index d5db7fb..dd610d6 100644 --- a/app/src/components/ui/list/List.tsx +++ b/app/src/components/ui/list/List.tsx @@ -20,6 +20,7 @@ import { import { zoneCameraUpdate } from "../../../services/visulization/zone/zoneCameraUpdation"; import { setFloorItemApi } from "../../../services/factoryBuilder/assest/floorAsset/setFloorItemApi"; import OuterClick from "../../../utils/outerClick"; +import { useParams } from "react-router-dom"; interface Asset { id: string; @@ -50,6 +51,7 @@ const List: React.FC = ({ items = [], remove }) => { {} ); const { setFloorItems } = useFloorItems(); + const { projectId } = useParams(); useEffect(() => { @@ -58,23 +60,23 @@ const List: React.FC = ({ items = [], remove }) => { activeSides: [], panelOrder: [], lockedPanels: [], - zoneId: "", + zoneUuid: "", zoneViewPortTarget: [], zoneViewPortPosition: [], widgets: [], }); }, [activeModule]); - const toggleZoneExpansion = (zoneId: string) => { + const toggleZoneExpansion = (zoneUuid: string) => { setExpandedZones((prev) => ({ ...prev, - [zoneId]: !prev[zoneId], + [zoneUuid]: !prev[zoneUuid], })); }; async function handleSelectZone(id: string) { try { - if (selectedZone?.zoneId === id) { + if (selectedZone?.zoneUuid === id) { return; } @@ -83,14 +85,14 @@ const List: React.FC = ({ items = [], remove }) => { const email = localStorage.getItem("email"); const organization = email?.split("@")[1]?.split(".")[0] ?? ""; - let response = await getZoneData(id, organization); + let response = await getZoneData(id, organization, projectId); setSelectedZone({ zoneName: response?.zoneName, activeSides: response?.activeSides ?? [], panelOrder: response?.panelOrder ?? [], lockedPanels: response?.lockedPanels ?? [], widgets: response?.widgets ?? [], - zoneId: response?.zoneId, + zoneUuid: response?.zoneUuid, zoneViewPortTarget: response?.viewPortCenter ?? [], zoneViewPortPosition: response?.viewPortposition ?? [], }); @@ -110,7 +112,7 @@ const List: React.FC = ({ items = [], remove }) => { const isDuplicate = zones.some( (zone: any) => zone.zoneName.trim().toLowerCase() === newName.trim().toLowerCase() && - zone.zoneId !== selectedZone.zoneId + zone.zoneUuid !== selectedZone.zoneUuid ); if (isDuplicate) { @@ -119,7 +121,7 @@ const List: React.FC = ({ items = [], remove }) => { } const zonesdata = { - zoneId: selectedZone.zoneId, + zoneUuid: selectedZone.zoneUuid, zoneName: newName, }; @@ -129,7 +131,7 @@ const List: React.FC = ({ items = [], remove }) => { setZones((prevZones: any[]) => prevZones.map((zone) => - zone.zoneId === selectedZone.zoneId + zone.zoneUuid === selectedZone.zoneUuid ? { ...zone, zoneName: newName } : zone ) @@ -161,7 +163,7 @@ const List: React.FC = ({ items = [], remove }) => { return zones.some( (zone: any) => zone.zoneName.trim().toLowerCase() === name.trim().toLowerCase() && - zone.zoneId !== selectedZone.zoneId + zone.zoneUuid !== selectedZone.zoneUuid ); }; @@ -199,7 +201,7 @@ const List: React.FC = ({ items = [], remove }) => { if (isOutsideClick(evt.target)) { // Clear selected zone setSelectedZone({ - zoneId: '', + zoneUuid: '', zoneName: '', activeSides: [], panelOrder: [], @@ -241,7 +243,7 @@ const List: React.FC = ({ items = [], remove }) => { toggleZoneExpansion(item.id); }} > -
+