diff --git a/src/app/plant-builder/PlantBuilder.tsx b/src/app/plant-builder/PlantBuilder.tsx
index 699ebd5..6c54fbe 100644
--- a/src/app/plant-builder/PlantBuilder.tsx
+++ b/src/app/plant-builder/PlantBuilder.tsx
@@ -509,12 +509,21 @@ export const PlantBuilder = () => {
) : step === "builder" ? (
-
- {/* Sidebar Container */}
+
+
+
+
+ {/* Sidebar Container (overlay; does not shift canvas) */}
{showComponentLibrary && (
@@ -533,15 +542,6 @@ export const PlantBuilder = () => {
)}
-
-
-
) : step === "compliance" ? (
@@ -624,14 +624,14 @@ export const PlantBuilder = () => {
Add Component
-
@@ -822,4 +822,4 @@ export const PlantBuilder = () => {
);
};
-export default PlantBuilder;
\ No newline at end of file
+export default PlantBuilder;
diff --git a/src/app/plant-operator/plant-builder/PlantBuilder.tsx b/src/app/plant-operator/plant-builder/PlantBuilder.tsx
index 1b3fb49..99c67ee 100644
--- a/src/app/plant-operator/plant-builder/PlantBuilder.tsx
+++ b/src/app/plant-operator/plant-builder/PlantBuilder.tsx
@@ -59,7 +59,7 @@ import {
PlacedComponent,
Connection,
} from "./types";
-import { createPlant } from "@/services/plant-builder/plants";
+import { createPlant, fetchPlantById, Plant } from "@/services/plant-builder/plants";
import { createDigitalTwin, fetchDigitalTwinJsonForPlant } from "@/services/plant-builder/digitalTwins";
import { updateComponentInstance, deleteComponentInstance } from "@/services/plant-builder/componentInstances";
import { buildConnectionPayloadForComponent, StoredConnectionPayload } from "@/lib/plant-builder/connection-utils";
@@ -167,6 +167,20 @@ export const PlantBuilder = () => {
setStep("builder");
+ const mapPlantToInfo = (plant: Plant): PlantInfo => {
+ const metadata = plant.metadata || {};
+ return {
+ plantName: plant.name || "New Plant",
+ projectName: metadata.projectName || "",
+ projectType: metadata.projectType || "",
+ primaryFuelType: metadata.primaryFuelType || "",
+ country: plant.location || metadata.country || "",
+ status: plant.status || "",
+ commercialOperationalDate: metadata.commercialOperationalDate || "",
+ investment: metadata.investment,
+ };
+ };
+
(async () => {
try {
toast.info("Loading digital twin from database…");
@@ -222,6 +236,13 @@ export const PlantBuilder = () => {
setComponents(mappedComponents);
setConnections(mappedConnections);
setOriginalComponents(mappedComponents); // Track originals for delete detection
+
+ try {
+ const plant = await fetchPlantById(plantId);
+ setPlantInfo(mapPlantToInfo(plant));
+ } catch (err) {
+ console.warn("Failed to load plant details:", err);
+ }
// Set global IDs for Canvas persistence
try {
@@ -261,7 +282,6 @@ export const PlantBuilder = () => {
const payload = {
name: info.plantName,
- user_id: 1, // hardcoded for now
location: info.country,
status: info.status,
metadata: {
@@ -858,12 +878,22 @@ export const PlantBuilder = () => {
) : step === "builder" ? (
-
- {/* Sidebar Container */}
+
+
+
+
+ {/* Sidebar Container (overlay; does not shift canvas) */}
{showComponentLibrary && (
@@ -882,16 +912,6 @@ export const PlantBuilder = () => {
)}
-
-
-
) : step === "compliance" ? (
@@ -966,23 +986,15 @@ export const PlantBuilder = () => {
Process Flow Diagram
-
-
@@ -1037,23 +1049,7 @@ export const PlantBuilder = () => {
-
+