From e6d6fa6efcd4ac7abccfab56bb2db2f6a31c4965 Mon Sep 17 00:00:00 2001 From: fullsizemalt <106900403+fullsizemalt@users.noreply.github.com> Date: Wed, 17 Dec 2025 03:39:46 -0800 Subject: [PATCH] fix(3d-viewer): remove duplicate function definitions from file - Cleans up duplicate Facility3DViewerPage, FacilityScene, and PlantInstances functions - Ensures single clean export default --- frontend/src/pages/Facility3DViewerPage.tsx | 142 +++----------------- 1 file changed, 16 insertions(+), 126 deletions(-) diff --git a/frontend/src/pages/Facility3DViewerPage.tsx b/frontend/src/pages/Facility3DViewerPage.tsx index 5921690..9b0136c 100644 --- a/frontend/src/pages/Facility3DViewerPage.tsx +++ b/frontend/src/pages/Facility3DViewerPage.tsx @@ -49,123 +49,6 @@ class ErrorBoundary extends Component<{ children: ReactNode }, ErrorBoundaryStat } } -// ... unchanged parts ... - -// Update Facility3DViewerPage to use ErrorBoundary -export default function Facility3DViewerPage() { - const [status, setStatus] = useState('Initializing...'); - const [floorData, setFloorData] = useState(null); - const [selectedPlant, setSelectedPlant] = useState(null); - - useEffect(() => { - loadData(); - }, []); - - async function loadData() { - setStatus('Loading layout...'); - try { - const props = await layoutApi.getProperties(); - if (props[0]?.buildings[0]?.floors[0]) { - const floorId = props[0].buildings[0].floors[0].id; - setStatus('Fetching 3D assets...'); - const data = await layoutApi.getFloor3D(floorId); - setFloorData(data); - setStatus(''); - } else { - setStatus('No floor layout found'); - } - } catch (err) { - setStatus('Error: ' + (err as Error).message); - } - } - - return ( -
- {/* Header Overlay */} -
-
- - Back - -
-

- Facility Viewer 3D - BETA -

-

- {floorData ? `${floorData.floor.name} • ${floorData.stats.occupiedPositions} Plants` : 'Loading...'} -

-
-
- - {/* Legend */} -
-
Veg
-
Flower
-
Dry
-
Empty
-
-
- - {/* Error/Status Overlay */} - {status && ( -
-
- -

{status}

-
-
- )} - - {/* Selection Overlay */} - {selectedPlant && ( -
-
-

{selectedPlant.plant.tagNumber}

- -
-
-
- Strain: - {selectedPlant.plant.strain || 'Unknown'} -
-
- Stage: - {selectedPlant.plant.stage || 'N/A'} -
-
- Batch: - {selectedPlant.plant.batchName || '-'} -
-
- Location: - R{selectedPlant.row} T{selectedPlant.tier} S{selectedPlant.slot} -
-
-
- )} - - - - Loading 3D Scene...}> - {floorData && ( - - )} - - - -
- ); -} - function PlantInstances({ positions, onPlantClick }: { positions: any[], onPlantClick: (p: any) => void }) { if (!positions || !Array.isArray(positions) || positions.length === 0) return null; @@ -178,7 +61,7 @@ function PlantInstances({ positions, onPlantClick }: { positions: any[], onPlant // Limit instances to prevent crash on huge datasets just in case if (safePositions.length > 5000) { console.warn('Too many positions to render:', safePositions.length); - return null; + return null; // Or return a subset } return ( @@ -363,6 +246,11 @@ export default function Facility3DViewerPage() {

{status}

+ {status.includes('Error') && ( + + )}
)} @@ -401,14 +289,16 @@ export default function Facility3DViewerPage() { )} - - {floorData && ( - - )} - + + Loading 3D Scene...}> + {floorData && ( + + )} + + );