import { Box, Text, Flex } from "@chakra-ui/react"; import { Responsive, WidthProvider } from "react-grid-layout"; import { useDashboardStore } from "@/store/useDashboardStore.jsx"; // React-Grid-Layout requires this wrapper to automatically calculate screen width const ResponsiveGridLayout = WidthProvider(Responsive); export default function MyDashboard() { // 1. ☁️ Connect to the Cloud (Zustand) const widgets = useDashboardStore(state => state.widgets); const isEditing = useDashboardStore(state => state.isEditing); const updateLayoutPositions = useDashboardStore(state => state.updateLayoutPositions); // 2. 🛠️ Format the data for RGL // RGL expects a very specific array format for its layout prop const rglLayout = widgets.map(w => ({ i: w.id, x: w.x, y: w.y, w: w.w, h: w.h, isResizable: false // 🚫 The magic lock! No resizing allowed globally. })); return ( updateLayoutPositions(newLayout)} // Fires when user drops a widget compactType="vertical" // Auto-packs widgets to the top > {/* 3. 🎨 Paint the Widgets */} {widgets.map(widget => ( {/* 🚧 Temporary Placeholder! Eventually, we will swap this block out for a dynamic component loader that looks at widget.type and loads the correct graph or table. */} {widget.type} Size: {widget.size} ))} {/* Empty State Helper */} {widgets.length === 0 && ( Your dashboard is empty. Click Settings to add widgets. )} ); }