Add selectedVersion checks in multiple components to prevent API calls without a valid version

This commit is contained in:
2025-06-23 10:09:09 +05:30
parent 1ac0e86e74
commit 5d0c36071e
7 changed files with 12 additions and 4 deletions

View File

@@ -73,6 +73,7 @@ function MainScene() {
}, [activeModule])
useEffect(() => {
console.log('versionHistory: ', versionHistory);
if (versionHistory.length > 0) {
setSelectedVersion(versionHistory[0])
}

View File

@@ -14,7 +14,7 @@ function AislesGroup() {
const { projectId } = useParams();
useEffect(() => {
if (projectId) {
if (projectId && selectedVersion) {
getAisleApi(projectId, selectedVersion?.versionId || '').then((aisles) => {
if (aisles && aisles.length > 0) {
setAisles(aisles);

View File

@@ -98,7 +98,7 @@ const DistanceText = () => {
useEffect(() => {
if (!email) return;
if (!email || !selectedVersion) return;
getLines(organization, projectId, selectedVersion?.versionId || '').then((data) => {
data = objectLinesToArray(data);

View File

@@ -49,6 +49,7 @@ const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoin
}, [toolMode, state]);
useEffect(() => {
if (!selectedVersion) return;
getLines(organization, projectId, selectedVersion?.versionId || '').then((data) => {

View File

@@ -23,6 +23,10 @@ const WallsMeshComponent = ({ lines }: any) => {
useEffect(() => {
if (updateScene) {
if (!selectedVersion) {
setUpdateScene(false);
return;
};
getLines(organization, projectId, selectedVersion?.versionId || '').then((data) => {
const Lines: Types.Lines = objectLinesToArray(data);
localStorage.setItem("Lines", JSON.stringify(Lines));

View File

@@ -72,6 +72,7 @@ const ZoneGroup: React.FC = () => {
);
useEffect(() => {
if (!selectedVersion) return;
getZonesApi(organization, projectId, selectedVersion?.versionId || '').then((data) => {
if (data && data.length > 0) {
const fetchedZones = data.map((zone: any) => ({
@@ -90,10 +91,10 @@ const ZoneGroup: React.FC = () => {
);
setZonePoints(fetchedPoints);
}else{
} else {
setZones([]);
}
}).catch((err)=>{
}).catch((err) => {
console.error(err);
})
}, [selectedVersion?.versionId]);

View File

@@ -41,6 +41,7 @@ function Products() {
}, [comparisonProduct])
useEffect(() => {
if (!selectedVersion) return;
getAllProductsApi(projectId || '', selectedVersion?.versionId || '').then((data) => {
if (data && data.length === 0) {
const id = THREE.MathUtils.generateUUID();