// project import
import Routes from 'routes';
import ThemeCustomization from 'themes';
import Locales from 'components/Locales';
// import RTLLayout from 'components/RTLLayout';
import ScrollTop from 'components/ScrollTop';
import Snackbar from 'components/@extended/Snackbar';
import Notistack from 'components/third-party/Notistack';
import { useNavigate } from 'react-router';
import { useEffect } from 'react';
import InternetStatus from 'components/nearle_components/updateNetworkStatus';
import { useDispatch, useSelector } from 'react-redux';

// auth-provider
// import { JWTProvider as AuthProvider } from 'contexts/JWTContext';

// ==============================|| APP - THEME, ROUTER, LOCAL  ||============================== //

const App = () => {
  let navigate = useNavigate();
  useEffect(() => {
    if (!localStorage.getItem('authname')) {
      navigate('/login');
    }
  }, []);
  const { openItem } = useSelector((state) => state.menu);
  console.log('openItem', openItem);

  return (
    <>
      <ThemeCustomization>
        <InternetStatus />
        {/* <RTLLayout> */}
        <Locales>
          <ScrollTop>
            {/* <AuthProvider> */}
            <>
              <Notistack>
                <Routes />
                <Snackbar />
              </Notistack>
            </>
            {/* </AuthProvider> */}
          </ScrollTop>
        </Locales>
        {/* </RTLLayout> */}
      </ThemeCustomization>
    </>
  );
};
export default App;
