i have a react app embedded with tableau dashboard presenting a certain project which is defined by the file of the tableau, i need to create a dropdown menu that switches between different tableau projects, which means it takes different urls based on the folder specified for it in the dropdown optinos and populates the app accordingly.
The embedding is happenning through a url in this manner:
import React from 'react'
import "../App.css"
import TableauView from 'insights-tableau';
function Finance() {
return(<div className='MainDashboard'>
<div className='dashboard-container'>
<TableauView src="https://isr-tableau/views/Demo/Finance" toolbar="hidden" />
</div>
</div> )
}
export default Finance
and i have different views arranged inside the app in this way:
import { createRoot } from "react-dom/client";
import {
createBrowserRouter,
RouterProvider,
Outlet,
} from "react-router-dom";
import MonitoringOverview from "./routes/MonitoringOverview";
import PerformanceQuality from "./routes/PerformanceQuality";
import Finance from "./routes/Finance";
import Navbar from "./components/Navbar/Navbar";
import "./App.css";
import LoginScreen from "./routes/LoginScreen/LoginScreen";
import UserConfig from "./routes/UserConfig/UserConfig.js";
import Simulation from "./routes/Simulation";
import Fraud from "./routes/Fraud";
import Deployment from "./routes/Deployment";
import Planning from "./routes/Planning";
const AppLayout = () => (
<>
<Navbar />
<Outlet />
</>
);
const router = createBrowserRouter([
{
path: '/',
element: <LoginScreen />
},
{
element: <AppLayout />,
children: [
{
path: "monitoringoverview",
element: <MonitoringOverview />,
},
{
path: "performancequality",
element: <PerformanceQuality />,
},
{
path: "finance",
element: <Finance />,
},
{
path: "simulation",
element: <Simulation />,
},
{
path: 'userconfig',
element: <UserConfig />
},
{
path: 'fraud',
element: <Fraud />
},
{
path: 'deploymentrecommendations',
element: <Deployment />
},
{
path: 'planning',
element: <Planning />
}
],
},
]);
createRoot(document.getElementById("root")).render(
<RouterProvider router={router} />
and the navbar also needs to populate itself with the relevant project tabs
How should i approach this? i thought a state for the app for each project and the dropdown switches between these states, if this is my best option how should i do it and if there is a better way please let me know.
Thanks in advnace