import { useState, useEffect } from 'react' import './App.css' import InfiniteCanvas from './components/InfiniteCanvas' import AdvancedCharts from './components/AdvancedCharts' import DataflowCanvas from './components/DataflowCanvas' import ERDiagramCanvas from './components/ERDiagramCanvas' import { FaDatabase, FaChartBar, FaProjectDiagram, FaSitemap, FaFolder, FaCog, FaChevronDown, FaChevronRight, FaTachometerAlt } from 'react-icons/fa' import { Breadcrumbs, Link, Typography } from '@mui/material' import { createTheme, ThemeProvider } from '@mui/material/styles' // Create a custom Material UI theme to match your application's dark theme const darkTheme = createTheme({ palette: { mode: 'dark', primary: { main: '#00a99d', }, text: { primary: '#ffffff', secondary: '#aaaaaa', }, background: { default: '#121212', paper: '#1a1a1a', }, }, typography: { fontFamily: '"Inter", "Roboto", "Helvetica", "Arial", sans-serif', }, }); function App() { // Initialize activeTab based on URL pathname if present const getInitialTab = () => { const pathname = window.location.pathname; if (pathname === '/charts') return 'charts'; if (pathname === '/data_mappings') return 'data_mappigs'; if (pathname === '/er_diagram') return 'er_diagram'; if (pathname === '/settings') return 'settings'; // Default to canvas/qubit_service window.history.pushState(null, '', '/qubit_service'); return 'canvas'; }; const [activeTab, setActiveTab] = useState(getInitialTab()); // Add state to track the current database for DataflowCanvas const [currentDbSlug, setCurrentDbSlug] = useState(null); // Add state to track if the current database has schemas const [hasSchemas, setHasSchemas] = useState(true); // Add state to track whether the sidebar dropdown is open const [isDropdownOpen, setIsDropdownOpen] = useState(true); // Handle browser back/forward navigation useEffect(() => { const handleLocationChange = () => { const pathname = window.location.pathname; if (pathname === '/qubit_service') setActiveTab('canvas'); else if (pathname === '/charts') setActiveTab('charts'); else if (pathname === '/data_mappings') setActiveTab('data_mappigs'); else if (pathname === '/er_diagram') setActiveTab('er_diagram'); // Settings tab would be handled here too }; window.addEventListener('popstate', handleLocationChange); return () => { window.removeEventListener('popstate', handleLocationChange); }; }, []); // Listen for custom events to switch tabs useEffect(() => { // Handler for switching to DataFlow tab const handleViewDataFlow = (event) => { // Switch to the dataflow tab setActiveTab('dataflow'); // Update URL path window.history.pushState(null, '', '/data_mappings'); // Set the current database slug to force DataflowCanvas to re-render setCurrentDbSlug(event.detail.databaseSlug); // Set whether this database has schemas setHasSchemas(!event.detail.isEmpty); // Log the database info console.log('Viewing DataFlow for database:', event.detail); console.log('Database has schemas:', !event.detail.isEmpty); }; // Handler for switching to any tab const handleSwitchToTab = (event) => { // Switch to the specified tab setActiveTab(event.detail); // Update URL path based on the tab let path = '/qubit_service'; if (event.detail === 'charts') path = '/charts'; if (event.detail === 'data_mappigs') path = '/data_mappings'; if (event.detail === 'er_diagram') path = '/er_diagram'; if (event.detail === 'settings') path = '/settings'; window.history.pushState(null, '', path); console.log('Switching to tab:', event.detail); }; // Add event listeners window.addEventListener('viewDataFlow', handleViewDataFlow); window.addEventListener('switchToTab', handleSwitchToTab); // Clean up return () => { window.removeEventListener('viewDataFlow', handleViewDataFlow); window.removeEventListener('switchToTab', handleSwitchToTab); }; }, []); return (
{/* Logo and Title */}

{/* The Metricverse */} Qubit Service

{/* User profile and controls */}
John Doe
{/* Sidebar navigation with dropdown */}
{/* Main Qbit Item with Dropdown */}
setIsDropdownOpen(!isDropdownOpen)} style={{ display: 'flex', alignItems: 'center', padding: '12px 15px', borderRadius: '6px', cursor: 'pointer', background: 'rgba(0, 169, 157, 0.15)', transition: 'all 0.2s ease', marginBottom: '5px' }} > Qbit {isDropdownOpen ? : }
{/* Dropdown items container with animation */}
{/* Overview Item */}
{ setActiveTab('canvas'); window.history.pushState(null, '', '/qubit_service'); }} style={{ display: 'flex', alignItems: 'center', padding: '8px 15px', borderRadius: '6px', cursor: 'pointer', background: activeTab === 'canvas' ? 'rgba(0, 169, 157, 0.1)' : 'transparent', transition: 'all 0.2s ease' }} > Overview
{/* ER Diagram Item */}
{ setActiveTab('er_diagram'); window.history.pushState(null, '', '/er_diagram'); }} style={{ display: 'flex', alignItems: 'center', padding: '8px 15px', borderRadius: '6px', cursor: 'pointer', background: activeTab === 'er_diagram' ? 'rgba(0, 169, 157, 0.1)' : 'transparent', transition: 'all 0.2s ease' }} > ER Diagram
{/* Data Mapping Item */}
{ setActiveTab('dataflow'); window.history.pushState(null, '', '/data_mappings'); }} style={{ display: 'flex', alignItems: 'center', padding: '8px 15px', borderRadius: '6px', cursor: 'pointer', background: activeTab === 'dataflow' ? 'rgba(0, 169, 157, 0.1)' : 'transparent', transition: 'all 0.2s ease' }} > Data Mapping
{/* Settings Item */}
{ alert('Settings functionality not implemented yet'); }} style={{ display: 'flex', alignItems: 'center', padding: '8px 15px', borderRadius: '6px', cursor: 'pointer', background: activeTab === 'settings' ? 'rgba(0, 169, 157, 0.1)' : 'transparent', transition: 'all 0.2s ease' }} > Dashboard
{/* Advanced Charts Item */} {/*
{ setActiveTab('charts'); window.history.pushState(null, '', '/charts'); }} style={{ display: 'flex', alignItems: 'center', padding: '8px 15px', borderRadius: '6px', cursor: 'pointer', background: activeTab === 'charts' ? 'rgba(0, 169, 157, 0.1)' : 'transparent', transition: 'all 0.2s ease' }} > Advanced Charts
*/}
{activeTab === 'canvas' && ( <>

Overview

{ e.preventDefault(); setIsDropdownOpen(true); // Ensure dropdown is open }} sx={{ fontWeight: 500 }} > Qubit Overview

{/* Infinite Canvas - Zoom and pan without limits */} The Only Limit is Your Imagination.

Scroll to zoom • Drag to pan • Connect nodes

)} {activeTab === 'charts' && (
{/* */}
)} {activeTab === 'dataflow' && ( <>

Visualize data flows between tables

Add tables • Create processes • Connect data flows

)} {activeTab === 'er_diagram' && ( <>

ER Diagram

)}
) } export default App