fixed widget state saving bug

+ decluttered props by using prop forwarding
+ renamed DashboardCanvas to HomeCanvas
This commit is contained in:
2025-08-04 15:38:19 -07:00
parent f250f11d8d
commit 9b8f7ea4d4
4 changed files with 32 additions and 72 deletions
+5 -23
View File
@@ -1,38 +1,20 @@
// This Canvas component will be used to dynamically populate
// the main canvas section of the web App with a default state
// of 'WidgetCanvas'
import { Box, useRecipe } from "@chakra-ui/react";
import { Box } from "@chakra-ui/react";
import GlobalMapCanvas from "./views/GlobalMapCanvas";
import RegionalMapCanvas from "./views/RegionalMapCanvas";
import VolcanoCanvas from "./views/VolcanoCanvas";
import AdminCanvas from "./views/AdminCanvas";
import AccountCanvas from "./views/AccountCanvas"
import SettingsCanvas from "./views/SettingsCanvas"
import { DashboardCanvas } from "./views/DashboardCanvas";
import { HomeCanvas } from "./views/HomeCanvas";
import { DASHBOARD_VIEWS } from "@/constants/viewKeys";
export default function Canvas({ onCancel, isEditable, setIsEditable, isDelete, setIsDelete, view, layout, setLayout, setOriginalLayout, onLayoutChange, onChangeView }) {
const recipe = useRecipe({ key: "canvas" });
const styles = recipe();
export default function Canvas({...props}) {
const { view } = props;
return (
<Box height="100%" width="100%">
{/* Check if view is a tab inside the Canvas Header */}
{ DASHBOARD_VIEWS.includes(view) && (
<DashboardCanvas
view={ view }
layout={ layout }
setLayout={ setLayout }
setOriginalLayout={ setOriginalLayout }
onLayoutChange={ onLayoutChange }
onChangeView={ onChangeView }
onCancel={ onCancel }
isEditable={ isEditable }
setIsEditable={ setIsEditable }
isDelete={ isDelete }
setIsDelete={ setIsDelete }
/>
<HomeCanvas {...props}/>
)}
{view === "global" && <GlobalMapCanvas />}
{view === "regional" && <RegionalMapCanvas />}