text: import React, { useState, useEffect } from "react";
  import { Route, Switch, Redirect } from "react-router-dom";
  import { Routes } from "../routes";
  
  // pages
  import DashboardOverview from "./dashboard/DashboardOverview";
  import Details from "./Details";
  import Signin from "./examples/Signin";
  import Signup from "./examples/Signup";
  import ForgotPassword from "./examples/ForgotPassword";
  import ResetPassword from "./examples/ResetPassword";
  import Lock from "./examples/Lock";
  import NotFoundPage from "./examples/NotFound";
  import ServerError from "./examples/ServerError";
  
  // components
  import Sidebar from "../components/Sidebar";
  import Navbar from "../components/Navbar";
  import Footer from "../components/Footer";
  import Preloader from "../components/Preloader";
  
  import Accordion from "./components/Accordion";
  import Alerts from "./components/Alerts";
  import Badges from "./components/Badges";
  import Breadcrumbs from "./components/Breadcrumbs";
  import Buttons from "./components/Buttons";
  import Forms from "./components/Forms";
  import Modals from "./components/Modals";
  import Navs from "./components/Navs";
  import Navbars from "./components/Navbars";
  import Pagination from "./components/Pagination";
  import Popovers from "./components/Popovers";
  import Progress from "./components/Progress";
  import Tables from "./components/Tables";
  import Tabs from "./components/Tabs";
  import Tooltips from "./components/Tooltips";
  import Toasts from "./components/Toasts";
  
  const RouteWithLoader = ({ component: Component, ...rest }) => {
    const [loaded, setLoaded] = useState(false);
  
    useEffect(() => {
      const timer = setTimeout(() => setLoaded(true), 1000);
      return () => clearTimeout(timer);
    }, []);
  
    return (
      <Route
        {...rest}
        render={(props) => (
          <>
            {" "}
            <Preloader show={loaded ? false : true} /> <Component {...props} />{" "}
          </>
        )}
      />
    );
  };
  
  const RouteWithSidebar = ({ component: Component, ...rest }) => {
    const [loaded, setLoaded] = useState(false);
  
    useEffect(() => {
      const timer = setTimeout(() => setLoaded(true), 1000);
      return () => clearTimeout(timer);
    }, []);
  
    const localStorageIsSettingsVisible = () => {
      return localStorage.getItem("settingsVisible") === "false" ? false : true;
    };
  
    const [showSettings, setShowSettings] = useState(
      localStorageIsSettingsVisible
    );
  
    const toggleSettings = () => {
      setShowSettings(!showSettings);
      localStorage.setItem("settingsVisible", !showSettings);
    };
  
    return (
      <Route
        {...rest}
        render={(props) => (
          <>
            <Preloader show={loaded ? false : true} />
            <Sidebar />
  
            <main className="content">
              <Navbar />
              <Component {...props} />
              {/* <Footer toggleSettings={toggleSettings} showSettings={showSettings} /> */}
            </main>
          </>
        )}
      />
    );
  };
  
  export default () => (
    <Switch>
      <RouteWithLoader exact path={Routes.Signin.path} component={Signin} />
      <RouteWithLoader exact path={Routes.Signup.path} component={Signup} />
      <RouteWithLoader
        exact
        path={Routes.ForgotPassword.path}
        component={ForgotPassword}
      />
      <RouteWithLoader
        exact
        path={Routes.ResetPassword.path}
        component={ResetPassword}
      />
      <RouteWithLoader exact path={Routes.Lock.path} component={Lock} />
      <RouteWithLoader
        exact
        path={Routes.NotFound.path}
        component={NotFoundPage}
      />
      <RouteWithLoader
        exact
        path={Routes.ServerError.path}
        component={ServerError}
      />
  
      {/* pages */}
      <RouteWithSidebar
        exact
        path={Routes.DashboardOverview.path}
        component={DashboardOverview}
      />
      <RouteWithSidebar exact path={Routes.Details.path} component={Details} />
  
      <Redirect to={Routes.NotFound.path} />
    </Switch>
  );
  