Add selectedVersion checks in multiple components to prevent API calls without a valid version
This commit is contained in:
@@ -73,6 +73,7 @@ function MainScene() {
|
||||
}, [activeModule])
|
||||
|
||||
useEffect(() => {
|
||||
console.log('versionHistory: ', versionHistory);
|
||||
if (versionHistory.length > 0) {
|
||||
setSelectedVersion(versionHistory[0])
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -98,7 +98,7 @@ const DistanceText = () => {
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (!email) return;
|
||||
if (!email || !selectedVersion) return;
|
||||
|
||||
getLines(organization, projectId, selectedVersion?.versionId || '').then((data) => {
|
||||
data = objectLinesToArray(data);
|
||||
|
||||
@@ -49,6 +49,7 @@ const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoin
|
||||
}, [toolMode, state]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!selectedVersion) return;
|
||||
|
||||
getLines(organization, projectId, selectedVersion?.versionId || '').then((data) => {
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user