

import React from "react";
import { SystemParameterProvider } from './context/SystemParameterContext';
import {
  BrowserRouter,
  Route,
  Routes,
  Navigate,
  useLocation,
} from "react-router-dom";
import "assets/plugins/nucleo/css/nucleo.css";
import "@fortawesome/fontawesome-free/css/all.min.css";
import "bootstrap-icons/font/bootstrap-icons.css";

import "assets/scss/argon-dashboard-react.scss";
import About from "views/examples/about";
import AdminLayout from "layouts/Admin.js";
import AuthLayout from "layouts/Auth.js";
import Profile from "views/examples/Profile";
import UserDetailsView from "components/Dashboard/Reportbuilder/UserDetailsView";
import SetupView from "components/Dashboard/SetupView";
import UserMaintenanceView from "components/Dashboard/UserMaintenanceView";

import MenuAccessControl from "components/Dashboard/MenuAccessControl";
import UserGroupMaintenance from "components/Dashboard/UserGroupMaintenance";
import SystemParameterForm from "components/Dashboard/SystemParameter";
import MenuMaintenance from "components/Dashboard/MenuMaintenance";
import AccessTypeManagement from "components/Dashboard/AccessType";
import APIRegistry from "components/Dashboard/APIRegistry";
import TOKENRegistry from "components/Dashboard/TOKENRegistry";

import Error404 from "views/examples/Error404";
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import Register from "views/examples/Register";

import DataManagement from "components/Dashboard/DataManagement";
import ValidationRule from "components/Dashboard/ValidationRule";
import MappingRule from "components/Dashboard/MappingRule";
import MultiDynamicBugs from "components/Dashboard/MultiDynamicsBugs";
import Login from "views/examples/Login";
import ResetPassword from "views/examples/resetPassword";
import ReportBuild2All from "components/Dashboard/Reportbuild2/Report-build2all/ReportBuild2All";
import ReportBuild2Add from "components/Dashboard/Reportbuild2/Report-build2add/ReportBuild2Add";
import ReportBuild2Edit from "./components/Dashboard/Reportbuild2/Report-build2edit/ReportBuildEdit";
import ReportQuery from "components/Dashboard/Reportbuilder/reportQuery";
import DynamicForm from "components/Dashboard/DynamicForm/DynamicForm2";
import DynamicFormAdd from "components/Dashboard/DynamicForm/DynamicFormAdd";
import ReportRunnerAll from "components/Dashboard/ReportRunner/ReportRunnerAll";
import ReportRunnerEdit from "./components/Dashboard/ReportRunner/ReportRunnerEdit";
import ReportRunner2Edit from "./components/Dashboard/ReportRunner/ReportRunner2Edit";
import SubMenuMaintenance from "components/Dashboard/SubmenuMaintenance";
import MenuAccessControl2 from "components/Dashboard/MenuAccessControl2";
import Index from "views/Index";
import DashboardRunnerAll from "components/Dashboard/dashboardRunner/dashboardRunnerAll/dashboardRunnerAll";
import DashboardNewAll from "components/Dashboard/dashboardnew/dashboardnewAll/DashboardNewAll";
import DashboardNewAdd from "components/Dashboard/dashboardnew/dashboardnewAdd/DashboardbuilderAdd";
import DashboardNewEdit from "./components/Dashboard/dashboardnew/DashboardnewEdit/EditFormNewDash";
import EditNewDash from "components/Dashboard/dashboardnew/EditNewDash/EditNewDash";
import ProtectedRoute from "ProtectedRoute";
import DashboardRunner from "components/Dashboard/dashboardRunner/dashboardRunner";
import Regform from "views/examples/regform";
import SequenceGenerator from "components/Dashboard/sequencegenerator";
// Inside <Routes>

const App = () => {
  return (
    <SystemParameterProvider>
      <div>
        {/* ToastContainer should be placed in the root component */}
        <ToastContainer
          position="top-right"
          autoClose={1500}
          hideProgressBar={false}
          newestOnTop
          closeOnClick
          rtl={false}
          pauseOnFocusLoss
          draggable
          pauseOnHover
        />

        <BrowserRouter basename="/">
          <Routes>
            <Route path="/" element={<Navigate to="/auth/login" replace />} />
            <Route path="*" element={<Navigate to="/auth/login" replace />} />

            {/* ptotecting the admin page  */}

            <Route path="/admin/*" element={
              <ProtectedRoute>
                <AdminLayout />
              </ProtectedRoute>
            }>
              <Route path="regform" element={<Regform />} />
              <Route path="error404" element={<Error404 />} />
              <Route path="resetpassword" element={<ResetPassword />} />

              <Route path="index" element={<Index />} />
              <Route path="profile" element={<Profile />} />
              <Route path="user-report" element={<UserDetailsView />} />
              <Route path="setting" element={<SetupView />} />
              <Route path="resetpassword" element={<ResetPassword />} />

              {/* Dynamic Routes */}
              <Route path="datamanagement" element={<DataManagement />} />
              <Route path="validationrule" element={<ValidationRule />} />
              <Route path="mappingrule" element={<MappingRule />} />
              <Route path="multidynmicbugs" element={<MultiDynamicBugs />} />
              <Route path="about" element={<About />} />
              {/* Static Routes */}
              <Route path="user-maintenance" element={<UserMaintenanceView />} />
              <Route path="menu-access-control" element={<MenuAccessControl />} />
              <Route path="submenu/:menuItemId" element={<SubMenuMaintenance />} />
              <Route path="sequence-generator" element={<SequenceGenerator />} />
              <Route path="menu-access-control2" element={<MenuAccessControl2 />} />
              <Route path="user-group-maintenance" element={<UserGroupMaintenance />} />
              <Route path="system-parameter" element={<SystemParameterForm />} />
              <Route path="menu-maintenance" element={<MenuMaintenance />} />
              <Route path="sub-menu-maintenance/:menuItemId" element={<SubMenuMaintenance />} />
              <Route path="access-type" element={<AccessTypeManagement />} />
              <Route path="api-registry" element={<APIRegistry />} />
              <Route path="token-registry" element={<TOKENRegistry />} />
              <Route path="dynamic-form-add" element={<DynamicFormAdd />} />
              <Route path="reportbuild2all" element={<ReportBuild2All />} />
              <Route path="reportbuild2add" element={<ReportBuild2Add />} />
              <Route path="reportbuild2edit" element={<ReportBuild2Edit />} />
              <Route path="reportquery" element={<ReportQuery />} />
              <Route path="report-runner" element={<ReportRunnerAll />} />
              <Route path="report-runner1/:id" element={<ReportRunnerEdit />} />
              <Route path="report-runner2/:id" element={<ReportRunner2Edit />} />
              <Route path="dynamic-form" element={<DynamicForm />} />
              <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>
            {/* buildercomponents */}

            <Route path="/auth/*" element={<AuthLayout />}>
              <Route path="login" element={<Login />} />
              <Route path="register" element={<Register />} />
            </Route>
          </Routes>
        </BrowserRouter>
      </div>
    </SystemParameterProvider>
  );
};

export default App;

