Add keyViews.js file inside src/constants to track current view in Sidebar and Canvas

This commit is contained in:
Daniel S. Hansen
2025-07-29 11:04:29 -07:00
parent 416873fc08
commit 89c32e4f6e
4 changed files with 32 additions and 12 deletions
@@ -9,6 +9,7 @@ import { HiUsers } from "react-icons/hi2";
import { VscThreeBars } from "react-icons/vsc";
import { useState, useEffect } from "react";
import { Seismic } from "../Canvas/views/DashboardCanvasNav/Seismic";
import { DASHBOARD_VIEWS } from "@/constants/viewKeys";
export default function Sidebar({ view, onChangeView }) {
const [isOpen, setIsOpen] = useState(true);
@@ -33,12 +34,13 @@ export default function Sidebar({ view, onChangeView }) {
// Track currrent view from both Sidebar and Canvas when 'view' changes
useEffect(() => {
console.log("typeof view =", typeof view);
console.log("Current view = ", view);
const dashboardViews = ["widget", "gas", "seismic", "remote", "activity"];
// const dashboardViews = ["widget", "gas", "seismic", "remote", "daily"];
const newIndex = buttons.findIndex((btn) => {
if (btn.view === "widget") {
return dashboardViews.includes(view); // Group match
return DASHBOARD_VIEWS.includes(view); // Group match
}
return btn.view === view; // Exact match
});
@@ -47,8 +49,6 @@ export default function Sidebar({ view, onChangeView }) {
setActiveButton(newIndex);
}
}, [view]);
return (
<Box