Add keyViews.js file inside src/constants to track current view in Sidebar and Canvas
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user