removing redundancies
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { HStack, Flex, Tabs } from "@chakra-ui/react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { useState } from "react";
|
||||
import WidgetCanvas from "./DashboardCanvasNav/WidgetCanvas";
|
||||
import { SearchBar } from "../components/SearchBar";
|
||||
import { SettingsButton } from "../components/SettingsButton";
|
||||
@@ -11,10 +11,7 @@ import { CancelButton } from "../components/CancelButton";
|
||||
import { SaveButton } from "../components/SaveButton";
|
||||
import DeleteAllButton from "../components/DeleteAllButton";
|
||||
|
||||
export function DashboardCanvas({ view, setView, layout, setLayout, onLayoutChange }) {
|
||||
const [isEditable, setIsEditable] = useState(false); // editable=true means static=false (vice versa)
|
||||
const [isDelete, setIsDelete] = useState(false);
|
||||
const [originalLayout, setOriginalLayout] = useState([]);
|
||||
export function DashboardCanvas({ view, layout, setLayout, onLayoutChange, onCancel, isDelete, setIsDelete, isEditable, setIsEditable, onChangeView }) {
|
||||
const [widgetArray, setWidgetArray] = useState([]);
|
||||
|
||||
const onAddWidget = (ID) => {
|
||||
@@ -35,7 +32,6 @@ export function DashboardCanvas({ view, setView, layout, setLayout, onLayoutChan
|
||||
const onEditWidgets = () => {
|
||||
console.log("widgets are now editable");
|
||||
setOriginalLayout(layout); // Backup layout before editing
|
||||
|
||||
// Set all widgets to editable, static: false
|
||||
setLayout(prevLayout =>
|
||||
prevLayout.map(item => ({
|
||||
@@ -48,7 +44,6 @@ export function DashboardCanvas({ view, setView, layout, setLayout, onLayoutChan
|
||||
|
||||
const onSave = () => {
|
||||
console.log("saving widgets...");
|
||||
|
||||
// Set all widgets back to static: true
|
||||
setLayout(prevLayout =>
|
||||
prevLayout.map(item => ({
|
||||
@@ -56,7 +51,6 @@ export function DashboardCanvas({ view, setView, layout, setLayout, onLayoutChan
|
||||
static: true
|
||||
}))
|
||||
);
|
||||
|
||||
setIsEditable(false);
|
||||
setIsDelete(false);
|
||||
setOriginalLayout([]); // Clear backup layout
|
||||
|
||||
Reference in New Issue
Block a user