import React from "react";
import { SystemParameterProvider } from './context/SystemParameterContext';
import {
  BrowserRouter,
  Routes,
  Route,
  Navigate
} from "react-router-dom";
import { ThemeProvider, createTheme } from '@mui/material/styles';
import CssBaseline from '@mui/material/CssBaseline';
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";

// Import components
import Login from "./components/Login/Login";
import Dashboard from "./components/Dashboard/dashboard";
import HomePage from "./components/Dashboard/HomePage";
import Setup from "./components/Dashboard/Setup";
import UserMaintenance from "./components/Dashboard/UserMaintance";
import UserGroupMaintenance from "./components/Dashboard/UserGroupMaintance/UserGroupMaintance";
import MenuMaintenance from "./components/Dashboard/MenuMaintance/MenuMaintance";
import MenuAccessControl from "./components/Dashboard/MenuAccessControl/MenuAccessControl";
import SystemParameters from "./components/Dashboard/SystemParameters/SystemParameters";
import AccessType from "./components/Dashboard/AccessType/AccessType";
import ApiRegistry from "./components/Dashboard/ApiRegistery/ApiRegistery";
import TokenRegistry from "./components/Dashboard/TokenRegistery/TokenRegistery";
import CodeExtension from "./components/Dashboard/Codeextension";
import DynamicTable from "./components/Dashboard/Dynamictable";
import Report from "./components/Dashboard/reports/Report";
import SequenceGenerator from "./components/Dashboard/document sequence/sequencegenerator";
import About from "./components/Dashboard/dropdown/about";
import Profile from "./components/Dashboard/dropdown/profile";
import DashboardRunner from "./components/dashboardnew/dashboardrunner/dashboardrunner";
import DashboardRunnerAll from "./components/dashboardnew/dashboardrunner/dashboardrunnerall";
import DashboardNewAll from "./components/dashboardnew/dashboardbuildernewall";
import DashboardNewAdd from "./components/dashboardnew/dashboardadd/dashboardbuilderadd";
import DashboardNewEdit from "./components/dashboardnew/editdashboard/editformdashboard";
import EditNewDash from "./components/dashboardnew/editdashboard/editdashboard";
import SubMenuMaintenance from "./components/Dashboard/sub menu/submenumaintanence";
import ReportRunnerAll from "./components/Dashboard/reports/reportrunnerall";
import ReportBuilderSQL from "./components/Dashboard/reports/reportbuildersql";
const theme = createTheme({
  palette: {
    primary: {
      main: '#1976d2',
    },
    secondary: {
      main: '#dc004e',
    },
  },
});

const App = () => {
  return (
    <ThemeProvider theme={theme}>
      <CssBaseline />
      <SystemParameterProvider>
        <BrowserRouter>
          <ToastContainer
            position="top-right"
            autoClose={1500}
            hideProgressBar={false}
            newestOnTop
            closeOnClick
            rtl={false}
            pauseOnFocusLoss
            draggable
            pauseOnHover
          />
          
          <Routes>
            <Route path="/login" element={<Login />} />
            
            {/* Main dashboard route */}
            <Route path="/dashboard/*" element={<Dashboard />}>
              <Route index element={<HomePage />} />
              
              {/* Setup section with all maintenance routes */}
              <Route path="setup" element={<Setup />}>
                <Route index element={<div>Select a setup option from the menu</div>} />
                <Route path="user-maintenance" element={<UserMaintenance />} />
                <Route path="user-group-maintenance" element={<UserGroupMaintenance />} />
                <Route path="menu-maintenance" element={<MenuMaintenance />} />
                <Route path="sub-menu-maintenance/:menuItemId" element={<SubMenuMaintenance/>} />
            
                <Route path="menu-access-control" element={<MenuAccessControl />} />
                <Route path="system-parameters" element={<SystemParameters />} />
                <Route path="access-type" element={<AccessType />} />
                <Route path="api-registry" element={<ApiRegistry />} />
                <Route path="token-registry" element={<TokenRegistry />} />
                <Route path="document-sequence" element={<SequenceGenerator />} />
                {/* Additional components */}
                <Route path="code-extension" element={<CodeExtension />} />
                <Route path="dynamic-table" element={<DynamicTable />} />
                   
              </Route>
                <Route path="dashboard-runner-all" element={<DashboardRunnerAll/>}/>
                <Route path="dashboard-new-all" element={<DashboardNewAll/>}/>
                <Route path="dashboard-new-add" element={<DashboardNewAdd/>}/>
                <Route path="dashboard-new-edit/:id" element={<DashboardNewEdit/>}/> 
                <Route path="edit-new-dash/:id" element={<EditNewDash/>}/>
                <Route path="dashrunner/:id" element={  <DashboardRunner/>}/>
               <Route path="reports" element={<Report />} />
                <Route path="user-report" element={<ReportBuilderSQL />} />
              {/* <Route path="reports" element={<ReportRunnerAll />} /> */}
                <Route path="about" element={<About />} />
              <Route path="profile" element={<Profile />} />  
            </Route>
            {/* buildercomponents */}



            
            <Route path="*" element={<Navigate to="/" replace />} />
          </Routes>
        </BrowserRouter>
      </SystemParameterProvider>
    </ThemeProvider>
  );
};

export default App;