From b6597a912aed3a880ab591230f84d23bad87352d Mon Sep 17 00:00:00 2001 From: Gomathi9520 Date: Fri, 23 May 2025 12:12:23 +0530 Subject: [PATCH] chore: update ProductionCapacity component for improved readability and maintainability --- .../widgets/3d/cards/ProductionCapacity.tsx | 129 +++++++++--------- 1 file changed, 66 insertions(+), 63 deletions(-) diff --git a/app/src/modules/visualization/widgets/3d/cards/ProductionCapacity.tsx b/app/src/modules/visualization/widgets/3d/cards/ProductionCapacity.tsx index 324f53c..a0620e9 100644 --- a/app/src/modules/visualization/widgets/3d/cards/ProductionCapacity.tsx +++ b/app/src/modules/visualization/widgets/3d/cards/ProductionCapacity.tsx @@ -31,6 +31,7 @@ interface ProductionCapacityProps { type: string; position: [number, number, number]; rotation: [number, number, number]; + scale?: [number, number, number]; Data?: any; onContextMenu?: (event: React.MouseEvent) => void; // onPointerDown:any @@ -41,7 +42,8 @@ const ProductionCapacity: React.FC = ({ type, Data, position, - rotation, + rotation = [0, 0, 0], + scale = [0.5, 0.5, 0.5], onContextMenu, }) => { const { selectedChartId, setSelectedChartId } = useWidgetStore(); @@ -198,74 +200,75 @@ const ProductionCapacity: React.FC = ({ useEffect(() => { }, [rotation]); return ( - - { - e.preventDefault(); - e.stopPropagation(); - }} - onDrop={(e) => { - e.preventDefault(); - }} - > -
setSelectedChartId({ id: id, type: type })} - onContextMenu={onContextMenu} - style={{ - width: "300px", // Original width - height: "300px", // Original height - // transform: transformStyle.transform, - transformStyle: "preserve-3d", - position: "absolute", - transform: "translate(-50%, -50%)", + <> + {position && scale && rotation && { + e.preventDefault(); + e.stopPropagation(); + }} + onDrop={(e) => { + e.preventDefault(); }} > -
-
Production Capacity
-
-
1,200
{" "} -
units/hour
-
-
-
-
Current
-
1500
+
setSelectedChartId({ id: id, type: type })} + onContextMenu={onContextMenu} + style={{ + width: "300px", // Original width + height: "300px", // Original height + // transform: transformStyle.transform, + transformStyle: "preserve-3d", + position: "absolute", + transform: "translate(-50%, -50%)", + }} + > +
+
Production Capacity
+
+
1,200
{" "} +
units/hour
-
-
Target
-
2.345
+
+
+
Current
+
1500
+
+
+
Target
+
2.345
+
+ {/*
units/hour
*/}
- {/*
units/hour
*/} +
{" "} +
+ {/* Bar Chart */} + 0 + ? chartData + : defaultChartData + } + options={chartOptions} + />
-
{" "} -
- {/* Bar Chart */} - 0 - ? chartData - : defaultChartData - } - options={chartOptions} - />
-
- + } + ); };